PropalStatus   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 13
c 1
b 0
f 0
dl 0
loc 75
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A draft() 0 3 1
A billed() 0 3 1
A fromInteger() 0 6 1
A refused() 0 3 1
A validated() 0 3 1
A getValue() 0 3 1
A signed() 0 3 1
A equals() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
4
namespace Dolibarr\Client\Domain\Proposal;
5
6
use Webmozart\Assert\Assert;
7
8
final class PropalStatus
9
{
10
    /**
11
     * @var int
12
     */
13
    private $value;
14
15
    private function __construct($status = 0)
16
    {
17
        $this->value = $status;
18
    }
19
20
    /**
21
     * @return PropalStatus
22
     */
23
    public static function draft()
24
    {
25
        return new self(0);
26
    }
27
28
    /**
29
     * @return PropalStatus
30
     */
31
    public static function validated()
32
    {
33
        return new self(1);
34
    }
35
36
    /**
37
     * @return PropalStatus
38
     */
39
    public static function signed()
40
    {
41
        return new self(2);
42
    }
43
44
    /**
45
     * @return PropalStatus
46
     */
47
    public static function refused()
48
    {
49
        return new self(3);
50
    }
51
52
    /**
53
     * @return PropalStatus
54
     */
55
    public static function billed()
56
    {
57
        return new self(4);
58
    }
59
60
    /**
61
     * @return int
62
     */
63
    public function getValue()
64
    {
65
        return $this->value;
66
    }
67
68
    public static function fromInteger($value)
69
    {
70
        Assert::lessThanEq($value, 4);
71
        Assert::greaterThanEq($value, 0);
72
73
        return new self($value);
74
    }
75
    /**
76
     * @param PropalStatus $status
77
     *
78
     * @return bool
79
     */
80
    public function equals(PropalStatus $status)
81
    {
82
        return $this->value === $status->getValue();
83
    }
84
}
85