1 | <?php |
||
15 | class SimpleHtmlDomNode extends \ArrayObject implements SimpleHtmlDomNodeInterface |
||
16 | { |
||
17 | /** @noinspection MagicMethodsValidityInspection */ |
||
18 | /** |
||
19 | * @param string $name |
||
20 | * |
||
21 | * @return array|null |
||
22 | */ |
||
23 | 3 | public function __get($name) |
|
24 | { |
||
25 | 3 | $name = strtolower($name); |
|
26 | |||
27 | 3 | if ($this->count() > 0) { |
|
28 | 3 | $return = array(); |
|
29 | |||
30 | 3 | foreach ($this as $node) { |
|
31 | 3 | if ($node instanceof SimpleHtmlDom) { |
|
32 | 3 | $return[] = $node->{$name}; |
|
33 | } |
||
34 | } |
||
35 | |||
36 | 3 | return $return; |
|
37 | } |
||
38 | |||
39 | return null; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x) |
||
44 | */ |
||
45 | public function outertext() |
||
46 | { |
||
47 | $this->innerHtml(); |
||
|
|||
48 | } |
||
49 | |||
50 | /** |
||
51 | * alias for "$this->innerHtml()" (added for compatibly-reasons with v1.x) |
||
52 | */ |
||
53 | public function innertext() |
||
54 | { |
||
55 | $this->innerHtml(); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param string $selector |
||
60 | * @param int $idx |
||
61 | * |
||
62 | * @return SimpleHtmlDomNode[]|SimpleHtmlDomNode|null |
||
63 | */ |
||
64 | public function __invoke($selector, $idx = null) |
||
65 | { |
||
66 | return $this->find($selector, $idx); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @return string |
||
71 | */ |
||
72 | 1 | public function __toString() |
|
81 | |||
82 | /** |
||
83 | * Find one node with a CSS selector. |
||
84 | * |
||
85 | * @param string $selector |
||
86 | * |
||
87 | * @return SimpleHtmlDomNode|null |
||
88 | */ |
||
89 | public function findOne(string $selector) |
||
93 | |||
94 | /** |
||
95 | * Find list of nodes with a CSS selector. |
||
96 | * |
||
97 | * @param string $selector |
||
98 | * @param int $idx |
||
99 | * |
||
100 | * @return SimpleHtmlDomNode[]|SimpleHtmlDomNode|null |
||
101 | */ |
||
102 | 11 | public function find(string $selector, $idx = null) |
|
128 | |||
129 | /** |
||
130 | * Get html of elements. |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | 1 | public function innerHtml(): array |
|
143 | |||
144 | /** |
||
145 | * Get plain text. |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | 1 | public function text(): array |
|
158 | } |
||
159 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: