Skip to content

Commit bed158a

Browse files
Fix
1 parent 3273570 commit bed158a

File tree

3 files changed

+4
-33
lines changed

3 files changed

+4
-33
lines changed

bin/gendiff

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (file_exists($autoloadPathLocal)) {
1111
require_once $autoloadPathGlobal;
1212
}
1313

14-
use function Differ\Parser\parseDiff;
14+
use function Differ\Parser\parse;
1515

1616
$doc = <<<DOC
1717
Generate diff
@@ -29,4 +29,4 @@ DOC;
2929

3030
$args = Docopt::handle($doc, array('version' => 'Gendiff 1.0'));
3131

32-
parseDiff($args['<firstFile>'], $args['<secondFile>'], $args['--format']);
32+
parse($args['<firstFile>'], $args['<secondFile>'], $args['--format']);

src/Differ/Translator.php

-16
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use Symfony\Component\Yaml\Yaml;
66

7-
use function Differ\Parser\parseError;
8-
97
function getJson(string $path): array
108
{
119
$content = getFileContent($path);
@@ -21,25 +19,11 @@ function getFileContent(string $path): string
2119
{
2220
$dirPath = __DIR__;
2321

24-
// Colors for beautiful :)
25-
$normalColor = "\x1b[0m";
26-
$redColor = "\x1b[41m";
27-
2822
if (str_starts_with($path, '/')) {
2923
$fullPath = $path;
3024
} else {
3125
$fullPath = "{$dirPath}/../../{$path}";
3226
}
3327

34-
if (!file_exists($fullPath)) {
35-
$errorMessage = <<<DOC
36-
{$redColor}ERROR!{$normalColor}
37-
38-
File: "{$fullPath}" don't exists!
39-
DOC;
40-
41-
parseError($errorMessage);
42-
}
43-
4428
return file_get_contents($fullPath);
4529
}

src/Parser.php

+2-15
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,11 @@
22

33
namespace Differ\Parser;
44

5-
use JetBrains\PhpStorm\NoReturn;
6-
75
use function cli\line;
86
use function Differ\Differ\genDiff;
97

10-
#[NoReturn] function parse(string $string): void
11-
{
12-
line('%s', $string);
13-
exit();
14-
}
15-
16-
#[NoReturn] function parseDiff(string $pathToFile1, string $pathToFile2, string $format): void
8+
function parse(string $pathToFile1, string $pathToFile2, string $format): void
179
{
1810
$resultString = genDiff($pathToFile1, $pathToFile2, $format);
19-
parse($resultString);
20-
}
21-
22-
#[NoReturn] function parseError(string $errorMessage): void
23-
{
24-
parse($errorMessage);
11+
line($resultString);
2512
}

0 commit comments

Comments
 (0)