1 | <?php |
||
6 | final class ItemList |
||
7 | { |
||
8 | /** |
||
9 | * |
||
10 | */ |
||
11 | private CONST STATE_NONE = 0; |
||
12 | /** |
||
13 | * |
||
14 | */ |
||
15 | private CONST STATE_NAME = 1; |
||
16 | /** |
||
17 | * |
||
18 | */ |
||
19 | private CONST STATE_SECTION = 2; |
||
20 | /** |
||
21 | * |
||
22 | */ |
||
23 | private CONST STATE_PARTIAL = 3; |
||
24 | /** |
||
25 | * |
||
26 | */ |
||
27 | private CONST STATE_OCTET = 4; |
||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | private $list = []; |
||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | private $size; |
||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $body; |
||
40 | |||
41 | /** |
||
42 | * ItemList constructor. |
||
43 | * @param array $list |
||
44 | */ |
||
45 | public function __construct(array $list = []) |
||
49 | |||
50 | /** |
||
51 | * @param Item $item |
||
52 | * @return ItemList |
||
53 | */ |
||
54 | public function withItem(Item $item): self |
||
60 | |||
61 | /** |
||
62 | * @param int $size |
||
63 | * @return ItemList |
||
64 | */ |
||
65 | public function withOctet(int $size): self |
||
71 | |||
72 | /** |
||
73 | * @param string $body |
||
74 | * @return ItemList |
||
75 | */ |
||
76 | public function withBody(string $body): self |
||
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | public function getBody(): string |
||
90 | |||
91 | /** |
||
92 | * @param $name |
||
93 | * @return Item |
||
94 | */ |
||
95 | public function getName($name): Item |
||
105 | |||
106 | /** |
||
107 | * @return Item |
||
108 | */ |
||
109 | public function last(): Item |
||
117 | |||
118 | /** |
||
119 | * @return string |
||
120 | */ |
||
121 | public function __toString(): string |
||
139 | |||
140 | /** |
||
141 | * @param string $serializedList |
||
142 | * @return ItemList |
||
143 | */ |
||
144 | public static function fromString(string $serializedList): self |
||
250 | } |