Task::isReady()   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
    private $data;
21
22 156
    private function __construct(int $id, string $state, $data)
23
    {
24 156
        $this->id = $id;
25 156
        $this->state = $state;
26 156
        $this->data = $data;
27 156
    }
28
29 156
    public static function createFromTuple(array $tuple) : self
30
    {
31 156
        [$id, $state, $data] = $tuple + [2 => null];
32
33 156
        return new self($id, $state, $data);
34
    }
35
36 142
    public function getId() : int
37
    {
38 142
        return $this->id;
39
    }
40
41 126
    public function getState() : string
42
    {
43 126
        return $this->state;
44
    }
45
46 140
    public function getData()
47
    {
48 140
        return $this->data;
49
    }
50
51 10
    public function isReady() : bool
52
    {
53 10
        return States::READY === $this->state;
54
    }
55
56 10
    public function isTaken() : bool
57
    {
58 10
        return States::TAKEN === $this->state;
59
    }
60
61 10
    public function isDone() : bool
62
    {
63 10
        return States::DONE === $this->state;
64
    }
65
66 10
    public function isBuried() : bool
67
    {
68 10
        return States::BURIED === $this->state;
69
    }
70
71 10
    public function isDelayed() : bool
72
    {
73 10
        return States::DELAYED === $this->state;
74
    }
75
}
76