ValidateFileCommand::loadDefinitions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 5
cp 0
crap 2
rs 10
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