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

AbstractJob   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 75
ccs 13
cts 16
cp 0.8125
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setId() 0 5 1
A getId() 0 3 1
A setData() 0 5 1
A setScheduler() 0 4 1
A updateProgress() 0 4 1
A getData() 0 3 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