Completed
Pull Request — master (#45)
by Aleh
03:31
created

Project::getRootFolder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Padawan\Domain;
4
5
use Padawan\Domain\Project\Index;
6
use Padawan\Domain\Project\Config;
7
8
class Project
9
{
10
    private $index;
11
    private $rootFolder;
12
    private $config;
13
    private $plugins = [];
14
15
    public function __construct(Index $index, $rootFolder = "")
16
    {
17
        $this->index        = $index;
18
        $this->rootFolder   = $rootFolder;
19
        $this->config       = Config::default();
20
    }
21
22
    /**
23
     * @return Project
24
     */
25
    public static function withConfig(
26
        Index $index,
27
        $rootFolder,
28
        Config $config
29
    ) {
30
        $self = new static($index, $rootFolder);
31
        $self->config = $config;
32
        return $self;
33
    }
34
    public function getRootFolder()
35
    {
36
        return $this->rootFolder;
37
    }
38
    public function getRootDir()
39
    {
40
        return $this->getRootFolder();
41
    }
42
43
    /**
44
     * Returns project's index
45
     * @return Index
46
     */
47
    public function getIndex()
48
    {
49
        return $this->index;
50
    }
51
    public function setIndex(Index $index)
52
    {
53
        $this->index = $index;
54
    }
55
    public function getPlugins()
56
    {
57
        return $this->plugins;
58
    }
59
    public function addPlugin($key, $plugin)
60
    {
61
        $this->plugins[$key] = $plugin;
62
    }
63
    public function getPlugin($key)
64
    {
65
        if (array_key_exists($key, $this->plugins)) {
66
            return $this->plugins[$key];
67
        }
68
        return [];
69
    }
70
}
71