Completed
Push — master ( 329115...539a70 )
by Propa
05:34
created

Date::getLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Propaganistas\LaravelIntl;
4
5
use Propaganistas\LaravelIntl\Concerns\WithLocales;
6
use Propaganistas\LaravelIntl\Contracts\Intl;
7
use Propaganistas\LaravelIntl\Proxies\Date as DateProxy;
8
use Punic\Data as FormatterData;
9
10
/**
11
 * @mixin \Jenssegers\Date\Date
12
 */
13
class Date extends Intl
14
{
15
    use WithLocales {
16
        setLocale as _setLocale;
17
        setFallbackLocale as _setFallbackLocale;
18
    }
19
20
    /**
21
     * Dynamically handle calls to the class.
22
     *
23
     * @param string $method
24
     * @param array $parameters
25
     * @return mixed
26
     */
27 85
    public function __call($method, $parameters)
28
    {
29 85
        return DateProxy::make()->{$method}(...$parameters);
30
    }
31
32
    /**
33
     * Set the current locale.
34
     *
35
     * @param string $locale
36
     * @return $this
37
     * @throws \Punic\Exception\InvalidLocale
38
     */
39 90
    public function setLocale($locale)
40
    {
41 90
        DateProxy::setLocale($locale);
42
43 88
        FormatterData::setDefaultLocale($locale);
44
45 88
        return $this->_setLocale($locale);
46
    }
47
48
    /**
49
     * Set the fallback locale.
50
     *
51
     * @param string $locale
52
     * @return $this
53
     * @throws \Punic\Exception\InvalidLocale
54
     */
55 88
    public function setFallbackLocale($locale)
56
    {
57 88
        DateProxy::setFallbackLocale($locale);
58
59 88
        FormatterData::setFallbackLocale($locale);
60
61 88
        return $this->_setFallbackLocale($locale);
62
    }
63
}