Context   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 18
dl 0
loc 47
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getPre() 0 3 1
A setPost() 0 4 1
A setPre() 0 4 1
A unserialize() 0 3 1
A getPost() 0 3 1
A __construct() 0 5 1
A serialize() 0 7 1
1
<?php namespace Rollbar\Payload;
2
3
class Context implements \Serializable
4
{
5
    private $pre;
6
    private $post;
7
    private $utilities;
8
9
    public function __construct($pre, $post)
10
    {
11
        $this->utilities = new \Rollbar\Utilities();
12
        $this->setPre($pre);
13
        $this->setPost($post);
14
    }
15
16
    public function getPre()
17
    {
18
        return $this->pre;
19
    }
20
21
    public function setPre($pre)
22
    {
23
        $this->pre = $pre;
24
        return $this;
25
    }
26
27
    public function getPost()
28
    {
29
        return $this->post;
30
    }
31
32
    public function setPost($post)
33
    {
34
        $this->post = $post;
35
        return $this;
36
    }
37
38
    public function serialize()
39
    {
40
        $result = array(
41
            "pre" => $this->pre,
42
            "post" => $this->post,
43
        );
44
        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...
45
    }
46
    
47
    public function unserialize($serialized)
48
    {
49
        throw new \Exception('Not implemented yet.');
50
    }
51
}
52