Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
25 | 6 | public function extract(): int |
|
26 | { |
||
27 | 6 | $tokensReplaced = 0; |
|
28 | 6 | foreach ($this->tokenizers as $tokenizer) { |
|
29 | 4 | foreach ($tokenizer->tokenize() as $tokenCollection) { |
|
30 | // tento kod by som mohol dat do nejakeho file updatera |
||
31 | 4 | $content = file_get_contents($tokenCollection->getFilePath()); |
|
32 | 4 | $newTexts = []; |
|
33 | 4 | foreach ($tokenCollection->getTokens() as $token) { |
|
34 | 4 | $newTexts[$token->getOriginalBlock()] = str_replace($token->getOriginalText(), $token->getTranslationCode(), $token->getOriginalBlock()); |
|
35 | 4 | $tokensReplaced++; |
|
36 | } |
||
37 | 4 | $content = str_replace(array_keys($newTexts), array_values($newTexts), $content); |
|
38 | 4 | file_put_contents($tokenCollection->getFilePath(), $content); |
|
39 | |||
40 | 4 | $this->saver->save($tokenCollection); |
|
41 | } |
||
42 | } |
||
43 | 6 | return $tokensReplaced; |
|
44 | } |
||
46 |