Total Complexity | 9 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | final class Packaging |
||
17 | { |
||
18 | private array $parcel; |
||
19 | private ?array $subPackage; |
||
20 | private ?array $consumerUnit; |
||
21 | |||
22 | public function __construct(array $parcel, ?array $subPackage = null, ?array $consumerUnit = null) |
||
23 | { |
||
24 | $this->parcel = $parcel; |
||
25 | $this->subPackage = $subPackage; |
||
26 | $this->consumerUnit = $consumerUnit; |
||
27 | } |
||
28 | |||
29 | public static function fromArray(array $packages): self |
||
30 | { |
||
31 | $parcel = Storage::fromArray($packages[0])->toArray(); |
||
32 | $subPackage = null; |
||
33 | $consumerUnit = null; |
||
34 | |||
35 | for ($i = 1; $i < 3; ++$i) { |
||
36 | if (null !== $packages[$i]) { |
||
37 | if (1 === $i) { |
||
38 | $subPackage = Storage::fromArray($packages[$i])->toArray(); |
||
39 | } |
||
40 | if (2 === $i) { |
||
41 | $consumerUnit = Storage::fromArray($packages[$i])->toArray(); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | return new self($parcel, $subPackage, $consumerUnit); |
||
47 | } |
||
48 | |||
49 | public function parcel(): array |
||
50 | { |
||
51 | return $this->parcel; |
||
52 | } |
||
53 | |||
54 | public function subPackage(): ?array |
||
57 | } |
||
58 | |||
59 | public function consumerUnit(): ?array |
||
62 | } |
||
63 | } |
||
64 |