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.
Completed
Pull Request — master (#688)
by
unknown
18:52
created

DateTime::getFormat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
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 View Code Duplication
    protected function getFormatedDate($date)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        if (! is_null($date)) {
63
            if (! $date instanceof Carbon) {
64
                $date = Carbon::parse($date);
65
            }
66
67
            $date = $date->timezone($this->getTimezone())->format($this->getFormat());
68
        }
69
70
        return $date;
71
    }
72
}
73