Radio   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 2
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A uncheckOthers() 0 8 2
A click() 0 9 2
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 Radio extends Checkbox
11
{
12
    const CHECKED = "//input[@type='radio' and @name='%s' and @checked]";
13
14 1
    public function uncheckOthers()
15
    {
16 1
        $xpath = sprintf(Radio::CHECKED, $this->getName());
17
18 1
        foreach ($this->getReader()->query($xpath) as $radio) {
19 1
            $radio->removeAttribute('checked');
20 1
        }
21 1
    }
22
23 1
    public function click()
24
    {
25 1
        if ($this->hasAttribute('checked')) {
26 1
            $this->removeAttribute('checked');
27 1
        } else {
28 1
            $this->uncheckOthers();
29 1
            $this->setAttribute('checked', 'checked');
30
        }
31 1
    }
32
}
33