Total Complexity | 10 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
7 | class Worlds implements WorldsInterface |
||
8 | { |
||
9 | public $worlds = array(); |
||
10 | |||
11 | |||
12 | public function push( WorldInterface $world ) |
||
13 | { |
||
14 | $this->worlds[ $world->getId() ] = $world; |
||
15 | return $this; |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * @implements ContainerInterface |
||
20 | * @return WorldInterface |
||
21 | */ |
||
22 | public function get( $id_or_slug ) |
||
23 | { |
||
24 | $filter = function( $world, $id ) use ($id_or_slug) { |
||
|
|||
25 | return ($world->getId() == $id_or_slug |
||
26 | or $world->getSlug() == $id_or_slug); |
||
27 | }; |
||
28 | |||
29 | $worlds = new \CallbackFilterIterator( $this->getIterator(), $filter); |
||
30 | $worlds->rewind(); |
||
31 | if ($worlds->valid()): |
||
32 | return $worlds->current(); |
||
33 | else: |
||
34 | throw new WorldNotFoundException("Could not find product world with ID or slug '$id_or_slug'"); |
||
35 | endif; |
||
36 | } |
||
37 | |||
38 | |||
39 | |||
40 | /** |
||
41 | * @implements ContainerInterface |
||
42 | * @return boolean |
||
43 | */ |
||
44 | public function has ($id_or_slug ) |
||
53 | } |
||
54 | |||
55 | |||
56 | /** |
||
57 | * @implements IteratorAggregate |
||
58 | */ |
||
59 | public function getIterator() |
||
62 | } |
||
63 | |||
64 | |||
65 | /** |
||
66 | * @implements Countable |
||
67 | */ |
||
68 | public function count() |
||
73 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.