Completed
Pull Request — master (#86)
by
unknown
03:35
created

Translate::getLocale()   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 2
Bugs 0 Features 0
Metric Value
c 2
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 Ups\NodeInterface;
7
8
/**
9
 * Class Translate
10
 * @package Ups\Entity
11
 */
12
class Translate implements NodeInterface
13
{
14
    /**
15
     * @deprecated
16
     */
17
    public $LanguageCode;
18
19
    /**
20
     * @deprecated
21
     */
22
    public $DialectCode;
23
24
    /**
25
     * @deprecated
26
     */
27
    public $Code;
28
29
    /**
30
     * @var string
31
     */
32
    private $languageCode;
33
34
    /**
35
     * @var string
36
     */
37
    private $dialectCode;
38
39
    /**
40
     * @var string
41
     */
42
    private $code;
43
44
    /**
45
     * @var string
46
     */
47
    private $locale;
48
49
    /**
50
     * @param null $response
51
     */
52 1
    public function __construct($response = null)
53
    {
54 1
        if (null != $response) {
55
            if (isset($response->LanguageCode)) {
56
                $this->setLanguageCode($response->LanguageCode);
57
            }
58
            if (isset($response->DialectCode)) {
59
                $this->setDialectCode($response->DialectCode);
60
            }
61
            if (isset($response->Code)) {
62
                $this->setCode($response->Code);
63
            }
64
            if (isset($response->Locale)) {
65
                $this->setLocale($response->Locale);
66
            }
67
        }
68 1
    }
69
70
    /**
71
     * @param DOMDocument|null $document
72
     * @return \DOMElement
73
     */
74 1
    public function toNode(DOMDocument $document = null)
75
    {
76 1
        if (null === $document) {
77
            $document = new DOMDocument();
78
        }
79
80 1
        $node = $document->createElement('Translate');
81
82 1
        $node->appendChild($document->createElement('LanguageCode', $this->getLanguageCode()));
83
84 1
        if ($this->getCode()) {
85
            $node->appendChild($document->createElement('Code', $this->getCode()));
86
        }
87
88 1
        if ($this->getDialectCode()) {
89
            $node->appendChild($document->createElement('DialectCode', $this->getDialectCode()));
90
        }
91
92 1
        if ($this->getLocale()) {
93
            $node->appendChild($document->createElement('Locale', $this->getLocale()));
94
        }
95
96 1
        return $node;
97
    }
98
99
    /**
100
     * @return string|null
101
     */
102 1
    public function getLanguageCode()
103
    {
104 1
        return $this->languageCode;
105
    }
106
107
    /**
108
     * @param mixed $languageCode
109
     */
110 1
    public function setLanguageCode($languageCode)
111
    {
112 1
        $this->LanguageCode = $languageCode;
0 ignored issues
show
Deprecated Code introduced by
The property Ups\Entity\Translate::$LanguageCode has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
113 1
        $this->languageCode = $languageCode;
114 1
    }
115
116
    /**
117
     * @return string|null
118
     */
119 1
    public function getDialectCode()
120
    {
121 1
        return $this->dialectCode;
122
    }
123
124
    /**
125
     * @param mixed $dialectCode
126
     */
127
    public function setDialectCode($dialectCode)
128
    {
129
        $this->DialectCode = $dialectCode;
0 ignored issues
show
Deprecated Code introduced by
The property Ups\Entity\Translate::$DialectCode has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
130
        $this->dialectCode = $dialectCode;
131
    }
132
133
    /**
134
     * @return null|string
135
     */
136 1
    public function getCode()
137
    {
138 1
        return $this->code;
139
    }
140
141
    /**
142
     * @param mixed $code
143
     */
144
    public function setCode($code)
145
    {
146
        $this->Code = $code;
0 ignored issues
show
Deprecated Code introduced by
The property Ups\Entity\Translate::$Code has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
147
        $this->code = $code;
148
    }
149
150
    /**
151
     * @return null|string
152
     */
153 1
    public function getLocale()
154
    {
155 1
        return $this->locale;
156
    }
157
158
    /**
159
     * @param mixed $locale
160
     */
161
    public function setLocale($locale)
162
    {
163
        $this->locale = $locale;
164
    }
165
}
166