Completed
Pull Request — master (#3)
by Tomáš
06:46
created

Configuration::getSourceDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sculpin\Core\Configuration;
13
14
use Dflydev\DotAccessConfiguration\Configuration as BaseConfiguration;
15
16
final class Configuration extends BaseConfiguration
17
{
18
    /**
19
     * @var array
20
     */
21
    private $raws = [];
22
23
    /**
24
     * @var string
25
     */
26
    private $permalink;
27
28
    /**
29
     * @var string
30
     */
31
    private $defaultFormatter;
32
33
    public function __construct(string $sourceDir, string $outputDir)
34
    {
35
        parent::__construct([
36
            'sourceDir' => $sourceDir,
37
            'outputDir' => $outputDir
38
        ]);
39
    }
40
41
    public function getSourceDir() : string
42
    {
43
        return $this->data()->get('sourceDir');
44
    }
45
46
    public function getOutputDir() : string
47
    {
48
        return $this->data()->get('outputDir');
49
    }
50
51
    /**
52
     * NOTE: Does not clear existing values first.
53
     */
54
    public function setRaws(array $raws = [])
55
    {
56
        foreach ($raws as $raw) {
57
            $this->addRaw($raw);
58
        }
59
    }
60
61
    public function addRaw(string $pattern)
62
    {
63
        if (substr($pattern, 0, 2) == './') {
64
            $pattern = substr($pattern, 2);
65
        }
66
        if (!in_array($pattern, $this->raws)) {
67
            $this->raws[] = $pattern;
68
        }
69
    }
70
71
    public function raws() : array
72
    {
73
        return $this->raws;
74
    }
75
76
    public function permalink() : string
77
    {
78
        return $this->permalink;
79
    }
80
81
    public function setDefaultFormatter(string $defaultFormatter)
82
    {
83
        $this->defaultFormatter = $defaultFormatter;
84
    }
85
86
    public function defaultFormatter() : string
87
    {
88
        return $this->defaultFormatter;
89
    }
90
}
91