stg / ieu_hydrator
ieUtilities - Hydrator
dev-master
2016-11-30 12:30 UTC
This package is auto-updated.
Last update: 2024-10-27 04:18:12 UTC
README
Simple PHP hydration/extraction concept. Inspired by the work of Zend/Hydator.
Example
use ieu\Hydrator\ClosureHydrator; use ieu\Hydrator\NamingStrategies\UnderscoreNamingStrategy; // Setup $namingStrategy = new UnderscoreNamingStrategy; $hydrator = (new ClosureHydrator) ->setNamingStrategy(namingStrategy); // Usage class Dummy { protected $aName; protected $bName; } $dummy = $hydrator->hydrate(new Dummy, ['aName' => 1, 'bName' => 2]); $data = $hydrator->extract($dummy); // Returns ['a_name' => 1, 'b_name' => 2]