Task   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 10
eloc 17
c 2
b 0
f 0
dl 0
loc 66
ccs 23
cts 23
cp 1
rs 10

10 Methods

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