Completed
Push — master ( 7bdb3a...32fdd0 )
by Emil
02:25
created

Schedule::setInterval()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Glooby\TaskBundle\Model;
4
5
use Cron\CronExpression;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * @author Emil Kilhage
11
 */
12
class Schedule implements ScheduleInterface
13
{
14
    /**
15
     * @var int
16
     */
17
    protected $id;
18
19
    /**
20
     * @var string
21
     */
22
    protected $name;
23
24
    /**
25
     * @var \DateTime
26
     */
27
    protected $created;
28
29
    /**
30
     * @var string
31
     */
32
    protected $interval;
33
34
    /**
35
     * @var bool
36
     */
37
    protected $active = true;
38
39
    /**
40
     * @var int
41
     */
42
    protected $timeout = 0;
43
44
    /**
45
     * @var int
46
     */
47
    protected $version = 1;
48
49
    /**
50
     * @var array
51
     */
52
    protected $params = [];
53
54
    /**
55
     * @var ArrayCollection
56
     */
57
    protected $runs;
58
59
    /**
60
     * Schedule constructor.
61
     */
62
    public function __construct()
63
    {
64
        $this->created = new \DateTime();
65
        $this->runs = new ArrayCollection();
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getId()
72
    {
73
        return $this->id;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function getName()
80
    {
81
        return $this->name;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function setName($name)
88
    {
89
        $this->name = $name;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function getCreated()
96
    {
97
        return $this->created;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function setCreated($created)
104
    {
105
        $this->created = $created;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function parseExpression()
112
    {
113
        return CronExpression::factory($this->getInterval());
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function getInterval()
120
    {
121
        return $this->interval;
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function setInterval($interval)
128
    {
129
        $this->interval = $interval;
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135
    public function isActive()
136
    {
137
        return $this->active;
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    public function setActive($active)
144
    {
145
        $this->active = $active;
146
    }
147
148
    /**
149
     * {@inheritdoc}
150
     */
151
    public function getTimeout()
152
    {
153
        return $this->timeout;
154
    }
155
156
    /**
157
     * {@inheritdoc}
158
     */
159
    public function setTimeout($timeout)
160
    {
161
        $this->timeout = $timeout;
162
    }
163
164
    /**
165
     * {@inheritdoc}
166
     */
167
    public function getParams()
168
    {
169
        return $this->params;
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function hasParams()
176
    {
177
        return count($this->params) > 0;
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183
    public function setParams(array $params)
184
    {
185
        $this->params = $params;
186
    }
187
188
    /**
189
     * {@inheritdoc}
190
     */
191
    public function getVersion()
192
    {
193
        return $this->version;
194
    }
195
196
    /**
197
     * {@inheritdoc}
198
     */
199
    public function setVersion($version)
200
    {
201
        $this->version = $version;
202
    }
203
}
204