1<?php 2/** 3 * File containing the ezcBaseValueException class. 4 * 5 * @package Base 6 * @version 1.8 7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved. 8 * @license http://ez.no/licenses/new_bsd New BSD License 9 */ 10/** 11 * ezcBaseValueException is thrown whenever the type or value of the given 12 * variable is not as expected. 13 * 14 * @package Base 15 * @version 1.8 16 */ 17class ezcBaseValueException extends ezcBaseException 18{ 19 /** 20 * Constructs a new ezcBaseValueException on the $name variable. 21 * 22 * @param string $settingName The name of the setting where something was 23 * wrong with. 24 * @param mixed $value The value that the option was tried to be set too. 25 * @param string $expectedValue A string explaining the allowed type and value range. 26 * @param string $variableType What type of variable was tried to be set (setting, argument). 27 */ 28 function __construct( $settingName, $value, $expectedValue = null, $variableType = 'setting' ) 29 { 30 $type = gettype( $value ); 31 if ( in_array( $type, array( 'array', 'object', 'resource' ) ) ) 32 { 33 $value = serialize( $value ); 34 } 35 $msg = "The value '{$value}' that you were trying to assign to $variableType '{$settingName}' is invalid."; 36 if ( $expectedValue ) 37 { 38 $msg .= " Allowed values are: " . $expectedValue . '.'; 39 } 40 parent::__construct( $msg ); 41 } 42} 43?> 44