Passed
Push — master ( 864e2a...68b437 )
by Mike
05:47
created

TwigConfig   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 118
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
wmc 10
eloc 33
dl 0
loc 118
ccs 30
cts 32
cp 0.9375
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getBaseTemplateClass() 0 3 1
A isCache() 0 3 1
A getCachePath() 0 3 1
A isStrictVariables() 0 3 1
A isDebug() 0 3 1
A getOptimization() 0 3 1
A getModulePaths() 0 18 1
A getAutoescape() 0 3 1
A isAutoReload() 0 3 1
A getCharset() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Twig;
6
7
8
use Xervice\Config\XerviceConfig;
9
use Xervice\Core\Config\AbstractConfig;
10
use Xervice\Core\CoreConfig;
11
12
class TwigConfig extends AbstractConfig
13
{
14
    public const DEBUG = 'twig.debug';
15
16
    public const CHARSET = 'twig.charset';
17
18
    public const BASE_TEMPLATE_CLASS = 'twig.base.template.class';
19
20
    public const STRICT_VARIABLES = 'twig.strict.variables';
21
22
    public const AUTOESCAPE = 'twig.autoescape';
23
24
    public const CACHE = 'twig.cache';
25
26
    public const CACHE_PATH = 'twig.cache.path';
27
28
    public const AUTO_RELOAD = 'twig.auto.reload';
29
30
    public const OPTIMIZATIONS = 'twig.optimizations';
31
32
    public const MODULE_PATHS = 'twig.module.paths';
33
34
    /**
35
     * @return array
36
     */
37 2
    public function getModulePaths(): array
38
    {
39 2
        return $this->get(
40 2
            self::MODULE_PATHS,
41
            [
42 2
                sprintf(
43 2
                    '%s/src/%s',
44 2
                    $this->get(XerviceConfig::APPLICATION_PATH),
45 2
                    $this->get(CoreConfig::PROJECT_LAYER_NAMESPACE)
46
                ),
47 2
                sprintf(
48 2
                    '%s/src/%s',
49 2
                    $this->get(XerviceConfig::APPLICATION_PATH),
50 2
                    'Xervice'
51
                ),
52 2
                sprintf(
53 2
                    '%s/vendor/xervice/*/src/Xervice',
54 2
                    $this->get(XerviceConfig::APPLICATION_PATH)
55
                )
56
            ]
57
        );
58
    }
59
60
    /**
61
     * @return bool
62
     */
63 2
    public function isDebug(): bool
64
    {
65 2
        return $this->get(self::DEBUG, false);
66
    }
67
68
    /**
69
     * @return string
70
     */
71 2
    public function getCharset(): string
72
    {
73 2
        return $this->get(self::CHARSET, 'UTF-8');
74
    }
75
76
    /**
77
     * @return string
78
     */
79 2
    public function getBaseTemplateClass(): string
80
    {
81 2
        return $this->get(self::BASE_TEMPLATE_CLASS, 'Twig_Template');
82
    }
83
84
    /**
85
     * @return bool
86
     */
87 2
    public function isStrictVariables(): bool
88
    {
89 2
        return $this->get(self::STRICT_VARIABLES, false);
90
    }
91
92
    /**
93
     * @return string
94
     */
95 2
    public function getAutoescape(): string
96
    {
97 2
        return $this->get(self::AUTOESCAPE, 'html');
98
    }
99
100
    /**
101
     * @return bool
102
     */
103 2
    public function isCache(): bool
104
    {
105 2
        return $this->get(self::CACHE, false);
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getCachePath(): string
112
    {
113
        return $this->get(self::CACHE_PATH);
114
    }
115
116
    /**
117
     * @return bool
118
     */
119 2
    public function isAutoReload(): bool
120
    {
121 2
        return $this->get(self::AUTO_RELOAD, false);
122
    }
123
124
    /**
125
     * @return int
126
     */
127 2
    public function getOptimization(): int
128
    {
129 2
        return $this->get(self::OPTIMIZATIONS, -1);
130
    }
131
}