Completed
Pull Request — master (#7)
by Klaus
02:27
created

Job   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 58
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\Queue;
6
7
abstract class Job
8
{
9
    protected bool $status = false;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
10
11
    /**
12
     * @var mixed
13
     */
14
    protected $payload = null;
15
16
    /**
17
     * @param mixed $payload
18
     */
19
    public function __construct($payload = null)
20
    {
21
        if (!$payload) {
22
            return;
23
        }
24
25
        $this->setPayload($payload);
26
    }
27
28
    public function getQueue(): string
29
    {
30
        return get_class($this);
31
    }
32
33
    /**
34
     * @return mixed
35
     */
36
    public function getPayload()
37
    {
38
        return $this->payload;
39
    }
40
41
    /**
42
     * @param mixed $payload
43
     */
44
    public function setPayload($payload): void
45
    {
46
        $this->payload = $payload;
47
    }
48
49
    public function isPersistent(): bool
50
    {
51
        return false;
52
    }
53
54
    public function isFinished(): bool
55
    {
56
        return $this->status;
57
    }
58
59
    public function fail(): void
60
    {
61
        $this->status = false;
62
    }
63
64
    public function finish(): void
65
    {
66
        $this->status = true;
67
    }
68
69
    abstract public function perform(): void;
70
}
71