ExceptionInfo::setClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php namespace Rollbar\Payload;
2
3
class ExceptionInfo implements \Serializable
4
{
5
    private $class;
6
    private $message;
7
    private $description;
8
    private $utilities;
9
10
    public function __construct($class, $message, $description = null)
11
    {
12
        $this->utilities = new \Rollbar\Utilities();
13
        $this->setClass($class);
14
        $this->setMessage($message);
15
        $this->setDescription($description);
16
    }
17
18
    public function getClass()
19
    {
20
        return $this->class;
21
    }
22
23
    public function setClass($class)
24
    {
25
        $this->class = $class;
26
        return $this;
27
    }
28
29
    public function getMessage()
30
    {
31
        return $this->message;
32
    }
33
34
    public function setMessage($message)
35
    {
36
        $this->message = $message;
37
        return $this;
38
    }
39
40
    public function getDescription()
41
    {
42
        return $this->description;
43
    }
44
45
    public function setDescription($description)
46
    {
47
        $this->description = $description;
48
        return $this;
49
    }
50
51
    public function serialize()
52
    {
53
        $result = array(
54
            "class" => $this->class,
55
            "message" => $this->message,
56
            "description" => $this->description,
57
        );
58
        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...
59
    }
60
    
61
    public function unserialize($serialized)
62
    {
63
        throw new \Exception('Not implemented yet.');
64
    }
65
}
66