Passed
Push — master ( 39e4c0...d4ca25 )
by Michael
03:36
created

Link::getLinkName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Mapper\Definition;
5
6
/**
7
 * Link definition
8
 *
9
 * @package Mapper\Definition
10
 */
11
class Link
12
{
13
    /**
14
     * Unique name of link-object inside of document or resource
15
     *
16
     * @var string
17
     */
18
    protected $name;
19
20
    /**
21
     * Name of repository supposed to contain link
22
     *
23
     * @var string
24
     */
25
    protected $repositoryName;
26
27
    /**
28
     * Name of resource inside of repository
29
     *
30
     * @var string
31
     */
32
    protected $resourceName;
33
34
    /**
35
     * Parameters for link resolving
36
     *
37
     * @var array
38
     */
39
    protected $parameters = [];
40
41
    /**
42
     * Additional metadata
43
     *
44
     * @var array
45
     */
46
    protected $metadata = [];
47
48
    /**
49
     * Link constructor.
50
     *
51
     * @param string $name
52
     * @param string $repositoryName
53
     * @param string $linkName
54
     */
55 3
    public function __construct(string $name, string $repositoryName, string $linkName)
56
    {
57 3
        $this->name           = $name;
58 3
        $this->repositoryName = $repositoryName;
59 3
        $this->linkName       = $linkName;
0 ignored issues
show
Bug introduced by
The property linkName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
60 3
    }
61
62
    /**
63
     * Get unique name of link-object inside of document or resource
64
     *
65
     * @return string
66
     */
67 1
    public function getName(): string
68
    {
69 1
        return $this->name;
70
    }
71
72
    /**
73
     * Get name of repository supposed to contain link
74
     *
75
     * @return string
76
     */
77 1
    public function getRepositoryName(): string
78
    {
79 1
        return $this->repositoryName;
80
    }
81
82
    /**
83
     * Get name of link inside of repository
84
     *
85
     * @return string
86
     */
87 1
    public function getLinkName(): string
88
    {
89 1
        return $this->linkName;
90
    }
91
92
    /**
93
     * Set parameters for link resolving (overwrites existing ones)
94
     *
95
     * @param array $parameters
96
     */
97 1
    public function setParameters(array $parameters)
98
    {
99 1
        $this->parameters = $parameters;
100 1
    }
101
102
    /**
103
     * Get parameters for link resolving
104
     *
105
     * @return array
106
     */
107 1
    public function getParameters(): array
108
    {
109 1
        return $this->parameters;
110
    }
111
112
    /**
113
     * Set metadata (overwrites existing one)
114
     *
115
     * @param array $metadata
116
     */
117 1
    public function setMetadata(array $metadata)
118
    {
119 1
        $this->metadata = $metadata;
120 1
    }
121
122
    /**
123
     * Get metadata
124
     *
125
     * @return array
126
     */
127 1
    public function getMetadata(): array
128
    {
129 1
        return $this->metadata;
130
    }
131
}