Skip to content

Commit

Permalink
modified files, deleted comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmuS2024 committed Nov 12, 2024
1 parent bddffa1 commit a0b2080
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/Differ.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ function genDiff(mixed $file1Path, mixed $file2Path, string $formatName = 'styli
if ($dataFromFile1 !== false && $dataFromFile2 !== false) {
$parsedData1 = parseDataWithFormat($dataFromFile1, getFileExtension($file1Path));
$parsedData2 = parseDataWithFormat($dataFromFile2, getFileExtension($file2Path));
$dataDiff = getArraysDiffer($parsedData1, $parsedData2);
return getFormattedDiff($dataDiff, $formatName);
if ($parsedData1 !== false && $parsedData2 !== false) {
$dataDiff = getArraysDiffer($parsedData1, $parsedData2);
return getFormattedDiff($dataDiff, $formatName);
}
}
return "Reading of file(s) error!\n";
}
Expand Down
1 change: 0 additions & 1 deletion src/Formatters/Plain.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function iter(mixed $value1, string $level = '', mixed $key1 = null): array
if (is_array($value['value'])) {
$newLevel = getLevel($level, $value['key']);
$arrayResult = iter($value['value'], $newLevel, $value['key']);
//var_dump($arrayResult);
$stringResult = getStringFromArray($arrayResult);
$result = getIterResult($value, $stringResult, $newLevel, true);
return "{$result}{$stringResult}";
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function parseDataWithFormat(string $data, string $format): mixed
$result = match ($format) {
'json' => json_decode($data, true),
'yaml', 'yml' => Yaml::parse($data),
default => null,
default => false,
};
return $result ?? false;
}
10 changes: 0 additions & 10 deletions tests/DiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,4 @@ public function testFilesDiffJsonToJsonFormat(): void
$diffStringFromFiles = genDiff($pathToFile1, $pathToFile2, 'json');
$this->assertStringEqualsFile($pathToFile3, $diffStringFromFiles);
}
/*
public function testFilesNotFound(): void
{
$pathToFile1 = $this->getFixtureFullPath('File.json');
$pathToFile2 = $this->getFixtureFullPath('File5.json');
$pathToFile3 = $this->getFixtureFullPath('ParseError.txt');
$diffStringFromFiles = genDiff($pathToFile1, $pathToFile2);
$this->assertStringEqualsFile($pathToFile3, $diffStringFromFiles);
}
*/
}

0 comments on commit a0b2080

Please sign in to comment.