1 | <?php |
||
22 | final class File extends \SplFileInfo |
||
23 | { |
||
24 | /** @var string */ |
||
25 | private $relativePath; |
||
26 | |||
27 | /** |
||
28 | * File Constructor. |
||
29 | * |
||
30 | * @param string $filePath An absolute file path or a path relative to the current working directory. |
||
31 | * |
||
32 | * @since 0.2.0 |
||
33 | */ |
||
34 | 156 | public function __construct($filePath) |
|
40 | |||
41 | /** |
||
42 | * Get a new File object for another file relative to this file. |
||
43 | * |
||
44 | * @param string $path |
||
45 | * |
||
46 | * @return File |
||
47 | */ |
||
48 | 11 | public function createFileForRelativePath($path) |
|
52 | |||
53 | /** |
||
54 | * Whether or not this file exists on the filesystem. |
||
55 | * |
||
56 | * @return bool |
||
57 | */ |
||
58 | 147 | public function exists() |
|
62 | |||
63 | /** |
||
64 | * Get the name of the file without an extension. |
||
65 | * |
||
66 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
67 | * definition. |
||
68 | * |
||
69 | * @since 0.2.0 |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 5 | public function getBasename($suffix = null) |
|
77 | |||
78 | /** |
||
79 | * Get the name of the with the extension. |
||
80 | * |
||
81 | * @since 0.2.0 |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | public function getFilename() |
|
89 | |||
90 | /** |
||
91 | * Get the absolute path to this file. |
||
92 | * |
||
93 | * @since 0.2.0 |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 156 | public function getAbsolutePath() |
|
101 | |||
102 | /** |
||
103 | * Get the path to the parent folder of this file. |
||
104 | * |
||
105 | * @since 0.2.0 |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | 1 | public function getParentFolder() |
|
113 | |||
114 | /** |
||
115 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
116 | * |
||
117 | * @since 0.2.0 |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 127 | public function getRelativeFilePath() |
|
125 | |||
126 | /** |
||
127 | * Get the path to the parent folder this file, relative to where it was created; likely the current working directory. |
||
128 | * |
||
129 | * @since 0.2.0 |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 2 | public function getRelativeParentFolder() |
|
137 | |||
138 | /** |
||
139 | * Get the contents of this file. |
||
140 | * |
||
141 | * @since 0.2.0 |
||
142 | * |
||
143 | * @throws \RuntimeException When the file could not be read. |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | 146 | public function getContents() |
|
166 | |||
167 | /** |
||
168 | * Check if a file is safe to read. |
||
169 | */ |
||
170 | 146 | private function isSafeToRead() |
|
185 | |||
186 | /** |
||
187 | * A vfsStream friendly way of getting the realpath() of something. |
||
188 | * |
||
189 | * @param string $path |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | 156 | public static function realpath($path) |
|
197 | |||
198 | /** |
||
199 | * Check whether a given path is on the virtual filesystem. |
||
200 | * |
||
201 | * @param string $path |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | 156 | private static function isVFS($path) |
|
209 | } |
||
210 |
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.