| Total Complexity | 8 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | final class Mapper implements MakesMap |
||
| 20 | { |
||
| 21 | private $name; |
||
| 22 | private $properties; |
||
| 23 | |||
| 24 | private function __construct(string $name, array $properties = []) |
||
| 25 | { |
||
| 26 | $this->name = $name; |
||
| 27 | $this->properties = $properties; |
||
| 28 | } |
||
| 29 | |||
| 30 | public static function forThe(string $className) : self |
||
| 31 | { |
||
| 32 | return new self($className); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function property( |
||
| 41 | } |
||
| 42 | |||
| 43 | public function hydrator() : Hydrates |
||
| 44 | { |
||
| 45 | return MappedHydrator::fromThis($this->map()); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function map() : MapsObject |
||
| 49 | { |
||
| 50 | $class = $this->name; |
||
| 51 | $properties = []; |
||
| 52 | foreach ($this->properties as $name => $instruction) { |
||
| 53 | $properties[] = $instruction->followFor($name); |
||
| 54 | } |
||
| 55 | return Mapping::ofThe($class, ...$properties); |
||
| 56 | } |
||
| 57 | |||
| 58 | private function add( |
||
| 64 | } |
||
| 65 | } |
||
| 66 |