Conditions | 5 |
Paths | 9 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
80 | protected function getFormatValue($date) |
||
81 | { |
||
82 | if (! empty($date)) { |
||
83 | if (is_numeric($date)) { |
||
84 | $date = Carbon::createFromTimestamp($date); |
||
85 | } |
||
86 | if (! ($date instanceof Carbon)) { |
||
87 | $date = Carbon::parse($date); |
||
88 | } |
||
89 | |||
90 | $date->timezone($this->getTimezone()); |
||
|
|||
91 | |||
92 | if ($this->getFormat() == 'humans') { |
||
93 | $date = $date->diffForHumans(); |
||
94 | } else { |
||
95 | $date = $date->format($this->getFormat()); |
||
96 | } |
||
97 | } |
||
98 | |||
99 | return $date; |
||
100 | } |
||
101 | } |
||
102 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: