Site   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 201
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 0
cbo 0
dl 0
loc 201
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A getBillingStatuses() 0 14 1
A getTypes() 0 9 1
A __construct() 0 13 3
A getId() 0 4 1
A getTitle() 0 4 1
A getHost() 0 4 1
A getCompanyId() 0 4 1
A getContactEmail() 0 4 1
A getCreatedAt() 0 4 1
A getUpdatedAt() 0 4 1
A getThemeId() 0 4 1
A getBillingStatus() 0 4 1
A getType() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Yproximite\Api\Model\Site;
5
6
use Yproximite\Api\Model\ModelInterface;
7
8
/**
9
 * Class Site
10
 */
11
class Site implements ModelInterface
12
{
13
    const BILLING_STATUS_TEST                 = 'test';
14
    const BILLING_STATUS_TRIAL                = 'trial';
15
    const BILLING_STATUS_FREE                 = 'free';
16
    const BILLING_STATUS_PARTNER              = 'partner';
17
    const BILLING_STATUS_DIRECT               = 'direct';
18
    const BILLING_STATUS_IN_DEVELOPMENT       = 'in-development';
19
    const BILLING_STATUS_WAITING_SUBSCRIPTION = 'waiting-subscription';
20
    const BILLING_STATUS_ERROR                = 'error';
21
    const BILLING_STATUS_CANCELED             = 'canceled';
22
23
    const TYPE_ROOT         = 'root';
24
    const TYPE_SITE         = 'site';
25
    const TYPE_PLATFORM     = 'platform';
26
    const TYPE_SUB_PLATFORM = 'sub-platform';
27
28
    /**
29
     * @var int
30
     */
31
    private $id;
32
33
    /**
34
     * @var string
35
     */
36
    private $title;
37
38
    /**
39
     * @var string
40
     */
41
    private $host;
42
43
    /**
44
     * @var int|null
45
     */
46
    private $companyId;
47
48
    /**
49
     * @var string|null
50
     */
51
    private $contactEmail;
52
53
    /**
54
     * @var \DateTime
55
     */
56
    private $createdAt;
57
58
    /**
59
     * @var \DateTime
60
     */
61
    private $updatedAt;
62
63
    /**
64
     * @var int|null
65
     */
66
    private $themeId;
67
68
    /**
69
     * @var string
70
     */
71
    private $billingStatus;
72
73
    /**
74
     * @var string
75
     */
76
    private $type;
77
78
    /**
79
     * @return string[]
80
     */
81
    public static function getBillingStatuses(): array
82
    {
83
        return [
84
            self::BILLING_STATUS_TEST,
85
            self::BILLING_STATUS_TRIAL,
86
            self::BILLING_STATUS_FREE,
87
            self::BILLING_STATUS_PARTNER,
88
            self::BILLING_STATUS_DIRECT,
89
            self::BILLING_STATUS_IN_DEVELOPMENT,
90
            self::BILLING_STATUS_WAITING_SUBSCRIPTION,
91
            self::BILLING_STATUS_ERROR,
92
            self::BILLING_STATUS_CANCELED,
93
        ];
94
    }
95
96
    /**
97
     * @return string[]
98
     */
99
    public static function getTypes(): array
100
    {
101
        return [
102
            self::TYPE_ROOT,
103
            self::TYPE_SITE,
104
            self::TYPE_PLATFORM,
105
            self::TYPE_SUB_PLATFORM,
106
        ];
107
    }
108
109
    /**
110
     * Site constructor.
111
     *
112
     * @param array $data
113
     */
114
    public function __construct(array $data)
115
    {
116
        $this->id            = (int) $data['id'];
117
        $this->title         = (string) $data['title'];
118
        $this->host          = (string) $data['host'];
119
        $this->companyId     = !empty($data['company']) ? (int) $data['company'] : null;
120
        $this->contactEmail  = (string) $data['contactEmail'];
121
        $this->createdAt     = new \DateTime($data['createdAt']['date']);
122
        $this->updatedAt     = new \DateTime($data['updatedAt']['date']);
123
        $this->themeId       = !empty($data['theme']) ? (int) $data['theme'] : null;
124
        $this->billingStatus = (string) $data['billingStatus'];
125
        $this->type          = (string) $data['type'];
126
    }
127
128
    /**
129
     * @return int
130
     */
131
    public function getId(): int
132
    {
133
        return $this->id;
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    public function getTitle(): string
140
    {
141
        return $this->title;
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    public function getHost(): string
148
    {
149
        return $this->host;
150
    }
151
152
    /**
153
     * @return int|null
154
     */
155
    public function getCompanyId()
156
    {
157
        return $this->companyId;
158
    }
159
160
    /**
161
     * @return null|string
162
     */
163
    public function getContactEmail()
164
    {
165
        return $this->contactEmail;
166
    }
167
168
    /**
169
     * @return \DateTime
170
     */
171
    public function getCreatedAt(): \DateTime
172
    {
173
        return $this->createdAt;
174
    }
175
176
    /**
177
     * @return \DateTime
178
     */
179
    public function getUpdatedAt(): \DateTime
180
    {
181
        return $this->updatedAt;
182
    }
183
184
    /**
185
     * @return int|null
186
     */
187
    public function getThemeId()
188
    {
189
        return $this->themeId;
190
    }
191
192
    /**
193
     * @see Site::getBillingStatuses()
194
     *
195
     * @return string
196
     */
197
    public function getBillingStatus(): string
198
    {
199
        return $this->billingStatus;
200
    }
201
202
    /**
203
     * @see Site::getTypes()
204
     *
205
     * @return string
206
     */
207
    public function getType(): string
208
    {
209
        return $this->type;
210
    }
211
}
212