Task::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the tarantool/queue package.
5
 *
6
 * (c) Eugene Leonovich <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Tarantool\Queue;
15
16
final class Task
17
{
18
    private $id;
19
    private $state;
20
21
    /** @var mixed */
22
    private $data;
23
24
    /**
25
     * @param mixed $data
26
     */
27 78
    private function __construct(int $id, string $state, $data)
28
    {
29 78
        $this->id = $id;
30 78
        $this->state = $state;
31 78
        $this->data = $data;
32
    }
33
34 78
    public static function fromTuple(array $tuple) : self
35
    {
36 78
        [$id, $state, $data] = $tuple + [2 => null];
37
38 78
        return new self($id, $state, $data);
39
    }
40
41 71
    public function getId() : int
42
    {
43 71
        return $this->id;
44
    }
45
46 63
    public function getState() : string
47
    {
48 63
        return $this->state;
49
    }
50
51
    /**
52
     * @return mixed
53
     */
54 70
    public function getData()
55
    {
56 70
        return $this->data;
57
    }
58
59 5
    public function isReady() : bool
60
    {
61 5
        return States::READY === $this->state;
62
    }
63
64 5
    public function isTaken() : bool
65
    {
66 5
        return States::TAKEN === $this->state;
67
    }
68
69 5
    public function isDone() : bool
70
    {
71 5
        return States::DONE === $this->state;
72
    }
73
74 5
    public function isBuried() : bool
75
    {
76 5
        return States::BURIED === $this->state;
77
    }
78
79 5
    public function isDelayed() : bool
80
    {
81 5
        return States::DELAYED === $this->state;
82
    }
83
}
84