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 — timezone-service ( 50c73a )
by Eric
02:23
created

TimeZoneRequest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 10
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 100
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLocation() 0 4 1
A setLocation() 0 4 1
A getDate() 0 4 1
A setDate() 0 4 1
A hasLanguage() 0 4 1
A getLanguage() 0 4 1
A setLanguage() 0 4 1
A buildQuery() 0 13 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Service\TimeZone;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class TimeZoneRequest
20
{
21
    /**
22
     * @var Coordinate
23
     */
24
    private $location;
25
26
    /**
27
     * @var \DateTime
28
     */
29
    private $date;
30
31
    /**
32
     * @var string|null
33
     */
34
    private $language;
35
36
    /**
37
     * @param Coordinate     $location
38
     * @param \DateTime|null $date
39
     */
40
    public function __construct(Coordinate $location, \DateTime $date = null)
41
    {
42
        $this->setLocation($location);
43
        $this->setDate($date);
0 ignored issues
show
Bug introduced by
It seems like $date defined by parameter $date on line 40 can be null; however, Ivory\GoogleMap\Service\...eZoneRequest::setDate() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
44
    }
45
46
    /**
47
     * @return Coordinate
48
     */
49
    public function getLocation()
50
    {
51
        return $this->location;
52
    }
53
54
    /**
55
     * @param Coordinate $location
56
     */
57
    public function setLocation(Coordinate $location)
58
    {
59
        $this->location = $location;
60
    }
61
62
    /**
63
     * @return \DateTime
64
     */
65
    public function getDate()
66
    {
67
        return $this->date;
68
    }
69
70
    /**
71
     * @param \DateTime $date
72
     */
73
    public function setDate(\DateTime $date)
74
    {
75
        $this->date = $date;
76
    }
77
78
    /**
79
     * @return bool
80
     */
81
    public function hasLanguage()
82
    {
83
        return $this->language !== null;
84
    }
85
86
    /**
87
     * @return string|null
88
     */
89
    public function getLanguage()
90
    {
91
        return $this->language;
92
    }
93
94
    /**
95
     * @param string|null $language
96
     */
97
    public function setLanguage( $language )
98
    {
99
        $this->language = $language;
100
    }
101
102
    /**
103
     * @return mixed[]
104
     */
105
    public function buildQuery()
106
    {
107
        $query = [
108
            'location'  => $this->location->getLatitude().','.$this->location->getLongitude(),
109
            'timestamp' => $this->date->getTimestamp(),
110
        ];
111
112
        if ($this->hasLanguage()) {
113
            $query['language'] = $this->language;
114
        }
115
116
        return $query;
117
    }
118
}
119