BundleVersion   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 180
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 14
c 5
b 0
f 0
lcom 2
cbo 1
dl 0
loc 180
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A getName() 0 4 1
A setInstallationDate() 0 5 1
A getInstallationDate() 0 4 1
A isInstalled() 0 4 1
A setVersion() 0 5 1
A getVersion() 0 4 1
A setInstalledVersion() 0 5 1
A getInstalledVersion() 0 4 1
A setUpdateDate() 0 5 1
A getUpdateDate() 0 4 1
A needUpdate() 0 4 1
A isVersionned() 0 4 1
1
<?php
2
3
namespace kujaff\VersionsBundle\Entity;
4
5
/**
6
 * Bundles
7
 */
8
class BundleVersion
9
{
10
    /**
11
     * @var integer
12
     */
13
    private $id;
14
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @var \DateTime
22
     */
23
    private $installationDate;
24
25
    /**
26
     * @var Version
27
     */
28
    private $installedVersion;
29
30
    /**
31
     * @var Version
32
     */
33
    private $version;
34
35
    /**
36
     * @var \DateTime
37
     */
38
    private $updateDate;
39
40
    /**
41
     * Constructor
42
     *
43
     * @param string $name
44
     */
45
    public function __construct($name)
46
    {
47
        $this->name = $name;
48
    }
49
50
    /**
51
     * Get id
52
     *
53
     * @return integer
54
     */
55
    public function getId()
56
    {
57
        return $this->id;
58
    }
59
60
    /**
61
     * Get name
62
     *
63
     * @return string
64
     */
65
    public function getName()
66
    {
67
        return $this->name;
68
    }
69
70
    /**
71
     * Set installation date
72
     *
73
     * @param \DateTime $date
74
     * @return BundleVersion
75
     */
76
    public function setInstallationDate($date)
77
    {
78
        $this->installationDate = $date;
79
        return $this;
80
    }
81
82
    /**
83
     * Get installation date
84
     *
85
     * @return \DateTime
86
     */
87
    public function getInstallationDate()
88
    {
89
        return $this->installationDate;
90
    }
91
92
    /**
93
     * Indicate if bundle is installed
94
     *
95
     * @return boolean
96
     */
97
    public function isInstalled()
98
    {
99
        return ($this->getInstallationDate() !== null);
100
    }
101
102
    /**
103
     * Set version
104
     *
105
     * @param Version $version
106
     * @return BundleVersion
107
     */
108
    public function setVersion(Version $version)
109
    {
110
        $this->version = $version;
111
        return $this;
112
    }
113
114
    /**
115
     * Get version
116
     *
117
     * @return Version
118
     */
119
    public function getVersion()
120
    {
121
        return $this->version;
122
    }
123
124
    /**
125
     * Set installed version
126
     *
127
     * @param Version $version
128
     * @return BundleVersion
129
     */
130
    public function setInstalledVersion(Version $version)
131
    {
132
        $this->installedVersion = $version;
133
        return $this;
134
    }
135
136
    /**
137
     * Get installed version
138
     *
139
     * @return Version
140
     */
141
    public function getInstalledVersion()
142
    {
143
        return $this->installedVersion;
144
    }
145
146
    /**
147
     * Set update date
148
     *
149
     * @param \DateTime $date
150
     * @return BundleVersion
151
     */
152
    public function setUpdateDate($date)
153
    {
154
        $this->updateDate = $date;
155
        return $this;
156
    }
157
158
    /**
159
     * Get update date
160
     *
161
     * @return \DateTime
162
     */
163
    public function getUpdateDate()
164
    {
165
        return $this->updateDate;
166
    }
167
168
    /**
169
     * Indicate if the bundle needs an update
170
     *
171
     * @return boolean
172
     */
173
    public function needUpdate()
174
    {
175
        return ($this->getVersion()->asString() != $this->getInstalledVersion()->asString());
176
    }
177
178
    /**
179
     * Indicate if bundle is versionned
180
     *
181
     * @return boolean
182
     */
183
    public function isVersionned()
184
    {
185
        return ($this->getVersion() instanceof Version);
186
    }
187
}
188