ValidateFileCommand::configure()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 17
ccs 0
cts 15
cp 0
crap 6
rs 9.7
c 0
b 0
f 0
1
<?php
2
/**
3
 * ValidateFileCommand class file
4
 */
5
6
namespace Graviton\JsonSchemaBundle\Command;
7
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Finder\SplFileInfo;
11
12
/**
13
 * Validate JSON definition file
14
 *
15
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
16
 * @license  https://opensource.org/licenses/MIT MIT License
17
 * @link     http://swisscom.ch
18
 */
19
class ValidateFileCommand extends AbstractValidateCommand
20
{
21
    /**
22
     * Configures the current command.
23
     *
24
     * @return void
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
30
        if ($this->getName() === null) {
31
            $this->setName('graviton:validate:definition:file');
32
        }
33
34
        $this
35
            ->setDescription('Validate a JSON definition')
36
            ->addOption(
37
                'path',
38
                '',
39
                InputOption::VALUE_REQUIRED,
40
                'Path to the json definition.'
41
            );
42
    }
43
44
    /**
45
     * Load JSON definitions
46
     *
47
     * @param InputInterface $input Command input
48
     * @return SplFileInfo[]
49
     */
50
    protected function loadDefinitions(InputInterface $input)
51
    {
52
        $file = $input->getOption('path');
53
        return [new SplFileInfo($file, $file, $file)];
54
    }
55
}
56