xplo.re Medusa Core Framework 3.1
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • Autoloader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Iterator
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • String
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • UseVersion
  • Version

Functions

  • ns_expand
  • ns_file_exists
  • ns_get_version
  • ns_resolve

Class Value

A value represents any type of data and offers data conversion.

Core\Object implements Core\Chainable
Extended by Core\Set implements Core\Accessor
Extended by Core\Value implements Core\Comparable, Core\Equality, Core\Identity

Direct known subclasses

Core\Env_File, Core\Env_FileList, Core\Filter_Value

Namespace: Core
Package: Core
Since: 3.1
Requires: PHP 5.3
Version: 1.0
Located at Value.inc.php

Methods summary

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

Core\Object::__toString
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

Core\Value::isEqualTo()

Since

3.1

Implementation of

Core\Comparable::compareTo()
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

Core\Exception\InvalidArgument

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

Core\Delegate

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

Core\Equality::isEqualTo()
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

Core\Identity::isIdenticalTo()
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

Methods inherited from Core\Set

__get(), __isset()

Methods inherited from Core\Object

__autocreateFactory(), __call(), __processParameters(), attachMethod(), chain(), getValueForKey(), getValueForKeyPath(), getValueForUndefinedKey(), hash(), issetValueForKey(), setValueForKey(), setValueForKeyPath(), setValueForUndefinedKey(), uuid()

Constants summary

string Bit

Equals a call to Core\Value::bit().

Equals a call to Core\Value::bit().

Since

3.1
# 'bit'
string Boolean

Equals a call to Core\Value::bool().

Equals a call to Core\Value::bool().

Since

3.1
# 'bool'
string Float

Equals a call to Core\Value::float().

Equals a call to Core\Value::float().

Since

3.1
# 'float'
string Integer

Equals a call to Core\Value::int().

Equals a call to Core\Value::int().

Since

3.1
# 'int'
string LowercaseString

First transform a stored string to lowercase, then returns Core\Value::string().

First transform a stored string to lowercase, then returns Core\Value::string().

Since

3.1
# 'toLower.string'
string String

Equals a call to Core\Value::string().

Equals a call to Core\Value::string().

Since

3.1
# 'string'
string StringObject

Equals a call to Core\Value::stringObject().

Equals a call to Core\Value::stringObject().

Since

3.1
# 'stringObject'
string UppercaseString

First transform a stored string to uppercase, then returns Core\Value::string().

First transform a stored string to uppercase, then returns Core\Value::string().

Since

3.1
# 'toUpper.string'

Constants inherited from Core\Object

AnyParameterType, AutochainParameterType, AutocreateParameterType, BooleanParameterType, CharParameterType, EnumParameterType, IntegerParameterType, RealParameterType, StringParameterType, UserParameterType

Properties summary

protected callable $_v_onSet

Callback invoked on value changes.

Callback invoked on value changes.

Since

3.1
#
protected mixed $_v_value

Internal value represented by this instance.

Internal value represented by this instance.

Since

3.1
#

Magic properties

public read-only boolean $bit

See Core\Value::bit().

public read-only boolean $bool

See Core\Value::bool().

public read-only float $float

See Core\Value::float().

public read-only integer $int

See Core\Value::int().

public read-only boolean $isArray

See Core\Value::isArray().

public read-only boolean $isBoolean

See Core\Value::isBoolean().

public read-only boolean $isCallable

See Core\Value::isCallable().

public read-only boolean $isCallback

See Core\Value::isCallback().

public read-only boolean $isFloat

See Core\Value::isFloat().

public read-only boolean $isInteger

See Core\Value::isInteger().

public read-only boolean $isNull

See Core\Value::isNull().

public read-only boolean $isNumeric

See Core\Value::isNumeric().

public read-only boolean $isOffset

See Core\Value::isOffset().

public read-only boolean $isObject

See Core\Value::isObject().

public read-only boolean $isResource

See Core\Value::isResource().

public read-only boolean $isScalar

See Core\Value::isScalar().

public read-only boolean $isString

See Core\Value::isString().

public read-only callable $onSet

Callback invoked if the value represented by this instance has changed.

public read-only string $string

See Core\Value::string().

public read-only Core\String $stringObject

See Core\Value::stringObject().

public read-only mixed $value

Raw internal value represented by this instance.

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.1 API documentation generated by ApiGen