Checkbox::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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 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