package Default
inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator

 Methods

Define if extract values will use camel case or name with underscore

__construct(boolean|array $underscoreSeparatedKeys = true
inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator::__construct()

Parameters

$underscoreSeparatedKeys

booleanarray

Initializes a new instance of this class.

__construct() 
Inherited

Add a new filter to take care of what needs to be hydrated.

addFilter(string $name, callable|\Zend\Stdlib\Hydrator\Filter\FilterInterface $filter, integer $condition = \Zend\Stdlib\Hydrator\Filter\FilterComposite::CONDITION_OR

To exclude e.g. the method getServiceLocator:

$composite->addFilter("servicelocator", function ($property) { list($class, $method) = explode('::', $property); if ($method === 'getServiceLocator') { return false; } return true; }, FilterComposite::CONDITION_AND );

inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator::addFilter()

Parameters

$name

$filter

$condition

Add a new filter to take care of what needs to be hydrated.

addFilter(string $name, callable|\Zend\Stdlib\Hydrator\Filter\FilterInterface $filter, integer $condition = \Zend\Stdlib\Hydrator\Filter\FilterComposite::CONDITION_OR) : \Zend\Stdlib\Hydrator\Filter\FilterComposite
Inherited

To exclude e.g. the method getServiceLocator:

$composite->addFilter("servicelocator", function ($property) { list($class, $method) = explode('::', $property); if ($method === 'getServiceLocator') { return false; } return true; }, FilterComposite::CONDITION_AND );

inherited_from \Zend\Stdlib\Hydrator\FilterEnabledInterface::addFilter()

Parameters

$name

string

Index in the composite

$filter

callable\Zend\Stdlib\Hydrator\Filter\FilterInterface

$condition

integer

Returns

\Zend\Stdlib\Hydrator\Filter\FilterComposite

Adds the given strategy under the given name.

addStrategy(string $name, \Zend\Stdlib\Hydrator\Strategy\StrategyInterface $strategy) : \Zend\Stdlib\Hydrator\HydratorInterface
Inherited
inherited_from \Zend\Stdlib\Hydrator\StrategyEnabledInterface::addStrategy()

Parameters

$name

string

The name of the strategy to register.

$strategy

\Zend\Stdlib\Hydrator\Strategy\StrategyInterface

The strategy to register.

Returns

\Zend\Stdlib\Hydrator\HydratorInterface

Extract values from an object with class methods

extract(object $object) : array

Extracts the getter/setter of the given $object.

Parameters

$object

object

Exceptions

\Zend\Stdlib\Exception\BadMethodCallException for a non-object $object

Returns

array

Convert a name for extraction. If no naming strategy exists, the plain value is returned.

extractName(string $name, null $object = null) : mixed
Inherited

Parameters

$name

string

The name to convert.

$object

null

The object is optionally provided as context.

Returns

mixed

Converts a value for extraction. If no strategy exists the plain value is returned.

extractValue(string $name, mixed $value, mixed $object = null) : mixed
Inherited

Parameters

$name

string

The name of the strategy to use.

$value

mixed

The value that should be converted.

$object

mixed

The object is optionally provided as context.

Returns

mixed

Get the filter instance

getFilter() : \Zend\Stdlib\Hydrator\Filter\FilterComposite
Inherited

Returns

\Zend\Stdlib\Hydrator\Filter\FilterComposite

Gets the naming strategy.

getNamingStrategy() : \Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface
Inherited
inherited_from \Zend\Stdlib\Hydrator\NamingStrategyEnabledInterface::getNamingStrategy()

Returns

\Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface

Gets the strategy with the given name.

getStrategy(string $name) : \Zend\Stdlib\Hydrator\Strategy\StrategyInterface
Inherited
inherited_from \Zend\Stdlib\Hydrator\StrategyEnabledInterface::getStrategy()

Parameters

$name

string

The name of the strategy to get.

Exceptions

\Zend\Stdlib\Exception\InvalidArgumentException

Returns

\Zend\Stdlib\Hydrator\Strategy\StrategyInterface

getUnderscoreSeparatedKeys()

getUnderscoreSeparatedKeys() : boolean

Returns

boolean

Check whether a specific filter exists at key $name or not

hasFilter(string $name) : boolean
Inherited
inherited_from \Zend\Stdlib\Hydrator\FilterEnabledInterface::hasFilter()

Parameters

$name

string

Index in the composite

Returns

boolean

Checks if a naming strategy exists.

hasNamingStrategy() : boolean
Inherited
inherited_from \Zend\Stdlib\Hydrator\NamingStrategyEnabledInterface::hasNamingStrategy()

Returns

boolean

Checks if the strategy with the given name exists.

hasStrategy(string $name) : boolean
Inherited
inherited_from \Zend\Stdlib\Hydrator\StrategyEnabledInterface::hasStrategy()

Parameters

$name

string

The name of the strategy to check for.

Returns

boolean

Hydrate an object by populating getter/setter methods

hydrate(array $data, object $object) : object

Hydrates an object by getter/setter methods of the object.

Parameters

$data

array

$object

object

Exceptions

\Zend\Stdlib\Exception\BadMethodCallException for a non-object $object

Returns

object

Converts a value for hydration. If no naming strategy exists, the plain value is returned.

hydrateName(string $name, array $data = null) : mixed
Inherited

Parameters

$name

string

The name to convert.

$data

array

The whole data is optionally provided as context.

Returns

mixed

Converts a value for hydration. If no strategy exists the plain value is returned.

hydrateValue(string $name, mixed $value, array $data = null) : mixed
Inherited

Parameters

$name

string

The name of the strategy to use.

$value

mixed

The value that should be converted.

$data

array

The whole data is optionally provided as context.

Returns

mixed

Remove a filter from the composition.

removeFilter($name) 

To not extract "has" methods, you simply need to unregister it

$filterComposite->removeFilter('has');

inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator::removeFilter()

Parameters

$name

Remove a filter from the composition.

removeFilter($name) : \Zend\Stdlib\Hydrator\Filter\FilterComposite
Inherited

To not extract "has" methods, you simply need to unregister it

$filterComposite->removeFilter('has');

inherited_from \Zend\Stdlib\Hydrator\FilterEnabledInterface::removeFilter()

Parameters

$name

Returns

\Zend\Stdlib\Hydrator\Filter\FilterComposite

Removes the naming strategy

removeNamingStrategy() 
inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator::removeNamingStrategy()

Removes the naming strategy

removeNamingStrategy() : \Zend\Stdlib\Hydrator\ClassMethods
Inherited
inherited_from \Zend\Stdlib\Hydrator\NamingStrategyEnabledInterface::removeNamingStrategy()
fluent This method is part of a fluent interface and will return the same instance

Returns

\Zend\Stdlib\Hydrator\ClassMethods

Removes the strategy with the given name.

removeStrategy(string $name) : \Zend\Stdlib\Hydrator\HydratorInterface
Inherited
inherited_from \Zend\Stdlib\Hydrator\StrategyEnabledInterface::removeStrategy()

Parameters

$name

string

The name of the strategy to remove.

Returns

\Zend\Stdlib\Hydrator\HydratorInterface

Adds the given naming strategy

setNamingStrategy(\Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface $strategy) 
inherited_from \Zend\Stdlib\Hydrator\AbstractHydrator::setNamingStrategy()

Parameters

$strategy

Adds the given naming strategy

setNamingStrategy(\Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface $strategy) : \Zend\Stdlib\Hydrator\ClassMethods
Inherited
inherited_from \Zend\Stdlib\Hydrator\NamingStrategyEnabledInterface::setNamingStrategy()
fluent This method is part of a fluent interface and will return the same instance

Parameters

$strategy

\Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface

The naming to register.

Returns

\Zend\Stdlib\Hydrator\ClassMethods

setOptions()

setOptions(array|\Traversable $options) : \Zend\Stdlib\Hydrator\ClassMethods
inherited_from \Zend\Stdlib\Hydrator\HydratorOptionsInterface::setOptions()

Parameters

$options

array\Traversable

Exceptions

\Zend\Stdlib\Exception\InvalidArgumentException

Returns

\Zend\Stdlib\Hydrator\ClassMethods

setUnderscoreSeparatedKeys()

setUnderscoreSeparatedKeys(boolean $underscoreSeparatedKeys) : \Zend\Stdlib\Hydrator\ClassMethods

Parameters

$underscoreSeparatedKeys

boolean

Returns

\Zend\Stdlib\Hydrator\ClassMethods

Reset all local hydration/extraction caches

resetCaches() 

 Properties

 

Composite to filter the methods, that need to be hydrated

$filterComposite : \Zend\Stdlib\Hydrator\Filter\FilterComposite

Default

 

An instance of NamingStrategyInterface

$namingStrategy : \Zend\Stdlib\Hydrator\NamingStrategy\NamingStrategyInterface

Default

 

The list with strategies that this hydrator has.

$strategies : \ArrayObject

Default

 

Flag defining whether array keys are underscore-separated (true) or camel case (false)

$underscoreSeparatedKeys : boolean

Default

true
 

$callableMethodFilter

$callableMethodFilter : \Zend\Stdlib\Hydrator\Filter\FilterInterface

Default

 

A map of extraction methods to property name to be used during extraction, indexed by class name and method name

$extractionMethodsCache : array<mixed,string[]>

Default

array()
 

Holds the names of the methods used for hydration, indexed by class::property name, false if the hydration method is not callable/usable for hydration purposes

$hydrationMethodsCache : array<mixed,string> | array<mixed,boolean>

Default

array()