Task   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
eloc 17
dl 0
loc 58
c 0
b 0
f 0
ccs 24
cts 24
cp 1
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A isDelayed() 0 3 1
A getData() 0 3 1
A isTaken() 0 3 1
A getState() 0 3 1
A __construct() 0 5 1
A createFromTuple() 0 5 1
A getId() 0 3 1
A isBuried() 0 3 1
A isDone() 0 3 1
A isReady() 0 3 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