Completed
Branch dev (ed868c)
by Raffael
03:59
created

AbstractJob::setScheduler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * TaskScheduler
7
 *
8
 * @author      Raffael Sahli <[email protected]>
9
 * @copyright   Copryright (c) 2017-2019 gyselroth GmbH (https://gyselroth.com)
10
 * @license     MIT https://opensource.org/licenses/MIT
11
 */
12
13
namespace TaskScheduler;
14
15
use MongoDB\BSON\ObjectId;
16
17
abstract class AbstractJob implements JobInterface
18
{
19
    /**
20
     * Data.
21
     *
22
     * @var mixed
23
     **/
24
    protected $data;
25
26
    /**
27
     * Scheduler
28
     *
29
     * @var Scheduler
30
     */
31
    protected $scheduler;
32
33
    /**
34
     * Job ID.
35
     *
36
     * @var ObjectId
37
     */
38
    protected $id;
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 16
    public function setData($data): JobInterface
44
    {
45 16
        $this->data = $data;
46
47 16
        return $this;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 1
    public function getData()
54
    {
55 1
        return $this->data;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 16
    public function setId(ObjectId $id): JobInterface
62
    {
63 16
        $this->id = $id;
64
65 16
        return $this;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71 1
    public function getId(): ObjectId
72
    {
73 1
        return $this->id;
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79 14
    public function setScheduler(Scheduler $scheduler): JobInterface
80
    {
81 14
        $this->scheduler = $scheduler;
82 14
        return $this;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function updateProgress(float $progress): JobInterface
89
    {
90
        $this->scheduler->updateJobProgress($this, $progress);
91
        return $this;
92
    }
93
}
94