Entity::id()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Domain\Model;
13
14
/**
15
 * Abstract Entity Class.
16
 *
17
 * @author Karel Osorio Ramírez <[email protected]>
18
 */
19
abstract class Entity implements EntityInterface
20
{
21
    /**
22
     * @var IdInterface
23
     */
24
    protected $id;
25
26
    /**
27
     * @param IdInterface $id
28
     */
29
    public function __construct(IdInterface $id)
30
    {
31
        $this->id = $id;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function id()
38
    {
39
        return $this->id;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function equals($other)
46
    {
47
        return $other instanceof static && $this->id()->equals($other->id());
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function hashCode()
54
    {
55
        return $this->id()->hashCode();
56
    }
57
}
58