Package   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 4
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setWeight() 0 15 3
A getWeight() 0 4 1
1
<?php
2
3
/**
4
 *
5
 */
6
namespace SimpleUPS;
7
8
/**
9
 * @internal
10
 * @since 1.0
11
 */
12
class Package extends \SimpleUPS\Model
13
{
14
    private
15
        /* @var Weight $weight */
16
        $weight;
17
18
    /**
19
     * Set the weight of this package
20
     *
21
     * @param Float|Weight $weight
22
     *
23
     * @return Package
24
     */
25
    public function setWeight($weight)
26
    {
27
        if (is_numeric($weight)) {
28
            $weightObject = new Weight();
29
            $weightObject->setWeight($weight);
30
            $weight = $weightObject;
31
        } else {
32
            if (!($weight instanceOf Weight)) {
33
                throw new \Exception('Weight must either be numeric or an instance of \SimpleUPS\Weight');
34
            }
35
        }
36
37
        $this->weight = $weight;
38
        return $this;
39
    }
40
41
    /**
42
     * Get weight of package
43
     * @return Weight
44
     */
45
    public function getWeight()
46
    {
47
        return $this->weight;
48
    }
49
}