# AbstractList.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00017     abstract class AbstractList implements ArrayAccess, SimplifiedArrayAccess
    00018     {
    00019         protected $list = array();
    00020
    00021         public function offsetGet($offset)
    00022         {
    00023             if (isset($this->list[$offset]))
    00024                 return $this->list[$offset];
    00025
    00026             throw new MissingElementException(
    00027                 "no object found with index == '{$offset}'"
    00028             );
    00029         }
    00030
    00034         public function offsetUnset($offset)
    00035         {
    00036             unset($this->list[$offset]);
    00037
    00038             return $this;
    00039         }
    00040
    00041         public function offsetExists($offset)
    00042         {
    00043             return isset($this->list[$offset]);
    00044         }
    00045
    00046         // SAA goes here
    00047
    00051         public function clean()
    00052         {
    00053             $this->list = array();
    00054
    00055             return $this;
    00056         }
    00057
    00058         public function isEmpty()
    00059         {
    00060             return ($this->list === array());
    00061         }
    00062
    00063         public function getList()
    00064         {
    00065             return $this->list;
    00066         }
    00067
    00068         public function set($name, $var)
    00069         {
    00070             return $this->offsetSet($name, $var);
    00071         }
    00072
    00073         public function get($name)
    00074         {
    00075             return $this->offsetGet($name);
    00076         }
    00077
    00078         public function has($name)
    00079         {
    00080             return $this->offsetExists($name);
    00081         }
    00082
    00083         public function drop($name)
    00084         {
    00085             return $this->offsetUnset($name);
    00086         }
    00087     }
    00088 ?>