Completed
Push — master ( c9bbeb...1f0ecb )
by Ivan
03:21
created

Checkbox   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 4 1
A click() 0 8 2
A getValue() 0 4 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
    public function setValue($value)
16
    {
17
        $this->setAttribute('value', $value);
18
    }
19
20
    public function click()
21
    {
22
        if ($this->hasAttribute('checked')) {
23
            $this->removeAttribute('checked');
24
        } else {
25
            $this->setAttribute('checked', 'checked');
26
        }
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getValue()
33
    {
34
        return $this->getAttribute('value');
35
    }
36
}
37