August 2016
Intermediate to advanced
610 pages
11h 55m
English
The Hydrator pattern is a variation of the Data Transfer Object design pattern. Its design principle is quite simple: moving data from one place to another. In this illustration, we will define classes to move data from an array to an object.
Hydrator class that is able to use getters and setters. For this illustration we will use Application\Generic\Hydrator\GetSet:namespace Application\Generic\Hydrator;
class GetSet
{
// code
}hydrate() method, which takes both an array and an object as arguments. It then calls the setXXX() methods on the object to populate it with values from the array. We use get_class() to determine the object's class, and then get_class_methods() ...Read now
Unlock full access