1 | <?php |
||
10 | final class SectionList |
||
11 | { |
||
12 | /** |
||
13 | * |
||
14 | */ |
||
15 | private CONST RFC_3501_SECTION_FIXED = [ |
||
16 | 'HEADER' => true, |
||
17 | 'TEXT' => true, |
||
18 | ]; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $sections = []; |
||
24 | |||
25 | /** |
||
26 | * SectionList constructor. |
||
27 | * @param array $sections |
||
28 | */ |
||
29 | 11 | public function __construct(array $sections = []) |
|
37 | |||
38 | /** |
||
39 | * @return string |
||
40 | */ |
||
41 | 8 | public function __toString(): string |
|
48 | |||
49 | /** |
||
50 | * @param string $sections |
||
51 | * @return SectionList |
||
52 | */ |
||
53 | 2 | public static function fromString(string $sections): self |
|
85 | |||
86 | /** |
||
87 | * @param string $section |
||
88 | */ |
||
89 | 8 | private function validateSection(string $section): void |
|
105 | } |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: