Advertisement
dragonbe

fixing some typos

Aug 27th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)) {
  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());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement