Passed
Push — master ( 224db0...04cfc9 )
by Thiago
33s
created

Parcel::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php
2
namespace MrPrompt\ShipmentCommon\Base;
3
4
use DateTime;
5
6
/**
7
 * Parcel
8
 *
9
 * @author Thiago Paes <[email protected]>
10
 */
11
class Parcel
12
{
13
    /**
14
     *
15
     * @var DateTime
16
     */
17
    private $maturity;
18
19
    /**
20
     *
21
     * @var float
22
     */
23
    private $price;
24
25
    /**
26
     * @var int
27
     */
28
    private $key;
29
30
    /**
31
     * @var int
32
     */
33
    private $quantity;
34
35
    /**
36
     * Constructor
37
     * 
38
     * @param DateTime $maturity
39
     * @param float $price
40
     * @param int $key
41
     * @param int $quantity
42
     */
43 13
    public function __construct(
44
        DateTime $maturity = null,
45
        float $price = 0.00,
46
        int $key = 0,
47
        int $quantity = 1
48
    ) {
49 13
        $this->maturity = $maturity ?? new DateTime();
50 13
        $this->price = $price;
51 13
        $this->key = $key;
52 13
        $this->quantity = $quantity;
53 13
    }
54
55
    /**
56
     * @return the $maturity
57
     */
58 1
    public function getMaturity(): DateTime
59
    {
60 1
        return $this->maturity;
61
    }
62
63
    /**
64
     * @param \DateTime $maturity
65
     */
66 1
    public function setMaturity(DateTime $maturity)
67
    {
68 1
        $this->maturity = $maturity;
69 1
    }
70
71
    /**
72
     * @return the $price
73
     */
74 1
    public function getPrice(): float
75
    {
76 1
        return $this->price;
77
    }
78
79
    /**
80
     * @param float $price
81
     */
82 1
    public function setPrice(float $price)
83
    {
84 1
        $this->price = $price;
85 1
    }
86
87
    /**
88
     * @return int
89
     */
90 1
    public function getKey(): int
91
    {
92 1
        return $this->key;
93
    }
94
95
    /**
96
     * @param int $key
97
     */
98 1
    public function setKey(int $key = 0)
99
    {
100 1
        $this->key = (int) $key;
101 1
    }
102
103
    /**
104
     * @return int
105
     */
106 1
    public function getQuantity(): int
107
    {
108 1
        return $this->quantity;
109
    }
110
111
    /**
112
     * @param int $quantity
113
     */
114 1
    public function setQuantity(int $quantity = 1)
115
    {
116 1
        $this->quantity = $quantity;
117 1
    }
118
}
119