pax_global_header00006660000000000000000000000064125765443630014531gustar00rootroot0000000000000052 comment=f3ed8b833355140350bbed98d8a7b8b66875903f zend-hydrator-1.0.0/000077500000000000000000000000001257654436300143215ustar00rootroot00000000000000zend-hydrator-1.0.0/CHANGELOG.md000066400000000000000000000017561257654436300161430ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file, in reverse chronological order by release. ## 1.0.0 - 2015-09-17 Initial release. This ports all hydrator classes and functionality from [zend-stdlib](https://github.com/zendframework/zend-stdlib) to a standalone repository. All final keywords are removed, to allow a deprecation cycle in the zend-stdlib component. Please note: the following classes will be marked as `final` for a version 2.0.0 release to immediately follow 1.0.0: - `Zend\Hydrator\NamingStrategy\IdentityNamingStrategy` - `Zend\Hydrator\NamingStrategy\ArrayMapNamingStrategy` - `Zend\Hydrator\NamingStrategy\CompositeNamingStrategy` - `Zend\Hydrator\Strategy\ExplodeStrategy` - `Zend\Hydrator\Strategy\StrategyChain` - `Zend\Hydrator\Strategy\DateTimeFormatterStrategy` - `Zend\Hydrator\Strategy\BooleanStrategy` As such, you should not extend them. ### Added - Nothing. ### Deprecated - Nothing. ### Removed - Nothing. ### Fixed - Nothing. zend-hydrator-1.0.0/CONTRIBUTING.md000066400000000000000000000164451257654436300165640ustar00rootroot00000000000000# CONTRIBUTING ## RESOURCES If you wish to contribute to Zend Framework, please be sure to read/subscribe to the following resources: - [Coding Standards](https://github.com/zendframework/zf2/wiki/Coding-Standards) - [Contributor's Guide](http://framework.zend.com/participate/contributor-guide) - ZF Contributor's mailing list: Archives: http://zend-framework-community.634137.n4.nabble.com/ZF-Contributor-f680267.html Subscribe: zf-contributors-subscribe@lists.zend.com - ZF Contributor's IRC channel: #zftalk.dev on Freenode.net If you are working on new features or refactoring [create a proposal](https://github.com/zendframework/zend-hydrator/issues/new). ## Reporting Potential Security Issues If you have encountered a potential security vulnerability, please **DO NOT** report it on the public issue tracker: send it to us at [zf-security@zend.com](mailto:zf-security@zend.com) instead. We will work with you to verify the vulnerability and patch it as soon as possible. When reporting issues, please provide the following information: - Component(s) affected - A description indicating how to reproduce the issue - A summary of the security vulnerability and impact We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure; this helps protect users and provides them with a chance to upgrade and/or update in order to protect their applications. For sensitive email communications, please use [our PGP key](http://framework.zend.com/zf-security-pgp-key.asc). ## RUNNING TESTS > ### Note: testing versions prior to 2.4 > > This component originates with Zend Framework 2. During the lifetime of ZF2, > testing infrastructure migrated from PHPUnit 3 to PHPUnit 4. In most cases, no > changes were necessary. However, due to the migration, tests may not run on > versions < 2.4. As such, you may need to change the PHPUnit dependency if > attempting a fix on such a version. To run tests: - Clone the repository: ```console $ git clone git@github.com:zendframework/zend-hydrator.git $ cd ``` - Install dependencies via composer: ```console $ curl -sS https://getcomposer.org/installer | php -- $ ./composer.phar install ``` If you don't have `curl` installed, you can also download `composer.phar` from https://getcomposer.org/ - Run the tests via `phpunit` and the provided PHPUnit config, like in this example: ```console $ ./vendor/bin/phpunit ``` You can turn on conditional tests with the phpunit.xml file. To do so: - Copy `phpunit.xml.dist` file to `phpunit.xml` - Edit `phpunit.xml` to enable any specific functionality you want to test, as well as to provide test values to utilize. ## Running Coding Standards Checks This component uses [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) for coding standards checks, and provides configuration for our selected checks. `phpcs` is installed by default via Composer. To run checks only: ```console $ ./vendor/bin/phpcs ``` `phpcs` also provides a tool that can automatically fix many CS issues, `phpcbf`: ```console $ ./vendor/bin/phpcbf ``` If you allow `phpcbf` to fix CS issues, please re-run the tests to ensure they pass, and make sure you add and commit the changes after verification. ## Recommended Workflow for Contributions Your first step is to establish a public repository from which we can pull your work into the master repository. We recommend using [GitHub](https://github.com), as that is where the component is already hosted. 1. Setup a [GitHub account](http://github.com/), if you haven't yet 2. Fork the repository (http://github.com/zendframework/zend-hydrator) 3. Clone the canonical repository locally and enter it. ```console $ git clone git://github.com:zendframework/zend-hydrator.git $ cd zend-hydrator ``` 4. Add a remote to your fork; substitute your GitHub username in the command below. ```console $ git remote add {username} git@github.com:{username}/zend-hydrator.git $ git fetch {username} ``` ### Keeping Up-to-Date Periodically, you should update your fork or personal repository to match the canonical ZF repository. Assuming you have setup your local repository per the instructions above, you can do the following: ```console $ git checkout master $ git fetch origin $ git rebase origin/master # OPTIONALLY, to keep your remote up-to-date - $ git push {username} master:master ``` If you're tracking other branches -- for example, the "develop" branch, where new feature development occurs -- you'll want to do the same operations for that branch; simply substitute "develop" for "master". ### Working on a patch We recommend you do each new feature or bugfix in a new branch. This simplifies the task of code review as well as the task of merging your changes into the canonical repository. A typical workflow will then consist of the following: 1. Create a new local branch based off either your master or develop branch. 2. Switch to your new local branch. (This step can be combined with the previous step with the use of `git checkout -b`.) 3. Do some work, commit, repeat as necessary. 4. Push the local branch to your remote repository. 5. Send a pull request. The mechanics of this process are actually quite trivial. Below, we will create a branch for fixing an issue in the tracker. ```console $ git checkout -b hotfix/9295 Switched to a new branch 'hotfix/9295' ``` ... do some work ... ```console $ git commit ``` ... write your log message ... ```console $ git push {username} hotfix/9295:hotfix/9295 Counting objects: 38, done. Delta compression using up to 2 threads. Compression objects: 100% (18/18), done. Writing objects: 100% (20/20), 8.19KiB, done. Total 20 (delta 12), reused 0 (delta 0) To ssh://git@github.com/{username}/zend-hydrator.git b5583aa..4f51698 HEAD -> master ``` To send a pull request, you have two options. If using GitHub, you can do the pull request from there. Navigate to your repository, select the branch you just created, and then select the "Pull Request" button in the upper right. Select the user/organization "zendframework" as the recipient. If using your own repository - or even if using GitHub - you can use `git format-patch` to create a patchset for us to apply; in fact, this is **recommended** for security-related patches. If you use `format-patch`, please send the patches as attachments to: - zf-devteam@zend.com for patches without security implications - zf-security@zend.com for security patches #### What branch to issue the pull request against? Which branch should you issue a pull request against? - For fixes against the stable release, issue the pull request against the "master" branch. - For new features, or fixes that introduce new elements to the public API (such as new public methods or properties), issue the pull request against the "develop" branch. ### Branch Cleanup As you might imagine, if you are a frequent contributor, you'll start to get a ton of branches both locally and on your remote. Once you know that your changes have been accepted to the master repository, we suggest doing some cleanup of these branches. - Local branch cleanup ```console $ git branch -d ``` - Remote branch removal ```console $ git push {username} : ``` zend-hydrator-1.0.0/LICENSE.md000066400000000000000000000027551257654436300157360ustar00rootroot00000000000000Copyright (c) 2005-2015, Zend Technologies USA, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Zend Technologies USA, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zend-hydrator-1.0.0/README.md000066400000000000000000000012731257654436300156030ustar00rootroot00000000000000# zend-hydrator [![Build Status](https://secure.travis-ci.org/zendframework/zend-hydrator.svg?branch=master)](https://secure.travis-ci.org/zendframework/zend-hydrator) [![Coverage Status](https://coveralls.io/repos/zendframework/zend-hydrator/badge.svg?branch=master)](https://coveralls.io/r/zendframework/zend-hydrator?branch=master) `Zend\Hydrator` provides utilities for mapping arrays to objects, and vice versa, including facilities for filtering which data is mapped as well as providing mechanisms for mapping nested structures. - File issues at https://github.com/zendframework/zend-hydrator/issues - Documentation is at http://framework.zend.com/manual/current/en/index.html#zend-stdlib zend-hydrator-1.0.0/composer.json000066400000000000000000000026631257654436300170520ustar00rootroot00000000000000{ "name": "zendframework/zend-hydrator", "description": " ", "license": "BSD-3-Clause", "keywords": [ "zf2", "hydrator" ], "homepage": "https://github.com/zendframework/zend-hydrator", "autoload": { "psr-4": { "Zend\\Hydrator\\": "src/" } }, "require": { "php": ">=5.5", "zendframework/zend-stdlib": "^2.5.1" }, "require-dev": { "zendframework/zend-eventmanager": "^2.5.1", "zendframework/zend-inputfilter": "^2.5.1", "zendframework/zend-serializer": "^2.5.1", "zendframework/zend-servicemanager": "^2.5.1", "zendframework/zend-filter": "^2.5.1", "phpunit/PHPUnit": "~4.0", "squizlabs/php_codesniffer": "^2.0@dev" }, "suggest": { "zendframework/zend-eventmanager": "^2.5.1, to support aggregate hydrator usage", "zendframework/zend-serializer": "^2.5.1, to use the SerializableStrategy", "zendframework/zend-servicemanager": "^2.5.1, to support hydrator plugin manager usage", "zendframework/zend-filter": "^2.5.1, to support naming strategy hydrator usage" }, "minimum-stability": "dev", "prefer-stable": true, "extra": { "branch-alias": { "dev-master": "1.0-dev", "dev-develop": "1.1-dev" } }, "autoload-dev": { "psr-4": { "ZendTest\\Hydrator\\": "test/" } } } zend-hydrator-1.0.0/phpcs.xml000066400000000000000000000011031257654436300161530ustar00rootroot00000000000000 Zend Framework coding standard src test zend-hydrator-1.0.0/src/000077500000000000000000000000001257654436300151105ustar00rootroot00000000000000zend-hydrator-1.0.0/src/AbstractHydrator.php000066400000000000000000000170121257654436300211020ustar00rootroot00000000000000strategies = new ArrayObject(); $this->filterComposite = new Filter\FilterComposite(); } /** * Gets the strategy with the given name. * * @param string $name The name of the strategy to get. * * @throws Exception\InvalidArgumentException * @return Strategy\StrategyInterface */ public function getStrategy($name) { if (isset($this->strategies[$name])) { return $this->strategies[$name]; } if (!isset($this->strategies['*'])) { throw new Exception\InvalidArgumentException(sprintf( '%s: no strategy by name of "%s", and no wildcard strategy present', __METHOD__, $name )); } return $this->strategies['*']; } /** * Checks if the strategy with the given name exists. * * @param string $name The name of the strategy to check for. * @return bool */ public function hasStrategy($name) { return array_key_exists($name, $this->strategies) || array_key_exists('*', $this->strategies); } /** * Adds the given strategy under the given name. * * @param string $name The name of the strategy to register. * @param Strategy\StrategyInterface $strategy The strategy to register. * @return HydratorInterface */ public function addStrategy($name, Strategy\StrategyInterface $strategy) { $this->strategies[$name] = $strategy; return $this; } /** * Removes the strategy with the given name. * * @param string $name The name of the strategy to remove. * @return HydratorInterface */ public function removeStrategy($name) { unset($this->strategies[$name]); return $this; } /** * Converts a value for extraction. If no strategy exists the plain value is returned. * * @param string $name The name of the strategy to use. * @param mixed $value The value that should be converted. * @param mixed $object The object is optionally provided as context. * @return mixed */ public function extractValue($name, $value, $object = null) { if ($this->hasStrategy($name)) { $strategy = $this->getStrategy($name); $value = $strategy->extract($value, $object); } return $value; } /** * Converts a value for hydration. If no strategy exists the plain value is returned. * * @param string $name The name of the strategy to use. * @param mixed $value The value that should be converted. * @param array $data The whole data is optionally provided as context. * @return mixed */ public function hydrateValue($name, $value, $data = null) { if ($this->hasStrategy($name)) { $strategy = $this->getStrategy($name); $value = $strategy->hydrate($value, $data); } return $value; } /** * Convert a name for extraction. If no naming strategy exists, the plain value is returned. * * @param string $name The name to convert. * @param null $object The object is optionally provided as context. * @return mixed */ public function extractName($name, $object = null) { if ($this->hasNamingStrategy()) { $name = $this->getNamingStrategy()->extract($name, $object); } return $name; } /** * Converts a value for hydration. If no naming strategy exists, the plain value is returned. * * @param string $name The name to convert. * @param array $data The whole data is optionally provided as context. * @return mixed */ public function hydrateName($name, $data = null) { if ($this->hasNamingStrategy()) { $name = $this->getNamingStrategy()->hydrate($name, $data); } return $name; } /** * Get the filter instance * * @return Filter\FilterComposite */ public function getFilter() { return $this->filterComposite; } /** * Add a new filter to take care of what needs to be hydrated. * 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 * ); * * * @param string $name Index in the composite * @param callable|Filter\FilterInterface $filter * @param int $condition * @return Filter\FilterComposite */ public function addFilter($name, $filter, $condition = Filter\FilterComposite::CONDITION_OR) { return $this->filterComposite->addFilter($name, $filter, $condition); } /** * Check whether a specific filter exists at key $name or not * * @param string $name Index in the composite * @return bool */ public function hasFilter($name) { return $this->filterComposite->hasFilter($name); } /** * Remove a filter from the composition. * To not extract "has" methods, you simply need to unregister it * * * $filterComposite->removeFilter('has'); * * * @param $name * @return Filter\FilterComposite */ public function removeFilter($name) { return $this->filterComposite->removeFilter($name); } /** * Adds the given naming strategy * * @param NamingStrategy\NamingStrategyInterface $strategy The naming to register. * @return self */ public function setNamingStrategy(NamingStrategy\NamingStrategyInterface $strategy) { $this->namingStrategy = $strategy; return $this; } /** * Gets the naming strategy. * * @return NamingStrategy\NamingStrategyInterface */ public function getNamingStrategy() { return $this->namingStrategy; } /** * Checks if a naming strategy exists. * * @return bool */ public function hasNamingStrategy() { return isset($this->namingStrategy); } /** * Removes the naming strategy * * @return self */ public function removeNamingStrategy() { $this->namingStrategy = null; return $this; } } zend-hydrator-1.0.0/src/Aggregate/000077500000000000000000000000001257654436300167765ustar00rootroot00000000000000zend-hydrator-1.0.0/src/Aggregate/AggregateHydrator.php000066400000000000000000000041461257654436300231170ustar00rootroot00000000000000getEventManager()->attachAggregate(new HydratorListener($hydrator), $priority); } /** * {@inheritDoc} */ public function extract($object) { $event = new ExtractEvent($this, $object); $this->getEventManager()->trigger($event); return $event->getExtractedData(); } /** * {@inheritDoc} */ public function hydrate(array $data, $object) { $event = new HydrateEvent($this, $object, $data); $this->getEventManager()->trigger($event); return $event->getHydratedObject(); } /** * {@inheritDoc} */ public function setEventManager(EventManagerInterface $eventManager) { $eventManager->setIdentifiers([__CLASS__, get_class($this)]); $this->eventManager = $eventManager; } /** * {@inheritDoc} */ public function getEventManager() { if (null === $this->eventManager) { $this->setEventManager(new EventManager()); } return $this->eventManager; } } zend-hydrator-1.0.0/src/Aggregate/ExtractEvent.php000066400000000000000000000040571257654436300221310ustar00rootroot00000000000000target = $target; $this->extractionObject = $extractionObject; } /** * Retrieves the object from which data is extracted * * @return object */ public function getExtractionObject() { return $this->extractionObject; } /** * @param object $extractionObject * * @return void */ public function setExtractionObject($extractionObject) { $this->extractionObject = $extractionObject; } /** * Retrieves the data that has been extracted * * @return array */ public function getExtractedData() { return $this->extractedData; } /** * @param array $extractedData * * @return void */ public function setExtractedData(array $extractedData) { $this->extractedData = $extractedData; } /** * Merge provided data with the extracted data * * @param array $additionalData * * @return void */ public function mergeExtractedData(array $additionalData) { $this->extractedData = array_merge($this->extractedData, $additionalData); } } zend-hydrator-1.0.0/src/Aggregate/HydrateEvent.php000066400000000000000000000034401257654436300221120ustar00rootroot00000000000000target = $target; $this->hydratedObject = $hydratedObject; $this->hydrationData = $hydrationData; } /** * Retrieves the object that is being hydrated * * @return object */ public function getHydratedObject() { return $this->hydratedObject; } /** * @param object $hydratedObject */ public function setHydratedObject($hydratedObject) { $this->hydratedObject = $hydratedObject; } /** * Retrieves the data that is being used for hydration * * @return array */ public function getHydrationData() { return $this->hydrationData; } /** * @param array $hydrationData */ public function setHydrationData(array $hydrationData) { $this->hydrationData = $hydrationData; } } zend-hydrator-1.0.0/src/Aggregate/HydratorListener.php000066400000000000000000000040051257654436300230100ustar00rootroot00000000000000hydrator = $hydrator; } /** * {@inheritDoc} */ public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(HydrateEvent::EVENT_HYDRATE, [$this, 'onHydrate'], $priority); $this->listeners[] = $events->attach(ExtractEvent::EVENT_EXTRACT, [$this, 'onExtract'], $priority); } /** * Callback to be used when {@see HydrateEvent::EVENT_HYDRATE} is triggered * * @param HydrateEvent $event * @return object * @internal */ public function onHydrate(HydrateEvent $event) { $object = $this->hydrator->hydrate($event->getHydrationData(), $event->getHydratedObject()); $event->setHydratedObject($object); return $object; } /** * Callback to be used when {@see ExtractEvent::EVENT_EXTRACT} is triggered * * @param ExtractEvent $event * @return array * @internal */ public function onExtract(ExtractEvent $event) { $data = $this->hydrator->extract($event->getExtractionObject()); $event->mergeExtractedData($data); return $data; } } zend-hydrator-1.0.0/src/ArraySerializable.php000066400000000000000000000051201257654436300212240ustar00rootroot00000000000000getArrayCopy(); $filter = $this->getFilter(); foreach ($data as $name => $value) { if (!$filter->filter($name)) { unset($data[$name]); continue; } $extractedName = $this->extractName($name, $object); // replace the original key with extracted, if differ if ($extractedName !== $name) { unset($data[$name]); $name = $extractedName; } $data[$name] = $this->extractValue($name, $value, $object); } return $data; } /** * Hydrate an object * * Hydrates an object by passing $data to either its exchangeArray() or * populate() method. * * @param array $data * @param object $object * @return object * @throws Exception\BadMethodCallException for an $object not implementing exchangeArray() or populate() */ public function hydrate(array $data, $object) { $replacement = []; foreach ($data as $key => $value) { $name = $this->hydrateName($key, $data); $replacement[$name] = $this->hydrateValue($name, $value, $data); } if (is_callable([$object, 'exchangeArray'])) { $object->exchangeArray($replacement); } elseif (is_callable([$object, 'populate'])) { $object->populate($replacement); } else { throw new Exception\BadMethodCallException( sprintf('%s expects the provided object to implement exchangeArray() or populate()', __METHOD__) ); } return $object; } } zend-hydrator-1.0.0/src/ClassMethods.php000066400000000000000000000202541257654436300202150ustar00rootroot00000000000000setUnderscoreSeparatedKeys($underscoreSeparatedKeys); $this->callableMethodFilter = new Filter\OptionalParametersFilter(); $this->filterComposite->addFilter('is', new Filter\IsFilter()); $this->filterComposite->addFilter('has', new Filter\HasFilter()); $this->filterComposite->addFilter('get', new Filter\GetFilter()); $this->filterComposite->addFilter( 'parameter', new Filter\OptionalParametersFilter(), Filter\FilterComposite::CONDITION_AND ); } /** * @param array|Traversable $options * @return ClassMethods * @throws Exception\InvalidArgumentException */ public function setOptions($options) { if ($options instanceof Traversable) { $options = ArrayUtils::iteratorToArray($options); } elseif (!is_array($options)) { throw new Exception\InvalidArgumentException( 'The options parameter must be an array or a Traversable' ); } if (isset($options['underscoreSeparatedKeys'])) { $this->setUnderscoreSeparatedKeys($options['underscoreSeparatedKeys']); } return $this; } /** * @param bool $underscoreSeparatedKeys * @return ClassMethods */ public function setUnderscoreSeparatedKeys($underscoreSeparatedKeys) { $this->underscoreSeparatedKeys = (bool) $underscoreSeparatedKeys; if ($this->underscoreSeparatedKeys) { $this->setNamingStrategy(new NamingStrategy\UnderscoreNamingStrategy); } elseif ($this->getNamingStrategy() instanceof NamingStrategy\UnderscoreNamingStrategy) { $this->removeNamingStrategy(); } return $this; } /** * @return bool */ public function getUnderscoreSeparatedKeys() { return $this->underscoreSeparatedKeys; } /** * Extract values from an object with class methods * * Extracts the getter/setter of the given $object. * * @param object $object * @return array * @throws Exception\BadMethodCallException for a non-object $object */ public function extract($object) { if (!is_object($object)) { throw new Exception\BadMethodCallException(sprintf( '%s expects the provided $object to be a PHP object)', __METHOD__ )); } $objectClass = get_class($object); // reset the hydrator's hydrator's cache for this object, as the filter may be per-instance if ($object instanceof Filter\FilterProviderInterface) { $this->extractionMethodsCache[$objectClass] = null; } // pass 1 - finding out which properties can be extracted, with which methods (populate hydration cache) if (! isset($this->extractionMethodsCache[$objectClass])) { $this->extractionMethodsCache[$objectClass] = []; $filter = $this->filterComposite; $methods = get_class_methods($object); if ($object instanceof Filter\FilterProviderInterface) { $filter = new Filter\FilterComposite( [$object->getFilter()], [new Filter\MethodMatchFilter('getFilter')] ); } foreach ($methods as $method) { $methodFqn = $objectClass . '::' . $method; if (! ($filter->filter($methodFqn) && $this->callableMethodFilter->filter($methodFqn))) { continue; } $attribute = $method; if (strpos($method, 'get') === 0) { $attribute = substr($method, 3); if (!property_exists($object, $attribute)) { $attribute = lcfirst($attribute); } } $this->extractionMethodsCache[$objectClass][$method] = $attribute; } } $values = []; // pass 2 - actually extract data foreach ($this->extractionMethodsCache[$objectClass] as $methodName => $attributeName) { $realAttributeName = $this->extractName($attributeName, $object); $values[$realAttributeName] = $this->extractValue($realAttributeName, $object->$methodName(), $object); } return $values; } /** * Hydrate an object by populating getter/setter methods * * Hydrates an object by getter/setter methods of the object. * * @param array $data * @param object $object * @return object * @throws Exception\BadMethodCallException for a non-object $object */ public function hydrate(array $data, $object) { if (!is_object($object)) { throw new Exception\BadMethodCallException(sprintf( '%s expects the provided $object to be a PHP object)', __METHOD__ )); } $objectClass = get_class($object); foreach ($data as $property => $value) { $propertyFqn = $objectClass . '::$' . $property; if (! isset($this->hydrationMethodsCache[$propertyFqn])) { $setterName = 'set' . ucfirst($this->hydrateName($property, $data)); $this->hydrationMethodsCache[$propertyFqn] = is_callable([$object, $setterName]) ? $setterName : false; } if ($this->hydrationMethodsCache[$propertyFqn]) { $object->{$this->hydrationMethodsCache[$propertyFqn]}($this->hydrateValue($property, $value, $data)); } } return $object; } /** * {@inheritDoc} */ public function addFilter($name, $filter, $condition = Filter\FilterComposite::CONDITION_OR) { $this->resetCaches(); return parent::addFilter($name, $filter, $condition); } /** * {@inheritDoc} */ public function removeFilter($name) { $this->resetCaches(); return parent::removeFilter($name); } /** * {@inheritDoc} */ public function setNamingStrategy(NamingStrategy\NamingStrategyInterface $strategy) { $this->resetCaches(); return parent::setNamingStrategy($strategy); } /** * {@inheritDoc} */ public function removeNamingStrategy() { $this->resetCaches(); return parent::removeNamingStrategy(); } /** * Reset all local hydration/extraction caches */ private function resetCaches() { $this->hydrationMethodsCache = $this->extractionMethodsCache = []; } } zend-hydrator-1.0.0/src/DelegatingHydrator.php000066400000000000000000000024061257654436300214030ustar00rootroot00000000000000hydrators = $hydrators; } /** * {@inheritdoc} */ public function hydrate(array $data, $object) { return $this->getHydrator($object)->hydrate($data, $object); } /** * {@inheritdoc} */ public function extract($object) { return $this->getHydrator($object)->extract($object); } /** * Gets hydrator of an object * * @param object $object * @return HydratorInterface */ protected function getHydrator($object) { return $this->hydrators->get(get_class($object)); } } zend-hydrator-1.0.0/src/DelegatingHydratorFactory.php000066400000000000000000000016021257654436300227300ustar00rootroot00000000000000orFilter = new ArrayObject($orFilter); $this->andFilter = new ArrayObject($andFilter); } /** * Add a filter to the composite. Has to be indexed with $name in * order to identify a specific filter. * * This example will exclude all methods from the hydration, that starts with 'getService' * * $composite->addFilter('exclude', * function ($method) { * if (preg_match('/^getService/', $method) { * return false; * } * return true; * }, FilterComposite::CONDITION_AND * ); * * * @param string $name * @param callable|FilterInterface $filter * @param int $condition Can be either * FilterComposite::CONDITION_OR or FilterComposite::CONDITION_AND * @throws InvalidArgumentException * @return FilterComposite */ public function addFilter($name, $filter, $condition = self::CONDITION_OR) { if (!is_callable($filter) && !($filter instanceof FilterInterface)) { throw new InvalidArgumentException( 'The value of ' . $name . ' should be either a callable or ' . 'an instance of Zend\Stdlib\Hydrator\Filter\FilterInterface' ); } if ($condition === self::CONDITION_OR) { $this->orFilter[$name] = $filter; } elseif ($condition === self::CONDITION_AND) { $this->andFilter[$name] = $filter; } return $this; } /** * Remove a filter from the composition * * @param $name string Identifier for the filter * @return FilterComposite */ public function removeFilter($name) { if (isset($this->orFilter[$name])) { unset($this->orFilter[$name]); } if (isset($this->andFilter[$name])) { unset($this->andFilter[$name]); } return $this; } /** * Check if $name has a filter registered * * @param $name string Identifier for the filter * @return bool */ public function hasFilter($name) { return isset($this->orFilter[$name]) || isset($this->andFilter[$name]); } /** * Filter the composite based on the AND and OR condition * Will return true if one from the "or conditions" and all from * the "and condition" returns true. Otherwise false * * @param $property string Parameter will be e.g. Parent\Namespace\Class::method * @return bool */ public function filter($property) { $andCount = count($this->andFilter); $orCount = count($this->orFilter); // return true if no filters are registered if ($orCount === 0 && $andCount === 0) { return true; } elseif ($orCount === 0 && $andCount !== 0) { $returnValue = true; } else { $returnValue = false; } // Check if 1 from the or filters return true foreach ($this->orFilter as $filter) { if (is_callable($filter)) { if ($filter($property) === true) { $returnValue = true; break; } continue; } else { if ($filter->filter($property) === true) { $returnValue = true; break; } } } // Check if all of the and condition return true foreach ($this->andFilter as $filter) { if (is_callable($filter)) { if ($filter($property) === false) { return false; } continue; } else { if ($filter->filter($property) === false) { return false; } } } return $returnValue; } } zend-hydrator-1.0.0/src/Filter/FilterInterface.php000066400000000000000000000011231257654436300221110ustar00rootroot00000000000000method = $method; $this->exclude = $exclude; } public function filter($property) { $pos = strpos($property, '::'); if ($pos !== false) { $pos += 2; } else { $pos = 0; } if (substr($property, $pos) === $this->method) { return !$this->exclude; } return $this->exclude; } } zend-hydrator-1.0.0/src/Filter/NumberOfParameterFilter.php000066400000000000000000000025511257654436300235750ustar00rootroot00000000000000numberOfParameters = (int) $numberOfParameters; } /** * @param string $property the name of the property * @return bool * @throws InvalidArgumentException */ public function filter($property) { try { $reflectionMethod = new ReflectionMethod($property); } catch (ReflectionException $exception) { throw new InvalidArgumentException( "Method $property doesn't exist" ); } return $reflectionMethod->getNumberOfParameters() === $this->numberOfParameters; } } zend-hydrator-1.0.0/src/Filter/OptionalParametersFilter.php000066400000000000000000000031161257654436300240260ustar00rootroot00000000000000getParameters(), function (ReflectionParameter $parameter) { return ! $parameter->isOptional(); } ); return static::$propertiesCache[$property] = empty($mandatoryParameters); } } zend-hydrator-1.0.0/src/FilterEnabledInterface.php000066400000000000000000000033061257654436300221440ustar00rootroot00000000000000 * $composite->addFilter( * "servicelocator", * function ($property) { * list($class, $method) = explode('::', $property); * if ($method === 'getServiceLocator') { * return false; * } * return true; * }, * FilterComposite::CONDITION_AND * ); * * * @param string $name Index in the composite * @param callable|Filter\FilterInterface $filter * @param int $condition * @return Filter\FilterComposite */ public function addFilter($name, $filter, $condition = Filter\FilterComposite::CONDITION_OR); /** * Check whether a specific filter exists at key $name or not * * @param string $name Index in the composite * @return bool */ public function hasFilter($name); /** * Remove a filter from the composition. * To not extract "has" methods, you simply need to unregister it * * * $filterComposite->removeFilter('has'); * * * @param $name * @return Filter\FilterComposite */ public function removeFilter($name); } zend-hydrator-1.0.0/src/HydrationInterface.php000066400000000000000000000010721257654436300214030ustar00rootroot00000000000000hydrator = $hydrator; return $this; } /** * Retrieve hydrator * * @param void * @return null|HydratorInterface * @access public */ public function getHydrator() { return $this->hydrator; } } zend-hydrator-1.0.0/src/HydratorInterface.php000066400000000000000000000006401257654436300212360ustar00rootroot00000000000000 'Zend\Hydrator\DelegatingHydrator', ]; /** * Default set of adapters * * @var array */ protected $invokableClasses = [ 'arrayserializable' => 'Zend\Hydrator\ArraySerializable', 'classmethods' => 'Zend\Hydrator\ClassMethods', 'objectproperty' => 'Zend\Hydrator\ObjectProperty', 'reflection' => 'Zend\Hydrator\Reflection' ]; /** * Default factory-based adapters * * @var array */ protected $factories = [ 'Zend\Hydrator\DelegatingHydrator' => 'Zend\Hydrator\DelegatingHydratorFactory', ]; /** * {@inheritDoc} */ public function validatePlugin($plugin) { if ($plugin instanceof HydratorInterface) { // we're okay return; } throw new Exception\RuntimeException(sprintf( 'Plugin of type %s is invalid; must implement Zend\Hydrator\HydratorInterface', (is_object($plugin) ? get_class($plugin) : gettype($plugin)) )); } } zend-hydrator-1.0.0/src/Iterator/000077500000000000000000000000001257654436300167015ustar00rootroot00000000000000zend-hydrator-1.0.0/src/Iterator/HydratingArrayIterator.php000066400000000000000000000016621257654436300240610ustar00rootroot00000000000000setHydrator($hydrator); $this->setPrototype($prototype); parent::__construct($data); } /** * @inheritdoc */ public function setPrototype($prototype) { if (is_object($prototype)) { $this->prototype = $prototype; return; } if (!class_exists($prototype)) { throw new InvalidArgumentException( sprintf('Method %s was passed an invalid class name: %s', __METHOD__, $prototype) ); } $this->prototype = new $prototype; } /** * @inheritdoc */ public function setHydrator(HydratorInterface $hydrator) { $this->hydrator = $hydrator; } /** * @return object Returns hydrated clone of $prototype */ public function current() { $currentValue = parent::current(); $object = clone $this->prototype; $this->hydrator->hydrate($currentValue, $object); return $object; } } zend-hydrator-1.0.0/src/NamingStrategy/000077500000000000000000000000001257654436300200445ustar00rootroot00000000000000zend-hydrator-1.0.0/src/NamingStrategy/ArrayMapNamingStrategy.php000066400000000000000000000024061257654436300251500ustar00rootroot00000000000000extractionMap = $extractionMap; $this->hydrationMap = array_flip($extractionMap); } /** * {@inheritDoc} */ public function hydrate($name) { return isset($this->hydrationMap[$name]) ? $this->hydrationMap[$name] : $name; } /** * {@inheritDoc} */ public function extract($name) { return isset($this->extractionMap[$name]) ? $this->extractionMap[$name] : $name; } } zend-hydrator-1.0.0/src/NamingStrategy/CompositeNamingStrategy.php000066400000000000000000000033671257654436300254050ustar00rootroot00000000000000namingStrategies = array_map( function (NamingStrategyInterface $strategy) { // this callback is here only to ensure type-safety return $strategy; }, $strategies ); $this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy(); } /** * {@inheritDoc} */ public function extract($name) { $strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy; return $strategy->extract($name); } /** * {@inheritDoc} */ public function hydrate($name) { $strategy = isset($this->namingStrategies[$name]) ? $this->namingStrategies[$name] : $this->defaultNamingStrategy; return $strategy->hydrate($name); } } zend-hydrator-1.0.0/src/NamingStrategy/IdentityNamingStrategy.php000066400000000000000000000011701257654436300252220ustar00rootroot00000000000000mapping = $mapping; $this->reverse = $reverse ?: $this->flipMapping($mapping); } /** * Safelly flip mapping array. * * @param array $array Array to flip * @return array Flipped array * @throws InvalidArgumentException */ protected function flipMapping(array $array) { array_walk($array, function ($value) { if (!is_string($value) && !is_int($value)) { throw new InvalidArgumentException('Mapping array can\'t be flipped because of invalid value'); } }); return array_flip($array); } /** * Converts the given name so that it can be extracted by the hydrator. * * @param string $name The original name * @return mixed The hydrated name */ public function hydrate($name) { if (array_key_exists($name, $this->mapping)) { return $this->mapping[$name]; } return $name; } /** * Converts the given name so that it can be hydrated by the hydrator. * * @param string $name The original name * @return mixed The extracted name */ public function extract($name) { if (array_key_exists($name, $this->reverse)) { return $this->reverse[$name]; } return $name; } } zend-hydrator-1.0.0/src/NamingStrategy/NamingStrategyInterface.php000066400000000000000000000020221257654436300253260ustar00rootroot00000000000000getUnderscoreToStudlyCaseFilter()->filter($name); } /** * Remove capitalized letters and prepend underscores. * * @param string $name * @return string */ public function extract($name) { return $this->getCamelCaseToUnderscoreFilter()->filter($name); } /** * @return FilterChain */ protected function getUnderscoreToStudlyCaseFilter() { if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) { return static::$underscoreToStudlyCaseFilter; } $filter = new FilterChain(); $filter->attachByName('WordUnderscoreToStudlyCase'); return static::$underscoreToStudlyCaseFilter = $filter; } /** * @return FilterChain */ protected function getCamelCaseToUnderscoreFilter() { if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) { return static::$camelCaseToUnderscoreFilter; } $filter = new FilterChain(); $filter->attachByName('WordCamelCaseToUnderscore'); $filter->attachByName('StringToLower'); return static::$camelCaseToUnderscoreFilter = $filter; } } zend-hydrator-1.0.0/src/NamingStrategyEnabledInterface.php000066400000000000000000000020351257654436300236510ustar00rootroot00000000000000getFilter(); foreach ($data as $name => $value) { // Filter keys, removing any we don't want if (! $filter->filter($name)) { unset($data[$name]); continue; } // Replace name if extracted differ $extracted = $this->extractName($name, $object); if ($extracted !== $name) { unset($data[$name]); $name = $extracted; } $data[$name] = $this->extractValue($name, $value, $object); } return $data; } /** * {@inheritDoc} * * Hydrate an object by populating public properties * * Hydrates an object by setting public properties of the object. * * @throws Exception\BadMethodCallException for a non-object $object */ public function hydrate(array $data, $object) { if (!is_object($object)) { throw new Exception\BadMethodCallException( sprintf('%s expects the provided $object to be a PHP object)', __METHOD__) ); } $properties = & self::$skippedPropertiesCache[get_class($object)]; if (! isset($properties)) { $reflection = new ReflectionClass($object); $properties = array_fill_keys( array_map( function (ReflectionProperty $property) { return $property->getName(); }, $reflection->getProperties( ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PROTECTED + ReflectionProperty::IS_STATIC ) ), true ); } foreach ($data as $name => $value) { $property = $this->hydrateName($name, $data); if (isset($properties[$property])) { continue; } $object->$property = $this->hydrateValue($property, $value, $data); } return $object; } } zend-hydrator-1.0.0/src/Reflection.php000066400000000000000000000054361257654436300177230ustar00rootroot00000000000000extractName($property->getName(), $object); if (!$this->filterComposite->filter($propertyName)) { continue; } $value = $property->getValue($object); $result[$propertyName] = $this->extractValue($propertyName, $value, $object); } return $result; } /** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return object */ public function hydrate(array $data, $object) { $reflProperties = self::getReflProperties($object); foreach ($data as $key => $value) { $name = $this->hydrateName($key, $data); if (isset($reflProperties[$name])) { $reflProperties[$name]->setValue($object, $this->hydrateValue($name, $value, $data)); } } return $object; } /** * Get a reflection properties from in-memory cache and lazy-load if * class has not been loaded. * * @param string|object $input * @throws Exception\InvalidArgumentException * @return ReflectionProperty[] */ protected static function getReflProperties($input) { if (is_object($input)) { $input = get_class($input); } elseif (!is_string($input)) { throw new Exception\InvalidArgumentException('Input must be a string or an object.'); } if (isset(static::$reflProperties[$input])) { return static::$reflProperties[$input]; } static::$reflProperties[$input] = []; $reflClass = new ReflectionClass($input); $reflProperties = $reflClass->getProperties(); foreach ($reflProperties as $property) { $property->setAccessible(true); static::$reflProperties[$input][$property->getName()] = $property; } return static::$reflProperties[$input]; } } zend-hydrator-1.0.0/src/Strategy/000077500000000000000000000000001257654436300167125ustar00rootroot00000000000000zend-hydrator-1.0.0/src/Strategy/BooleanStrategy.php000066400000000000000000000062421257654436300225310ustar00rootroot00000000000000trueValue = $trueValue; $this->falseValue = $falseValue; } /** * Converts the given value so that it can be extracted by the hydrator. * * @param bool $value The original value. * @throws InvalidArgumentException * @return int|string Returns the value that should be extracted. */ public function extract($value) { if (!is_bool($value)) { throw new InvalidArgumentException(sprintf( 'Unable to extract. Expected bool. %s was given.', is_object($value) ? get_class($value) : gettype($value) )); } return $value === true ? $this->trueValue : $this->falseValue; } /** * Converts the given value so that it can be hydrated by the hydrator. * * @param int|string $value The original value. * @throws InvalidArgumentException * @return bool Returns the value that should be hydrated. */ public function hydrate($value) { if (!is_string($value) && !is_int($value)) { throw new InvalidArgumentException(sprintf( 'Unable to hydrate. Expected string or int. %s was given.', is_object($value) ? get_class($value) : gettype($value) )); } if ($value === $this->trueValue) { return true; } if ($value === $this->falseValue) { return false; } throw new InvalidArgumentException(sprintf( 'Unexpected value %s can\'t be hydrated. Expect %s or %s as Value.', $value, $this->trueValue, $this->falseValue )); } } zend-hydrator-1.0.0/src/Strategy/ClosureStrategy.php000066400000000000000000000060111257654436300225600ustar00rootroot00000000000000 * function ($value) { * return $value; * }; * * * @var callable */ protected $extractFunc = null; /** * Function, used in hydrate method, default: * * * function ($value) { * return $value; * }; * * * @var callable */ protected $hydrateFunc = null; /** * You can describe how your values will extract and hydrate, like this: * * * $hydrator->addStrategy('category', new ClosureStrategy( * function (Category $value) { * return (int) $value->id; * }, * function ($value) { * return new Category((int) $value); * } * )); * * * @param callable $extractFunc - anonymous function, that extract values * from object * @param callable $hydrateFunc - anonymous function, that hydrate values * into object */ public function __construct($extractFunc = null, $hydrateFunc = null) { if (isset($extractFunc)) { if (!is_callable($extractFunc)) { throw new \Exception('$extractFunc must be callable'); } $this->extractFunc = $extractFunc; } else { $this->extractFunc = function ($value) { return $value; }; } if (isset($hydrateFunc)) { if (!is_callable($hydrateFunc)) { throw new \Exception('$hydrateFunc must be callable'); } $this->hydrateFunc = $hydrateFunc; } else { $this->hydrateFunc = function ($value) { return $value; }; } } /** * Converts the given value so that it can be extracted by the hydrator. * * @param mixed $value The original value. * @param array $object The object is optionally provided as context. * @return mixed Returns the value that should be extracted. */ public function extract($value, $object = null) { $func = $this->extractFunc; return $func($value, $object); } /** * Converts the given value so that it can be hydrated by the hydrator. * * @param mixed $value The original value. * @param array $data The whole data is optionally provided as context. * @return mixed Returns the value that should be hydrated. */ public function hydrate($value, $data = null) { $func = $this->hydrateFunc; return $func($value, $data); } } zend-hydrator-1.0.0/src/Strategy/DateTimeFormatterStrategy.php000066400000000000000000000034121257654436300245260ustar00rootroot00000000000000format = (string) $format; $this->timezone = $timezone; } /** * {@inheritDoc} * * Converts to date time string * * @param mixed|DateTime $value * * @return mixed|string */ public function extract($value) { if ($value instanceof DateTime) { return $value->format($this->format); } return $value; } /** * Converts date time string to DateTime instance for injecting to object * * {@inheritDoc} * * @param mixed|string $value * * @return mixed|DateTime */ public function hydrate($value) { if ($value === '' || $value === null) { return; } if ($this->timezone) { $hydrated = DateTime::createFromFormat($this->format, $value, $this->timezone); } else { $hydrated = DateTime::createFromFormat($this->format, $value); } return $hydrated ?: $value; } } zend-hydrator-1.0.0/src/Strategy/DefaultStrategy.php000066400000000000000000000017051257654436300225350ustar00rootroot00000000000000setValueDelimiter($delimiter); $this->explodeLimit = ($explodeLimit === null) ? null : (int) $explodeLimit; } /** * Sets the delimiter string that the values will be split upon * * @param string $delimiter * @return self */ private function setValueDelimiter($delimiter) { if (!is_string($delimiter)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects Delimiter to be string, %s provided instead', __METHOD__, is_object($delimiter) ? get_class($delimiter) : gettype($delimiter) )); } if (empty($delimiter)) { throw new Exception\InvalidArgumentException('Delimiter cannot be empty.'); } $this->valueDelimiter = $delimiter; } /** * {@inheritDoc} * * Split a string by delimiter * * @param string|null $value * * @return string[] * * @throws Exception\InvalidArgumentException */ public function hydrate($value) { if (null === $value) { return []; } if (!(is_string($value) || is_numeric($value))) { throw new Exception\InvalidArgumentException(sprintf( '%s expects argument 1 to be string, %s provided instead', __METHOD__, is_object($value) ? get_class($value) : gettype($value) )); } if ($this->explodeLimit !== null) { return explode($this->valueDelimiter, $value, $this->explodeLimit); } return explode($this->valueDelimiter, $value); } /** * {@inheritDoc} * * Join array elements with delimiter * * @param string[] $value The original value. * * @return string|null */ public function extract($value) { if (!is_array($value)) { throw new Exception\InvalidArgumentException(sprintf( '%s expects argument 1 to be array, %s provided instead', __METHOD__, is_object($value) ? get_class($value) : gettype($value) )); } return empty($value) ? null : implode($this->valueDelimiter, $value); } } zend-hydrator-1.0.0/src/Strategy/SerializableStrategy.php000066400000000000000000000066651257654436300235710ustar00rootroot00000000000000setSerializer($serializer); if ($serializerOptions) { $this->setSerializerOptions($serializerOptions); } } /** * Serialize the given value so that it can be extracted by the hydrator. * * @param mixed $value The original value. * @return mixed Returns the value that should be extracted. */ public function extract($value) { $serializer = $this->getSerializer(); return $serializer->serialize($value); } /** * Unserialize the given value so that it can be hydrated by the hydrator. * * @param mixed $value The original value. * @return mixed Returns the value that should be hydrated. */ public function hydrate($value) { $serializer = $this->getSerializer(); return $serializer->unserialize($value); } /** * Set serializer * * @param string|SerializerAdapter $serializer * @return SerializableStrategy */ public function setSerializer($serializer) { if (!is_string($serializer) && !$serializer instanceof SerializerAdapter) { throw new InvalidArgumentException(sprintf( '%s expects either a string serializer name or Zend\Serializer\Adapter\AdapterInterface instance; ' . 'received "%s"', __METHOD__, (is_object($serializer) ? get_class($serializer) : gettype($serializer)) )); } $this->serializer = $serializer; return $this; } /** * Get serializer * * @return SerializerAdapter */ public function getSerializer() { if (is_string($this->serializer)) { $options = $this->getSerializerOptions(); $this->setSerializer(SerializerFactory::factory($this->serializer, $options)); } elseif (null === $this->serializer) { $this->setSerializer(SerializerFactory::getDefaultAdapter()); } return $this->serializer; } /** * Set configuration options for instantiating a serializer adapter * * @param mixed $serializerOptions * @return SerializableStrategy */ public function setSerializerOptions($serializerOptions) { $this->serializerOptions = $serializerOptions; return $this; } /** * Get configuration options for instantiating a serializer adapter * * @return mixed */ public function getSerializerOptions() { return $this->serializerOptions; } } zend-hydrator-1.0.0/src/Strategy/StrategyChain.php000066400000000000000000000033201257654436300221660ustar00rootroot00000000000000extractionStrategies = array_map( function (StrategyInterface $strategy) { // this callback is here only to ensure type-safety return $strategy; }, $extractionStrategies ); $this->hydrationStrategies = array_reverse($extractionStrategies); } /** * {@inheritDoc} */ public function extract($value) { foreach ($this->extractionStrategies as $strategy) { $value = $strategy->extract($value); } return $value; } /** * {@inheritDoc} */ public function hydrate($value) { foreach ($this->hydrationStrategies as $strategy) { $value = $strategy->hydrate($value); } return $value; } } zend-hydrator-1.0.0/src/Strategy/StrategyInterface.php000066400000000000000000000020761257654436300230530ustar00rootroot00000000000000