Total Complexity | 3 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class DefaultCarrierFactory implements CarrierFactory |
||
14 | { |
||
15 | 25 | public function __construct( |
|
16 | private readonly MethodFactory $methodFactory, |
||
17 | ) { |
||
18 | 25 | } |
|
19 | |||
20 | /** @inheritDoc */ |
||
21 | 9 | public function create(string $carrier, array $data): Carrier |
|
22 | { |
||
23 | 9 | return new DefaultCarrier($carrier, $data['name'], array_map(fn (array $methods) => $this->methodFactory->createCollection($methods), array_filter([ |
|
24 | 9 | Version::V2V1 => $data['methods'] ?? [], |
|
25 | 9 | Version::V2V2 => $data['v2_methods'] ?? [], |
|
26 | 9 | ]))); |
|
27 | } |
||
28 | |||
29 | /** @inheritDoc */ |
||
30 | 6 | public function createCollection(array $data): CarrierCollection |
|
34 | 6 | ); |
|
35 | } |
||
36 | } |
||
37 |