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

Checkbox::click()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 2
cts 2
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
        $this->setAttribute('value', $value);
18 2
    }
19
20 1
    public function click()
21
    {
22
        if ($this->hasAttribute('checked')) {
23
            $this->removeAttribute('checked');
24
        } else {
25
            $this->setAttribute('checked', 'checked');
26 1
        }
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getValue()
33
    {
34
        return $this->getAttribute('value');
35
    }
36
}
37