Accessorial   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 71
loc 71
rs 10
wmc 5
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setCode() 5 5 1
A getCode() 4 4 1
A setDescription() 5 5 1
A getDescription() 4 4 1
A fromXml() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace SimpleUPS\Track\SmallPackage;
2
3
/**
4
 * @since 1.0
5
 */
6 View Code Duplication
class Accessorial extends \SimpleUPS\Model
0 ignored issues
show
Duplication introduced by
This class 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...
7
{
8
9
    private
10
        /* @var string $code */
11
        $code,
12
13
        /* @var string $description */
14
        $description;
15
16
    /**
17
     * @internal
18
     *
19
     * @param string $code
20
     *
21
     * @return Accessorial
22
     */
23
    public function setCode($code)
24
    {
25
        $this->code = (string)$code;
26
        return $this;
27
    }
28
29
    /**
30
     * The code indicating accessorial for a given UPS World Wide Express Shipment.
31
     * @return string
32
     */
33
    public function getCode()
34
    {
35
        return $this->code;
36
    }
37
38
    /**
39
     * @internal
40
     *
41
     * @param string $description
42
     *
43
     * @return Accessorial
44
     */
45
    public function setDescription($description)
46
    {
47
        $this->description = (string)$description;
48
        return $this;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getDescription()
55
    {
56
        return $this->description;
57
    }
58
59
    /**
60
     * @internal
61
     *
62
     * @param \SimpleXMLElement $xml
63
     *
64
     * @return Accessorial
65
     */
66
    public static function fromXml(\SimpleXMLElement $xml)
67
    {
68
        $accessorial = new Accessorial();
69
        $accessorial->setIsResponse();
70
        $accessorial
71
            ->setCode($xml->Code)
72
            ->setDescription($xml->Description);
73
74
        return $accessorial;
75
    }
76
}