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.

RangeFinder   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 20
lcom 0
cbo 2
dl 0
loc 82
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A findRangeInFreeTime() 0 6 2
A findOpenInFreeTime() 0 8 2
A findOpenRangeInWorkingHours() 0 6 2
A findOpenInWorkingHours() 0 8 2
A findCloseInWorkingHours() 0 6 2
A findCloseRangeInWorkingHours() 0 6 2
A findCloseInFreeTime() 0 8 2
A findPreviousRangeInFreeTime() 0 6 2
A findPreviousOpenInFreeTime() 0 8 2
A findPreviousCloseInWorkingHours() 0 8 2
1
<?php
2
3
namespace Spatie\OpeningHours\Helpers;
4
5
use Spatie\OpeningHours\Time;
6
use Spatie\OpeningHours\TimeRange;
7
8
trait RangeFinder
9
{
10
    protected function findRangeInFreeTime(Time $time, TimeRange $timeRange)
11
    {
12
        if ($timeRange->start()->isAfter($time)) {
0 ignored issues
show
Documentation introduced by
$time is of type object<Spatie\OpeningHours\Time>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
13
            return $timeRange;
14
        }
15
    }
16
17
    protected function findOpenInFreeTime(Time $time, TimeRange $timeRange)
18
    {
19
        $range = $this->findRangeInFreeTime($time, $timeRange);
20
21
        if ($range) {
22
            return $range->start();
23
        }
24
    }
25
26
    protected function findOpenRangeInWorkingHours(Time $time, TimeRange $timeRange)
27
    {
28
        if ($timeRange->start()->isBefore($time)) {
0 ignored issues
show
Documentation introduced by
$time is of type object<Spatie\OpeningHours\Time>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
            return $timeRange;
30
        }
31
    }
32
33
    protected function findOpenInWorkingHours(Time $time, TimeRange $timeRange)
34
    {
35
        $range = $this->findOpenRangeInWorkingHours($time, $timeRange);
36
37
        if ($range) {
38
            return $range->start();
39
        }
40
    }
41
42
    protected function findCloseInWorkingHours(Time $time, TimeRange $timeRange)
43
    {
44
        if ($timeRange->containsTime($time)) {
45
            return $timeRange->end();
46
        }
47
    }
48
49
    protected function findCloseRangeInWorkingHours(Time $time, TimeRange $timeRange)
50
    {
51
        if ($timeRange->containsTime($time)) {
52
            return $timeRange;
53
        }
54
    }
55
56
    protected function findCloseInFreeTime(Time $time, TimeRange $timeRange)
57
    {
58
        $range = $this->findRangeInFreeTime($time, $timeRange);
59
60
        if ($range) {
61
            return $range->end();
62
        }
63
    }
64
65
    protected function findPreviousRangeInFreeTime(Time $time, TimeRange $timeRange)
66
    {
67
        if ($timeRange->end()->isBefore($time)) {
0 ignored issues
show
Documentation introduced by
$time is of type object<Spatie\OpeningHours\Time>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
68
            return $timeRange;
69
        }
70
    }
71
72
    protected function findPreviousOpenInFreeTime(Time $time, TimeRange $timeRange)
73
    {
74
        $range = $this->findPreviousRangeInFreeTime($time, $timeRange);
75
76
        if ($range) {
77
            return $range->start();
78
        }
79
    }
80
81
    protected function findPreviousCloseInWorkingHours(Time $time, TimeRange $timeRange)
82
    {
83
        $end = $timeRange->end();
84
85
        if ($end->isBefore($time)) {
0 ignored issues
show
Documentation introduced by
$time is of type object<Spatie\OpeningHours\Time>, but the function expects a object<self>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
86
            return $end;
87
        }
88
    }
89
}
90