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 | 156 | public function __construct($filePath) |
|
44 | |||
45 | /** |
||
46 | * Get a new File object for another file relative to this file. |
||
47 | * |
||
48 | * @param string $path |
||
49 | * |
||
50 | * @return File |
||
51 | */ |
||
52 | 11 | public function createFileForRelativePath($path) |
|
56 | |||
57 | /** |
||
58 | * Whether or not this file exists on the filesystem. |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | 148 | public function exists() |
|
66 | |||
67 | /** |
||
68 | * Get the name of the file without an extension. |
||
69 | * |
||
70 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
71 | * definition. |
||
72 | * |
||
73 | * @since 0.2.0 |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 5 | public function getBasename($suffix = null) |
|
81 | |||
82 | /** |
||
83 | * Get the name of the with the extension. |
||
84 | * |
||
85 | * @since 0.2.0 |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 1 | public function getFilename() |
|
93 | |||
94 | /** |
||
95 | * Get the absolute path to this file. |
||
96 | * |
||
97 | * @since 0.2.0 |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 156 | public function getAbsolutePath() |
|
105 | |||
106 | /** |
||
107 | * Get the path to the parent folder of this file. |
||
108 | * |
||
109 | * @since 0.2.0 |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 1 | public function getParentFolder() |
|
117 | |||
118 | /** |
||
119 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
120 | * |
||
121 | * @since 0.2.0 |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 126 | public function getRelativeFilePath() |
|
129 | |||
130 | /** |
||
131 | * Get the path to the parent folder this file, relative to where it was created; likely the current working directory. |
||
132 | * |
||
133 | * @since 0.2.0 |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 2 | public function getRelativeParentFolder() |
|
141 | |||
142 | /** |
||
143 | * Get the contents of this file. |
||
144 | * |
||
145 | * @since 0.2.0 |
||
146 | * |
||
147 | * @throws \RuntimeException When the file could not be read. |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | 146 | public function getContents() |
|
165 | |||
166 | /** |
||
167 | * Check if a file is safe to read. |
||
168 | */ |
||
169 | 146 | private function isSafeToRead() |
|
193 | |||
194 | /** |
||
195 | * A vfsStream friendly way of getting the realpath() of something. |
||
196 | * |
||
197 | * @param string $path |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | 156 | public static function realpath($path) |
|
205 | |||
206 | /** |
||
207 | * Check whether a given path is on the virtual filesystem. |
||
208 | * |
||
209 | * @param string $path |
||
210 | * |
||
211 | * @return bool |
||
212 | */ |
||
213 | 156 | private static function isVFS($path) |
|
217 | } |
||
218 |
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.