StatementId   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A fromUuid() 0 7 1
A fromString() 0 4 1
A getValue() 0 4 1
A equals() 0 4 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
/**
15
 * An Experience API {@link https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#statement Statement} identifier.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
final class StatementId
20
{
21
    private $uuid;
22
23
    private function __construct()
24
    {
25
    }
26
27
    public static function fromUuid(Uuid $uuid): self
28
    {
29
        $id = new self();
30
        $id->uuid = $uuid;
31
32
        return $id;
33
    }
34
35
    /**
36
     * Creates a statement id based on the given UUID string.
37
     *
38
     * @throws \InvalidArgumentException when the given id is not a well-formed UUID
39
     */
40
    public static function fromString(string $id): self
41
    {
42
        return self::fromUuid(Uuid::fromString($id));
43
    }
44
45
    public function getValue(): string
46
    {
47
        return (string) $this->uuid;
48
    }
49
50
    public function equals(StatementId $id): bool
51
    {
52
        return $this->uuid->equals($id->uuid);
53
    }
54
}
55