1 | <?php |
||
28 | class FilesystemLocation implements LocationInterface |
||
29 | { |
||
30 | |||
31 | /** |
||
32 | * Path that this location points to. |
||
33 | * |
||
34 | * @since 0.1.0 |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $path; |
||
39 | |||
40 | /** |
||
41 | * Extensions that this location can accept. |
||
42 | * |
||
43 | * @since 0.1.0 |
||
44 | * |
||
45 | * @var ExtensionCollection |
||
46 | */ |
||
47 | protected $extensions; |
||
48 | |||
49 | /** |
||
50 | * Instantiate a FilesystemLocation object. |
||
51 | * |
||
52 | * @since 0.1.0 |
||
53 | * |
||
54 | * @param string $path Path that this location points to. |
||
55 | * @param ExtensionCollection|array|string|null $extensions Optional. Extensions that this location can accept. |
||
56 | */ |
||
57 | 35 | public function __construct($path, $extensions = null) |
|
62 | |||
63 | /** |
||
64 | * Get the first URI that matches the given criteria. |
||
65 | * |
||
66 | * @since 0.1.0 |
||
67 | * |
||
68 | * @param array $criteria Criteria to match. |
||
69 | * |
||
70 | * @return string|false URI that matches the criteria or false if none found. |
||
71 | */ |
||
72 | 34 | public function getURI(array $criteria) |
|
80 | |||
81 | /** |
||
82 | * Get all URIs that match the given criteria. |
||
83 | * |
||
84 | * @since 0.1.1 |
||
85 | * |
||
86 | * @param array $criteria Criteria to match. |
||
87 | * |
||
88 | * @return URICollection URIs that match the criteria or an empty collection if none found. |
||
89 | */ |
||
90 | 34 | public function getURIs(array $criteria) |
|
112 | |||
113 | /** |
||
114 | * Get the name pattern to pass to the file finder. |
||
115 | * |
||
116 | * @since 0.1.3 |
||
117 | * |
||
118 | * @param array $criteria Criteria to match. |
||
119 | * @param string $extension Extension to match. |
||
120 | * |
||
121 | * @return string Name pattern to pass to the file finder. |
||
122 | */ |
||
123 | 34 | protected function getNamePattern(array $criteria, $extension) |
|
137 | |||
138 | /** |
||
139 | * Get the path pattern to pass to the file finder. |
||
140 | * |
||
141 | * @since 0.1.3 |
||
142 | * |
||
143 | * @return string Path pattern to pass to the file finder. |
||
144 | */ |
||
145 | 34 | protected function getPathPattern() |
|
149 | |||
150 | /** |
||
151 | * Get an array as a regular expression pattern string. |
||
152 | * |
||
153 | * @since 0.1.3 |
||
154 | * |
||
155 | * @param array $array Array to generate the pattern for. |
||
156 | * |
||
157 | * @return string Generated regular expression pattern. |
||
158 | */ |
||
159 | protected function arrayToRegexPattern(array $array) |
||
167 | |||
168 | /** |
||
169 | * Validate the extensions and return a collection. |
||
170 | * |
||
171 | * @since 0.1.1 |
||
172 | * |
||
173 | * @param ExtensionCollection|array|string|null $extensions Extensions to validate. |
||
174 | * |
||
175 | * @return ExtensionCollection Validated extensions collection. |
||
176 | */ |
||
177 | 35 | protected function validateExtensions($extensions) |
|
189 | } |
||
190 |