Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function execute(FileList $fileList, $moduleNameSpaceStart = '') |
||
16 | { |
||
17 | $filePhpFiles = array_merge($fileList->getPhpFileList(), $fileList->getTemplates()); |
||
18 | $namespacesFromFiles = []; |
||
19 | |||
20 | /** @var SplFileInfo $file */ |
||
21 | foreach ($filePhpFiles as $file) { |
||
22 | $pattern = '/([A-z0-9]+' . preg_quote('\\', '/') . '){2}/'; |
||
23 | |||
24 | preg_match_all($pattern, $file->getContents(), $matches); |
||
25 | |||
26 | foreach ($matches[0] as $match) { |
||
27 | $removeLeadingSlash = ltrim($match, '\\'); |
||
28 | $splitNamespace = explode('\\', $removeLeadingSlash, 3); |
||
29 | |||
30 | if ($splitNamespace[0] === $moduleNameSpaceStart) { |
||
31 | continue; |
||
32 | } |
||
33 | |||
34 | $namespacesFromFiles[] = $splitNamespace[0] . '\\' . $splitNamespace[1] . '\\'; |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return array_unique($namespacesFromFiles); |
||
39 | } |
||
41 |