ValueObject::equals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Tleckie\ValueObject;
4
5
/**
6
 * Class ValueObject
7
 *
8
 * @package Tleckie\ValueObject
9
 * @author  Teodoro Leckie Westberg <[email protected]>
10
 */
11
class ValueObject implements ValueObjectInterface
12
{
13
    /** @var mixed  */
14
    protected mixed $value;
15
16
    /**
17
     * ValueObject constructor.
18
     *
19
     * @param mixed $value
20
     */
21
    public function __construct(mixed $value)
22
    {
23
        $this->value = $value;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function value(): mixed
30
    {
31
        return $this->value;
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    final public function equals(ValueObjectInterface $value): bool
38
    {
39
        return $this->value() === $value->value();
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function __toString(): string
46
    {
47
        return \sprintf('%s', $this->value);
48
    }
49
}
50