Status::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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