PrimaryKeyReference::getUrl()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Apie\PrimaryKeyPlugin\ValueObjects;
5
6
use Apie\Core\Models\ApiResourceClassMetadata;
7
use Apie\ValueObjects\ValueObjectInterface;
8
9
/**
10
 * Value object for making a primary key reference to an Apie resource.
11
 */
12
final class PrimaryKeyReference
13
{
14
    /**
15
     * @var ApiResourceClassMetadata
16
     */
17
    private $metadata;
18
19
    /**
20
     * @var string
21
     */
22
    private $identifierValue;
23
24
    /**
25
     * @var string
26
     */
27
    private $resourceUrl;
28
29
    /**
30
     * @param ApiResourceClassMetadata $metadata
31
     * @param string|int|float|bool|object $identifierValue
32
     */
33
    public function __construct(ApiResourceClassMetadata $metadata, string $resourceUrl, $identifierValue)
34
    {
35
        $this->metadata = $metadata;
36
        $this->resourceUrl = $resourceUrl;
37
        if ($identifierValue instanceof ValueObjectInterface) {
38
            $this->identifierValue = (string) $identifierValue->toNative();
39
        } else {
40
            $this->identifierValue = (string) $identifierValue;
41
        }
42
    }
43
44
    /**
45
     * @return ApiResourceClassMetadata
46
     */
47
    public function getMetadata(): ApiResourceClassMetadata
48
    {
49
        return $this->metadata;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getUrl(): string
56
    {
57
        return $this->resourceUrl;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getIdentifierValue(): string
64
    {
65
        return $this->identifierValue;
66
    }
67
}
68