Completed
Push — master ( 86b2cd...b16d12 )
by Richard
03:26
created

AnalyzeCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 16 1
A execute() 0 11 2
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 * 
5
 * Copyright (c) 2016 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received 
8
 * a copy of the license along with the code.
9
 */
10
11
namespace Lechimp\Dicto\App;
12
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Output\OutputInterface;
16
17
/**
18
 * Command to run an analysis.
19
 */
20
class AnalyzeCommand extends Command {
21
    /**
22
     * @inheritdoc
23
     */
24
    public function configure() {
25
        $this
26
            ->setName("analyze")
27
            ->setDescription
28
                ("Runs an analysis"
29
                )
30
            ->setHelp
31
                ("This command will index a codebase and analyze it, according to "
32
                ."the given configs."
33
                )
34
            ->addArgument
35
                ( "configs"
36
                , InputArgument::IS_ARRAY
37
                , "Give paths to config files, separated by spaces."
38
                );
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function execute(InputInterface $input, OutputInterface $output) {
45
        $config_paths = $input->getArgument("configs");
46
        if (count($config_paths) == 0) {
47
            $output->writeLn("<error>You need to give the path to at least one config.</error>");
48
            return;
49
        }
50
        $config = $this->load_config($config_paths);
51
        $dic = $this->build_dic($config);
52
        $this->configure_runtime($config);
53
        $dic["engine"]->run();
54
    }
55
}
56