Completed
Push — master ( 1ec574...c8c410 )
by Tobias
10:40 queued 40s
created

Configuration   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 188
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 188
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 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
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
    public function __construct(array $data)
94
    {
95
        $this->name = $data['name'];
96
        $this->locales = $data['locales'];
97
        $this->projectRoot = $data['project_root'];
98
        $this->outputDir = $data['output_dir'];
99
        $this->dirs = $data['dirs'];
100
        $this->excludedDirs = $data['excluded_dirs'];
101
        $this->excludedNames = $data['excluded_names'];
102
        $this->externalTranslationsDirs = $data['external_translations_dirs'];
103
        $this->outputFormat = $data['output_format'];
104
        $this->blacklistDomains = $data['blacklist_domains'];
105
        $this->whitelistDomains = $data['whitelist_domains'];
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getName()
112
    {
113
        return $this->name;
114
    }
115
116
    /**
117
     * @return array
118
     */
119
    public function getLocales()
120
    {
121
        return $this->locales;
122
    }
123
124
    /**
125
     * @return string
126
     */
127
    public function getProjectRoot()
128
    {
129
        return $this->projectRoot;
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getOutputDir()
136
    {
137
        return $this->outputDir;
138
    }
139
140
    /**
141
     * @return array
142
     */
143
    public function getDirs()
144
    {
145
        return $this->dirs;
146
    }
147
148
    /**
149
     * @return array
150
     */
151
    public function getExcludedDirs()
152
    {
153
        return $this->excludedDirs;
154
    }
155
156
    /**
157
     * @return array
158
     */
159
    public function getExcludedNames()
160
    {
161
        return $this->excludedNames;
162
    }
163
164
    /**
165
     * @return array
166
     */
167
    public function getExternalTranslationsDirs()
168
    {
169
        return $this->externalTranslationsDirs;
170
    }
171
172
    /**
173
     * @return string
174
     */
175
    public function getOutputFormat()
176
    {
177
        return $this->outputFormat;
178
    }
179
180
    /**
181
     * @return array
182
     */
183
    public function getBlacklistDomains()
184
    {
185
        return $this->blacklistDomains;
186
    }
187
188
    /**
189
     * @return array
190
     */
191
    public function getWhitelistDomains()
192
    {
193
        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
    public function getPathsToTranslationFiles()
203
    {
204
        return array_merge($this->externalTranslationsDirs, [$this->getOutputDir()]);
205
    }
206
}
207