SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | class Cupboard | |
3 | { | |
4 | protected $_items; | |
5 | ||
6 | public function __construct() | |
7 | { | |
8 | $this->_items = array(); | |
9 | } | |
10 | ||
11 | public function insert($item) | |
12 | { | |
13 | $this->_items[] = $item; | |
14 | return $this; | |
15 | } | |
16 | ||
17 | public function remove($item) | |
18 | { | |
19 | - | if (($key = array_search($item, $this->_items)) !== FALSE) { |
19 | + | if (($key = array_search($item, $this->_items) !== FALSE)) { |
20 | unset($this->_items[$key]); | |
21 | } | |
22 | return $this; | |
23 | } | |
24 | ||
25 | public function getAll() | |
26 | { | |
27 | return $this->_items; | |
28 | } | |
29 | } | |
30 | ||
31 | $cup = new Cupboard; | |
32 | - | var_dump($cup->insert('spoon')->insert('knife')->remove('spoon')->insert('plate')->getAll()); |
32 | + | var_dump($cup->insert('spoon')->insert('knife')->remove('spoon')->insert('plate')->getAll()); |