1 | <?php |
||
31 | trait PathAwareTrait |
||
32 | { |
||
33 | use MountableTrait; |
||
34 | |||
35 | /** |
||
36 | * cache of Path objects |
||
37 | * |
||
38 | * @var Path[] |
||
39 | * @access protected |
||
40 | */ |
||
41 | protected $path_cache = []; |
||
42 | |||
43 | /** |
||
44 | * {@inheritDoc} |
||
45 | */ |
||
46 | public function path(/*# string */ $path)/*# : Path */ |
||
64 | |||
65 | /** |
||
66 | * Normalize the path |
||
67 | * |
||
68 | * Replaces '.', '..', prepends '/', keeps trailing '/' |
||
69 | * |
||
70 | * @param string $path |
||
71 | * @return string |
||
72 | * @access protected |
||
73 | */ |
||
74 | protected function normalize(/*# string */ $path)/*# : string */ |
||
80 | |||
81 | /** |
||
82 | * Generate Path object. Override this method if you want to |
||
83 | * |
||
84 | * @param string $path |
||
85 | * @return Path |
||
86 | * @access protected |
||
87 | */ |
||
88 | protected function newPath(/*# string */ $path)/*# : Path */ |
||
93 | |||
94 | /** |
||
95 | * Split into mount point and the remain |
||
96 | * |
||
97 | * @param string $path |
||
98 | * @return array [ mountpoint, remain ] |
||
99 | * @access protected |
||
100 | */ |
||
101 | protected function splitPath(/*# string */ $path)/*# : array */ |
||
111 | |||
112 | /** |
||
113 | * Merge path |
||
114 | * |
||
115 | * @param string $prefix |
||
116 | * @param string $suffix |
||
117 | * @return string |
||
118 | * @access protected |
||
119 | */ |
||
120 | protected function mergePath( |
||
126 | |||
127 | /** |
||
128 | * Is this path in cache ? |
||
129 | * |
||
130 | * @param string $key |
||
131 | * @return bool |
||
132 | * @access protected |
||
133 | */ |
||
134 | protected function hasPathCache(/*# string */ $key)/*# : bool */ |
||
138 | |||
139 | /** |
||
140 | * Get Path object from local cache |
||
141 | * |
||
142 | * @param string $key |
||
143 | * @return Path |
||
144 | * @access protected |
||
145 | */ |
||
146 | protected function getFromCache(/*# string */ $key) |
||
150 | |||
151 | /** |
||
152 | * Save Path object to local cache |
||
153 | * |
||
154 | * @param string $key |
||
155 | * @param object $obj |
||
156 | * @access protected |
||
157 | */ |
||
158 | protected function saveToCache(/*# string */ $key, $obj) |
||
169 | |||
170 | /** |
||
171 | * Generate an unique key for the path |
||
172 | * |
||
173 | * @param string $path |
||
174 | * @return string |
||
175 | * @access protected |
||
176 | */ |
||
177 | protected function getCacheKey(/*# string */ $path)/*# : string */ |
||
181 | } |
||
182 |