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 | * Whether or not this file exists on the filesystem. |
||
41 | * |
||
42 | * @return bool |
||
43 | */ |
||
44 | 126 | public function exists() |
|
48 | |||
49 | /** |
||
50 | * Get the name of the file without an extension. |
||
51 | * |
||
52 | * @param null $suffix This value will be discarded and is only needed to be able to override the \SplFileInfo |
||
53 | * definition. |
||
54 | * |
||
55 | * @since 0.2.0 |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 5 | public function getBasename($suffix = null) |
|
63 | |||
64 | /** |
||
65 | * Get the name of the with the extension. |
||
66 | * |
||
67 | * @since 0.2.0 |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 1 | public function getFilename() |
|
75 | |||
76 | /** |
||
77 | * Get the absolute path to this file. |
||
78 | * |
||
79 | * @since 0.2.0 |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | 130 | public function getAbsolutePath() |
|
87 | |||
88 | /** |
||
89 | * Get the path to the parent folder of this file. |
||
90 | * |
||
91 | * @since 0.2.0 |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 1 | public function getParentFolder() |
|
99 | |||
100 | /** |
||
101 | * Get the file path to this file, relative to where it was created; likely the current working directory. |
||
102 | * |
||
103 | * @since 0.2.0 |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 107 | public function getRelativeFilePath() |
|
113 | |||
114 | /** |
||
115 | * Get the path to the parent folder 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 | 1 | public function getRelativeParentFolder() |
|
125 | |||
126 | /** |
||
127 | * Get the contents of this file. |
||
128 | * |
||
129 | * @since 0.2.0 |
||
130 | * |
||
131 | * @throws \RuntimeException When the file could not be read. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | 126 | public function getContents() |
|
152 | } |
||
153 |
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.