VisitableArray::acceptVisitor()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 4 Features 0
Metric Value
c 5
b 4
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace PEIP\Base;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
/**
14
 * VisitableArray.
15
 *
16
 * @author Timo Michna <timomichna/yahoo.de>
17
 * @extends RecursiveArrayIterator
18
 * @implements RecursiveIterator, Iterator, Traversable, ArrayAccess, SeekableIterator, Serializable, \PEIP\INF\Base\Visitable
19
 */
20
class VisitableArray extends \RecursiveArrayIterator implements \PEIP\INF\Base\Visitable
21
{
22
    /**
23
     * @param $visitor
24
     *
25
     * @return
26
     */
27
    public function acceptVisitor(\PEIP\INF\Base\Visitor $visitor)
28
    {
29
        if ($this->hasChildren()) {
30
            foreach ($this->getChildren as $child) {
0 ignored issues
show
Bug introduced by
The property getChildren does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
                $child->acceptVisitor($visitor);
32
            }
33
        }
34
        $this->acceptVisitor($visitor);
35
    }
36
}
37