Passed
Pull Request — master (#202)
by
unknown
04:39 queued 01:35
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
    const SHIPMENT_CHARGE_TYPE_TRANSPORTATION = '01';
10
    const SHIPMENT_CHARGE_TYPE_DUTIES = '02';
11
12
    const TYPE_BILL_SHIPPER = 'billShipper';
13
    const TYPE_BILL_RECEIVER = 'billReceiver';
14
    const TYPE_BILL_THIRD_PARTY = 'billThirdParty';
15
    const TYPE_CONSIGNEE_BILLED = 'consigneeBilled';
16
17
    /**
18
     * @var type
19
     */
20
    private $type;
21
22
    /**
23
     * @var billShipper
24
     */
25
    private $billShipper;
26
27
    /**
28
     * @var billReceiver
29
     */
30
    private $billReceiver;
31
32
    /**
33
     * @var BillThirdParty
34
     */
35
    private $billThirdParty;
36
37
    /**
38
     * @var bool
39
     */
40
    private $consigneeBilled;
41
42
    public function __construct($type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION, $bill_type = self::TYPE_BILL_SHIPPER, $attributes = null)
43
    {
44
        switch ($type) {
45
            case self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION:
46
                $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...
47
                break;
48
            case self::SHIPMENT_CHARGE_TYPE_DUTIES:
49
                $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...
50
                break;
51
            default:
52
                throw new LogicException(sprintf('Unknown ShipmentCharge charge type requested: "%s"', $type));
53
        }
54
55
        switch ($bill_type) {
56
            case self::TYPE_BILL_SHIPPER:
57
                $this->billShipper = new BillShipper($attributes);
58
                break;
59
/* 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...
60
            case self::TYPE_BILL_RECEIVER:
61
                $this->billReceiver = new BillReceiver($attributes);
62
                break;
63
*/
64
            case self::TYPE_BILL_THIRD_PARTY:
65
                $this->billThirdParty = new BillThirdParty($attributes);
66
                break;
67
            case self::TYPE_CONSIGNEE_BILLED:
68
                $this->consigneeBilled = true;
69
                break;
70
            default:
71
                throw new LogicException(sprintf('Unknown ShipmentCharge type requested: "%s"', $type));
72
        }
73
    }
74
75
    /**
76
     * @return BillShipper
77
     */
78
    public function getBillShipper()
79
    {
80
        return $this->billShipper;
81
    }
82
83
    /**
84
     * @param BillShipper $billShipper
85
     * @return ShipmentCharge
86
     */
87
    public function setBillShipper(BillShipper $billShipper= null)
88
    {
89
        $this->billShipper = $billShipper;
90
91
        return $this;
92
    }
93
94
    /**
95
     * @return BillReceiver
96
     */
97
    public function getBillReceiver()
98
    {
99
        return $this->billReceiver;
100
    }
101
102
    /**
103
     * @param BillReceiver $billReceiver
104
     * @return ShipmentCharge
105
     */
106
    public function setBillReceiver(BillReceiver $billReceiver= null)
107
    {
108
        $this->billReceiver = $billReceiver;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @return BillThirdParty
115
     */
116
    public function getBillThirdParty()
117
    {
118
        return $this->billThirdParty;
119
    }
120
121
    /**
122
     * @param BillThirdParty $billThirdParty
123
     * @return ShipmentCharge
124
     */
125
    public function setBillThirdParty(BillThirdParty $billThirdParty = null)
126
    {
127
        $this->billThirdParty = $billThirdParty;
128
129
        return $this;
130
    }
131
132
    /**
133
     * @return bool
134
     */
135
    public function getConsigneeBilled()
136
    {
137
        return $this->consigneeBilled;
138
    }
139
140
    /**
141
     * @param bool $consigneeBilled
142
     * @return ShipmentCharge
143
     */
144
    public function setConsigneeBilled($consigneeBilled)
145
    {
146
        $this->consigneeBilled = $consigneeBilled;
147
148
        return $this;
149
    }
150
151
    /**
152
     * @return String
153
     */
154
    public function getType()
155
    {
156
        return $this->type;
157
    }
158
}
159