Completed
Pull Request — master (#139)
by Kévin
22:48 queued 19:51
created

Application   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
dl 0
loc 80
ccs 18
cts 19
cp 0.9474
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getStringVersion() 0 9 2
A getCVVersion() 0 6 2
A getConfiguration() 0 4 1
A getIssuesCollector() 0 4 1
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