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 — master ( 7f1d39...078202 )
by Freek
03:49 queued 02:41
created

Period   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 46
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\UptimeMonitor\Helpers;
4
5
use Carbon\Carbon;
6
use Spatie\UptimeMonitor\Exceptions\InvalidPeriod;
7
8
class Period
9
{
10
    public Carbon $startDateTime;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
11
12
    public Carbon $endDateTime;
13
14
    public function __construct(Carbon $startDateTime, Carbon $endDateTime)
15
    {
16
        if ($startDateTime->gt($endDateTime)) {
17
            throw  InvalidPeriod::startDateMustComeBeforeEndDate($startDateTime, $endDateTime);
18
        }
19
20
        $this->startDateTime = $startDateTime;
21
22
        $this->endDateTime = $endDateTime;
23
    }
24
25
    public function duration(): string
26
    {
27
        $interval = $this->startDateTime->diff($this->endDateTime);
28
29
        if (! $this->startDateTime->diffInHours($this->endDateTime)) {
30
            return $interval->format('%im');
31
        }
32
33
        if (! $this->startDateTime->diffInDays($this->endDateTime)) {
34
            return $interval->format('%hh %im');
35
        }
36
37
        return $interval->format('%dd %hh %im');
38
    }
39
40
    public function toText(): string
41
    {
42
        $configuredDateFormat = config('uptime-monitor.notifications.date_format');
43
44
        return
45
            $this->startDateTime->format('H:i').' '
46
            .($this->startDateTime->isToday() ? '' : "on {$this->startDateTime->format($configuredDateFormat)} ")
47
            .'➡️ '
48
            .$this->endDateTime->format('H:i')
49
            .($this->endDateTime->isToday() ? '' : " on {$this->endDateTime->format($configuredDateFormat)}");
50
    }
51
}
52