ValueObjectTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 24
ccs 5
cts 6
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __clone() 0 4 1
A equals() 0 9 2
1
<?php
2
3
namespace Wambo\Core\ValueObject;
4
5
use Wambo\Core\Immutable\ImmutableTrait;
6
use Wambo\Core\ValueObject\Exception\ValueObjectException;
7
8
/**
9
 * Class ValueObjectTrait
10
 *
11
 * @package Wambo\Core\ValueObject
12
 */
13
trait ValueObjectTrait
14
{
15
    use ImmutableTrait;
16
    /**
17
     * Disable clone function to prevent clone Value Objects
18
     */
19 1
    final public function __clone()
20
    {
21 1
        throw new ValueObjectException('ValueObjects are not cloneable');
22
    }
23
    /**
24
     * @param ValueObjectInterface $obj
25
     * @return bool
26
     */
27 3
    public function equals(ValueObjectInterface $obj)
28
    {
29 3
        if (get_called_class() !== get_class($obj)) {
30
            return false;
31
        }
32
33
        /** @var ValueObjectInterface $this */
34 3
        return $this->getValue() === $obj->getValue();
35
    }
36
}