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

Payload::unserialize()   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 1
1
<?php namespace Rollbar\Payload;
2
3
use Rollbar\DataBuilder;
4
use Rollbar\Config;
5
6
class Payload implements \Serializable
7
{
8
    private $data;
9
    private $accessToken;
10
    private $utilities;
11
12
    public function __construct(Data $data, $accessToken)
13
    {
14
        $this->utilities = new \Rollbar\Utilities();
15
        $this->setData($data);
16
        $this->setAccessToken($accessToken);
17
    }
18
19
    /**
20
     * @return Data
21
     */
22
    public function getData()
23
    {
24
        return $this->data;
25
    }
26
27
    public function setData(Data $data)
28
    {
29
        $this->data = $data;
30
        return $this;
31
    }
32
33
    public function getAccessToken()
34
    {
35
        return $this->accessToken;
36
    }
37
38
    public function setAccessToken($accessToken)
39
    {
40
        $this->accessToken = $accessToken;
41
        return $this;
42
    }
43
44
    public function serialize()
45
    {
46
        $result = array(
47
            "data" => $this->data,
48
            "access_token" => $this->accessToken,
49
        );
50
        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...
51
    }
52
    
53
    public function unserialize($serialized)
54
    {
55
        throw new \Exception('Not implemented yet.');
56
    }
57
}
58