public
|
#
__construct( mixed $value, callable $onSetCallback = null )
Initialises a new value instance.
Initialises a new value instance.
Parameters
- $value
- Variable to initialise instance with.
- $onSetCallback
- Callback to invoke to perform actual value change on
Core\Value::set() calls.
Since
3.1
|
public
|
#
__clone( )
Initialises a clone of the current instance.
Initialises a clone of the current instance.
If the stored value is an object, the value is cloned.
Since
3.1
|
public
mixed
|
#
__invoke( )
Invokes a stored callback or returns the stored value.
Invokes a stored callback or returns the stored value.
If the stored value is callable (either a callback or an object), it is
invoked with all provided parameters, otherwise parameters are ignored
and the stored value is returned.
Returns
mixed Result of invoked callback or stored value.
Since
3.1
|
public
string
|
#
__toString( )
Returns the standard PHP string variant of the represented value.
Returns the standard PHP string variant of the represented value.
Returns
string String representation of stored value.
Since
3.1
Overrides
|
public
boolean
|
#
bit( boolean $default = null )
Returns a three-state bit conversion of the stored value.
Returns a three-state bit conversion of the stored value.
null is returned whenever the stored value is null or does not
conform to a generic representation of a Boolean value. Supported
Boolean conversions include 1 , true , "on" and "yes" for
true and 0 , false , "off" and "no" for false .
Parameters
- $default
Optional. Default value to return if the converted value yields
null .
Returns
boolean true , if the stored value is a known representation of
true , false if it is a known representation of
false , otherwise null .
Since
3.1
|
public
boolean
|
#
bool( boolean $default = null )
Returns a PHP similar Boolean conversion of the stored value.
Returns a PHP similar Boolean conversion of the stored value.
A value is considered false , if it evaluates to false
or is a string equal to "false" , "off" or "no" . Otherwise true
is returned, unless the stored value is null and null
is returned.
Parameters
- $default
Optional. Default value to return if the converted value yields
null .
Returns
boolean true , if the stored value evaluates to true ,
false if it evaluates to false , and null if
the stored value is null .
Since
3.1
|
public
integer
|
#
compareTo( mixed $var )
Compares the current value with another value.
Compares the current value with another value.
Parameters
- $var
- Value to compare current Value with.
Returns
integer Returns < 0 if the current value is less than the parameter value; >
0 if the current value is greater than the parameter value, and 0
if both are equal.
See
Since
3.1
Implementation of
|
public
array
|
#
explode( string $delimiter, integer $limit = null )
Returns a Value instance storing an array of exploded string segments.
Callbacks associated with the current instance are passed on to the
returned value instance.
Returns a Value instance storing an array of exploded string segments.
Callbacks associated with the current instance are passed on to the
returned value instance.
If any conversion is applied, the data type of the returned Value
instance is array, regardless of the current Value instance type.
This method equals a call to \explode() with the exception that
a limit of zero is not treated as 1 but disables limits.
Parameters
- $delimiter
- The delimiter string to split the currently stored string with.
- $limit
Optional. A positive number stops splitting the string after given limit
- 1 segments, storing the rest of the string as the last segment. A
negative number all segments except the last -limit are returned.
If the number is 0 or not set, limits are disabled.
Returns
array Value instance storing an array of string segments of the current value.
If the stored value is null , the instance itself is returned
instead.
Throws
Since
3.1
|
public
Core\Filter
|
#
filter( Core\URI |string $uri )
Filters the stored value against a named filter.
Filters the stored value against a named filter.
Assigned callbacks to this Value are passed on to the returned filter
Value.
Parameters
- $uri
- URI instance or URI string describing the filer driver to use.
Returns
Core\Filter Filter value instance storing the filtered and original value plus an
error flag. The returned object is based on Value thus inherits all
Value related properties and methods. Use Filter_Value::valid() to test
for validity of the returned value.
Since
3.1
|
public
float
|
#
float( float $default = null )
Returns a floating point conversion of the stored value.
Returns a floating point conversion of the stored value.
Parameters
- $default
- Default value to return if the converted value yields
null .
Returns
float A floating point number or null on failure.
Since
3.1
|
public
integer
|
#
int( integer $default = null )
Returns an integer conversion of the stored value.
Returns an integer conversion of the stored value.
Parameters
- $default
- Default value to return if the converted value yields
null .
Returns
integer An integer number or null on failure.
Since
3.1
|
public
boolean
|
#
isArray( )
Determines whether the stored value is an (native) array.
Determines whether the stored value is an (native) array.
Returns
boolean
true , if the stored value is an array, otherwise false .
Since
3.1
|
public
boolean
|
#
isBoolean( )
Determines whether the stored value is Boolean.
Determines whether the stored value is Boolean.
Returns
boolean
true , if the stored value is Boolean, otherwise false .
Since
3.1
|
public
boolean
|
#
isCallable( )
Determines whether the stored value is callable (callback or invokable).
Determines whether the stored value is callable (callback or invokable).
Returns
boolean
true , if the stored value is callable, otherwise false .
Since
3.1
|
public
boolean
|
#
isCallback( )
Determines whether the stored value is a callback.
Determines whether the stored value is a callback.
A callback is either a PHP native callback string or array or an
instance of the Delegate class.
Returns
boolean
true , if the stored value is a callback, otherwise false .
See
Since
3.1
|
public
boolean
|
#
isEqualTo( mixed $object )
Tests, whether the current value is equal to another value.
Tests, whether the current value is equal to another value.
Tests for equality of the current and provided values, hence value types
do not need to match.
Parameters
- $object
- Value or intrinsic type variable to compare current Value with.
Returns
boolean Returns true , if the current value and the value provided are
equal, otherwise false .
Since
3.1
Implementation of
|
public
boolean
|
#
isFloat( )
Determines whether the stored value is an floating point number.
Determines whether the stored value is an floating point number.
Returns
boolean true , if the stored value is a floating point number, otherwise
false .
Since
3.1
|
public
boolean
|
#
isIdenticalTo( mixed $object )
Tests, whether the current value is identical to another value.
Tests, whether the current value is identical to another value.
Tests for identity of the current and provided values, hence value types
need to match.
Parameters
- $object
- Value or intrinsic type variable to compare current Value with.
Returns
boolean Returns true , if the current value and the value provided are
identical, otherwise false .
Since
3.1
Implementation of
|
public
boolean
|
#
isInteger( )
Determines whether the stored value is an integer number.
Determines whether the stored value is an integer number.
Returns
boolean true , if the stored value is an integer number, otherwise
false .
Since
3.1
|
public
boolean
|
#
isNull( )
Determines whether the stored value is null .
Determines whether the stored value is null .
Returns
boolean
true , if the stored value is null, otherwise false .
Since
3.1
|
public
boolean
|
#
isNumeric( )
Determines whether the stored value is a number or numeric string.
Determines whether the stored value is a number or numeric string.
Returns
boolean true , if the stored value is a number or numeric string,
otherwise false .
Since
3.1
|
public
boolean
|
#
isOffset( )
Determines whether the stored value can be used as an array offset.
Determines whether the stored value can be used as an array offset.
Returns
boolean true , if the stored value can be used as an offset, otherwise
false .
Since
3.1
|
public
boolean
|
#
isObject( )
Determines whether the stored value is an object.
Determines whether the stored value is an object.
Returns
boolean
true , if the stored value is an object, otherwise false .
Since
3.1
|
public
boolean
|
#
isResource( )
Determines whether the stored value is a resource.
Determines whether the stored value is a resource.
Returns
boolean
true , if the stored value is a resource, otherwise false .
Since
3.1
|
public
boolean
|
#
isScalar( )
Determines whether the stored value is a scalar.
Determines whether the stored value is a scalar.
Scalar values are either integers, floats, strings and null . This
differs from the native PHP implementation that requires a scalar to
have a value (e.g. 0 is considered a scalar by this method, by PHP it
is not).
Returns
boolean
true , if the stored value is a scalar, otherwise false .
Since
3.1
|
public
boolean
|
#
isString( )
Determines whether the stored value is a string.
Determines whether the stored value is a string.
Returns
boolean
true , if the stored value is a string, otherwise false .
Since
3.1
|
public
mixed
|
#
set( mixed $value, boolean $returnValue = false )
Updates the stored value. Optionally invokes an assigned callback
method.
Updates the stored value. Optionally invokes an assigned callback
method.
Parameters
- $value
- New value to set.
- $returnValue
Optional. Whether to return the new value instead of the update result.
Default to false .
Returns
mixed If the return value flag is set, the new value value is returned,
otherwise true on success and false otherwise.
Event
Invokes the Value.Set callback prior to updating the value. If the
callback returns a value that evaluates to false , the update
procedure is cancelled.
Since
3.1
|
public
string
|
#
string( string $default = null )
Returns the string conversion of the stored value.
Returns the string conversion of the stored value.
Parameters
- $default
Optional. Default value to return if the converted value yields
null .
Returns
string A string or null if the stored value is null .
Since
3.1
|
public
Core\String
|
#
stringObject( string|Core\String $default = null )
Returns the string conversion of the stored value as a String instance.
Returns the string conversion of the stored value as a String instance.
Parameters
- $default
Optional. Default string value to return if the converted value yields
null .
Returns
Core\String A String instance containing the string variant of the stored value. If
the stored value is null , the default string value is used; if
the default string value is null , the returned String instance
represents an empty string.
Since
3.1
|
public
array
|
#
toArray( array $default = null )
Returns the value as an array.
Returns the value as an array.
The conversion of non-array values to an array behaves identical to the
way PHP treats conversions of scalars into arrays.
Parameters
- $default
- Optional. Default value to return if the converted value yields
null .
Returns
array If the value is an array, it is returned verbatim; otherwise all
non-null values are returned packed into an array with exactly
one element except for objects, which return an array of their public
properties; if the value is null , the default value or
null if no default is defined is returned.
Since
3.1
|
public
Core\Value
|
#
toLower( )
Returns a Value instance with lowercase variant of the current instance.
Callbacks associated with the current instance are passed on to the
returned value instance.
Returns a Value instance with lowercase variant of the current instance.
Callbacks associated with the current instance are passed on to the
returned value instance.
If any conversion is applied, the data type of the returned Value
instance is string, regardless of the current Value instance type.
Returns
Core\Value Value instance storing lowercased value. If the stored value is null
or the lowercase variant equals the current value, the instance itself
is returned.
Since
3.1
|
public
Core\Value
|
#
toUpper( )
Returns a Value instance with uppercase variant of the current instance.
Callbacks associated with the current instance are passed on to the
returned value instance.
Returns a Value instance with uppercase variant of the current instance.
Callbacks associated with the current instance are passed on to the
returned value instance.
If any conversion is applied, the data type of the returned Value
instance is string, regardless of the current Value instance type.
Returns
Core\Value Value instance storing uppercased value. If the stored value is null
or the uppercase variant equals the current value, the instance itself
is returned.
Since
3.1
|