1 | <?php |
||
8 | class ItemCodes implements ContainerInterface, \Countable, \IteratorAggregate |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @var ItemCodeInterface[] |
||
13 | */ |
||
14 | public $item_codes = array(); |
||
15 | |||
16 | |||
17 | 8 | public function push (ItemCodeInterface $item ) |
|
22 | |||
23 | /** |
||
24 | * @param string $code |
||
25 | * @return ItemCodeNotFoundException |
||
26 | */ |
||
27 | 8 | public function get($code) |
|
28 | { |
||
29 | 8 | if (!$this->has($code)): |
|
30 | 4 | throw new ItemCodeNotFoundException( "Could not find Item code '$code'." ); |
|
31 | endif; |
||
32 | |||
33 | 4 | return $this->item_codes[ $code ]; |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param string $code |
||
38 | * @return boolean |
||
39 | */ |
||
40 | 8 | public function has($code) |
|
41 | { |
||
42 | 8 | return array_key_exists($code, $this->item_codes); |
|
43 | } |
||
44 | |||
45 | |||
46 | /** |
||
47 | * @return int |
||
48 | */ |
||
49 | 12 | public function count() |
|
53 | |||
54 | /** |
||
55 | * @return ArrayIterator |
||
56 | */ |
||
57 | 16 | public function getIterator() |
|
61 | } |
||
62 |