ValidateFileCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 37
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 17 2
A loadDefinitions() 0 5 1
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