Passed
Pull Request — master (#269)
by Christopher
03:16
created

ODataContainerBase::getBaseURI()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace POData\ObjectModel;
5
6
7
abstract class ODataContainerBase
8
{
9
    /**
10
     * Entry id.
11
     *
12
     * @var string|null
13
     */
14
    public $id;
15
    /**
16
     * Feed title.
17
     *
18
     * @var ODataTitle
19
     */
20
    public $title;
21
22
    /**
23
     * Entry Self Link.
24
     *
25
     * @var ODataLink|null
26
     */
27
    public $selfLink;
28
29
    /**
30
     * Last updated timestamp.
31
     *
32
     * @var string|null
33
     */
34
    public $updated;
35
36
    /**
37
     * Service Base URI.
38
     *
39
     * @var string|null
40
     */
41
    public $baseURI;
42
43
    /**
44
     * ODataContainerBase constructor.
45
     * @param string|null $id
46
     * @param ODataTitle $title
47
     * @param string|null $updated
48
     * @param string|null $baseURI
49
     */
50
    public function __construct(?string $id, ?ODataTitle $title, ?string $selfLink, ?string $updated, ?string $baseURI)
51
    {
52
        $this
53
            ->setId($id)
54
            ->setTitle($title)
55
            ->setSelfLink($selfLink)
56
            ->setUpdated($updated)
57
            ->setBaseURI($baseURI);
58
    }
59
60
61
    /**
62
     * @return string|null
63
     */
64
    public function getId(): ?string
65
    {
66
        return $this->id;
67
    }
68
69
    /**
70
     * @param string|null $id
71
     * @return self
72
     */
73
    public function setId(?string $id): self
74
    {
75
        $this->id = $id;
76
        return $this;
77
    }
78
79
    /**
80
     * @return ODataTitle|null
81
     */
82
    public function getTitle(): ?ODataTitle
83
    {
84
        return $this->title;
85
    }
86
87
    /**
88
     * @param ODataTitle|null $title
89
     * @return self
90
     */
91
    public function setTitle(?ODataTitle $title): self
92
    {
93
        $this->title = $title;
94
        return $this;
95
    }
96
97
    /**
98
     * @return ODataLink|null
99
     */
100
    public function getSelfLink(): ?string
101
    {
102
        return $this->selfLink;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->selfLink could return the type POData\ObjectModel\ODataLink which is incompatible with the type-hinted return null|string. Consider adding an additional type-check to rule them out.
Loading history...
103
    }
104
105
    /**
106
     * @param string|null $selfLink
107
     * @return ODataEntry
108
     */
109
    public function setSelfLink(?string $selfLink): self
110
    {
111
        $this->selfLink = $selfLink;
0 ignored issues
show
Documentation Bug introduced by
It seems like $selfLink can also be of type string. However, the property $selfLink is declared as type POData\ObjectModel\ODataLink|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
112
        return $this;
113
    }
114
    /**
115
     * @return string|null
116
     */
117
    public function getUpdated(): ?string
118
    {
119
        return $this->updated;
120
    }
121
122
    /**
123
     * @param string|null $updated
124
     * @return ODataEntry
125
     */
126
    public function setUpdated(?string $updated): self
127
    {
128
        $this->updated = $updated;
129
        return $this;
130
    }
131
132
    /**
133
     * @return string|null
134
     */
135
    public function getBaseURI(): ?string
136
    {
137
        return $this->baseURI;
138
    }
139
140
    /**
141
     * @param string|null $baseURI
142
     * @return self
143
     */
144
    public function setBaseURI(?string $baseURI): self
145
    {
146
        $this->baseURI = $baseURI;
147
        return $this;
148
    }
149
}