Completed
Push — master ( 28dd7c...705fb1 )
by Tobias
07:56
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
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 Translation\Bundle\Model;
13
14
/**
15
 * This class is a PHP representation of `translation.configs.xxx`.
16
 *
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
final class Configuration
20
{
21
    /**
22
     * @var string
23
     */
24
    private $name;
25
26
    /**
27
     * @var array
28
     */
29
    private $locales;
30
31
    /**
32
     * Usually dirname('kernel.root_dir').
33
     *
34
     * @var string
35
     */
36
    private $projectRoot;
37
38
    /**
39
     * This is where we dump all translations.
40
     *
41
     * @var string
42
     */
43
    private $outputDir;
44
45
    /**
46
     * The absolute path to folders we scan for translations.
47
     *
48
     * @var array
49
     */
50
    private $dirs;
51
52
    /**
53
     * Directories we should not extract translations from.
54
     *
55
     * @var array
56
     */
57
    private $excludedDirs;
58
59
    /**
60
     * File names we should not extract translations from.
61
     *
62
     * @var array
63
     */
64
    private $excludedNames;
65
66
    /**
67
     * Directories that holds translation files but is out of our control.
68
     *
69
     * @var array
70
     */
71
    private $externalTranslationsDirs;
72
73
    /**
74
     * The format we store translation files in.
75
     *
76
     * @var string
77
     */
78
    private $outputFormat;
79
80
    /**
81
     * @var array
82
     */
83
    private $blacklistDomains;
84
85
    /**
86
     * @var array
87
     */
88
    private $whitelistDomains;
89
90
    /**
91
     * @param array $data
92
     */
93 3
    public function __construct(array $data)
94
    {
95 3
        $this->name = $data['name'];
96 3
        $this->locales = $data['locales'];
97 3
        $this->projectRoot = $data['project_root'];
98 3
        $this->outputDir = $data['output_dir'];
99 3
        $this->dirs = $data['dirs'];
100 3
        $this->excludedDirs = $data['excluded_dirs'];
101 3
        $this->excludedNames = $data['excluded_names'];
102 3
        $this->externalTranslationsDirs = $data['external_translations_dirs'];
103 3
        $this->outputFormat = $data['output_format'];
104 3
        $this->blacklistDomains = $data['blacklist_domains'];
105 3
        $this->whitelistDomains = $data['whitelist_domains'];
106 3
    }
107
108
    /**
109
     * @return string
110
     */
111 1
    public function getName()
112
    {
113 1
        return $this->name;
114
    }
115
116
    /**
117
     * @return array
118
     */
119 1
    public function getLocales()
120
    {
121 1
        return $this->locales;
122
    }
123
124
    /**
125
     * @return string
126
     */
127 1
    public function getProjectRoot()
128
    {
129 1
        return $this->projectRoot;
130
    }
131
132
    /**
133
     * @return string
134
     */
135 3
    public function getOutputDir()
136
    {
137 3
        return $this->outputDir;
138
    }
139
140
    /**
141
     * @return array
142
     */
143 1
    public function getDirs()
144
    {
145 1
        return $this->dirs;
146
    }
147
148
    /**
149
     * @return array
150
     */
151 1
    public function getExcludedDirs()
152
    {
153 1
        return $this->excludedDirs;
154
    }
155
156
    /**
157
     * @return array
158
     */
159 1
    public function getExcludedNames()
160
    {
161 1
        return $this->excludedNames;
162
    }
163
164
    /**
165
     * @return array
166
     */
167 1
    public function getExternalTranslationsDirs()
168
    {
169 1
        return $this->externalTranslationsDirs;
170
    }
171
172
    /**
173
     * @return string
174
     */
175 1
    public function getOutputFormat()
176
    {
177 1
        return $this->outputFormat;
178
    }
179
180
    /**
181
     * @return array
182
     */
183 1
    public function getBlacklistDomains()
184
    {
185 1
        return $this->blacklistDomains;
186
    }
187
188
    /**
189
     * @return array
190
     */
191 1
    public function getWhitelistDomains()
192
    {
193 1
        return $this->whitelistDomains;
194
    }
195
196
    /**
197
     * Get all paths where translation paths are stored. Both external files and
198
     * files created by us.
199
     *
200
     * @return array
201
     */
202 1
    public function getPathsToTranslationFiles()
203
    {
204 1
        return array_merge($this->externalTranslationsDirs, [$this->getOutputDir()]);
205
    }
206
}
207