Link   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 3 1
A to() 0 3 1
A __construct() 0 4 1
A path() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\RestResource;
4
5
final class Link
6
{
7
    /** @var string */
8
    private $path;
9
    /** @var RelationshipType */
10
    private $type;
11
12
    private function __construct(string $path, RelationshipType $type)
13
    {
14
        $this->path = $path;
15
        $this->type = $type;
16
    }
17
18
    public static function to(string $path, RelationshipType $type): self
19
    {
20
        return new self($path, $type);
21
    }
22
23
    /**
24
     * Retrieves the path this links to.
25
     *
26
     * @return string The path this link points to.
27
     */
28
    public function path(): string
29
    {
30
        return $this->path;
31
    }
32
33
    /**
34
     * Retrieves the type of relationship this link represents.
35
     *
36
     * @return RelationshipType The relationship type.
37
     */
38
    public function type(): RelationshipType
39
    {
40
        return $this->type;
41
    }
42
}
43