commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / packages / ezc / Base / src / exceptions / setting_value.php
1 <?php
2 /**
3 * File containing the ezcBaseSettingValueException class.
4 *
5 * @package Base
6 * @version 1.7
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 * ezcBaseSettingValueExeception is thrown whenever a value to a class'
12 * configuration option is either of the wrong type, or has a wrong value.
13 *
14 * @package Base
15 * @version 1.7
16 */
17 class ezcBaseSettingValueException extends ezcBaseException
18 {
19 /**
20 * Constructs a new ezcBaseConfigException
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 */
27 function __construct( $settingName, $value, $expectedValue = null )
28 {
29 $type = gettype( $value );
30 if ( in_array( $type, array( 'array', 'object', 'resource' ) ) )
31 {
32 $value = serialize( $value );
33 }
34 $msg = "The value '{$value}' that you were trying to assign to setting '{$settingName}' is invalid.";
35 if ( $expectedValue )
36 {
37 $msg .= " Allowed values are: " . $expectedValue;
38 }
39 parent::__construct( $msg );
40 }
41 }
42 ?>