ValueObject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 2
b 0
f 0
dl 0
loc 37
rs 10

4 Methods

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