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

NestedEntity::fromNative()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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