Completed
Push — master ( 0646cc...408e0c )
by Propa
05:16
created

Date::_setFallbackLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
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 12
        $this->date = \Jenssegers\Date\Date::make();
19 12
        $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 12
        $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 12
    public function __call($method, $args)
31
    {
32 12 View Code Duplication
        if (method_exists($this, '_' . $method)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33 12
            return call_user_func_array([$this, '_' . $method], $args);
34
        }
35
36 12
        return call_user_func_array([$this->date, $method], $args);
37
    }
38
39
    /**
40
     * Handle dynamic, static calls to the object.
41
     *
42
     * @param  string  $method
43
     * @param  array   $args
44
     * @return mixed
45
     */
46
    public static function __callStatic($method, $args)
47
    {
48
        $instance = new static;
49
50 View Code Duplication
        if (method_exists($instance, '_' . $method)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
            return call_user_func_array([$instance, '_' . $method], $args);
52
        }
53
54
        return call_user_func_array([$instance, $method], $args);
55
    }
56
57
    /**
58
     * Spoofed setLocale method.
59
     *
60
     * @param string $locale
61
     * @return $this
62
     */
63 12
    public function _setLocale($locale)
64
    {
65 12
        $this->date->setLocale($locale);
66
67 12
        return $this;
68
    }
69
70
    /**
71
     * Spoofed setFallbackLocale method.
72
     *
73
     * @param string $locale
74
     * @return $this
75
     */
76 12
    public function _setFallbackLocale($locale)
77
    {
78 12
        $this->date->setFallbackLocale($locale);
79
80 12
        return $this;
81
    }
82
}