Passed
Push — develop ( 28c299...928e2a )
by Mathias
12:40
created

ModuleOptions::getOperator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license       MIT
8
 * @author        [email protected]
9
 */
10
11
namespace Core\Options;
12
13
use Core\Application;
14
use Core\Options\Exception\MissingOptionException;
15
use Zend\Stdlib\AbstractOptions;
16
17
/**
18
 * Class ModuleOptions
19
 *
20
 * Default options of the Core Module
21
 *
22
 * @author Carsten Bleek <[email protected]>
23
 * @author Mathias Weitz <[email protected]>
24
 * @author Mathias Gelhausen <[email protected]>
25
 * @author Anthonius Munthi <https://itstoni.com>
26
 */
27
class ModuleOptions extends AbstractOptions
28
{
29
30
    /**
31
     * The sitename is used in Mails. Typically it's the name of your website
32
     *
33
     * @var string
34
     */
35
    protected $siteName = "YAWIK";
36
37
    /**
38
     * The logo of the site
39
     *
40
     * @var string
41
     */
42
    protected $siteLogo = "modules/Core/images/logo.jpg";
43
44
    /**
45
     * Contact Data, which can be used in Mail signatures or the imprint page.
46
     *
47
     * @var array $operator
48
     */
49
    protected $operator = array(
50
        'companyShortName' => 'Example Company Name',
51
        'companyFullName'  => 'Example Company Name Ltd. & Co KG',
52
        'companyTax'       => 'Your VAT Number',
53
        'postalCode'       => '4711',
54
        'city'             => 'Froschmoorstetten',
55
        'country'          => 'Auenland',
56
        'street'           => 'Rath Dínen 112',
57
        'name'             => 'Gimli & Legolas',
58
        'email'            => '[email protected]',
59
        'fax'              => '+49-0815-4711',
60
        'homepage'         => 'http://example.com'
61
    );
62
63
    /**
64
     * This array defines the languages, which can be used.
65
     *
66
     * @var array $supportedLanguages
67
     */
68
    protected $supportedLanguages = array(
69
        'de' => 'de_DE',
70
        'fr' => 'fr',
71
        'en' => 'en_US',
72
        'es' => 'es',
73
        'it' => 'it',
74
    );
75
76
    /**
77
     * if true, YAWIK tries to detect the browser settings
78
     *
79
     * @var bool
80
     */
81
    protected $detectLanguage = true;
82
83
    /**
84
     * The default language is used, if no language is set
85
     *
86
     * @var string
87
     */
88
    protected $defaultLanguage = 'en';
89
90
    /**
91
     * default currency used, if no currency is set
92
     *
93
     * @var string
94
     */
95
    protected $defaultCurrencyCode = "USD";
96
97
    /**
98
     * default tax rate used, if no tax rate is set
99
     *
100
     * @var string
101
     */
102
    protected $defaultTaxRate = "19";
103
104
    /**
105
     * Email address to send system messages to.
106
     *
107
     * @var string
108
     */
109
    protected $systemMessageEmail;
110
111
    /**
112
     * Cache directory location
113
     * @var string
114
     */
115
    protected $cacheDir;
116
117
    /**
118
     * Public directory location
119
     * @var string
120
     */
121
    protected $publicDir;
122
123
    /**
124
     * Public directory location
125
     * @var string
126
     */
127
    protected $logDir;
128
129
    /**
130
     * @return string
131
     * @throws MissingOptionException
132
     * @since 0.20 throws MissingOptionException instead of InvalidArgumentException
133
     */
134 8
    public function getSiteName()
135
    {
136 8
        if (empty($this->siteName)) {
137 1
            throw new MissingOptionException('siteName', $this);
0 ignored issues
show
Bug introduced by
$this of type Core\Options\ModuleOptions is incompatible with the type integer expected by parameter $target of Core\Options\Exception\M...xception::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

137
            throw new MissingOptionException('siteName', /** @scrutinizer ignore-type */ $this);
Loading history...
138
        }
139
140 7
        return $this->siteName;
141
    }
142
143
    /**
144
     * @param $siteName
145
     *
146
     * @return $this
147
     */
148 2
    public function setSiteName($siteName)
149
    {
150 2
        $this->siteName = $siteName;
151 2
        return $this;
152
    }
153
154
    /**
155
     * @return string
156
     */
157 1
    public function getSiteLogo()
158
    {
159 1
        return $this->siteLogo;
160
    }
161
162
    /**
163
     * @param $siteLogo
164
     *
165
     * @return $this
166
     */
167 1
    public function setSiteLogo($siteLogo)
168
    {
169 1
        $this->siteLogo = $siteLogo;
170 1
        return $this;
171
    }
172
173
174
    /**
175
     * Gets the operators contact data
176
     *
177
     * @return array
178
     */
179 5
    public function getOperator()
180
    {
181 5
        return $this->operator;
182
    }
183
184
    /**
185
     * Sets the operators contact data
186
     *
187
     * @param $operator
188
     *
189
     * @return $this
190
     */
191 1
    public function setOperator($operator)
192
    {
193 1
        $this->operator = $operator;
194
195 1
        return $this;
196
    }
197
198
    /**
199
     * Gets supported languages
200
     *
201
     * @return array
202
     */
203 6
    public function getSupportedLanguages()
204
    {
205 6
        return $this->supportedLanguages;
206
    }
207
208
    /**
209
     * Sets supported languages
210
     *
211
     * @param $supportedLanguages
212
     *
213
     * @return $this
214
     */
215 1
    public function setSupportedLanguages($supportedLanguages)
216
    {
217 1
        $this->supportedLanguages = $supportedLanguages;
218
219 1
        return $this;
220
    }
221
222
    /**
223
     * Gets the default languages
224
     *
225
     * @return string
226
     */
227 1
    public function getDefaultLanguage()
228
    {
229 1
        return $this->defaultLanguage;
230
    }
231
232
    /**
233
     * Sets the default language
234
     *
235
     * @param $defaultLanguage
236
     *
237
     * @return $this
238
     */
239 1
    public function setDefaultLanguage($defaultLanguage)
240
    {
241 1
        $this->defaultLanguage = $defaultLanguage;
242
243 1
        return $this;
244
    }
245
246
    /**
247
     * Enable or disable the detection of language setting of the browser
248
     *
249
     * @param $detectLanguage
250
     *
251
     * @return $this
252
     */
253 1
    public function setDetectLanguage($detectLanguage)
254
    {
255 1
        $this->detectLanguage = $detectLanguage;
256
257 1
        return $this;
258
    }
259
260
    /**
261
     * Gets the browser language detecting setting
262
     *
263
     * @return bool
264
     */
265 1
    public function isDetectLanguage()
266
    {
267 1
        return $this->detectLanguage;
268
    }
269
270
    /**
271
     * Gets the default languages
272
     *
273
     * @return string
274
     */
275 2
    public function getDefaultCurrencyCode()
276
    {
277 2
        return $this->defaultCurrencyCode;
278
    }
279
280
    /**
281
     * Sets the default language
282
     *
283
     * @param $defaultCurrency
284
     *
285
     * @return $this
286
     */
287 2
    public function setDefaultCurrencyCode($defaultCurrency)
288
    {
289 2
        $this->defaultCurrencyCode = $defaultCurrency;
290
291 2
        return $this;
292
    }
293
294
    /**
295
     * Gets the default tax rate
296
     *
297
     * @return string
298
     */
299 1
    public function getDefaultTaxRate()
300
    {
301 1
        return $this->defaultTaxRate;
302
    }
303
304
    /**
305
     * Sets the default tax rate
306
     *
307
     * @param $defaultTaxRate
308
     *
309
     * @return $this
310
     */
311 1
    public function setDefaultTaxRate($defaultTaxRate)
312
    {
313 1
        $this->defaultTaxRate = $defaultTaxRate;
314
315 1
        return $this;
316
    }
317
318
    /**
319
     * Gets system message email address.
320
     *
321
     * @return string
322
     * @throws MissingOptionException if no value is set.
323
     * @since 0.20
324
     */
325 2
    public function getSystemMessageEmail()
326
    {
327 2
        if (!$this->systemMessageEmail) {
328 1
            throw new MissingOptionException('systemMessageEmail', $this);
0 ignored issues
show
Bug introduced by
$this of type Core\Options\ModuleOptions is incompatible with the type integer expected by parameter $target of Core\Options\Exception\M...xception::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

328
            throw new MissingOptionException('systemMessageEmail', /** @scrutinizer ignore-type */ $this);
Loading history...
329
        }
330 1
        return $this->systemMessageEmail;
331
    }
332
333
    /**
334
     * Sets system message email address.
335
     *
336
     * @param string $systemMessageEmail
337
     *
338
     * @return self
339
     * @since 0.20
340
     */
341 6
    public function setSystemMessageEmail($systemMessageEmail)
342
    {
343 6
        $this->systemMessageEmail = $systemMessageEmail;
344
345 6
        return $this;
346
    }
347
348
    /**
349
     * @return string
350
     */
351 1
    public function getCacheDir()
352
    {
353 1
        if (is_null($this->cacheDir)) {
0 ignored issues
show
introduced by
The condition is_null($this->cacheDir) is always false.
Loading history...
354 1
            $this->setCacheDir(getcwd().'/var/cache');
355
        }
356
357 1
        return $this->cacheDir;
358
    }
359
360
    /**
361
     * @param string $cacheDir
362
     */
363 1
    public function setCacheDir($cacheDir)
364
    {
365 1
        if (!is_dir($cacheDir)) {
366 1
            mkdir($cacheDir, 0777, true);
367
        }
368 1
        $this->cacheDir = $cacheDir;
369 1
    }
370
371
    /**
372
     * @return string
373
     */
374 5
    public function getPublicDir()
375
    {
376 5
        if (is_null($this->publicDir)) {
0 ignored issues
show
introduced by
The condition is_null($this->publicDir) is always false.
Loading history...
377 5
            $this->setPublicDir(getcwd().DIRECTORY_SEPARATOR.'public');
378
        }
379 5
        return $this->publicDir;
380
    }
381
382
    /**
383
     * @param string $publicDir
384
     * @return ModuleOptions
385
     */
386 5
    public function setPublicDir($publicDir)
387
    {
388 5
        $this->publicDir = $publicDir;
389
390 5
        return $this;
391
    }
392
393
    /**
394
     * @return string
395
     */
396 5
    public function getLogDir()
397
    {
398 5
        if (is_null($this->logDir)) {
0 ignored issues
show
introduced by
The condition is_null($this->logDir) is always false.
Loading history...
399 5
            $this->setLogDir(getcwd().'/var/log');
400
        }
401 5
        return $this->logDir;
402
    }
403
404
    /**
405
     * @param string $logDir
406
     * @return ModuleOptions
407
     */
408 5
    public function setLogDir($logDir)
409
    {
410 5
        if (!is_dir($logDir)) {
411 1
            mkdir($logDir, 0777, true);
412
        }
413 5
        $this->logDir = $logDir;
414
415 5
        return $this;
416
    }
417
418 1
    public function getConfigDir()
419
    {
420 1
        return Application::getConfigDir();
421
    }
422
}
423