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
Push — analysis-rdw4o3 ( a6c473 )
by butschster
12:11
created

Date::setSeconds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SleepingOwl\Admin\Display\Column\Filter;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\Facades\Log;
7
use SleepingOwl\Admin\Traits\DateFormat;
8
use SleepingOwl\Admin\Traits\DatePicker;
9
10
class Date extends Text
11
{
12
    use DatePicker, DateFormat;
13
14
    /**
15
     * @var string
16
     */
17
    protected $view = 'column.filter.date';
18
19
    /**
20
     * @var string
21
     */
22
    protected $format = 'Y-m-d';
23
24
    /**
25
     * @var string
26
     */
27
    protected $timezone;
28
29
    public function initialize()
30
    {
31
        parent::initialize();
32
        $this->setHtmlAttribute('data-type', 'date');
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getPickerFormat()
39
    {
40
        return $this->pickerFormat ?: config('sleeping_owl.dateFormat');
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    public function toArray()
47
    {
48
        return parent::toArray() + [
49
            'pickerFormat' => $this->getJsPickerFormat(),
50
        ];
51
    }
52
53
    /**
54
     * @param string $date
55
     *
56
     * @return string
57
     */
58
    public function parseValue($date)
59
    {
60
        if (empty($date)) {
61
            return;
62
        }
63
64
        //contains in date
65
        $this->setOperator('contains');
66
67
        if (! $date instanceof Carbon) {
0 ignored issues
show
introduced by
$date is never a sub-type of Carbon\Carbon.
Loading history...
68
            try {
69
                $date = Carbon::parse($date);
70
            } catch (\Exception $e) {
71
                try {
72
                    $date = Carbon::createFromFormat($this->getPickerFormat(), $date);
73
                } catch (\Exception $e) {
74
                    Log::error('Unable to parse date!', [
75
                        'format' => $this->getPickerFormat(),
76
                        'date' => $date,
77
                        'exception' => $e,
78
                    ]);
79
80
                    return;
81
                }
82
            }
83
        }
84
85
        return $date->timezone($this->getTimezone())->format($this->getFormat());
86
    }
87
}
88