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

Date   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 93.75%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __call() 0 8 2
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
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
}