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
|
|
|
|