1 | <?php |
||
21 | final class File extends \SplFileInfo |
||
22 | { |
||
23 | /** @var string The path relative to the site's working directory. */ |
||
24 | private $relativePath; |
||
25 | |||
26 | /** @var string The original raw path given to the constructor. */ |
||
27 | private $rawPath; |
||
28 | |||
29 | /** |
||
30 | * File Constructor. |
||
31 | * |
||
32 | * @param string $filePath An absolute file path or a path relative to the current working directory. |
||
33 | * |
||
34 | * @since 0.2.0 |
||
35 | */ |
||
36 | 166 | public function __construct($filePath) |
|
46 | |||
47 | /** |
||
48 | * Get a new File object for another file relative to this file. |
||
49 | * |
||
50 | * @param string $path |
||
51 | * |
||
52 | * @return File |
||
53 | */ |
||
54 | 11 | public function createFileForRelativePath($path) |
|
58 | |||
59 | /** |
||
60 | * Whether or not this file exists on the filesystem. |
||
61 | * |
||
62 | * @return bool |
||
63 | */ |
||
64 | 157 | public function exists() |
|
68 | |||
69 | /** |
||
70 | * Get the name of the file without an extension. |
||
71 | * |
||
72 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
73 | * definition. |
||
74 | * |
||
75 | * @since 0.2.0 |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 5 | public function getBasename($suffix = null) |
|
83 | |||
84 | /** |
||
85 | * Get the name of the with the extension. |
||
86 | * |
||
87 | * @since 0.2.0 |
||
88 | * |
||
89 | * @return string |
||
90 | */ |
||
91 | 1 | public function getFilename() |
|
95 | |||
96 | /** |
||
97 | * Get the absolute path to this file. |
||
98 | * |
||
99 | * @since 0.2.0 |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 166 | public function getAbsolutePath() |
|
107 | |||
108 | /** |
||
109 | * Get the path to the parent folder of this file. |
||
110 | * |
||
111 | * @since 0.2.0 |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | 1 | public function getParentFolder() |
|
119 | |||
120 | /** |
||
121 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
122 | * |
||
123 | * @since 0.2.0 |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | 137 | public function getRelativeFilePath() |
|
131 | |||
132 | /** |
||
133 | * Get the path to the parent folder this file, relative to where it was created; likely the current working directory. |
||
134 | * |
||
135 | * @since 0.2.0 |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | 2 | public function getRelativeParentFolder() |
|
143 | |||
144 | /** |
||
145 | * Get the contents of this file. |
||
146 | * |
||
147 | * @since 0.2.0 |
||
148 | * |
||
149 | * @throws \RuntimeException When the file could not be read. |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | 156 | public function getContents() |
|
170 | |||
171 | /** |
||
172 | * Check if a file is safe to read. |
||
173 | */ |
||
174 | 166 | private function isSafeToRead() |
|
186 | |||
187 | 4 | private function buildNotFoundException() |
|
196 | |||
197 | /** |
||
198 | * A vfsStream friendly way of getting the realpath() of something. |
||
199 | * |
||
200 | * @param string $path |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | 166 | public static function realpath($path) |
|
208 | |||
209 | /** |
||
210 | * Check whether a given path is on the virtual filesystem. |
||
211 | * |
||
212 | * @param string $path |
||
213 | * |
||
214 | * @return bool |
||
215 | */ |
||
216 | 166 | private static function isVFS($path) |
|
220 | } |
||
221 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.