Skip to content

Commit 64f5754

Browse files
Removed code checking file existence
1 parent f23ab98 commit 64f5754

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/Differ/Translator.php

+5-14
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66

77
function getJson(string $path): array
88
{
9+
$content = getFileContent($path);
10+
911
if (str_ends_with($path, '.yaml') || str_ends_with($path, '.yml')) {
10-
return Yaml::parseFile($path);
12+
return Yaml::parse($content);
1113
}
1214

13-
return json_decode(getFileContent($path), true);
15+
return json_decode($content, true);
1416
}
1517

16-
function getFileContent(string $path): string
18+
function getFileContent(string $path): string|false
1719
{
18-
// Colors for beautiful :)
19-
$normalColor = "\x1b[0m";
20-
$redColor = "\x1b[41m";
2120
$dirPath = __DIR__;
2221

2322
if (str_starts_with($path, '/')) {
@@ -26,13 +25,5 @@ function getFileContent(string $path): string
2625
$fullPath = "{$dirPath}/../../{$path}";
2726
}
2827

29-
if (!file_exists($fullPath)) {
30-
return <<<DOC
31-
{$redColor}ERROR!{$normalColor}
32-
33-
File: "{$fullPath}" don't exists!
34-
DOC;
35-
}
36-
3728
return file_get_contents($fullPath);
3829
}

src/Parser.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,5 @@
88
function parse(string $pathToFile1, string $pathToFile2, string $format): void
99
{
1010
$resultString = genDiff($pathToFile1, $pathToFile2, $format);
11-
12-
if ($resultString) {
13-
line('%s', $resultString);
14-
} else {
15-
line('');
16-
}
11+
line('%s', $resultString);
1712
}

0 commit comments

Comments
 (0)