Invoice::number()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace OceanApplications\Postmen\Models;
4
5
class Invoice extends Model
6
{
7
    public $date;
8
    public $number;
9
    public $type;
10
    public $number_of_copies = 1;
11
12
    public function __construct()
13
    {
14
        $this->date = date('Y-m-d');
15
    }
16
17
    /**
18
     * @param string $value
19
     *
20
     * @return $this
21
     */
22
    public function number($value)
23
    {
24
        $this->number = strval($value);
25
26
        return $this;
27
    }
28
29
    /**
30
     * @param string $value
31
     *
32
     * @return $this
33
     */
34
    public function type($value)
35
    {
36
        $this->type = strval($value);
37
38
        return $this;
39
    }
40
41
    /**
42
     * @param int $value between 1 and 4
43
     *
44
     * @throws \Exception
45
     *
46
     * @return $this
47
     */
48
    public function number_of_copies($value)
49
    {
50
        if ($value >= 1 && $value <= 4) {
51
            $this->number_of_copies = $value;
52
        } else {
53
            $error = 'Number of copies must be between 1 and 4';
54
            throw new \Exception($error);
55
        }
56
57
        return $this;
58
    }
59
}
60