Conditions | 5 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function extract($directory, MessageCatalogue $catalogue): void |
||
23 | { |
||
24 | if (!is_dir($this->directory)) { |
||
25 | echo "Invalid directory: $this->directory" . PHP_EOL; |
||
26 | return; |
||
27 | } |
||
28 | $iterator = new \RecursiveIteratorIterator( |
||
29 | new \RecursiveDirectoryIterator($this->directory) |
||
30 | ); |
||
31 | foreach ($iterator as $file) { |
||
32 | if ($file->getExtension() !== 'js') { |
||
33 | continue; |
||
34 | } |
||
35 | $content = file_get_contents($file->getPathname()); |
||
36 | preg_match_all('/\$t\([\'"]([^\'"]+)[\'"]\)/', $content, $matches); |
||
37 | foreach ($matches[1] as $key) { |
||
38 | $catalogue->set($this->prefix . $key, $key); |
||
39 | } |
||
43 |