Completed
Pull Request — master (#24)
by Wachter
03:53
created

Task   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 34
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIntervalExpression() 0 4 1
A getInterval() 0 8 3
A setInterval() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\Entity;
13
14
use Cron\CronExpression;
15
use Task\Task as BaseTask;
16
17
/**
18
 * Extends base task with id and interval-expression which will be stored in database.
19
 */
20
class Task extends BaseTask
21
{
22
    /**
23
     * @var string
24
     */
25
    private $intervalExpression;
26
27
    /**
28
     * @return mixed
29
     */
30
    public function getIntervalExpression()
31
    {
32
        return $this->intervalExpression;
33
    }
34
35 7
    public function getInterval()
36
    {
37 7
        if (null === $this->interval && null !== $this->intervalExpression) {
38
            $this->interval = CronExpression::factory($this->intervalExpression);
39
        }
40
41 7
        return parent::getInterval();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 4
    public function setInterval(CronExpression $interval, \DateTime $firstExecution = null, \DateTime $lastExecution = null)
48
    {
49 4
        parent::setInterval($interval, $firstExecution, $lastExecution);
50
51 4
        $this->intervalExpression = $interval->getExpression();
52 4
    }
53
}
54