getComponentProjectFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\Command;
12
13
use ComponentManager\Platform\Platform;
14
use ComponentManager\Project\ComponentProjectFile;
15
use Symfony\Component\Console\Command\Command;
16
17
/**
18
 * Component project-aware command.
19
 *
20
 * Provides helpful utility methods for accessing the project in the currrent
21
 * working directory. Import this into command implementations to reduce
22
 * duplication.
23
 */
24
abstract class ComponentProjectAwareCommand extends Command {
25
    /**
26
     * Component project file.
27
     *
28
     * Lazily loaded -- be sure to call getProject() in order to ensure the
29
     * value is defined.
30
     *
31
     * @var ComponentProjectFile
32
     */
33
    protected $componentProjectFile;
34
35
    /**
36
     * Platform support library.
37
     *
38
     * @var Platform
39
     */
40
    protected $platform;
41
42
    /**
43
     * Initialiser.
44
     *
45
     * @param Platform $platform
46
     */
47
    public function __construct(Platform $platform) {
48
        $this->platform = $platform;
49
50
        parent::__construct();
51
    }
52
53
    /**
54
     * Get component project file.
55
     *
56
     * @return ComponentProjectFile
57
     */
58
    protected function getComponentProjectFile() {
59
        if ($this->componentProjectFile === null) {
60
            $this->componentProjectFile = new ComponentProjectFile(
61
                    ComponentProjectFile::FILENAME);
62
        }
63
64
        return $this->componentProjectFile;
65
    }
66
}
67