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 /* $Id: AbstractList.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00018     abstract class AbstractList implements ArrayAccess, SimplifiedArrayAccess
00019     {
00020         protected $list = array();
00021         
00022         public function offsetGet($offset)
00023         {
00024             if (isset($this->list[$offset]))
00025                 return $this->list[$offset];
00026             
00027             throw new MissingElementException(
00028                 "no object found with index == '{$offset}'"
00029             );
00030         }
00031         
00032         public function offsetUnset($offset)
00033         {
00034             unset($this->list[$offset]);
00035             
00036             return $this;
00037         }
00038         
00039         public function offsetExists($offset)
00040         {
00041             return isset($this->list[$offset]);
00042         }
00043         
00044         // SAA goes here
00045         
00046         public function clean()
00047         {
00048             $this->list = array();
00049         }
00050         
00051         public function isEmpty()
00052         {
00053             return ($this->list === array());
00054         }
00055         
00056         public function getList()
00057         {
00058             return $this->list;
00059         }
00060         
00061         public function set($name, $var)
00062         {
00063             return $this->offsetSet($name, $var);
00064         }
00065         
00066         public function get($name)
00067         {
00068             return $this->offsetGet($name);
00069         }
00070         
00071         public function has($name)
00072         {
00073             return $this->offsetExists($name);
00074         }
00075         
00076         public function drop($name)
00077         {
00078             return $this->offsetUnset($name);
00079         }
00080     }
00081 ?>

Generated on Sun Dec 9 21:56:24 2007 for onPHP by  doxygen 1.5.4