Completed
Pull Request — master (#47)
by Wachter
05:00
created

Task::getSystemKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
     * @var string
29
     */
30
    private $systemKey;
31
32
    /**
33
     * @return mixed
34
     */
35
    public function getIntervalExpression()
36
    {
37
        return $this->intervalExpression;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 8
    public function getInterval()
44
    {
45 8
        if (null === $this->interval && null !== $this->intervalExpression) {
46 2
            $this->interval = CronExpression::factory($this->intervalExpression);
47
        }
48
49 8
        return parent::getInterval();
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 5
    public function setInterval(CronExpression $interval, \DateTime $firstExecution = null, \DateTime $lastExecution = null)
56
    {
57 5
        parent::setInterval($interval, $firstExecution, $lastExecution);
58
59 5
        $this->intervalExpression = $interval->getExpression();
60 5
    }
61
62
    /**
63
     * Returns system-key.
64
     *
65
     * @return string
66
     */
67 1
    public function getSystemKey()
68
    {
69 1
        return $this->systemKey;
70
    }
71
72
    /**
73
     * Set system-key.
74
     *
75
     * @param string $systemKey
76
     *
77
     * @return $this
78
     */
79 3
    public function setSystemKey($systemKey)
80
    {
81 3
        $this->systemKey = $systemKey;
82
83 3
        return $this;
84
    }
85
}
86