1 | <?php |
||
12 | class PEMBundle implements \Countable, \IteratorAggregate |
||
13 | { |
||
14 | /** |
||
15 | * Array of PEM objects. |
||
16 | * |
||
17 | * @var PEM[] $_pems |
||
18 | */ |
||
19 | protected $_pems; |
||
20 | |||
21 | /** |
||
22 | * Constructor. |
||
23 | * |
||
24 | * @param PEM ...$pems |
||
25 | */ |
||
26 | public function __construct(PEM ...$pems) |
||
30 | |||
31 | /** |
||
32 | * Initialize from a string. |
||
33 | * |
||
34 | * @param string $str |
||
35 | * @throws \UnexpectedValueException |
||
36 | * @return self |
||
37 | */ |
||
38 | public static function fromString(string $str): self |
||
55 | |||
56 | /** |
||
57 | * Initialize from a file. |
||
58 | * |
||
59 | * @param string $filename |
||
60 | * @throws \RuntimeException If file reading fails |
||
61 | * @return self |
||
62 | */ |
||
63 | public static function fromFile($filename): self |
||
71 | |||
72 | /** |
||
73 | * Get self with PEM objects appended. |
||
74 | * |
||
75 | * @param PEM ...$pems |
||
76 | * @return self |
||
77 | */ |
||
78 | public function withPEMs(PEM ...$pems): self |
||
84 | |||
85 | /** |
||
86 | * Get all PEMs in a bundle. |
||
87 | * |
||
88 | * @return PEM[] |
||
89 | */ |
||
90 | public function all(): array |
||
94 | |||
95 | /** |
||
96 | * Get the first PEM in a bundle. |
||
97 | * |
||
98 | * @throws \LogicException If bundle contains no PEM objects |
||
99 | * @return PEM |
||
100 | */ |
||
101 | public function first(): PEM |
||
108 | |||
109 | /** |
||
110 | * |
||
111 | * @see \Countable::count() |
||
112 | * @return int |
||
113 | */ |
||
114 | public function count(): int |
||
118 | |||
119 | /** |
||
120 | * Get iterator for PEMs. |
||
121 | * |
||
122 | * @see \IteratorAggregate::getIterator() |
||
123 | * @return \ArrayIterator |
||
124 | */ |
||
125 | public function getIterator(): \ArrayIterator |
||
129 | |||
130 | /** |
||
131 | * Encode bundle to a string of contiguous PEM blocks. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | public function string(): string |
||
143 | |||
144 | /** |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | public function __toString() |
||
152 | } |
||
153 |