Passed
Pull Request — master (#464)
by Kirill
12:51
created

Options::delayed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Jobs;
13
14
final class Options implements \JsonSerializable
15
{
16
    /** @var int|null */
17
    private $delay = null;
18
19
    /** @var string|null */
20
    private $pipeline = null;
21
22
    /**
23
     * @param int $delay
24
     * @return self
25
     */
26
    public function withDelay(?int $delay): self
27
    {
28
        $options = clone $this;
29
        $options->delay = $delay;
30
31
        return $options;
32
    }
33
34
    /**
35
     * @return string|null
36
     */
37
    public function getPipeline(): ?string
38
    {
39
        return $this->pipeline;
40
    }
41
42
    /**
43
     * @param string|null $pipeline
44
     * @return self
45
     */
46
    public function withPipeline(?string $pipeline): self
47
    {
48
        $options = clone $this;
49
        $options->pipeline = $pipeline;
50
51
        return $options;
52
    }
53
54
    /**
55
     * @return int|null
56
     */
57
    public function getDelay(): ?int
58
    {
59
        return $this->delay;
60
    }
61
62
    /**
63
     * @return array|mixed
64
     */
65
    #[\ReturnTypeWillChange]
66
    public function jsonSerialize()
67
    {
68
        return [
69
            'delay'    => $this->delay,
70
            'pipeline' => $this->pipeline,
71
        ];
72
    }
73
74
    /**
75
     * @param int $delay
76
     * @return Options
77
     */
78
    public static function delayed(int $delay): Options
79
    {
80
        $options = new self();
81
        $options->delay = $delay;
82
83
        return $options;
84
    }
85
}
86