Completed
Push — master ( d9b797...3abea4 )
by Propa
06:42
created

Date::__callStatic()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 3
Ratio 30 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 3
loc 10
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Propaganistas\LaravelIntl;
2
3
use Illuminate\Support\Facades\App;
4
use Illuminate\Support\Facades\Config;
5
6
class Date
7
{
8
    /**
9
     * @var \Jenssegers\Date\Date
10
     */
11
    protected $date;
12
13
    /**
14
     * Date constructor.
15
     */
16 12
    public function __construct()
17
    {
18 8
        $this->date = \Jenssegers\Date\Date::make();
19 8
        $this->setLocale(App::getLocale());
0 ignored issues
show
Bug introduced by
The method setLocale() does not exist on Propaganistas\LaravelIntl\Date. Did you maybe mean _setLocale()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
20 8
        $this->setFallbackLocale(Config::get('app.fallback_locale'));
0 ignored issues
show
Bug introduced by
The method setFallbackLocale() does not exist on Propaganistas\LaravelIntl\Date. Did you maybe mean _setFallbackLocale()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
21 12
    }
22
23
    /**
24
     * Handle dynamic calls to the object.
25
     *
26
     * @param  string  $method
27
     * @param  array   $args
28
     * @return mixed
29
     */
30 8
    public function __call($method, $args)
31
    {
32 8
        if (method_exists($this, '_' . $method)) {
33 8
            return call_user_func_array([$this, '_' . $method], $args);
34
        }
35
36 8
        return call_user_func_array([$this->date, $method], $args);
37
    }
38
39
    /**
40
     * Spoofed setLocale method.
41
     *
42
     * @param string $locale
43
     * @return $this
44
     */
45 9
    public function _setLocale($locale)
46
    {
47 8
        $this->date->setLocale($locale);
48
49 9
        return $this;
50
    }
51
52
    /**
53
     * Spoofed setFallbackLocale method.
54
     *
55
     * @param string $locale
56
     * @return $this
57
     */
58 11
    public function _setFallbackLocale($locale)
59
    {
60 8
        $this->date->setFallbackLocale($locale);
61
62 11
        return $this;
63
    }
64
}