Completed
Push — master ( cd70c7...30ef4b )
by Joseph
08:00
created

NodeCollection::text()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Jclyons52\PHPQuery\Support;
4
5
class NodeCollection extends \ArrayObject
6
{
7
    /**
8
     * Allows array methods to be called on object
9
     *
10
     * @param  $func
11
     * @param  $argv
12
     * @return mixed
13
     * @throws \BadMethodCallException
14
     */
15
    public function __call($func, $argv)
16
    {
17
        if (!is_callable($func) || substr($func, 0, 6) !== 'array_') {
18
            throw new \BadMethodCallException(__CLASS__.'->'.$func);
19
        }
20
        return call_user_func_array($func, array_merge(array($this->getArrayCopy()), $argv));
21
    }
22
23
    public function text()
24
    {
25
        $text = [];
26
        
27
        foreach ($this as $node) {
28
            $text[] =  $node->text();
29
        }
30
31
        return $text;
32
    }
33
34
    public function attr($name, $value = null)
35
    {
36
        $attr = [];
37
38
        foreach ($this as $node) {
39
            $attr[] =  $node->attr($name, $value);
40
        }
41
42
        return $attr;
43
    }
44
}
45