Release   A
last analyzed

Complexity

Total Complexity 24

Size/Duplication

Total Lines 183
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 0
loc 183
rs 10
c 3
b 0
f 0
wmc 24
lcom 1
cbo 0

21 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDate() 0 8 2
A getDatestamp() 0 4 1
A getDownloadLink() 0 4 1
A getFiles() 0 4 1
A getFilesize() 0 4 1
A getMDHash() 0 4 1
A getName() 0 4 1
A getProjectStatus() 0 4 1
A getReleaseLink() 0 4 1
A getStatus() 0 4 1
A getTag() 0 4 1
A getTerm() 0 4 1
A getTerms() 0 4 1
A getVersion() 0 4 1
A getVersionExtra() 0 4 2
A getVersionMajor() 0 4 1
A getVersionPatch() 0 4 2
A hasTerm() 0 4 1
A setProjectStatus() 0 4 1
A setStatus() 0 4 1
1
<?php
2
3
/**
4
 * Drush Cerbere command line tools.
5
 * Copyright (C) 2015 - Sebastien Malot <[email protected]>
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License along
18
 * with this program; if not, write to the Free Software Foundation, Inc.,
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
 */
21
22
namespace Cerbere\Model;
23
24
/**
25
 * Class Release
26
 * @package Cerbere\Model
27
 */
28
class Release
29
{
30
    /**
31
     * @var array
32
     */
33
    protected $data;
34
35
    /**
36
     * @param array $data
37
     */
38
    public function __construct($data)
39
    {
40
        $this->data = $data;
41
    }
42
43
    /**
44
     * @return \DateTime
45
     */
46
    public function getDate()
47
    {
48
        if ($timestamp = $this->getDatestamp()) {
49
            return new \DateTime('@' . $timestamp);
50
        }
51
52
        return null;
53
    }
54
55
    /**
56
     * @return int
57
     */
58
    public function getDatestamp()
59
    {
60
        return $this->data['date'];
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getDownloadLink()
67
    {
68
        return $this->data['download_link'];
69
    }
70
71
    /**
72
     * @return array
73
     */
74
    public function getFiles()
75
    {
76
        return trim($this->data['files']);
77
    }
78
79
    /**
80
     * @return int
81
     */
82
    public function getFilesize()
83
    {
84
        return intval($this->data['filesize']);
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function getMDHash()
91
    {
92
        return $this->data['mdhash'];
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getName()
99
    {
100
        return $this->data['name'];
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    public function getProjectStatus()
107
    {
108
        return $this->data['project_status'];
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getReleaseLink()
115
    {
116
        return $this->data['release_link'];
117
    }
118
119
    /**
120
     * @return string
121
     */
122
    public function getStatus()
123
    {
124
        return $this->data['status'];
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getTag()
131
    {
132
        return $this->data['tag'];
133
    }
134
135
    /**
136
     * @param $term
137
     *
138
     * @return mixed
139
     */
140
    public function getTerm($term)
141
    {
142
        return $this->data['terms'][$term];
143
    }
144
145
    /**
146
     * @return array
147
     */
148
    public function getTerms()
149
    {
150
        return $this->data['terms'];
151
    }
152
153
    /**
154
     * @return string
155
     */
156
    public function getVersion()
157
    {
158
        return $this->data['version'];
159
    }
160
161
    /**
162
     * @return string
163
     */
164
    public function getVersionExtra()
165
    {
166
        return isset($this->data['version_extra']) ? $this->data['version_extra'] : '';
167
    }
168
169
    /**
170
     * @return string
171
     */
172
    public function getVersionMajor()
173
    {
174
        return $this->data['version_major'];
175
    }
176
177
    /**
178
     * @return string
179
     */
180
    public function getVersionPatch()
181
    {
182
        return isset($this->data['version_patch']) ? $this->data['version_patch'] : '';
183
    }
184
185
    /**
186
     * @param $term
187
     *
188
     * @return bool
189
     */
190
    public function hasTerm($term)
191
    {
192
        return isset($this->data['terms'][$term]);
193
    }
194
195
    /**
196
     * @param int $project_status
197
     */
198
    public function setProjectStatus($project_status)
199
    {
200
        $this->data['project_status'] = $project_status;
201
    }
202
203
    /**
204
     * @param int $status
205
     */
206
    public function setStatus($status)
207
    {
208
        $this->data['status'] = $status;
209
    }
210
}
211