NodeCollection::text()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
crap 2
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 6
    public function __call($func, $argv)
16
    {
17 6
        if (!is_callable($func) || substr($func, 0, 6) !== 'array_') {
18 3
            throw new \BadMethodCallException(__CLASS__.'->'.$func);
19
        }
20 3
        return call_user_func_array($func, array_merge(array($this->getArrayCopy()), $argv));
21
    }
22
23
    /**
24
     * @return array
25
     */
26 3
    public function text()
27
    {
28 3
        $text = [];
29
        
30 3
        foreach ($this as $node) {
31 3
            $text[] =  $node->text();
32 3
        }
33
34 3
        return $text;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @param string|null $value
40
     * @return array
41
     */
42 3
    public function attr($name, $value = null)
43
    {
44 3
        $attr = [];
45
46 3
        foreach ($this as $node) {
47 3
            $attr[] =  $node->attr($name, $value);
48 3
        }
49
50 3
        return $attr;
51
    }
52
}
53