1 | <?php |
||
11 | final class ArrayEnsurance implements EnsuranceInterface |
||
12 | { |
||
13 | use EnsuranceTrait; |
||
14 | |||
15 | /** |
||
16 | * ArrayEnsurance constructor. |
||
17 | * |
||
18 | * @param EnsuranceInterface $ensurance |
||
19 | */ |
||
20 | public function __construct(EnsuranceInterface $ensurance) |
||
25 | 9 | ||
26 | 9 | private function forEach(callable $callback): array |
|
30 | |||
31 | public function all(callable $callback): self |
||
37 | 1 | ||
38 | public function any(callable $callback): self |
||
44 | |||
45 | 1 | public function allTypeOf(string $type): self |
|
53 | |||
54 | public function anyTypeOf(string $type): self |
||
62 | 1 | ||
63 | /** |
||
64 | * @param $key |
||
65 | * |
||
66 | * @return ArrayEnsurance |
||
67 | */ |
||
68 | public function hasKey($key): self |
||
75 | 1 | ||
76 | /** |
||
77 | * @param $value |
||
78 | * |
||
79 | * @return ArrayEnsurance |
||
80 | */ |
||
81 | public function hasValue($value): self |
||
88 | 1 | ||
89 | /** |
||
90 | * @param int $length |
||
91 | * |
||
92 | * @return ArrayEnsurance |
||
93 | */ |
||
94 | public function hasLengthOf(int $length): self |
||
101 | 1 | ||
102 | /** |
||
103 | * @param int $length |
||
104 | * |
||
105 | * @return ArrayEnsurance |
||
106 | */ |
||
107 | public function isShorterThan(int $length): self |
||
114 | 1 | ||
115 | /** |
||
116 | * @param int $length |
||
117 | * |
||
118 | * @return ArrayEnsurance |
||
119 | */ |
||
120 | 1 | public function isShorterOrEqualsTo(int $length): self |
|
127 | |||
128 | /** |
||
129 | * @param int $length |
||
130 | * |
||
131 | 1 | * @return ArrayEnsurance |
|
132 | */ |
||
133 | 1 | public function isLongerThan(int $length): self |
|
140 | |||
141 | /** |
||
142 | * @param int $length |
||
143 | * |
||
144 | * @return ArrayEnsurance |
||
145 | */ |
||
146 | public function isLongerOrEqualTo(int $length): self |
||
153 | |||
154 | /** |
||
155 | * @return ArrayEnsurance |
||
156 | */ |
||
157 | public function isAssociative(): self |
||
165 | |||
166 | /** |
||
167 | * @return ArrayEnsurance |
||
168 | */ |
||
169 | public function isNotAssociative(): self |
||
177 | |||
178 | /** |
||
179 | * @return ArrayEnsurance |
||
180 | */ |
||
181 | public function isCallable(): self |
||
187 | } |
||
188 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.