Completed
Push — master ( 4e8bc9...f46df8 )
by Tobias
13:01 queued 05:03
created

Configuration   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 202
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 0
dl 0
loc 202
ccs 40
cts 40
cp 1
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getName() 0 4 1
A getLocales() 0 4 1
A getProjectRoot() 0 4 1
A getOutputDir() 0 4 1
A getDirs() 0 4 1
A getExcludedDirs() 0 4 1
A getExcludedNames() 0 4 1
A getExternalTranslationsDirs() 0 4 1
A getOutputFormat() 0 4 1
A getBlacklistDomains() 0 4 1
A getWhitelistDomains() 0 4 1
A getPathsToTranslationFiles() 0 4 1
A getXliffVersion() 0 4 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
     * @var string
92
     */
93
    private $xliffVersion;
94
95
    /**
96
     * @param array $data
97
     */
98 16
    public function __construct(array $data)
99
    {
100 16
        $this->name = $data['name'];
101 16
        $this->locales = $data['locales'];
102 16
        $this->projectRoot = $data['project_root'];
103 16
        $this->outputDir = $data['output_dir'];
104 16
        $this->dirs = $data['dirs'];
105 16
        $this->excludedDirs = $data['excluded_dirs'];
106 16
        $this->excludedNames = $data['excluded_names'];
107 16
        $this->externalTranslationsDirs = $data['external_translations_dirs'];
108 16
        $this->outputFormat = $data['output_format'];
109 16
        $this->blacklistDomains = $data['blacklist_domains'];
110 16
        $this->whitelistDomains = $data['whitelist_domains'];
111 16
        $this->xliffVersion = $data['xliff_version'];
112 16
    }
113
114
    /**
115
     * @return string
116
     */
117 3
    public function getName()
118
    {
119 3
        return $this->name;
120
    }
121
122
    /**
123
     * @return array
124
     */
125 3
    public function getLocales()
126
    {
127 3
        return $this->locales;
128
    }
129
130
    /**
131
     * @return string
132
     */
133 2
    public function getProjectRoot()
134
    {
135 2
        return $this->projectRoot;
136
    }
137
138
    /**
139
     * @return string
140
     */
141 7
    public function getOutputDir()
142
    {
143 7
        return $this->outputDir;
144
    }
145
146
    /**
147
     * @return array
148
     */
149 2
    public function getDirs()
150
    {
151 2
        return $this->dirs;
152
    }
153
154
    /**
155
     * @return array
156
     */
157 2
    public function getExcludedDirs()
158
    {
159 2
        return $this->excludedDirs;
160
    }
161
162
    /**
163
     * @return array
164
     */
165 2
    public function getExcludedNames()
166
    {
167 2
        return $this->excludedNames;
168
    }
169
170
    /**
171
     * @return array
172
     */
173 1
    public function getExternalTranslationsDirs()
174
    {
175 1
        return $this->externalTranslationsDirs;
176
    }
177
178
    /**
179
     * @return string
180
     */
181 2
    public function getOutputFormat()
182
    {
183 2
        return $this->outputFormat;
184
    }
185
186
    /**
187
     * @return array
188
     */
189 2
    public function getBlacklistDomains()
190
    {
191 2
        return $this->blacklistDomains;
192
    }
193
194
    /**
195
     * @return array
196
     */
197 2
    public function getWhitelistDomains()
198
    {
199 2
        return $this->whitelistDomains;
200
    }
201
202
    /**
203
     * Get all paths where translation paths are stored. Both external files and
204
     * files created by us.
205
     *
206
     * @return array
207
     */
208 5
    public function getPathsToTranslationFiles()
209
    {
210 5
        return array_merge($this->externalTranslationsDirs, [$this->getOutputDir()]);
211
    }
212
213
    /**
214
     * @return string
215
     */
216 2
    public function getXliffVersion()
217
    {
218 2
        return $this->xliffVersion;
219
    }
220
}
221