GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DateTime   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 62
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormatedDate() 0 11 3
A toArray() 0 7 1
A setModel() 0 6 1
1
<?php
2
3
namespace SleepingOwl\Admin\Display\Column;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
use SleepingOwl\Admin\Traits\DateFormat;
8
9
class DateTime extends NamedColumn
10
{
11
    use DateFormat;
12
    /**
13
     * Datetime format.
14
     * @var string
15
     */
16
    protected $format;
17
18
    /**
19
     * Datetime timezone.
20
     * @var string
21
     */
22
    protected $timezone;
23
24
    /**
25
     * @var string
26
     */
27
    protected $view = 'column.datetime';
28
29
    /**
30
     * @param Model $model
31
     *
32
     * @return $this
33
     */
34
    public function setModel(Model $model)
35
    {
36
        parent::setModel($model);
37
        $this->setHtmlAttribute('data-value', $this->getModelValue());
38
39
        return $this;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function toArray()
46
    {
47
        $value = $this->getModelValue();
48
49
        return parent::toArray() + [
50
            'value' => $this->getFormatedDate($value),
51
            'originalValue' => $value,
52
        ];
53
    }
54
55
    /**
56
     * @param string $date
57
     *
58
     * @return null|string
59
     */
60
    protected function getFormatedDate($date)
61
    {
62
        if (! is_null($date)) {
0 ignored issues
show
introduced by
The condition is_null($date) is always false.
Loading history...
63
            if (! ($date instanceof Carbon)) {
0 ignored issues
show
introduced by
$date is never a sub-type of Carbon\Carbon.
Loading history...
64
                $date = Carbon::parse($date);
65
            }
66
67
            $date = $date->timezone($this->getTimezone())->format($this->getFormat());
68
        }
69
70
        return $date;
71
    }
72
}
73