Completed
Pull Request — master (#139)
by Kévin
03:18
created

Application::getConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
class Application extends \Symfony\Component\Console\Application
9
{
10
    /**
11
     * @var Configuration
12
     */
13
    public $configuration;
14
15
    /**
16
     * @var IssuesCollector
17
     */
18
    protected $issuesCollector;
19
20
    /**
21
     * @var Compiler
22
     */
23
    public $compiler;
24
25
    const VERSION = '0.5.0';
26
27
    /**
28
     * Starts the application.
29
     */
30 732
    public function __construct()
31
    {
32 732
        parent::__construct('PHP Smart Analyzer', $this->getStringVersion());
33
34 732
        $this->add(new Command\CheckCommand());
35 732
        $this->add(new Command\DumpReferenceCommand());
36
37 732
        $this->issuesCollector = new IssuesCollector();
38 732
        $this->configuration = new Configuration();
39 732
    }
40
41
    /**
42
     * Returns the version as a string.
43
     *
44
     * @return string
45
     */
46 732
    protected function getStringVersion()
47
    {
48 732
        $hash = $this->getCVVersion();
49 732
        if (!empty($hash)) {
50 732
            return self::VERSION . ' #' . $hash;
51
        }
52
53
        return self::VERSION;
54
    }
55
56
    /**
57
     * Returns CV Version.
58
     *
59
     * @return string
60
     */
61 732
    protected function getCVVersion()
62
    {
63 732
        exec('git describe --always', $version_mini_hash);
64
65 732
        return $version_mini_hash ? $version_mini_hash[0] : '';
66
    }
67
68
    /**
69
     * Get the configuration object.
70
     *
71
     * @return Configuration
72
     */
73 19
    public function getConfiguration()
74
    {
75 19
        return $this->configuration;
76
    }
77
78
    /**
79
     * Get the IssuesCollector object.
80
     *
81
     * @return IssuesCollector
82
     */
83 19
    public function getIssuesCollector()
84
    {
85 19
        return $this->issuesCollector;
86
    }
87
}
88