Node   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 165
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 5
Bugs 0 Features 3
Metric Value
wmc 17
c 5
b 0
f 3
lcom 1
cbo 2
dl 0
loc 165
ccs 14
cts 18
cp 0.7778
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A queryIds() 0 4 1
A getCrawler() 0 4 1
A getId() 0 4 1
A __construct() 0 4 1
A with() 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 setFile() 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
    public function __construct(CrawlerInterface $crawler, $id) {
31
        $this->crawler = $crawler;
32
        $this->id = $id;
33
    }
34
35
    /**
36
     * @param  Query\AbstractQuery $query
37
     * @return array
38
     */
39 1
    public function queryIds(Query\AbstractQuery $query)
40
    {
41
        return $this->crawler->queryIds($query, $this->id);
42 1
    }
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
    public function with(callable $callback)
56
    {
57
        $callback($this);
58
    }
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
    public function getAttribute($name)
75
    {
76
        return $this->crawler->getAttribute($this->id, $name);
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getTagName()
83
    {
84
        return $this->crawler->getTagName($this->id);
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getText()
91
    {
92
        return $this->crawler->getText($this->id);
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getHtml()
99
    {
100
        return $this->crawler->getHtml($this->id);
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getValue()
107
    {
108
        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
        $this->crawler->setValue($this->id, $value);
118
119 1
        return $this;
120
    }
121
122
    /**
123
     * @param  string $file
124
     * @return self
125
     */
126 1
    public function setFile($file)
127
    {
128
        $this->crawler->setFile($this->id, $file);
129
130 1
        return $this;
131
    }
132
133
    /**
134
     * @return boolean
135
     */
136
    public function isVisible()
137
    {
138
        return $this->crawler->isVisible($this->id);
139
    }
140
141
    /**
142
     * @return boolean
143
     */
144
    public function isSelected()
145
    {
146
        return $this->crawler->isSelected($this->id);
147
    }
148
149
    /**
150
     * @return boolean
151
     */
152
    public function isChecked()
153
    {
154
        return $this->crawler->isChecked($this->id);
155
    }
156
157
    /**
158
     * @return self
159
     */
160 1
    public function select()
161
    {
162
        $this->crawler->select($this->id);
163
164 1
        return $this;
165
    }
166
167
    /**
168
     * @return self
169
     */
170 1
    public function click()
171
    {
172
        $this->crawler->click($this->id);
173
174 1
        return $this;
175
    }
176
}
177