1 | <?php |
||
16 | class TargetLocator |
||
17 | { |
||
18 | /** |
||
19 | * Locates the target for a resource in a context |
||
20 | * |
||
21 | * For example, adding /path/to/file where the context (current working |
||
22 | * directory) is /path/to will return `file` as target |
||
23 | * |
||
24 | * @param string $context |
||
25 | * @param string|resource $resource |
||
26 | * |
||
27 | * @return string |
||
28 | * |
||
29 | * @throws TargetLocatorException when the resource is invalid |
||
30 | */ |
||
31 | public function locate($context, $resource) |
||
44 | |||
45 | /** |
||
46 | * Locate the target for a resource. |
||
47 | * |
||
48 | * @param resource $resource |
||
49 | * |
||
50 | * @return string |
||
51 | * |
||
52 | * @throws TargetLocatorException |
||
53 | */ |
||
54 | private function locateResource($resource) |
||
65 | |||
66 | /** |
||
67 | * Locate the target for a string. |
||
68 | * |
||
69 | * @param $context |
||
70 | * @param string $resource |
||
71 | * |
||
72 | * @return string |
||
73 | * |
||
74 | * @throws TargetLocatorException |
||
75 | */ |
||
76 | private function locateString($context, $resource) |
||
102 | |||
103 | /** |
||
104 | * Removes backward path sequences (..) |
||
105 | * |
||
106 | * @param string $path |
||
107 | * |
||
108 | * @return string |
||
109 | * |
||
110 | * @throws TargetLocatorException In case the path is invalid |
||
111 | */ |
||
112 | private function cleanupPath($path) |
||
120 | |||
121 | /** |
||
122 | * Checks whether the path belong to the context |
||
123 | * |
||
124 | * @param string $path A resource path |
||
125 | * @param string $context |
||
126 | * |
||
127 | * @return bool |
||
128 | */ |
||
129 | private function isFileInContext($path, $context) |
||
133 | |||
134 | /** |
||
135 | * Gets the relative path from the context for the given path |
||
136 | * |
||
137 | * @param string $path A resource path |
||
138 | * @param string $context |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | private function getRelativePathFromContext($path, $context) |
||
146 | |||
147 | /** |
||
148 | * Checks if a scheme refers to a local filesystem |
||
149 | * |
||
150 | * @param string $scheme |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | private function isLocalFilesystem($scheme) |
||
158 | } |
||
159 |