Completed
Push — master ( 3ef192...31d2af )
by Propa
03:28
created

Date   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 61
ccs 15
cts 15
cp 1
rs 10
c 3
b 0
f 0
wmc 5
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 8 2
A __construct() 0 6 1
A _setLocale() 0 6 1
A _setFallbackLocale() 0 6 1
1
<?php namespace Propaganistas\LaravelIntl;
2
3
use Illuminate\Support\Facades\App;
4
use Illuminate\Support\Facades\Config;
5
use Propaganistas\LaravelIntl\Base\LocaleCallback;
6
7
class Date
8
{
9
    use LocaleCallback;
10
11
    /**
12
     * @var \Jenssegers\Date\Date
13
     */
14
    protected $date;
15
16
    /**
17
     * Date constructor.
18
     */
19 15
    public function __construct()
20
    {
21 15
        $this->date = \Jenssegers\Date\Date::make();
22 15
        $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...
23 15
        $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...
24 15
    }
25
26
    /**
27
     * Handle dynamic calls to the object.
28
     *
29
     * @param  string  $method
30
     * @param  array   $args
31
     * @return mixed
32
     */
33 15
    public function __call($method, $args)
34
    {
35 15
        if (method_exists($this, '_' . $method)) {
36 15
            return call_user_func_array([$this, '_' . $method], $args);
37
        }
38
39 15
        return call_user_func_array([$this->date, $method], $args);
40
    }
41
42
    /**
43
     * Spoofed setLocale method.
44
     *
45
     * @param string $locale
46
     * @return $this
47
     */
48 15
    public function _setLocale($locale)
49
    {
50 15
        $this->date->setLocale($locale);
51
52 15
        return $this;
53
    }
54
55
    /**
56
     * Spoofed setFallbackLocale method.
57
     *
58
     * @param string $locale
59
     * @return $this
60
     */
61 15
    public function _setFallbackLocale($locale)
62
    {
63 15
        $this->date->setFallbackLocale($locale);
64
65 15
        return $this;
66
    }
67
}