Completed
Push — master ( 6bb926...1e6b5f )
by Nils
02:11
created

CheckResult::setTool()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace whm\Smoke\Rules;
4
5
use phm\HttpWebdriverClient\Http\Response\UriAwareResponse;
6
use Psr\Http\Message\ResponseInterface;
7
8
class CheckResult
9
{
10
    const STATUS_SUCCESS = 'success';
11
    const STATUS_FAILURE = 'failure';
12
    const STATUS_SKIPPED = 'skipped';
13
    const STATUS_NONE = 'none';
14
15
    const HINT_KEY = '__hint';
16
17
    private $status;
18
    private $value;
19
    private $message;
20
    private $attributes = array();
21
    private $ruleName;
22
    private $url;
23
24
    private $tool;
25
26
    /**
27
     * @var UriAwareResponse
28
     */
29
    private $response;
30
31
    /**
32
     * Result constructor.
33
     *
34
     * @param $status
35
     * @param $value
36
     * @param $message
37
     */
38
    public function __construct($status, $message = '', $value = null, $url = null)
39
    {
40
        $this->status = $status;
41
        $this->value = $value;
42
        $this->message = $message;
43
        $this->url = $url;
44
    }
45
46
    /**
47
     * @return Attribute[]
48
     */
49
    public function getAttributes()
50
    {
51
        return $this->attributes;
52
    }
53
54
    /**
55
     * @param array $attributes
0 ignored issues
show
Documentation introduced by
There is no parameter named $attributes. Did you maybe mean $attribute?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
56
     */
57
    public function addAttribute(Attribute $attribute)
58
    {
59
        $this->attributes[] = $attribute;
60
    }
61
62
    public function setHint($message)
63
    {
64
        $this->addAttribute(new Attribute(self::HINT_KEY, $message, false));
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function getStatus()
71
    {
72
        return $this->status;
73
    }
74
75
    /**
76
     * @return mixed
77
     */
78
    public function getValue()
79
    {
80
        return $this->value;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getTool()
87
    {
88
        return $this->tool;
89
    }
90
91
    /**
92
     * @param string $tool
93
     */
94
    public function setTool($tool)
95
    {
96
        $this->tool = $tool;
97
    }
98
99
    /**
100
     * @return string
101
     */
102
    public function getMessage()
103
    {
104
        return $this->message;
105
    }
106
107
    /**
108
     * @param string $message
109
     */
110
    public function setMessage($message)
111
    {
112
        $this->message = $message;
113
    }
114
115
    /**
116
     * @return UriAwareResponse
117
     */
118
    public function getResponse()
119
    {
120
        return $this->response;
121
    }
122
123
    /**
124
     * @param ResponseInterface $response
125
     */
126
    public function setResponse(ResponseInterface $response)
127
    {
128
        $this->response = $response;
0 ignored issues
show
Documentation Bug introduced by
$response is of type object<Psr\Http\Message\ResponseInterface>, but the property $response was declared to be of type object<phm\HttpWebdriver...ponse\UriAwareResponse>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
129
    }
130
131
    /**
132
     * @return mixed
133
     */
134
    public function getRuleName()
135
    {
136
        return $this->ruleName;
137
    }
138
139
    /**
140
     * @param mixed $ruleName
141
     */
142
    public function setRuleName($ruleName)
143
    {
144
        $this->ruleName = $ruleName;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getUrl()
151
    {
152
        return $this->url;
153
    }
154
}
155