Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 2.108 |
Changes | 0 |
1 | <?php |
||
22 | 3 | public function check(string $pathToFile, StandardParametersData $standardParametersData): Result |
|
23 | { |
||
24 | 3 | $fileContent = file_get_contents($pathToFile); |
|
25 | 3 | $fileContent = str_replace("\r", '', $fileContent); // remove carriage returns |
|
26 | |||
27 | 3 | $rightFileLines = YamlAlphabeticalDataFactory::getCorrectYamlLines($pathToFile, $standardParametersData->getDepth(), $standardParametersData->getAlphabeticalPrioritizedKeys()); |
|
28 | |||
29 | 3 | $rightFileContent = implode("\n", $rightFileLines); |
|
30 | |||
31 | 3 | if ($fileContent === $rightFileContent) { |
|
32 | 3 | return new Result($pathToFile, Result::RESULT_CODE_OK); |
|
33 | } |
||
34 | |||
35 | $differ = new Differ(new UnifiedDiffOutputBuilder()); |
||
36 | $diffBetweenStrings = $differ->diff($fileContent, $rightFileContent); |
||
37 | |||
38 | return new Result($pathToFile, Result::RESULT_CODE_INVALID_FILE_SYNTAX, $diffBetweenStrings); |
||
39 | } |
||
41 |