PHP Class Doctrine\ODM\OrientDB\Caster\Caster

Inheritance: implements Doctrine\ODM\OrientDB\Caster\CasterInterface
Show file Open project: doctrine/orientdb-odm

Protected Properties

Property Type Description
$dateClass
$falseValues
$inflector
$properties
$trueValues
$value

Public Methods

Method Description
__construct ( Hydrator $hydrator, Cached $inflector, mixed $value = null, string $dateClass = '\DateTime' ) Instantiates a new Caster.
castBinary ( ) : string Casts the given $value to a binary.
castBoolean ( ) : boolean Casts the given $value to boolean or tries to guess if it's an implicit boolean value, like the string 'true'.
castByte ( ) : mixed Casts the given $value to a byte.
castDate ( ) : DateTime Casts the given $value to a DateTime object.
castDateTime ( ) : DateTime Casts the given $value to a DateTime object.
castDecimal ( ) : integer Casts the internal value to an integer cmprehended between a range of accepted integers.
castDouble ( ) : float Casts the given $value to a double (well.
castEmbedded ( ) : mixed Given an embedded record, it uses the manager to hydrate it.
castEmbeddedArrays ( ) : Array Casts embedded arrays, given the $cast property of the internal annotation.
castEmbeddedList ( ) : Array Casts a list of embedded entities
castEmbeddedMap ( ) : Array Casts a map (key-value preserved) of embedded entities
castEmbeddedSet ( ) : Array Casts a set of embedded entities
castFloat ( ) : float Casts the value to a float.
castInBuffer ( integer $limit, string $type ) : integer Casts the current value into an integer verifying it belongs to a certain range ( -$limit < $value > + $limit ).
castInteger ( ) : integer Casts the value into an integer.
castLink ( ) : Doctrine\ODM\OrientDB\Proxy\Proxy
castLinklist ( ) : Array Hydrates multiple objects through a Mapper.
castLinkmap ( ) : Array Hydrates multiple objects through a Mapper.
castLinkset ( ) : Array Hydrates multiple objects through a Mapper.
castLong ( ) : mixed Casts the given $value to a long.
castNone ( ) : mixed This function is mostly for embedded arrays of mixed type as it is primarily just a way to bypass the caster
castShort ( ) : mixed Casts the value to a short.
castString ( ) : string Casts the value to string.
setProperty ( string $key, mixed $property ) Defines properties that can be internally used by the caster.
setValue ( mixed $value ) Sets the internal value to work with.

Protected Methods

Method Description
assignDateClass ( string $class ) Assigns the class used to cast dates and datetimes.
castArrayOf ( string $type ) : Array Given a $type, it casts each element of the value array with a method.
castLinkCollection ( ) : Array | null Given the internal value of the caster (an array), it iterates over each element of the array and hydrates it.
convertJsonCollectionToArray ( ) If a JSON value is converted in an object containing other objects to hydrate, this method converts the main object in an array.
getDateClass ( ) : string Returns the class used to cast date and datetimes.
getHydrator ( ) : Hydrator Returns the hydrator.
getProperty ( string $key ) : mixed Returns a property of the Caster, given its $key.
handleMismatch ( Closure $castFunction, $expectedType )
raiseMismatch ( $expectedType ) Throws an exception whenever $value can not be casted as $expectedType.

Method Details

__construct() public method

Instantiates a new Caster.
public __construct ( Hydrator $hydrator, Cached $inflector, mixed $value = null, string $dateClass = '\DateTime' )
$hydrator Doctrine\ODM\OrientDB\Mapper\Hydration\Hydrator
$inflector Doctrine\OrientDB\Util\Inflector\Cached
$value mixed
$dateClass string The class used to cast dates and datetimes

assignDateClass() protected method

If the $class is a subclass of \DateTime, it uses it, it uses \DateTime otherwise.
protected assignDateClass ( string $class )
$class string

castArrayOf() protected method

Given a $type, it casts each element of the value array with a method.
protected castArrayOf ( string $type ) : Array
$type string
return Array

castBinary() public method

Casts the given $value to a binary.
public castBinary ( ) : string
return string

castBoolean() public method

Casts the given $value to boolean or tries to guess if it's an implicit boolean value, like the string 'true'.
public castBoolean ( ) : boolean
return boolean

castByte() public method

Casts the given $value to a byte.
public castByte ( ) : mixed
return mixed

castDate() public method

If the value was stored as a timestamp, it sets the value to the DateTime object via the setTimestamp method.
public castDate ( ) : DateTime
return DateTime

castDateTime() public method

Casts the given $value to a DateTime object.
public castDateTime ( ) : DateTime
return DateTime

castDecimal() public method

Casts the internal value to an integer cmprehended between a range of accepted integers.
public castDecimal ( ) : integer
return integer

castDouble() public method

.. float).
public castDouble ( ) : float
return float

