Conditions | 4 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
76 | protected function findRelativeFileWithPath(string $prefix, string $name, string $suffix): string |
||
77 | { |
||
78 | // $relDir$prefix/$name.$suffix, $relDir$prefix/$name_$suffix, |
||
1 ignored issue
–
show
|
|||
79 | // $relDir$prefix.$name.$suffix, $relDir$prefix_$name.$suffix, $relDir$prefix_$name_$suffix, |
||
1 ignored issue
–
show
|
|||
80 | // $relDir$name.$suffix, $relDir$name_$suffix, |
||
1 ignored issue
–
show
|
|||
81 | // $relDir$prefix.$suffix, $relDir$prefix_$suffix, |
||
1 ignored issue
–
show
|
|||
82 | // $relDir'common'.$suffix, $relDir'common'_$suffix, $relDir$suffix |
||
1 ignored issue
–
show
|
|||
83 | $combinations = '%1$s%2$s/%3$s.%4$s,%1$s%2$s/%3$s_%4$s' |
||
84 | . ',%1$s%2$s.%3$s.%4$s,%1$s%2$s_%3$s.%4$s,%1$s%2$s_%3$s_%4$s' |
||
85 | . ',%1$s%3$s.%4$s,%1$s%3$s_%4$s' |
||
86 | . ',%1$s%2$s.%4$s,%1$s%2$s_%4$s' |
||
87 | . ',%1$scommon.%4$s,%1$scommon_%4$s,%1$s%4$s'; |
||
88 | $fileNames = explode(',', sprintf($combinations, $this->getRelativeBaseDir(), $prefix, $name, $suffix)); |
||
89 | $fpn = $this->getFpn(); |
||
90 | foreach ($fileNames as $fileName) { |
||
91 | $fileName = $fpn->normalizeFile($fileName); |
||
92 | if (is_readable($fileName) && is_file($fileName)) { |
||
93 | return $fileName; |
||
94 | } |
||
95 | } |
||
96 | $mess = sprintf('Failed to find accessible file in %1$s using "%1$s", "%2$s", and "%3$s"', |
||
97 | $this->getRelativeBaseDir(), |
||
98 | $prefix, |
||
99 | $name, |
||
100 | $suffix); |
||
101 | throw new YapealFileSystemException($mess); |
||
102 | } |
||
103 | /** |
||
124 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.