| 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 |
||
| 20 | 4 | public function check(string $pathToFile, StandardParametersData $standardParametersData): Result |
|
| 21 | { |
||
| 22 | 4 | $yamlContent = file_get_contents($pathToFile); |
|
| 23 | 4 | $yamlContent = str_replace("\r", '', $yamlContent); // remove carriage returns |
|
| 24 | 4 | $yamlLines = explode("\n", $yamlContent); |
|
| 25 | |||
| 26 | 4 | $correctYamlLines = YamlEmptyLineAtEndDataFactory::getCorrectYamlContent($yamlLines); |
|
| 27 | 4 | $correctYamlContent = implode("\n", $correctYamlLines); |
|
| 28 | |||
| 29 | 4 | if ($yamlContent === $correctYamlContent) { |
|
| 30 | 3 | return new Result($pathToFile, Result::RESULT_CODE_OK); |
|
| 31 | } |
||
| 32 | |||
| 33 | 1 | $differ = new Differ(); |
|
| 34 | 1 | $diffBetweenStrings = $differ->diff($yamlContent, $correctYamlContent); |
|
| 35 | |||
| 36 | 1 | return new Result($pathToFile, Result::RESULT_CODE_INVALID_FILE_SYNTAX, $diffBetweenStrings, true); |
|
| 37 | } |
||
| 46 |