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

NestedEntity   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 20
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A equals() 0 12 4
A __toString() 0 4 1
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