1 | <?php |
||
17 | class PropertyDefinitions implements IteratorAggregate { |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $propertyDefinitionFile; |
||
23 | |||
24 | /** |
||
25 | * @var array|null |
||
26 | */ |
||
27 | private $propertyDefinitions; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $localPropertyDefinitions = array(); |
||
33 | |||
34 | /** |
||
35 | * @since 2.0 |
||
36 | * |
||
37 | * @param string $propertyDefinitionFile |
||
38 | */ |
||
39 | 4 | public function __construct( $propertyDefinitionFile = '' ) { |
|
40 | 4 | $this->propertyDefinitionFile = $propertyDefinitionFile; |
|
41 | |||
42 | 4 | if ( $this->propertyDefinitionFile === '' ) { |
|
43 | 4 | $this->propertyDefinitionFile = $GLOBALS['sespPropertyDefinitionFile']; |
|
44 | 4 | } |
|
45 | 4 | } |
|
46 | |||
47 | /** |
||
48 | * @since 2.0 |
||
49 | * |
||
50 | * @param array $localPropertyDefinitions |
||
51 | */ |
||
52 | public function setLocalPropertyDefinitions( array $localPropertyDefinitions ) { |
||
55 | |||
56 | /** |
||
57 | * @since 2.0 |
||
58 | * |
||
59 | * @param array $propertyDefinitions |
||
60 | */ |
||
61 | 2 | public function setPropertyDefinitions( array $propertyDefinitions ) { |
|
62 | 2 | $this->propertyDefinitions = $propertyDefinitions; |
|
63 | 2 | } |
|
64 | |||
65 | /** |
||
66 | * @since 2.0 |
||
67 | * |
||
68 | * @param string $key |
||
69 | * |
||
70 | * @return boolean |
||
71 | */ |
||
72 | public function isLocalDef( $key ) { |
||
75 | |||
76 | /** |
||
77 | * @since 2.0 |
||
78 | * |
||
79 | * @param string $key |
||
80 | * |
||
81 | * @return boolean |
||
82 | */ |
||
83 | 1 | public function has( $key ) { |
|
84 | 1 | return isset( $this->propertyDefinitions[$key] ) || array_key_exists( $key, $this->propertyDefinitions ); |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * @since 2.3 |
||
89 | * |
||
90 | * @param string $key |
||
91 | * |
||
92 | * @return string |
||
93 | * @throws InvalidArgumentException |
||
94 | */ |
||
95 | 1 | public function get( $key ) { |
|
96 | |||
97 | 1 | if ( $this->has( $key ) ) { |
|
98 | 1 | return $this->propertyDefinitions[$key]; |
|
99 | } |
||
100 | |||
101 | throw new InvalidArgumentException( "{$key} is an unregistered option" ); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @since 2.0 |
||
106 | * |
||
107 | * @param string $key |
||
108 | * |
||
109 | * @return boolean |
||
110 | */ |
||
111 | 1 | public function deepHas( $key, $key2 ) { |
|
112 | 1 | return isset( $this->propertyDefinitions[$key][$key2] ); |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * @since 2.3 |
||
117 | * |
||
118 | * @param string $key |
||
119 | * |
||
120 | * @return string |
||
121 | * @throws InvalidArgumentException |
||
122 | */ |
||
123 | 1 | public function deepGet( $key, $key2 ) { |
|
124 | |||
125 | 1 | if ( $this->deepHas( $key, $key2 ) ) { |
|
126 | 1 | return $this->propertyDefinitions[$key][$key2]; |
|
127 | } |
||
128 | |||
129 | throw new InvalidArgumentException( "{$key}{$key2} is an unregistered option" ); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * @since 3.0 |
||
134 | * |
||
135 | * @param string $key |
||
136 | * @param mixed $default |
||
137 | * |
||
138 | * @return mixed |
||
139 | */ |
||
140 | public function safeGet( $key, $default = false ) { |
||
143 | |||
144 | /** |
||
145 | * @see IteratorAggregate::getIterator |
||
146 | * |
||
147 | * @since 2.0 |
||
148 | * |
||
149 | * @return Iterator |
||
150 | */ |
||
151 | 1 | public function getIterator() { |
|
159 | |||
160 | 1 | private function initPropertyDefinitions() { |
|
177 | |||
178 | } |
||
179 |