Id::fromNative()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
c 1
b 0
f 1
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Cubiche\Domain\Model\Tests\Fixtures;
11
12
use Cubiche\Domain\Model\IdInterface;
13
14
/**
15
 * Id class.
16
 *
17
 * @author Ivannis Suárez Jerez <[email protected]>
18
 */
19
class Id implements IdInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $value;
25
26
    /**
27
     * PostId constructor.
28
     *
29
     * @param string $value
30
     */
31
    public function __construct($value)
32
    {
33
        $this->value = $value;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function equals($other)
40
    {
41
        return $this->toNative() == $other->toNative();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function hashCode()
48
    {
49
        return $this->value;
50
    }
51
52
    /**
53
     * @param mixed $value
54
     *
55
     * @return static
56
     */
57
    public static function fromNative($value)
58
    {
59
        return new static($value);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function toNative()
66
    {
67
        return $this->value;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function __toString()
74
    {
75
        return \strval($this->toNative());
76
    }
77
}
78