DeliveryStatus::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LWI\DeliveryTracking;
4
5
/**
6
 * Class DeliveryStatus
7
 */
8
class DeliveryStatus
9
{
10
    const STATE_DELIVERED = 'delivered';
11
12
    const STATE_IN_PROGRESS = 'in_progress';
13
14
    /**
15
     * Current preparation state
16
     *
17
     * @var string
18
     */
19
    protected $state;
20
21
    /**
22
     * ExpeditionState constructor.
23
     * @param $state
24
     */
25 15
    protected function __construct($state)
26
    {
27 15
        $this->state = $state;
28 15
    }
29
30
    /**
31
     * @return string
32
     */
33 3
    public function __toString()
34
    {
35 3
        return $this->state;
36
    }
37
38
    /**
39
     * @return DeliveryStatus
40
     */
41 12
    public static function stateDelivered()
42
    {
43 12
        return new self(self::STATE_DELIVERED);
44
    }
45
46
    /**
47
     * @return bool
48
     */
49 9
    public function isDelivered()
50
    {
51 9
        return $this->state == self::STATE_DELIVERED;
52
    }
53
54
    /**
55
     * @return DeliveryStatus
56
     */
57 3
    public static function stateInProgress()
58
    {
59 3
        return new self(self::STATE_IN_PROGRESS);
60
    }
61
62
    /**
63
     * @return bool
64
     */
65 6
    public function isInProgress()
66
    {
67 6
        return $this->state == self::STATE_IN_PROGRESS;
68
    }
69
}
70