NodeCollection   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 7
c 2
b 0
f 2
lcom 0
cbo 0
dl 0
loc 48
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 7 3
A text() 0 10 2
A attr() 0 10 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