Completed
Push — master ( 97a51f...f68f57 )
by Ivan
01:58
created

Node   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A queryIds() 0 4 1
A getCrawler() 0 4 1
A with() 0 4 1
A getId() 0 4 1
A getAttribute() 0 4 1
A getTagName() 0 4 1
A getText() 0 4 1
A getHtml() 0 4 1
A getValue() 0 4 1
A setValue() 0 6 1
A isVisible() 0 4 1
A isSelected() 0 4 1
A isChecked() 0 4 1
A select() 0 6 1
A click() 0 6 1
1
<?php
2
3
namespace SP\Spiderling;
4
5
use Countable;
6
7
/**
8
 * @author    Ivan Kerin <[email protected]>
9
 * @copyright 2015, Clippings Ltd.
10
 * @license   http://spdx.org/licenses/BSD-3-Clause
11
 */
12
class Node
13
{
14
    use TraverseTrait;
15
16
    /**
17
     * @var string
18
     */
19
    private $id;
20
21
    /**
22
     * @var CrawlerInterface
23
     */
24
    private $crawler;
25
26
    /**
27
     * @param CrawlerInterface $crawler
28
     * @param string  $id
29
     */
30 1
    public function __construct(CrawlerInterface $crawler, $id) {
31 1
        $this->crawler = $crawler;
32 1
        $this->id = $id;
33 1
    }
34
35
    /**
36
     * @param  Query\AbstractQuery $query
37
     * @return array
38
     */
39 1
    public function queryIds(Query\AbstractQuery $query)
40
    {
41 1
        return $this->crawler->queryIds($query, $this->id);
42
    }
43
44
    /**
45
     * @return CrawlerInterface
46
     */
47 2
    public function getCrawler()
48
    {
49 2
        return $this->crawler;
50
    }
51
52
    /**
53
     * @param  callable $callback
54
     */
55 1
    public function with(callable $callback)
56
    {
57 1
        $callback($this);
58 1
    }
59
60
    /**
61
     * @return string
62
     */
63 2
    public function getId()
64
    {
65 2
        return $this->id;
66
    }
67
68
    // Accessors
69
70
    /**
71
     * @param  string $name
72
     * @return string
73
     */
74 1
    public function getAttribute($name)
75
    {
76 1
        return $this->crawler->getAttribute($this->id, $name);
77
    }
78
79
    /**
80
     * @return string
81
     */
82 1
    public function getTagName()
83
    {
84 1
        return $this->crawler->getTagName($this->id);
85
    }
86
87
    /**
88
     * @return string
89
     */
90 1
    public function getText()
91
    {
92 1
        return $this->crawler->getText($this->id);
93
    }
94
95
    /**
96
     * @return string
97
     */
98 1
    public function getHtml()
99
    {
100 1
        return $this->crawler->getHtml($this->id);
101
    }
102
103
    /**
104
     * @return string
105
     */
106 1
    public function getValue()
107
    {
108 1
        return $this->crawler->getValue($this->id);
109
    }
110
111
    /**
112
     * @param  mixed $value
113
     * @return self
114
     */
115 1
    public function setValue($value)
116
    {
117 1
        $this->crawler->setValue($this->id, $value);
118
119 1
        return $this;
120
    }
121
122
    /**
123
     * @return boolean
124
     */
125 1
    public function isVisible()
126
    {
127 1
        return $this->crawler->isVisible($this->id);
128
    }
129
130
    /**
131
     * @return boolean
132
     */
133 1
    public function isSelected()
134
    {
135 1
        return $this->crawler->isSelected($this->id);
136
    }
137
138
    /**
139
     * @return boolean
140
     */
141 1
    public function isChecked()
142
    {
143 1
        return $this->crawler->isChecked($this->id);
144
    }
145
146
    /**
147
     * @return self
148
     */
149 1
    public function select()
150
    {
151 1
        $this->crawler->select($this->id);
152
153 1
        return $this;
154
    }
155
156
    /**
157
     * @return self
158
     */
159 1
    public function click()
160
    {
161 1
        $this->crawler->click($this->id);
162
163 1
        return $this;
164
    }
165
}
166