1 | <?php |
||
31 | class VersionList implements IteratorAggregate, ArrayAccess, Countable |
||
32 | { |
||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $path; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | private $versions; |
||
42 | |||
43 | /** |
||
44 | * Creates a new version list. |
||
45 | * |
||
46 | * @param string $path The Puli path. |
||
47 | * @param PuliResource[] $versions The versions of the resource, starting |
||
48 | * with the first. |
||
49 | */ |
||
50 | 132 | public function __construct($path, array $versions) |
|
59 | |||
60 | /** |
||
61 | * Returns the path of the versioned resources. |
||
62 | * |
||
63 | * @return string The Puli path. |
||
64 | */ |
||
65 | 2 | public function getPath() |
|
69 | |||
70 | /** |
||
71 | * Returns the current version of the resource. |
||
72 | * |
||
73 | * @return PuliResource The current version. |
||
74 | */ |
||
75 | 19 | public function getCurrent() |
|
79 | |||
80 | /** |
||
81 | * Returns the current version number. |
||
82 | * |
||
83 | * @return int The current version number. |
||
84 | */ |
||
85 | 20 | public function getCurrentVersion() |
|
89 | |||
90 | /** |
||
91 | * Returns the first version of the resource. |
||
92 | * |
||
93 | * @return PuliResource The first version. |
||
94 | */ |
||
95 | 28 | public function getFirst() |
|
99 | |||
100 | /** |
||
101 | * Returns the first version number. |
||
102 | * |
||
103 | * @return int The first version number. |
||
104 | */ |
||
105 | 29 | public function getFirstVersion() |
|
109 | |||
110 | /** |
||
111 | * Returns whether a specific version exists. |
||
112 | * |
||
113 | * @param int $version The version number starting at 0. |
||
114 | * |
||
115 | * @return bool Whether the version exists. |
||
116 | */ |
||
117 | 1 | public function contains($version) |
|
121 | |||
122 | /** |
||
123 | * Returns a specific version of the resource. |
||
124 | * |
||
125 | * @param int $version The version number starting at 0. |
||
126 | * |
||
127 | * @return PuliResource The resource. |
||
128 | * |
||
129 | * @throws OutOfBoundsException If the version number does not exist. |
||
130 | */ |
||
131 | 103 | public function get($version) |
|
143 | |||
144 | /** |
||
145 | * Returns all version numbers. |
||
146 | * |
||
147 | * @return int[] The version numbers. |
||
|
|||
148 | */ |
||
149 | 93 | public function getVersions() |
|
153 | |||
154 | /** |
||
155 | * Returns the list as array indexed by version numbers. |
||
156 | * |
||
157 | * @return PuliResource[] The resource versions indexed by their version numbers. |
||
158 | */ |
||
159 | 1 | public function toArray() |
|
163 | |||
164 | /** |
||
165 | * {@inheritdoc} |
||
166 | */ |
||
167 | 1 | public function getIterator() |
|
171 | |||
172 | /** |
||
173 | * {@inheritdoc} |
||
174 | */ |
||
175 | 1 | public function offsetExists($offset) |
|
179 | |||
180 | /** |
||
181 | * {@inheritdoc} |
||
182 | */ |
||
183 | 1 | public function offsetGet($offset) |
|
187 | |||
188 | /** |
||
189 | * {@inheritdoc} |
||
190 | */ |
||
191 | public function offsetSet($offset, $value) |
||
195 | |||
196 | /** |
||
197 | * {@inheritdoc} |
||
198 | */ |
||
199 | public function offsetUnset($offset) |
||
203 | |||
204 | /** |
||
205 | * {@inheritdoc} |
||
206 | */ |
||
207 | 18 | public function count() |
|
211 | } |
||
212 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.