Completed
Push — master ( 23cb55...debaf4 )
by Nils
02:02
created

CheckResult   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 167
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 17
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 167
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getAttributes() 0 4 1
A addAttribute() 0 4 1
A setHint() 0 4 1
A getStatus() 0 4 1
A getValue() 0 4 1
A getTool() 0 4 1
A setTool() 0 4 1
A getIdentifierRule() 0 4 1
A setIdentifierRule() 0 4 1
A getMessage() 0 4 1
A setMessage() 0 4 1
A getResponse() 0 4 1
A setResponse() 0 4 1
A getRuleName() 0 4 1
A setRuleName() 0 4 1
A getUrl() 0 4 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
    const IDENTIFIER_RULE_STANDARD = 'standard';
18
    const IDENTIFIER_RULE_WITHOUT_SMOKE_PREFIX = 'withoutSmokePrefix';
19
20
    private $status;
21
    private $value;
22
    private $message;
23
    private $attributes = array();
24
    private $ruleName;
25
    private $url;
26
27
    private $tool;
28
    private $identifierRule = self::IDENTIFIER_RULE_STANDARD;
29
30
    /**
31
     * @var UriAwareResponse
32
     */
33
    private $response;
34
35
    /**
36
     * Result constructor.
37
     *
38
     * @param $status
39
     * @param $value
40
     * @param $message
41
     */
42
    public function __construct($status, $message = '', $value = null, $url = null)
43
    {
44
        $this->status = $status;
45
        $this->value = $value;
46
        $this->message = $message;
47
        $this->url = $url;
48
    }
49
50
    /**
51
     * @return Attribute[]
52
     */
53
    public function getAttributes()
54
    {
55
        return $this->attributes;
56
    }
57
58
    /**
59
     * @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...
60
     */
61
    public function addAttribute(Attribute $attribute)
62
    {
63
        $this->attributes[] = $attribute;
64
    }
65
66
    public function setHint($message)
67
    {
68
        $this->addAttribute(new Attribute(self::HINT_KEY, $message, false));
69
    }
70
71
    /**
72
     * @return mixed
73
     */
74
    public function getStatus()
75
    {
76
        return $this->status;
77
    }
78
79
    /**
80
     * @return mixed
81
     */
82
    public function getValue()
83
    {
84
        return $this->value;
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getTool()
91
    {
92
        return $this->tool;
93
    }
94
95
    /**
96
     * @param string $tool
97
     */
98
    public function setTool($tool)
99
    {
100
        $this->tool = $tool;
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getIdentifierRule()
107
    {
108
        return $this->identifierRule;
109
    }
110
111
    /**
112
     * @param string $identifier
0 ignored issues
show
Documentation introduced by
There is no parameter named $identifier. Did you maybe mean $identifierRule?

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...
113
     */
114
    public function setIdentifierRule($identifierRule)
115
    {
116
        $this->identifierRule = $identifierRule;
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getMessage()
123
    {
124
        return $this->message;
125
    }
126
127
    /**
128
     * @param string $message
129
     */
130
    public function setMessage($message)
131
    {
132
        $this->message = $message;
133
    }
134
135
    /**
136
     * @return UriAwareResponse
137
     */
138
    public function getResponse()
139
    {
140
        return $this->response;
141
    }
142
143
    /**
144
     * @param ResponseInterface $response
145
     */
146
    public function setResponse(ResponseInterface $response)
147
    {
148
        $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...
149
    }
150
151
    /**
152
     * @return mixed
153
     */
154
    public function getRuleName()
155
    {
156
        return $this->ruleName;
157
    }
158
159
    /**
160
     * @param mixed $ruleName
161
     */
162
    public function setRuleName($ruleName)
163
    {
164
        $this->ruleName = $ruleName;
165
    }
166
167
    /**
168
     * @return string
169
     */
170
    public function getUrl()
171
    {
172
        return $this->url;
173
    }
174
}
175