1 | <?php |
||
21 | final class File extends \SplFileInfo |
||
22 | { |
||
23 | private $relativePath; |
||
24 | |||
25 | /** |
||
26 | * File Constructor. |
||
27 | * |
||
28 | * @param string $absoluteFilePath The absolute file path |
||
29 | * @param string|null $relativePath The relative path to its parent folder with respect to the CWD |
||
30 | * |
||
31 | * @since 0.2.0 |
||
32 | */ |
||
33 | 95 | public function __construct($absoluteFilePath, $relativePath = null) |
|
44 | |||
45 | /** |
||
46 | * Whether or not this file exists on the filesystem. |
||
47 | * |
||
48 | * @return bool |
||
49 | */ |
||
50 | 87 | public function exists() |
|
54 | |||
55 | /** |
||
56 | * Get the name of the file without an extension. |
||
57 | * |
||
58 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
59 | * definition. |
||
60 | * |
||
61 | * @since 0.2.0 |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | 5 | public function getBasename($suffix = null) |
|
69 | |||
70 | /** |
||
71 | * Get the name of the with the extension. |
||
72 | * |
||
73 | * @since 0.2.0 |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 1 | public function getFilename() |
|
81 | |||
82 | /** |
||
83 | * Get the absolute path to this file. |
||
84 | * |
||
85 | * @since 0.2.0 |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 90 | public function getAbsolutePath() |
|
93 | |||
94 | /** |
||
95 | * Get the path to the parent folder of this file. |
||
96 | * |
||
97 | * @since 0.2.0 |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 1 | public function getParentFolder() |
|
105 | |||
106 | /** |
||
107 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
108 | * |
||
109 | * @since 0.2.0 |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | 68 | public function getRelativeFilePath() |
|
117 | |||
118 | /** |
||
119 | * Get the path to the parent folder 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 | 2 | public function getRelativeParentFolder() |
|
129 | |||
130 | /** |
||
131 | * Get the contents of this file. |
||
132 | * |
||
133 | * @since 0.2.0 |
||
134 | * |
||
135 | * @throws \RuntimeException When the file could not be read. |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | 87 | public function getContents() |
|
156 | |||
157 | /** |
||
158 | * A vfsStream friendly way of getting the realpath() of something. |
||
159 | * |
||
160 | * @param string $path |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | 95 | public static function realpath($path) |
|
173 | } |
||
174 |
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.