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 | 4 | public function check(string $pathToYamlFile, StandardParametersData $standardParametersData): Result |
|
23 | { |
||
24 | 4 | $fileContent = file_get_contents($pathToYamlFile); |
|
25 | 4 | $fileContent = str_replace("\r", '', $fileContent); // remove carriage returns |
|
26 | |||
27 | 4 | $rightFileLines = YamlAlphabeticalDataFactory::getCorrectYamlLines($pathToYamlFile, $standardParametersData->getDepth()); |
|
28 | |||
29 | 4 | $rightFileContent = implode("\n", $rightFileLines); |
|
30 | |||
31 | 4 | if ($fileContent === $rightFileContent) { |
|
32 | 4 | return new Result($pathToYamlFile, Result::RESULT_CODE_OK, ProcessOutput::STATUS_CODE_OK); |
|
33 | } |
||
34 | |||
35 | $differ = new Differ(); |
||
36 | $diffBetweenStrings = $differ->diff($fileContent, $rightFileContent); |
||
37 | |||
38 | return new Result($pathToYamlFile, Result::RESULT_CODE_INVALID_FILE_SYNTAX, ProcessOutput::STATUS_CODE_INVALID_FILE_SYNTAX, $diffBetweenStrings); |
||
39 | } |
||
41 |