Item::price()   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 Item extends Model
6
{
7
    public $description;
8
    public $quantity;
9
    public $price;
10
    public $weight;
11
    public $item_id;
12
    public $origin_country;
13
    public $sku;
14
    public $hs_code;
15
16
    /**
17
     * @param string $value
18
     *
19
     * @return $this
20
     */
21
    public function description($value)
22
    {
23
        $this->description = strval($value);
24
25
        return $this;
26
    }
27
28
    /**
29
     * @param int $value
30
     *
31
     * @return $this
32
     */
33
    public function quantity($value)
34
    {
35
        $this->quantity = intval($value);
36
37
        return $this;
38
    }
39
40
    /**
41
     * @param Money $price
42
     *
43
     * @return $this
44
     */
45
    public function price(Money $price)
46
    {
47
        $this->price = $price;
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param Weight $weight
54
     *
55
     * @return $this
56
     */
57
    public function weight(Weight $weight)
58
    {
59
        $this->weight = $weight;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @param string $value
66
     *
67
     * @return $this
68
     */
69
    public function item_id($value)
70
    {
71
        $this->item_id = strval($value);
72
73
        return $this;
74
    }
75
76
    /**
77
     * @param $value
78
     *
79
     * @throws \Exception
80
     *
81
     * @return $this
82
     */
83 View Code Duplication
    public function origin_country($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
84
    {
85
        if (in_array($value, $this->acceptedCountries)) {
86
            $this->origin_country = $value;
87
        } else {
88
            $error = 'Country code invalid or not serviceable';
89
            throw new \Exception($error);
90
        }
91
92
        return $this;
93
    }
94
95
    /**
96
     * @param $value
97
     *
98
     * @return $this
99
     */
100
    public function sku($value)
101
    {
102
        $this->sku = strval($value);
103
104
        return $this;
105
    }
106
107
    /**
108
     * @param $value
109
     *
110
     * @return $this
111
     */
112
    public function hs_code($value)
113
    {
114
        $this->hs_code = strval($value);
115
116
        return $this;
117
    }
118
}
119