Passed
Push — master ( 819f30...8ceff2 )
by Thorsten
02:22
created

NestedEntity::equals()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 7
cp 0.8571
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 4
nop 1
crap 4.0466
1
<?php
2
3
namespace Daikon\Entity\Entity;
4
5
use Daikon\Entity\ValueObject\ValueObjectInterface;
6
7
abstract class NestedEntity extends Entity implements ValueObjectInterface
8
{
9 2
    public function equals(ValueObjectInterface $otherValue): bool
10
    {
11 2
        if (!$otherValue instanceof self) {
12
            return false;
13
        }
14 2
        foreach ($this->getValueObjectMap() as $attrName => $value) {
15 2
            if (!$value->equals($otherValue->get($attrName))) {
16 2
                return false;
17
            }
18
        }
19 2
        return true;
20
    }
21
22 2
    public function __toString(): string
23
    {
24 2
        return sprintf("%s:%s", $this->getEntityType()->getName(), $this->getIdentity());
25
    }
26
}
27