Checkbox::click()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4286
cc 2
eloc 5
nc 2
nop 0
crap 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 Checkbox extends AbstractElement implements ClickableInterface, InputInterface
11
{
12
    /**
13
     * @param boolean $value
14
     */
15 2
    public function setValue($value)
16
    {
17 2
        $this->setAttribute('value', $value);
18 2
    }
19
20 1
    public function click()
21
    {
22 1
        if ($this->hasAttribute('checked')) {
23 1
            $this->removeAttribute('checked');
24 1
        } else {
25 1
            $this->setAttribute('checked', 'checked');
26
        }
27 1
    }
28
29
    /**
30
     * @return string
31
     */
32 4
    public function getValue()
33
    {
34 4
        return $this->getAttribute('value');
35
    }
36
}
37