Passed
Pull Request — master (#202)
by
unknown
02:45
created

ShipmentCharge::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ups\Entity;
4
5
use LogicException;
6
7
class ShipmentCharge
8
{
9
10
    const SHIPMENT_CHARGE_TYPE_TRANSPORTATION = '01';
11
    const SHIPMENT_CHARGE_TYPE_DUTIES = '02';
12
13
    const TYPE_BILL_SHIPPER = 'billShipper';
14
    const TYPE_BILL_RECEIVER = 'billReceiver';
15
    const TYPE_BILL_THIRD_PARTY = 'billThirdParty';
16
    const TYPE_CONSIGNEE_BILLED = 'consigneeBilled';
17
18
    /**
19
     * @var type
20
     */
21
    private $type;
22
23
    /**
24
     * @var billShipper
25
     */
26
    private $billShipper;
27
28
    /**
29
     * @var billReceiver
30
     */
31
    private $billReceiver;
32
33
    /**
34
     * @var BillThirdParty
35
     */
36
    private $billThirdParty;
37
38
    /**
39
     * @var bool
40
     */
41
    private $consigneeBilled;
42
43
    public function __construct($type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION, $bill_type = self::TYPE_BILL_SHIPPER, $attributes = null)
44
    {
45
        switch ($type) {
46
            case self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION:
47
                $this->type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION;
0 ignored issues
show
Documentation Bug introduced by
It seems like self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION of type string is incompatible with the declared type object<Ups\Entity\type> of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
                break;
49
            case self::SHIPMENT_CHARGE_TYPE_DUTIES:
50
                $this->type = self::SHIPMENT_CHARGE_TYPE_DUTIES;
0 ignored issues
show
Documentation Bug introduced by
It seems like self::SHIPMENT_CHARGE_TYPE_DUTIES of type string is incompatible with the declared type object<Ups\Entity\type> of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
51
                break;
52
            default:
53
                throw new LogicException(sprintf('Unknown ShipmentCharge charge type requested: "%s"', $type));
54
        }
55
56
        switch ($bill_type) {
57
            case self::TYPE_BILL_SHIPPER:
58
                $this->billShipper = new BillShipper($attributes);
59
                break;
60
/* TODO
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
            case self::TYPE_BILL_RECEIVER:
62
                $this->billReceiver = new BillReceiver($attributes);
63
                break;
64
*/
65
            case self::TYPE_BILL_THIRD_PARTY:
66
                $this->billThirdParty = new BillThirdParty($attributes);
67
                break;
68
            case self::TYPE_CONSIGNEE_BILLED:
69
                $this->consigneeBilled = true;
70
                break;
71
            default:
72
                throw new LogicException(sprintf('Unknown ShipmentCharge type requested: "%s"', $type));
73
        }
74
    }
75
76
    /**
77
     * @return BillShipper
78
     */
79
    public function getBillShipper()
80
    {
81
        return $this->billShipper;
82
    }
83
84
    /**
85
     * @param BillShipper $billShipper
86
     * @return ShipmentCharge
87
     */
88
    public function setBillShipper(BillShipper $billShipper= null)
89
    {
90
        $this->billShipper = $billShipper;
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return BillReceiver
97
     */
98
    public function getBillReceiver()
99
    {
100
        return $this->billReceiver;
101
    }
102
103
    /**
104
     * @param BillReceiver $billReceiver
105
     * @return ShipmentCharge
106
     */
107
    public function setBillReceiver(BillReceiver $billReceiver= null)
108
    {
109
        $this->billReceiver = $billReceiver;
110
111
        return $this;
112
    }
113
114
    /**
115
     * @return BillThirdParty
116
     */
117
    public function getBillThirdParty()
118
    {
119
        return $this->billThirdParty;
120
    }
121
122
    /**
123
     * @param BillThirdParty $billThirdParty
124
     * @return ShipmentCharge
125
     */
126
    public function setBillThirdParty(BillThirdParty $billThirdParty = null)
127
    {
128
        $this->billThirdParty = $billThirdParty;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @return bool
135
     */
136
    public function getConsigneeBilled()
137
    {
138
        return $this->consigneeBilled;
139
    }
140
141
    /**
142
     * @param bool $consigneeBilled
143
     * @return ShipmentCharge
144
     */
145
    public function setConsigneeBilled($consigneeBilled)
146
    {
147
        $this->consigneeBilled = $consigneeBilled;
148
149
        return $this;
150
    }
151
152
    /**
153
     * @return String
154
     */
155
    public function getType()
156
    {
157
        return $this->type;
158
    }
159
}
160