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

Trace::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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