Activity::setAddress()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 9.4285
1
<?php namespace SimpleUPS\Track\SmallPackage;
2
3
use \SimpleUPS\Address;
4
5
/**
6
 * A record of activity on a package
7
 * @since 1.0
8
 */
9
class Activity extends \SimpleUPS\Model
10
{
11
    private
12
        /* @var \SimpleUPS\Address $address */
13
        $address,
14
        /* @var string $locationCode */
15
        $locationCode,
16
17
        /* @var string $locationDescription */
18
        $locationDescription,
19
        /* @var string $signedForBy */
20
        $signedForBy,
21
22
        /* @var StatusType $statusType */
23
        $statusType,
24
        /* @var string $statusCode */
25
        $statusCode,
26
27
        /* @var \DateTime $timestamp */
28
        $timestamp;
29
30
    /**
31
     * @internal
32
     *
33
     * @param \SimpleUPS\Address $address
34
     *
35
     * @return Activity
36
     */
37
    public function setAddress(Address $address)
38
    {
39
        $this->address = $address;
40
        return $this;
41
    }
42
43
    /**
44
     * Location for this activity
45
     * @return \SimpleUPS\Address
46
     */
47
    public function getAddress()
48
    {
49
        return $this->address;
50
    }
51
52
    /**
53
     * @internal
54
     *
55
     * @param string $statusCode
56
     *
57
     * @return Activity
58
     */
59
    public function setStatusCode($statusCode)
60
    {
61
        $this->statusCode = (string)$statusCode;
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getStatusCode()
69
    {
70
        return $this->statusCode;
71
    }
72
73
    /**
74
     * @internal
75
     *
76
     * @param StatusType $statusType
77
     *
78
     * @return Activity
79
     */
80
    public function setStatusType(StatusType $statusType)
81
    {
82
        $this->statusType = $statusType;
83
        return $this;
84
    }
85
86
    /**
87
     * Status type of an activity
88
     * @return StatusType
89
     */
90
    public function getStatusType()
91
    {
92
        return $this->statusType;
93
    }
94
95
    /**
96
     * @internal
97
     *
98
     * @param \DateTime $timestamp
99
     *
100
     * @return Activity
101
     */
102
    public function setTimestamp(\DateTime $timestamp)
103
    {
104
        $this->timestamp = $timestamp;
105
        return $this;
106
    }
107
108
    /**
109
     * When activity took place
110
     * @return \DateTime
111
     */
112
    public function getTimestamp()
113
    {
114
        return $this->timestamp;
115
    }
116
117
    /**
118
     * @internal
119
     *
120
     * @param string $locationCode
121
     *
122
     * @return Activity
123
     */
124
    public function setLocationCode($locationCode)
125
    {
126
        $this->locationCode = (string)$locationCode;
127
        return $this;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    public function getLocationCode()
134
    {
135
        return $this->locationCode;
136
    }
137
138
    /**
139
     * @internal
140
     *
141
     * @param string $locationDescription
142
     *
143
     * @return Activity
144
     */
145
    public function setLocationDescription($locationDescription)
146
    {
147
        $this->locationDescription = (string)$locationDescription;
148
        return $this;
149
    }
150
151
    /**
152
     * @return string
153
     */
154
    public function getLocationDescription()
155
    {
156
        return $this->locationDescription;
157
    }
158
159
    /**
160
     * @internal
161
     *
162
     * @param string $signedForBy
163
     *
164
     * @return Activity
165
     */
166
    public function setSignedForBy($signedForBy)
167
    {
168
        $this->signedForBy = (string)$signedForBy;
169
        return $this;
170
    }
171
172
    /**
173
     * Name of the person who signed
174
     * @return string|null
175
     */
176
    public function getSignedForBy()
177
    {
178
        return $this->signedForBy;
179
    }
180
181
    /**
182
     * @internal
183
     *
184
     * @param \SimpleXMLElement $xml
185
     *
186
     * @return Activity
187
     */
188
    public static function fromXml(\SimpleXMLElement $xml)
189
    {
190
        $activity = new Activity();
191
        $activity->setIsResponse();
192
193
        if (isset($xml->ActivityLocation->Code)) {
194
            $activity->setLocationCode($xml->ActivityLocation->Code);
195
        }
196
197
        if (isset($xml->ActivityLocation->Description)) {
198
            $activity->setLocationDescription($xml->ActivityLocation->Description);
199
        }
200
201
        if (isset($xml->ActivityLocation->SignedForByName)) {
202
            $activity->setSignedForBy($xml->ActivityLocation->SignedForByName);
203
        }
204
205
        if (isset($xml->Date) && isset($xml->Time)) {
206
            $activity->setTimestamp(new \DateTime($xml->Date . ' ' . $xml->Time));
207
        }
208
209
        if (isset($xml->Status->StatusType)) {
210
            $activity->setStatusType(StatusType::fromXml($xml->Status->StatusType));
211
        }
212
213
        if (isset($xml->Status->StatusCode)) {
214
            $activity->setStatusCode($xml->Status->StatusCode->Code);
215
        }
216
217
        if (isset($xml->ActivityLocation->Address)) {
218
            $activity->setAddress(Address::fromXml($xml->ActivityLocation->Address));
219
        }
220
221
        return $activity;
222
    }
223
}