Completed
Push — master ( c1a156...8cadde )
by Kirill
08:14
created

SDLGrammarCompileCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 2
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Console;
11
12
use Railt\Compiler\Compiler;
13
use Railt\Console\Command;
14
use Railt\Io\File;
15
16
/**
17
 * Class SDLCompileCommand
18
 */
19
class SDLGrammarCompileCommand extends Command
20
{
21
    /**
22
     * @var string
23
     */
24
    private const SCHEMA_SDL_GRAMMAR = __DIR__ . '/../../resources/grammar.pp2';
25
26
    /**
27
     * @var string
28
     */
29
    protected $signature = 'sdl:grammar:compile';
30
31
    /**
32
     * @var string
33
     */
34
    protected $description = 'Compile GraphQL SDL Parser';
35
36
    /**
37
     * @throws \Railt\Io\Exception\ExternalFileException
38
     * @throws \Railt\Io\Exception\NotReadableException
39
     * @throws \Throwable
40
     */
41
    public function handle(): void
42
    {
43
        Compiler::load(File::fromPathname(self::SCHEMA_SDL_GRAMMAR))
0 ignored issues
show
Bug introduced by
It seems like \Railt\Io\File::fromPath...lf::SCHEMA_SDL_GRAMMAR) targeting Railt\Io\File::fromPathname() can also be of type object<Railt\Io\File>; however, Railt\Compiler\Compiler::load() does only seem to accept object<Railt\Io\Readable>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
44
            ->setClassName('Parser')
45
            ->setNamespace('Railt\\SDL\\Compiler')
46
            ->saveTo(__DIR__ . '/../Compiler');
47
48
        $this->info('OK');
49
    }
50
}
51