| Total Complexity | 8 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Chain implements ResultMapperInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Mapper chain. |
||
| 16 | * |
||
| 17 | * @var array<ResultMapperInterface> |
||
| 18 | */ |
||
| 19 | protected $mappers = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Class constructor. |
||
| 23 | * |
||
| 24 | * @param iterable<ResultMapperInterface> $mappers Mapper chain. |
||
| 25 | */ |
||
| 26 | public function __construct($mappers = []) |
||
| 27 | { |
||
| 28 | $this->addMappers($mappers); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Adds a Mapper to the chain. |
||
| 33 | * |
||
| 34 | * @param ResultMapperInterface $mapper |
||
| 35 | */ |
||
| 36 | public function addMapper(ResultMapperInterface $mapper) |
||
| 37 | { |
||
| 38 | if ($mapper instanceof self) { |
||
| 39 | return $this->addMappers($mapper->mappers); |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->mappers[] = $mapper; |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Add mappers to the chain. |
||
| 49 | * |
||
| 50 | * @param iterable<ResultMapperInterface> $mappers |
||
| 51 | */ |
||
| 52 | public function addMappers($mappers) |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @inheritDoc |
||
| 63 | */ |
||
| 64 | public function map(DateLexerResult $parts, DateRepresentationInterface $date) |
||
| 75 |