Completed
Push — master ( 20e704...9d61ac )
by Ivan
04:03
created

Node::setFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 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
     * @param  string $file
124
     * @return self
125
     */
126 1
    public function setFile($file)
127
    {
128 1
        $this->crawler->setFile($this->id, $file);
129
130 1
        return $this;
131
    }
132
133
    /**
134
     * @return boolean
135
     */
136 1
    public function isVisible()
137
    {
138 1
        return $this->crawler->isVisible($this->id);
139
    }
140
141
    /**
142
     * @return boolean
143
     */
144 1
    public function isSelected()
145
    {
146 1
        return $this->crawler->isSelected($this->id);
147
    }
148
149
    /**
150
     * @return boolean
151
     */
152 1
    public function isChecked()
153
    {
154 1
        return $this->crawler->isChecked($this->id);
155
    }
156
157
    /**
158
     * @return self
159
     */
160 1
    public function select()
161
    {
162 1
        $this->crawler->select($this->id);
163
164 1
        return $this;
165
    }
166
167
    /**
168
     * @return self
169
     */
170 1
    public function click()
171
    {
172 1
        $this->crawler->click($this->id);
173
174 1
        return $this;
175
    }
176
}
177