Completed
Push — master ( 21b23e...04c0e6 )
by Christian
04:03
created

StatementId::equals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
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 Xabbuh\XApi\Model;
13
14
use Rhumsaa\Uuid\Uuid;
15
16
/**
17
 * An Experience API {@link https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#statement Statement} identifier.
18
 *
19
 * @author Christian Flothmann <[email protected]>
20
 */
21
final class StatementId
22
{
23
    /**
24
     * @var Uuid
25
     */
26
    private $uuid;
27
28
    private function __construct()
29
    {
30
    }
31
32
    public static function fromUuid(Uuid $uuid)
33
    {
34
        $id = new self();
35
        $id->uuid = $uuid;
36
37
        return $id;
38
    }
39
40
    /**
41
     * Creates a statement id based on the given UUID string.
42
     *
43
     * @param string $id
44
     *
45
     * @return StatementId
46
     *
47
     * @throws \InvalidArgumentException when the given id is not a well-formed UUID
48
     */
49
    public static function fromString($id)
50
    {
51
        return self::fromUuid(Uuid::fromString($id));
52
    }
53
54
    public function getValue()
55
    {
56
        return $this->uuid->toString();
57
    }
58
59
    public function equals(StatementId $id)
60
    {
61
        return $this->uuid->equals($id->uuid);
62
    }
63
}
64