Tag   A
last analyzed

Complexity

Total Complexity 26

Size/Duplication

Total Lines 151
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 26
lcom 1
cbo 0
dl 0
loc 151
rs 10
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
B fromJson() 0 19 9
A fromProperties() 0 23 1
A getCount() 0 4 1
A setCount() 0 6 1
A getHasSynonyms() 0 4 1
A setHasSynonyms() 0 6 1
A getIsModeratorOnly() 0 4 1
A setIsModeratorOnly() 0 6 1
A getIsRequired() 0 4 1
A setIsRequired() 0 6 1
A getLastActivityDate() 0 4 1
A setLastActivityDate() 0 6 1
A getName() 0 4 1
A setName() 0 6 1
A getSynonyms() 0 4 1
A setSynonyms() 0 6 1
A getUserId() 0 4 1
A setUserId() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
/*
14
 * This file is part of the Stack Exchange Api Client library.
15
 *
16
 * (c) Beñat Espiña <[email protected]>
17
 *
18
 * For the full copyright and license information, please view the LICENSE
19
 * file that was distributed with this source code.
20
 */
21
22
namespace BenatEspina\StackExchangeApiClient\Model;
23
24
/**
25
 * The tag model class.
26
 *
27
 * @author Beñat Espiña <[email protected]>
28
 */
29
class Tag implements Model
30
{
31
    protected $count;
32
    protected $hasSynonyms;
33
    protected $isModeratorOnly;
34
    protected $isRequired;
35
    protected $lastActivityDate;
36
    protected $name;
37
    protected $synonyms;
38
    protected $userId;
39
40
    public static function fromJson(array $data)
41
    {
42
        $instance = new self();
43
        $instance
44
            ->setCount(array_key_exists('count', $data) ? $data['count'] : null)
45
            ->setHasSynonyms(array_key_exists('has_synonyms', $data) ? $data['has_synonyms'] : null)
46
            ->setIsModeratorOnly(array_key_exists('is_moderator_only', $data) ? $data['is_moderator_only'] : null)
47
            ->setIsRequired(array_key_exists('is_required', $data) ? $data['is_required'] : null)
48
            ->setLastActivityDate(
49
                array_key_exists('last_activity_date', $data)
50
                    ? new \DateTimeImmutable('@' . $data['last_activity_date'])
51
                    : null
52
            )
53
            ->setName(array_key_exists('name', $data) ? $data['name'] : null)
54
            ->setSynonyms(array_key_exists('synonyms', $data) ? $data['synonyms'] : null)
55
            ->setUserId(array_key_exists('user_id', $data) ? $data['user_id'] : null);
56
57
        return $instance;
58
    }
59
60
    public static function fromProperties(
61
        $count,
62
        $hasSynonyms,
63
        $isModeratorOnly,
64
        $isRequired,
65
        $name,
66
        $synonyms,
67
        \DateTimeInterface $lastActivityDate = null,
68
        $userId = null
69
    ) {
70
        $instance = new self();
71
        $instance
72
            ->setCount($count)
73
            ->setHasSynonyms($hasSynonyms)
74
            ->setIsModeratorOnly($isModeratorOnly)
75
            ->setIsRequired($isRequired)
76
            ->setLastActivityDate($lastActivityDate)
77
            ->setName($name)
78
            ->setSynonyms($synonyms)
79
            ->setUserId($userId);
80
81
        return $instance;
82
    }
83
84
    public function getCount()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
85
    {
86
        return $this->count;
87
    }
88
89
    public function setCount($count)
90
    {
91
        $this->count = $count;
92
93
        return $this;
94
    }
95
96
    public function getHasSynonyms()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
97
    {
98
        return $this->hasSynonyms;
99
    }
100
101
    public function setHasSynonyms($hasSynonyms)
102
    {
103
        $this->hasSynonyms = $hasSynonyms;
104
105
        return $this;
106
    }
107
108
    public function getIsModeratorOnly()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
109
    {
110
        return $this->isModeratorOnly;
111
    }
112
113
    public function setIsModeratorOnly($isModeratorOnly)
114
    {
115
        $this->isModeratorOnly = $isModeratorOnly;
116
117
        return $this;
118
    }
119
120
    public function getIsRequired()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
121
    {
122
        return $this->isRequired;
123
    }
124
125
    public function setIsRequired($isRequired)
126
    {
127
        $this->isRequired = $isRequired;
128
129
        return $this;
130
    }
131
132
    public function getLastActivityDate()
133
    {
134
        return $this->lastActivityDate;
135
    }
136
137
    public function setLastActivityDate(\DateTimeInterface $lastActivityDate = null)
138
    {
139
        $this->lastActivityDate = $lastActivityDate;
140
141
        return $this;
142
    }
143
144
    public function getName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
145
    {
146
        return $this->name;
147
    }
148
149
    public function setName($name)
150
    {
151
        $this->name = $name;
152
153
        return $this;
154
    }
155
156
    public function getSynonyms()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
157
    {
158
        return $this->synonyms;
159
    }
160
161
    public function setSynonyms($synonyms)
162
    {
163
        $this->synonyms = $synonyms;
164
165
        return $this;
166
    }
167
168
    public function getUserId()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
169
    {
170
        return $this->userId;
171
    }
172
173
    public function setUserId($userId)
174
    {
175
        $this->userId = $userId;
176
177
        return $this;
178
    }
179
}
180