Identifier   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 108
c 0
b 0
f 0
ccs 24
cts 24
cp 1
rs 10
wmc 8
lcom 1
cbo 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getId() 0 4 1
A setId() 0 6 1
A getType() 0 4 1
A setType() 0 6 1
A hasIdentifierMeta() 0 4 1
A getIdentifierMeta() 0 4 1
A setIdentifierMeta() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace Neomerx\JsonApi\Schema;
4
5
/**
6
 * Copyright 2015-2020 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Neomerx\JsonApi\Contracts\Schema\IdentifierInterface;
22
23
/**
24
 * @package Neomerx\JsonApi
25
 */
26
class Identifier implements IdentifierInterface
27
{
28
    /**
29
     * @var string
30
     */
31
    private $index;
32
33
    /**
34
     * @var string
35
     */
36
    private $type;
37
38
    /**
39
     * @var bool
40
     */
41
    private $hasMeta;
42
43
    /**
44
     * @var mixed
45
     */
46
    private $meta;
47
48
    /**
49
     * @param string $index
50
     * @param string $type
51
     * @param bool   $hasMeta
52
     * @param mixed  $meta
53
     *
54
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
55
     */
56 4
    public function __construct(string $index, string $type, bool $hasMeta = false, $meta = null)
57
    {
58 4
        $this->setId($index);
59 4
        $this->setType($type);
60
61 4
        $this->hasMeta = $hasMeta;
62 4
        $this->meta    = $meta;
63 4
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68 4
    public function getId(): string
69
    {
70 4
        return $this->index;
71
    }
72
73
    /**
74
     * @param string $index
75
     *
76
     * @return self
77
     */
78 4
    public function setId(string $index): self
79
    {
80 4
        $this->index = $index;
81
82 4
        return $this;
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88 4
    public function getType(): string
89
    {
90 4
        return $this->type;
91
    }
92
93
    /**
94
     * @param string $type
95
     *
96
     * @return self
97
     */
98 4
    public function setType(string $type): self
99
    {
100 4
        $this->type = $type;
101
102 4
        return $this;
103
    }
104
105
    /**
106
     * @inheritdoc
107
     */
108 4
    public function hasIdentifierMeta(): bool
109
    {
110 4
        return $this->hasMeta;
111
    }
112
113
    /**
114
     * @inheritdoc
115
     */
116 2
    public function getIdentifierMeta()
117
    {
118 2
        return $this->meta;
119
    }
120
121
    /**
122
     * @param mixed $meta
123
     *
124
     * @return self
125
     */
126 2
    public function setIdentifierMeta($meta): self
127
    {
128 2
        $this->meta    = $meta;
129 2
        $this->hasMeta = true;
130
131 2
        return $this;
132
    }
133
}
134