| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2.003 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 2 | public function fix(string $pathToYamlFile, string $pathToDumpFixedFile, StandardParametersData $standardParametersData): Result |
|
| 23 | { |
||
| 24 | 2 | $fileContent = file_get_contents($pathToYamlFile); |
|
| 25 | 2 | $fileContent = str_replace("\r", '', $fileContent); // remove carriage returns |
|
| 26 | |||
| 27 | 2 | $rightFileLines = YamlAlphabeticalDataFactory::getCorrectYamlLines($pathToYamlFile, $standardParametersData->getDepth()); |
|
| 28 | |||
| 29 | 2 | $rightFileContent = implode("\n", $rightFileLines); |
|
| 30 | |||
| 31 | 2 | if ($fileContent === $rightFileContent) { |
|
| 32 | return new Result($pathToYamlFile, Result::RESULT_CODE_OK, ProcessOutput::STATUS_CODE_OK); |
||
| 33 | } |
||
| 34 | |||
| 35 | 2 | file_put_contents($pathToDumpFixedFile, $rightFileContent); |
|
| 36 | |||
| 37 | 2 | $differ = new Differ(); |
|
| 38 | 2 | $diffBetweenStrings = $differ->diff($fileContent, $rightFileContent); |
|
| 39 | |||
| 40 | 2 | return new Result($pathToYamlFile, Result::RESULT_CODE_OK, ProcessOutput::STATUS_CODE_INVALID_FILE_SYNTAX, $diffBetweenStrings); |
|
| 41 | } |
||
| 43 |