GenerateCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 20 2
1
<?php
2
3
namespace Spatie\SchemaOrg\Generator\Console;
4
5
use Spatie\SchemaOrg\Generator\Definitions;
6
use Spatie\SchemaOrg\Generator\PackageGenerator;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class GenerateCommand extends Command
13
{
14
    protected function configure()
15
    {
16
        $this
17
            ->setName('generate')
18
            ->setDescription('Generate the package code from the schema.org docs')
19
            ->addOption('local', 'l', InputOption::VALUE_NONE, 'Use a cached version of the source');
20
    }
21
22
    /**
23
     * @param \Symfony\Component\Console\Input\InputInterface $input
24
     * @param \Symfony\Component\Console\Output\OutputInterface $output
25
     *
26
     * @return int
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $output->writeln('Generating package code...');
31
32
        $generator = new PackageGenerator();
33
34
        $definitions = new Definitions([
35
            'core' => 'https://raw.githubusercontent.com/schemaorg/schemaorg/master/data/releases/7.04/schema.rdfa',
36
        ]);
37
38
        if (! $input->getOption('local')) {
39
            $definitions->preload();
40
        }
41
42
        $generator->generate($definitions);
43
44
        $output->writeln('Done!');
45
46
        return 0;
47
    }
48
}
49