1
|
|
|
<?php namespace SimpleUPS\AddressValidate; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @since 1.0 |
5
|
|
|
*/ |
6
|
|
|
class Address extends \SimpleUPS\InstructionalAddress |
7
|
|
|
{ |
8
|
|
|
protected $CLASSIFICATION_UNKNOWN = 0; |
9
|
|
|
|
10
|
|
|
protected $CLASSIFICATION_COMMERCIAL = 1; |
11
|
|
|
|
12
|
|
|
protected $CLASSIFICATION_RESIDENTIAL = 2; |
13
|
|
|
|
14
|
|
|
private $classification; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @internal |
18
|
|
|
* |
19
|
|
|
* @param integer $classification |
20
|
|
|
* |
21
|
|
|
* @return Address |
22
|
|
|
*/ |
23
|
|
|
public function setClassification($classification) |
24
|
|
|
{ |
25
|
|
|
$this->classification = (int)$classification; |
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The classification of a given address by UPS |
31
|
|
|
* @internal |
32
|
|
|
* @return integer |
33
|
|
|
*/ |
34
|
|
|
public function getClassification() |
35
|
|
|
{ |
36
|
|
|
return $this->classification; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Determine if the address is a commercial location |
41
|
|
|
* It is possible for an address to be "Unknown", meaning it will not be |
42
|
|
|
* either Commercial or Residential. |
43
|
|
|
* This method is only usable when this object is supplied by the |
44
|
|
|
* address validation methods. |
45
|
|
|
* @see \SimpleUPS\AddressValidate\Address::isResidential() |
46
|
|
|
* @see \SimpleUPS\UPS::isValidAddress() |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
|
|
public function isCommercial() |
50
|
|
|
{ |
51
|
|
|
return $this->getClassification() == $this->CLASSIFICATION_COMMERCIAL; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Determine if the address is a residential location. |
56
|
|
|
* It is possible for an address to be "Unknown", meaning it will not be |
57
|
|
|
* either Commercial or Residential. |
58
|
|
|
* This method is only usable when this object is supplied by the |
59
|
|
|
* address validation methods. |
60
|
|
|
* @see \SimpleUPS\AddressValidate\Address::isCommercial() |
61
|
|
|
* @see \SimpleUPS\UPS::isValidAddress() |
62
|
|
|
* @return bool |
63
|
|
|
*/ |
64
|
|
|
public function isResidential() |
65
|
|
|
{ |
66
|
|
|
return $this->getClassification() == $this->CLASSIFICATION_RESIDENTIAL; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|