1 | <?php |
||
7 | class MethodCollection implements \IteratorAggregate, \Countable |
||
8 | { |
||
9 | private $methods = []; |
||
10 | private $resources = []; |
||
11 | |||
12 | public function getIterator() |
||
13 | { |
||
14 | return new \ArrayIterator($this->methods); |
||
15 | } |
||
16 | |||
17 | public function count() |
||
18 | { |
||
19 | return count($this->methods); |
||
20 | } |
||
21 | |||
22 | public function add($name, Method $method) |
||
23 | { |
||
24 | unset($this->methods[$name]); |
||
25 | |||
26 | $this->methods[$name] = $method; |
||
27 | } |
||
28 | |||
29 | public function all() |
||
30 | { |
||
31 | return $this->methods; |
||
32 | } |
||
33 | |||
34 | |||
35 | public function get($name) |
||
43 | |||
44 | /** |
||
45 | * Removes a route or an array of routes by name from the collection. |
||
46 | * |
||
47 | * @param string|array $name The route name or an array of route names |
||
48 | */ |
||
49 | public function remove($name) |
||
55 | |||
56 | public function addCollection(MethodCollection $collection) |
||
67 | |||
68 | public function getResources() |
||
72 | |||
73 | public function addResource(ResourceInterface $resource) |
||
77 | |||
78 | public function addDefaults(array $defaults) |
||
79 | { |
||
80 | if ($defaults) { |
||
|
|||
81 | /** |
||
89 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.