AbstractUnit   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 73
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1
ccs 23
cts 23
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCode() 0 4 1
A getParent() 0 4 1
A setParent() 0 4 1
A addSibling() 0 13 4
A getSiblings() 0 4 1
1
<?php
2
3
namespace Maketok\DataMigration\Unit;
4
5
abstract class AbstractUnit implements UnitInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $code;
11
    /**
12
     * @var UnitInterface
13
     */
14
    protected $parent;
15
    /**
16
     * @var UnitInterface[]
17
     */
18
    protected $siblings = [];
19
20
    /**
21
     * @param string $code
22
     */
23 56
    public function __construct($code)
24
    {
25 56
        $this->code = $code;
26 56
    }
27
28
    /**
29
     * @return string
30
     */
31 56
    public function getCode()
32
    {
33 56
        return $this->code;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 44
    public function getParent()
40
    {
41 44
        return $this->parent;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 32
    public function setParent(UnitInterface $parent)
48
    {
49 32
        $this->parent = $parent;
50 32
    }
51
52
    /**
53
     * {@inheritdoc}
54
     * @var bool $addSiblingBack
55
     */
56 20
    public function addSibling(UnitInterface $sibling, $addBack = true, $addSiblingBack = true)
57
    {
58 20
        if ($addSiblingBack) {
59
            /** @var AbstractUnit $oldSib */
60 20
            foreach ($this->siblings as $oldSib) {
61 2
                $oldSib->addSibling($sibling, true, false);
0 ignored issues
show
Unused Code introduced by
The call to UnitInterface::addSibling() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
62 20
            }
63 20
        }
64 20
        $this->siblings[$sibling->getCode()] = $sibling;
65 20
        if ($addBack) {
66 20
            $sibling->addSibling($this, false, false);
0 ignored issues
show
Unused Code introduced by
The call to UnitInterface::addSibling() has too many arguments starting with false.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
67 20
        }
68 20
    }
69
70
    /**
71
     * @return UnitInterface[]
72
     */
73 45
    public function getSiblings()
74
    {
75 45
        return $this->siblings;
76
    }
77
}
78