123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- require_once 'XML/XRD/LogicException.php';
- require_once 'XML/XRD/Element/Property.php';
- abstract class XML_XRD_PropertyAccess implements ArrayAccess
- {
-
- public $properties = array();
-
- public function offsetExists($type)
- {
- foreach ($this->properties as $prop) {
- if ($prop->type == $type) {
- return true;
- }
- }
- return false;
- }
-
- public function offsetGet($type)
- {
- foreach ($this->properties as $prop) {
- if ($prop->type == $type) {
- return $prop->value;
- }
- }
- return null;
- }
-
- public function offsetSet($type, $value)
- {
- throw new XML_XRD_LogicException('Changing properties not implemented');
- }
-
- public function offsetUnset($type)
- {
- throw new XML_XRD_LogicException('Changing properties not implemented');
- }
-
- public function getProperties($type = null)
- {
- if ($type === null) {
- return $this->properties;
- }
- $properties = array();
- foreach ($this->properties as $prop) {
- if ($prop->type == $type) {
- $properties[] = $prop;
- }
- }
- return $properties;
- }
- }
- ?>
|