Conditions | 6 |
Paths | 9 |
Total Lines | 31 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6.0131 |
Changes | 0 |
1 | <?php |
||
54 | 1 | public function load($className) |
|
55 | { |
||
56 | 1 | foreach ($this->addons as $addon) { |
|
57 | 1 | $namespace = $addon->phpNamespace(); |
|
58 | |||
59 | 1 | $namespacePrefix = $namespace ? $namespace.'\\' : ''; |
|
60 | |||
61 | // アドオンの名前空間下のクラスでないなら |
||
62 | 1 | if (!starts_with($className, $namespacePrefix)) { |
|
63 | 1 | continue; |
|
64 | } |
||
65 | |||
66 | // 名前空間を削る |
||
67 | 1 | $relativeClassName = substr($className, strlen($namespacePrefix)); |
|
68 | |||
69 | // クラスの相対パスを作成する(PSR-4) |
||
70 | 1 | $relativePath = $this->env->classToPath($relativeClassName); |
|
71 | |||
72 | // 全ディレクトリ下を探索する (PSR-4) |
||
|
|||
73 | 1 | foreach ($addon->config('addon.directories') as $directory) { |
|
74 | 1 | $path = $addon->path($directory.'/'.$relativePath); |
|
75 | 1 | if (file_exists($path)) { |
|
76 | require_once $path; |
||
77 | |||
78 | 1 | return true; |
|
79 | } |
||
80 | } |
||
81 | } |
||
82 | |||
83 | 1 | return false; |
|
84 | } |
||
85 | } |
||
86 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.