1 | <?php |
||
18 | class AnnotationsBag implements AnnotationsBagInterface |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Associative arrays of annotations |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | private $attributes = []; |
||
27 | |||
28 | /** |
||
29 | * The Constructor |
||
30 | * |
||
31 | * @param array $attributes |
||
32 | */ |
||
33 | public function __construct(array $attributes) |
||
37 | |||
38 | /** |
||
39 | * Unbox all annotations in the form of an associative array |
||
40 | * |
||
41 | * @return array associative array of annotations |
||
42 | */ |
||
43 | public function toArray() |
||
47 | |||
48 | /** |
||
49 | * Checks if a given annotation is declared |
||
50 | * |
||
51 | * @param string $key A valid annotation tag, should match parser rules |
||
52 | * @return boolean |
||
53 | */ |
||
54 | public function has($key) |
||
58 | |||
59 | /** |
||
60 | * Set a single annotation value |
||
61 | * |
||
62 | * @param string $key a valid annotation tag, should match parser rules |
||
63 | * @param mixed $value the param value |
||
64 | * @return self |
||
65 | */ |
||
66 | public function set($key, $value) |
||
72 | |||
73 | /** |
||
74 | * Retrieves a single annotation value |
||
75 | * |
||
76 | * @param string $key A valid annotation tag, should match parser rules |
||
77 | * @param mixed $defaut Default value in case $key is not set |
||
78 | * @return mixed|null |
||
79 | */ |
||
80 | public function get($key, $defaut = null) |
||
88 | |||
89 | /** |
||
90 | * Retrieve annotation values as an array even if there's only one single value |
||
91 | * |
||
92 | * @param string $key A valid annotation tag, should match parser rules |
||
93 | * @return array |
||
94 | */ |
||
95 | public function getAsArray($key) |
||
107 | |||
108 | /** |
||
109 | * Filters annotations based on a regexp |
||
110 | * |
||
111 | * @param string $pattern valid regexp |
||
112 | * @return \Minime\Annotations\AnnotationsBag Annotations collection with filtered results |
||
113 | */ |
||
114 | public function grep($pattern) |
||
122 | |||
123 | /** |
||
124 | * Isolates a given namespace of annotations. |
||
125 | * |
||
126 | * @param string $pattern namespace |
||
127 | * @param array $delimiters possible namespace delimiters to mask |
||
128 | * @return \Minime\Annotations\AnnotationsBag |
||
129 | */ |
||
130 | public function useNamespace($pattern, array $delimiters = ['.', '\\']) |
||
141 | |||
142 | /** |
||
143 | * Performs union operations against a given AnnotationsBag |
||
144 | * |
||
145 | * @param AnnotationsBag $bag The annotation bag to be united |
||
146 | * @return \Minime\Annotations\AnnotationsBag Annotations collection with union results |
||
147 | */ |
||
148 | public function union(AnnotationsBagInterface $bag) |
||
152 | |||
153 | /** |
||
154 | * Countable |
||
155 | */ |
||
156 | public function count() |
||
160 | |||
161 | /** |
||
162 | * JsonSerializable |
||
163 | */ |
||
164 | public function jsonSerialize() |
||
168 | |||
169 | /** |
||
170 | * IteratorAggregate |
||
171 | */ |
||
172 | public function getIterator() |
||
176 | |||
177 | /** |
||
178 | * ArrayAccess - Whether or not an offset exists. |
||
179 | */ |
||
180 | public function offsetExists($key) |
||
184 | |||
185 | /** |
||
186 | * ArrayAccess - Returns the value at specified offset. |
||
187 | */ |
||
188 | public function offsetGet($key) |
||
192 | |||
193 | /** |
||
194 | * ArrayAccess - Assigns a value to the specified offset. |
||
195 | */ |
||
196 | public function offsetSet($key, $value) |
||
202 | |||
203 | /** |
||
204 | * ArrayAccess - Unsets an offset. |
||
205 | */ |
||
206 | public function offsetUnset($key) |
||
210 | } |
||
211 |