|
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()); |
|
|
|
|
|
|
20
|
12 |
|
$this->setFallbackLocale(Config::get('app.fallback_locale')); |
|
|
|
|
|
|
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)) { |
|
|
|
|
|
|
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)) { |
|
|
|
|
|
|
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
|
|
|
} |
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.