Attribute   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 87
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getSerializedKey() 0 3 1
A setSerializedKey() 0 5 1
A setAttributeName() 0 5 1
A getAttributeName() 0 3 1
A setIsIdentifier() 0 5 1
A setType() 0 5 1
A isIdentifier() 0 3 1
A __construct() 0 14 2
A getType() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mapado\RestClientSdk\Mapping;
6
7
/**
8
 * Class Attribute
9
 *
10
 * @author Julien Deniau <[email protected]>
11
 */
12
class Attribute
13
{
14
    /**
15
     * @var string
16
     */
17
    private $serializedKey;
18
19
    /**
20
     * @var string
21
     */
22
    private $type;
23
24
    /**
25
     * @var bool
26
     */
27
    private $isIdentifier;
28
29
    /**
30
     * @var string
31
     */
32
    private $attributeName;
33
34
    /**
35
     * @throws \InvalidArgumentException
36
     */
37
    public function __construct(
38
        string $serializedKey,
39
        ?string $attributeName = null,
40
        ?string $type = null,
41
        bool $isIdentifier = false
42
    ) {
43
        if (empty($serializedKey)) {
44
            throw new \InvalidArgumentException('attribute name must be set');
45
        }
46
47
        $this->serializedKey = $serializedKey;
48
        $this->attributeName = $attributeName ?? $this->serializedKey;
49
        $this->type = $type ?? 'string';
50
        $this->isIdentifier = $isIdentifier;
51
    }
52
53
    public function getSerializedKey(): string
54
    {
55
        return $this->serializedKey;
56
    }
57
58
    public function setSerializedKey(string $serializedKey): self
59
    {
60
        $this->serializedKey = $serializedKey;
61
62
        return $this;
63
    }
64
65
    public function getType(): string
66
    {
67
        return $this->type;
68
    }
69
70
    public function setType(string $type): self
71
    {
72
        $this->type = $type;
73
74
        return $this;
75
    }
76
77
    public function isIdentifier(): bool
78
    {
79
        return $this->isIdentifier;
80
    }
81
82
    public function setIsIdentifier(bool $isIdentifier): self
83
    {
84
        $this->isIdentifier = $isIdentifier;
85
86
        return $this;
87
    }
88
89
    public function getAttributeName(): string
90
    {
91
        return $this->attributeName;
92
    }
93
94
    public function setAttributeName(string $attributeName): self
95
    {
96
        $this->attributeName = $attributeName;
97
98
        return $this;
99
    }
100
}
101