Conditions | 2 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 5 | public function check(string $pathToYamlFile, StandardParametersData $standardParametersData): Result |
|
22 | { |
||
23 | 5 | $yamlContent = file_get_contents($pathToYamlFile); |
|
24 | 5 | $yamlContent = str_replace("\r", '', $yamlContent); // remove carriage returns |
|
25 | 5 | $yamlLines = explode("\n", $yamlContent); |
|
26 | |||
27 | 5 | $correctYamlLines = YamlEmptyLineAtEndDataFactory::getCorrectYamlContent($yamlLines); |
|
28 | 5 | $correctYamlContent = implode("\n", $correctYamlLines); |
|
29 | |||
30 | 5 | if ($yamlContent === $correctYamlContent) { |
|
31 | 4 | return new Result($pathToYamlFile, Result::RESULT_CODE_OK, ProcessOutput::STATUS_CODE_OK); |
|
32 | } |
||
33 | |||
34 | 1 | $differ = new Differ(); |
|
35 | 1 | $diffBetweenStrings = $differ->diff($yamlContent, $correctYamlContent); |
|
36 | |||
37 | 1 | return new Result($pathToYamlFile, Result::RESULT_CODE_INVALID_FILE_SYNTAX, ProcessOutput::STATUS_CODE_INVALID_FILE_SYNTAX, $diffBetweenStrings, true); |
|
38 | } |
||
47 |