1 | <?php |
||
20 | final class File extends \SplFileInfo |
||
21 | { |
||
22 | private $relativePath; |
||
23 | |||
24 | /** |
||
25 | * File Constructor. |
||
26 | * |
||
27 | * @param string $absoluteFilePath The absolute file path |
||
28 | * @param string|null $relativePath The relative path to its parent folder with respect to the CWD |
||
29 | * |
||
30 | * @since 0.2.0 |
||
31 | */ |
||
32 | 156 | public function __construct($absoluteFilePath, $relativePath = null) |
|
38 | |||
39 | /** |
||
40 | * Get the name of the file without an extension. |
||
41 | * |
||
42 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
43 | * definition. |
||
44 | * |
||
45 | * @since 0.2.0 |
||
46 | * |
||
47 | * @return string |
||
48 | */ |
||
49 | 5 | public function getBasename($suffix = null) |
|
53 | |||
54 | /** |
||
55 | * Get the name of the with the extension. |
||
56 | * |
||
57 | * @since 0.2.0 |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 1 | public function getFilename() |
|
65 | |||
66 | /** |
||
67 | * Get the absolute path to this file. |
||
68 | * |
||
69 | * @since 0.2.0 |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 129 | public function getAbsolutePath() |
|
77 | |||
78 | /** |
||
79 | * Get the path to the parent folder of this file. |
||
80 | * |
||
81 | * @since 0.2.0 |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 1 | public function getParentFolder() |
|
89 | |||
90 | /** |
||
91 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
92 | * |
||
93 | * @since 0.2.0 |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | 90 | public function getRelativeFilePath() |
|
103 | |||
104 | /** |
||
105 | * Get the path to the parent folder this file, relative to where it was created; likely the current working directory. |
||
106 | * |
||
107 | * @since 0.2.0 |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 1 | public function getRelativeParentFolder() |
|
115 | |||
116 | /** |
||
117 | * Get the contents of this file. |
||
118 | * |
||
119 | * @since 0.2.0 |
||
120 | * |
||
121 | * @throws \RuntimeException When the file could not be read. |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 126 | public function getContents() |
|
142 | } |
||
143 |
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.