Completed
Push — master ( 4ce137...cce6a6 )
by Ivan
03:36 queued 01:24
created

Option   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 5
c 4
b 0
f 2
lcom 1
cbo 2
dl 0
loc 38
ccs 6
cts 8
cp 0.75
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 4 1
A setValue() 0 4 1
A getSelect() 0 4 1
A unselectOthers() 0 5 1
A select() 0 5 1
1
<?php
2
3
namespace SP\Crawler\Element;
4
5
/**
6
 * @author    Ivan Kerin <[email protected]>
7
 * @copyright 2015, Clippings Ltd.
8
 * @license   http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class Option extends AbstractElement implements InputInterface, SelectableInterface
11
{
12
    /**
13
     * @return string
14
     */
15
    public function getValue()
16
    {
17
        return $this->getAttribute('value');
18
    }
19
20 2
    public function setValue($value)
21
    {
22
        $this->setAttribute('value', $value);
23 2
    }
24
25
    /**
26
     * @return DOMElement
27
     */
28
    public function getSelect()
29
    {
30
        return $this->getChildren('./ancestor::select')->item(0);
31
    }
32
33 1
    public function unselectOthers()
34
    {
35
        $select = $this->getReader()->getInput($this->getSelect());
0 ignored issues
show
Compatibility introduced by
$this->getSelect() of type object<DOMNode> is not a sub-type of object<DOMElement>. It seems like you assume a child class of the class DOMNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
36
        $select->unselectAll();
37 1
    }
38
39
    /**
40
     * @param boolean $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

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

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

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

Loading history...
41
     */
42 1
    public function select()
43
    {
44
        $this->unselectOthers();
45
        $this->setAttribute('selected', 'seleced');
46 1
    }
47
}
48