Status   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 47
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getValue() 0 4 1
A setValue() 0 8 2
A __toString() 0 4 1
1
<?php
2
3
namespace Nord\Lumen\Core\Domain;
4
5
use Nord\Lumen\Core\Contracts\ValueObject;
6
use Nord\Lumen\Core\Exceptions\InvalidArgument;
7
8
class Status implements ValueObject
9
{
10
    /**
11
     * @var int
12
     */
13
    private $value;
14
15
    /**
16
     * Status constructor.
17
     *
18
     * @param int $value
19
     */
20
    public function __construct($value)
21
    {
22
        $this->setValue($value);
23
    }
24
25
    /**
26
     * @return int
27
     */
28
    public function getValue()
29
    {
30
        return $this->value;
31
    }
32
33
    /**
34
     * @param int $value
35
     *
36
     * @throws InvalidArgument
37
     */
38
    private function setValue($value)
39
    {
40
        if (!is_int($value)) {
41
            throw new InvalidArgument('Status must be an integer.');
42
        }
43
44
        $this->value = $value;
45
    }
46
47
    /**
48
     * @return string
49
     */
50
    public function __toString()
51
    {
52
        return (string) $this->getValue();
53
    }
54
}
55