castEmbedded() public method

Given an embedded record, it uses the manager to hydrate it.
public castEmbedded ( ) : mixed
return mixed

castEmbeddedArrays() public method

Casts embedded arrays, given the $cast property of the internal annotation.
public castEmbeddedArrays ( ) : Array
return Array

castEmbeddedList() public method

Casts a list of embedded entities
public castEmbeddedList ( ) : Array
return Array

castEmbeddedMap() public method

Casts a map (key-value preserved) of embedded entities
public castEmbeddedMap ( ) : Array
return Array

castEmbeddedSet() public method

Casts a set of embedded entities
public castEmbeddedSet ( ) : Array
return Array

castFloat() public method

Casts the value to a float.
public castFloat ( ) : float
return float

castInBuffer() public method

Casts the current value into an integer verifying it belongs to a certain range ( -$limit < $value > + $limit ).
public castInBuffer ( integer $limit, string $type ) : integer
$limit integer
$type string
return integer

castInteger() public method

Casts the value into an integer.
public castInteger ( ) : integer
return integer

castLinkCollection() protected method

Given the internal value of the caster (an array), it iterates over each element of the array and hydrates it.
See also: Caster::castLink for more insights
protected castLinkCollection ( ) : Array | null
return Array | null

castLinkmap() public method

A conversion needs to be done because of the non linearity of a JSON collection compared to a PHP array.
public castLinkmap ( ) : Array
return Array

castLinkset() public method

Hydrates multiple objects through a Mapper.
public castLinkset ( ) : Array
return Array

castLong() public method

Casts the given $value to a long.
public castLong ( ) : mixed
return mixed

castNone() public method

This function is mostly for embedded arrays of mixed type as it is primarily just a way to bypass the caster
public castNone ( ) : mixed
return mixed

castShort() public method

Casts the value to a short.
public castShort ( ) : mixed
return mixed

castString() public method

Casts the value to string.
public castString ( ) : string
return string

convertJsonCollectionToArray() protected method

If a JSON value is converted in an object containing other objects to hydrate, this method converts the main object in an array.

getDateClass() protected method

Returns the class used to cast date and datetimes.
protected getDateClass ( ) : string
return string

getHydrator() protected method

Returns the hydrator.
protected getHydrator ( ) : Hydrator
return Doctrine\ODM\OrientDB\Mapper\Hydration\Hydrator

getProperty() protected method

Returns a property of the Caster, given its $key.
protected getProperty ( string $key ) : mixed
$key string
return mixed

handleMismatch() protected method

protected handleMismatch ( Closure $castFunction, $expectedType )
$castFunction Closure

raiseMismatch() protected method

Throws an exception whenever $value can not be casted as $expectedType.
protected raiseMismatch ( $expectedType )

setProperty() public method

Defines properties that can be internally used by the caster.
public setProperty ( string $key, mixed $property )
$key string
$property mixed

setValue() public method

Sets the internal value to work with.
public setValue ( mixed $value )
$value mixed

Property Details

$dateClass protected property

protected $dateClass

$falseValues protected property

protected $falseValues

$inflector protected property

protected $inflector

$properties protected property

protected $properties

$trueValues protected property

protected $trueValues

$value protected property

protected $value