Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Latest commit

 

History

History
37 lines (25 loc) · 1018 Bytes

zend.stdlib.hydrator.namingstrategy.identitynamingstrategy.rst

File metadata and controls

37 lines (25 loc) · 1018 Bytes

IdentityNamingStrategy

Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy Will use the key it is given for hydration and extraction.

Basic Usage

$namingStrategy = new Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy();

echo $namingStrategy->hydrate('foo'); // outputs: foo
echo $namingStrategy->extract('bar'); // outputs: bar

This strategy can be used in hydrators as well:

class Foo
{
    public $foo;
}

$namingStrategy = new Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy();
$hydrator = new Zend\Stdlib\Hydrator\ObjectProperty();
$hydrator->setNamingStrategy($namingStrategy);

$foo = new Foo();
$hydrator->hydrate(array('foo' => 123), $foo);

print_r($foo); // Foo Object ( [foo] => 123 )
print_r($hydrator->extract($foo)); // Array ( [foo] => 123 )