Completed
Push — master ( 688cd0...364e9f )
by Stefan
02:52
created

LabelMethod::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class LabelMethod implements NodeInterface
10
{
11
    const C_PRINT_AND_MAIL = '01'; // UPS prints the label and mails the label to the customer.
12
    const C_ONE_ATTEMPT    = '02'; // UPS driver makes 1 attempt to bring the package label to the pickup location and pickup the package.
13
    const C_THREE_ATTEMPT  = '03'; // UPS driver makes 3 attempt to bring the package label to the pickup location and pickup the package.
14
    const C_ELECTRONIC     = '04'; // UPS electronically notifiesx the custoemr via e-mail that a label and receipt are available.
15
    const C_PRINT          = '05'; // The shipper prints the label and the Import Control Customer Receipt and includes w/ outbound shipment.
16
17
    /**
18
     * @var string
19
     */
20
    private $code;
21
22
    /**
23
     * @var string
24
     */
25
    private $description;
26
27
    /**
28
     * @param null|object $attributes
29
     */
30 6 View Code Duplication
    public function __construct($attributes = null)
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...
31
    {
32 6
        if (null !== $attributes) {
33 4
            if (isset($attributes->Code)) {
34 4
                $this->setCode($attributes->Code);
35 4
            }
36 4
            if (isset($attributes->Description)) {
37 4
                $this->setDescription($attributes->Description);
38 4
            }
39 4
        }
40 6
    }
41
42
    /**
43
     * @param null|DOMDocument $document
44
     *
45
     * @return DOMElement
46
     */
47 2 View Code Duplication
    public function toNode(DOMDocument $document = null)
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...
48
    {
49 2
        if (null === $document) {
50
            $document = new DOMDocument();
51
        }
52
53 2
        $node = $document->createElement('LabelMethod');
54
55 2
        $code = $this->getCode();
56 2
        if (isset($code)) {
57 2
            $node->appendChild($document->createElement('Code', $code));
58 2
        }
59
60 2
        $description = $this->getDescription();
61 2
        if (isset($description)) {
62 2
            $node->appendChild($document->createElement('Description', $description));
63 2
        }
64
65 2
        return $node;
66
    }
67
68
    /**
69
     * @return string
70
     */
71 4
    public function getCode()
72
    {
73 4
        return $this->code;
74
    }
75
76
    /**
77
     * @param string $code
78
     *
79
     * @return $this
80
     */
81 5
    public function setCode($code)
82
    {
83 5
        $this->code = $code;
84
85 5
        return $this;
86
    }
87
88
    /**
89
     * @return string
90
     */
91 4
    public function getDescription()
92
    {
93 4
        return $this->description;
94
    }
95
96
    /**
97
     * @param string $description
98
     *
99
     * @return $this
100
     */
101 5
    public function setDescription($description)
102
    {
103 5
        $this->description = $description;
104
105 5
        return $this;
106
    }
107
}
108