| Package | system.utils |
|---|---|
| Inheritance | class CPropertyValue |
| Since | 1.0 |
| Version | $Id: CPropertyValue.php 568 2009-01-23 22:50:14Z qiang.xue $ |
public function setPropertyName($value)
{
$value=CPropertyValue::ensureBoolean($value);
// $value is now of boolean type
}
| Method | Description | Defined By |
|---|---|---|
| ensureArray() | Converts a value to array type. If the value is a string and it is | CPropertyValue |
| ensureBoolean() | Converts a value to boolean type. | CPropertyValue |
| ensureEnum() | Converts a value to enum type. | CPropertyValue |
| ensureFloat() | Converts a value to float type. | CPropertyValue |
| ensureInteger() | Converts a value to integer type. | CPropertyValue |
| ensureObject() | Converts a value to object type. | CPropertyValue |
| ensureString() | Converts a value to string type. | CPropertyValue |
|
public static array ensureArray(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | array | |
Converts a value to array type. If the value is a string and it is in the form (a,b,c) then an array consisting of each of the elements will be returned. If the value is a string and it is not in this form then an array consisting of just the string will be returned. If the value is not a string then
|
public static boolean ensureBoolean(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | boolean | |
Converts a value to boolean type. Note, string 'true' (case-insensitive) will be converted to true, string 'false' (case-insensitive) will be converted to false. If a string represents a non-zero number, it will be treated as true.
|
public static string ensureEnum(string $value, string $enumType)
| ||
| $value | string | the enumerable value to be checked. |
| $enumType | string | the enumerable class name (make sure it is included before calling this function). |
| {return} | string | the valid enumeration value |
Converts a value to enum type.
This method checks if the value is of the specified enumerable type.
A value is a valid enumerable value if it is equal to the name of a constant
in the specified enumerable type (class).
For more details about enumerable, see CEnumerable.
|
public static float ensureFloat(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | float | |
Converts a value to float type.
|
public static integer ensureInteger(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | integer | |
Converts a value to integer type.
|
public static object ensureObject(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | object | |
Converts a value to object type.
|
public static string ensureString(mixed $value)
| ||
| $value | mixed | the value to be converted. |
| {return} | string | |
Converts a value to string type. Note, a boolean value will be converted to 'true' if it is true and 'false' if it is false.
Be the first person to leave a comment
Please login to leave your comment.