Completed
Push — master ( 83b55d...472d84 )
by Justin
03:47 queued 36s
created

Data::getPerson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php namespace Rollbar\Payload;
2
3
use Rollbar\Defaults;
4
5
class Data implements \Serializable
6
{
7
    private $environment;
8
    private $body;
9
    private $level;
10
    private $timestamp;
11
    private $codeVersion;
12
    private $platform;
13
    private $language;
14
    private $framework;
15
    private $context;
16
    private $request;
17
    private $person;
18
    private $server;
19
    private $custom;
20
    private $fingerprint;
21
    private $title;
22
    private $uuid;
23
    private $notifier;
24
    private $utilities;
25
26
    public function __construct($environment, Body $body)
27
    {
28
        $this->utilities = new \Rollbar\Utilities();
29
        $this->setEnvironment($environment);
30
        $this->setBody($body);
31
    }
32
33
    public function getEnvironment()
34
    {
35
        return $this->environment;
36
    }
37
38
    public function setEnvironment($environment)
39
    {
40
        $this->environment = $environment;
41
        return $this;
42
    }
43
44
    public function getBody()
45
    {
46
        return $this->body;
47
    }
48
49
    public function setBody(Body $body)
50
    {
51
        $this->body = $body;
52
        return $this;
53
    }
54
55
    /**
56
     * @return Level
57
     */
58
    public function getLevel()
59
    {
60
        return $this->level;
61
    }
62
63
    public function setLevel($level)
64
    {
65
        $this->level = $level;
66
        return $this;
67
    }
68
69
    public function getTimestamp()
70
    {
71
        return $this->timestamp;
72
    }
73
74
    public function setTimestamp($timestamp)
75
    {
76
        $this->timestamp = $timestamp;
77
        return $this;
78
    }
79
80
    public function getCodeVersion()
81
    {
82
        return $this->codeVersion;
83
    }
84
85
    public function setCodeVersion($codeVersion)
86
    {
87
        $this->codeVersion = $codeVersion;
88
        return $this;
89
    }
90
91
    public function getPlatform()
92
    {
93
        return $this->platform;
94
    }
95
96
    public function setPlatform($platform)
97
    {
98
        $this->platform = $platform;
99
        return $this;
100
    }
101
102
    public function getLanguage()
103
    {
104
        return $this->language;
105
    }
106
107
    public function setLanguage($language)
108
    {
109
        $this->language = $language;
110
        return $this;
111
    }
112
113
    public function getFramework()
114
    {
115
        return $this->framework;
116
    }
117
118
    public function setFramework($framework)
119
    {
120
        $this->framework = $framework;
121
        return $this;
122
    }
123
124
    public function getContext()
125
    {
126
        return $this->context;
127
    }
128
129
    public function setContext($context)
130
    {
131
        $this->context = $context;
132
        return $this;
133
    }
134
135
    /**
136
     * @return Request
137
     */
138
    public function getRequest()
139
    {
140
        return $this->request;
141
    }
142
143
    public function setRequest(Request $request = null)
144
    {
145
        $this->request = $request;
146
        return $this;
147
    }
148
149
    /**
150
     * @return Person
151
     */
152
    public function getPerson()
153
    {
154
        return $this->person;
155
    }
156
157
    public function setPerson(Person $person = null)
158
    {
159
        $this->person = $person;
160
        return $this;
161
    }
162
163
    /**
164
     * @return Server
165
     */
166
    public function getServer()
167
    {
168
        return $this->server;
169
    }
170
171
    public function setServer(Server $server = null)
172
    {
173
        $this->server = $server;
174
        return $this;
175
    }
176
177
    public function getCustom()
178
    {
179
        return $this->custom;
180
    }
181
182
    public function setCustom(array $custom = null)
183
    {
184
        $this->custom = $custom;
185
        return $this;
186
    }
187
188
    public function getFingerprint()
189
    {
190
        return $this->fingerprint;
191
    }
192
193
    public function setFingerprint($fingerprint)
194
    {
195
        $this->fingerprint = $fingerprint;
196
        return $this;
197
    }
198
199
    public function getTitle()
200
    {
201
        return $this->title;
202
    }
203
204
    public function setTitle($title)
205
    {
206
        $this->title = $title;
207
        return $this;
208
    }
209
210
    public function getUuid()
211
    {
212
        return $this->uuid;
213
    }
214
215
    public function setUuid($uuid)
216
    {
217
        $this->uuid = $uuid;
218
        return $this;
219
    }
220
221
    public function getNotifier()
222
    {
223
        return $this->notifier;
224
    }
225
226
    public function setNotifier(Notifier $notifier)
227
    {
228
        $this->notifier = $notifier;
229
        return $this;
230
    }
231
232
    public function serialize()
233
    {
234
        $result = array(
235
            "environment" => $this->environment,
236
            "body" => $this->body,
237
            "level" => $this->level,
238
            "timestamp" => $this->timestamp,
239
            "code_version" => $this->codeVersion,
240
            "platform" => $this->platform,
241
            "language" => $this->language,
242
            "framework" => $this->framework,
243
            "context" => $this->context,
244
            "request" => $this->request,
245
            "person" => $this->person,
246
            "server" => $this->server,
247
            "custom" => $this->custom,
248
            "fingerprint" => $this->fingerprint,
249
            "title" => $this->title,
250
            "uuid" => $this->uuid,
251
            "notifier" => $this->notifier,
252
        );
253
        return $this->utilities->serializeForRollbar($result);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->utilities-...lizeForRollbar($result) returns the type array which is incompatible with the return type mandated by Serializable::serialize() of string.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
254
    }
255
    
256
    public function unserialize($serialized)
257
    {
258
        throw new \Exception('Not implemented yet.');
259
    }
260
}
261