| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/core/src/lmbSetInterface.interface.php'); 10 11 /** 12 * class lmbSet. 13 * 14 * @package core 15 * @version $Id$ 16 */ 17 class lmbSet implements lmbSetInterface, Iterator//should Iterator be a part of lmbSetInterface? 18 { 19 protected $properties = array(); 20 21 function __construct($properties = array()) 22 { 23 if(is_array($properties)) 24 $this->properties = $properties; 25 else 26 $this->properties = array(); 27 } 28 29 function get($name) 30 { 31 if(isset($this->properties[$name])) 32 return $this->properties[$name]; 33 } 34 35 function getInteger($name) 36 { 37 return (int)$this->get($name); 38 } 39 40 function getNumeric($name) 41 { 42 return (0 + $this->get($name)); 43 } 44 45 function getArray($name) 46 { 47 if(!is_array($value = $this->get($name))) 48 return array(); 49 50 return $value; 51 } 52 53 function set($name, $value) 54 { 55 $this->properties[$name] = $value; 56 } 57 58 function remove($name) 59 { 60 if(isset($this->properties[$name])) 61 unset($this->properties[$name]); 62 } 63 64 function removeAll() 65 { 66 $this->properties = array(); 67 } 68 69 function reset() 70 { 71 return $this->removeAll(); 72 } 73 74 function import($property_list) 75 { 76 $this->properties = $property_list; 77 } 78 79 function merge($property_list) 80 { 81 if(is_array($property_list) || is_a($property_list, 'ArrayAccess')) 82 { 83 foreach($property_list as $name => $value) 84 $this->set($name, $value); 85 } 86 } 87 88 function export() 89 { 90 return $this->properties; 91 } 92 93 function has($name) 94 { 95 return isset($this->properties[$name]); 96 } 97 98 function isEmpty() 99 { 100 return sizeof($this->properties) == 0; 101 } 102 103 function getPropertyList() 104 { 105 return array_keys($this->properties); 106 } 107 108 //ArrayAccess interface 109 function offsetExists($offset) 110 { 111 return $this->has($offset); 112 } 113 114 function offsetGet($offset) 115 { 116 return $this->get($offset); 117 } 118 119 function offsetSet($offset, $value) 120 { 121 $this->set($offset, $value); 122 } 123 124 function offsetUnset($offset) 125 { 126 $this->remove($offset); 127 } 128 129 //Iterator interface 130 function valid() 131 { 132 return $this->valid; 133 } 134 135 function current() 136 { 137 return $this->current; 138 } 139 140 function next() 141 { 142 $this->current = next($this->properties); 143 $this->valid = $this->current !== false; 144 } 145 146 function rewind() 147 { 148 $this->current = reset($this->properties); 149 $this->valid = $this->current !== false; 150 } 151 152 function key() 153 { 154 return key($this->properties); 155 } 156 } 157 158 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Sep 8 04:35:41 2008 | Cross-referenced by PHPXref 0.7 |