|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Nickcheek\USPSLookup\Service; |
|
4
|
|
|
|
|
5
|
|
|
use Nickcheek\USPSLookup\USPSLookup; |
|
6
|
|
|
|
|
7
|
|
|
class Address extends USPSLookup |
|
8
|
|
|
{ |
|
9
|
|
|
public function __construct(){} |
|
10
|
|
|
|
|
11
|
|
|
public static function Verify($address,$address2,$city,$state,$zip) |
|
12
|
|
|
{ |
|
13
|
|
|
$Address = new \SimpleXMLElement("<AddressValidateRequest></AddressValidateRequest>"); |
|
14
|
|
|
$Address->addAttribute('USERID', self::$user); |
|
15
|
|
|
$Revision = $Address->addChild('Revision','1'); |
|
|
|
|
|
|
16
|
|
|
$add = $Address->addChild('Address'); |
|
17
|
|
|
$add->addAttribute('ID', '0'); |
|
18
|
|
|
$a1 = $add->addChild('Address1',$address); |
|
|
|
|
|
|
19
|
|
|
$a2 = $add->addChild('Address2',$address2); |
|
|
|
|
|
|
20
|
|
|
$c = $add->addChild('City',$city); |
|
|
|
|
|
|
21
|
|
|
$s = $add->addChild('State',$state); |
|
|
|
|
|
|
22
|
|
|
$z1 = $add->addChild('Zip5',$zip); |
|
|
|
|
|
|
23
|
|
|
$z2 = $add->addChild('Zip4'); |
|
|
|
|
|
|
24
|
|
|
$url = self::$service . 'Verify&XML='.$Address->asXML(); |
|
25
|
|
|
$response = simplexml_load_file($url); |
|
26
|
|
|
return $response; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public static function CityState($zip) |
|
30
|
|
|
{ |
|
31
|
|
|
$CityState = new \SimpleXMLElement("<CityStateLookupRequest></CityStateLookupRequest>"); |
|
32
|
|
|
$CityState->addAttribute('USERID', self::$user); |
|
33
|
|
|
$ZipCode = $CityState->addChild('ZipCode'); |
|
34
|
|
|
$ZipCode->addAttribute('ID', '0'); |
|
35
|
|
|
$Zip = $ZipCode->addChild('Zip5',$zip); |
|
|
|
|
|
|
36
|
|
|
$url = self::$service.'CityStateLookup&XML='.$CityState->asXML(); |
|
37
|
|
|
$response = simplexml_load_file($url); |
|
38
|
|
|
return $response; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public static function CityStateMultiple($zip) |
|
42
|
|
|
{ |
|
43
|
|
|
$CityState = new \SimpleXMLElement("<CityStateLookupRequest></CityStateLookupRequest>"); |
|
44
|
|
|
$CityState->addAttribute('USERID', self::$user); |
|
45
|
|
|
|
|
46
|
|
|
foreach($zip as $k=>$z){ |
|
47
|
|
|
$ZipCode = $CityState->addChild('ZipCode'); |
|
48
|
|
|
$ZipCode->addAttribute('ID', $k); |
|
49
|
|
|
$Zip = $ZipCode->addChild('Zip5',$z); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
$url = self::$service . 'CityStateLookup&XML='.$CityState->asXML(); |
|
53
|
|
|
$response = simplexml_load_file($url); |
|
54
|
|
|
return $response; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public static function ZipCode($address,$address2,$city,$state) |
|
58
|
|
|
{ |
|
59
|
|
|
$Address = new \SimpleXMLElement("<ZipCodeLookupRequest></ZipCodeLookupRequest>"); |
|
60
|
|
|
$Address->addAttribute('USERID', self::$user); |
|
61
|
|
|
$add = $Address->addChild('Address'); |
|
62
|
|
|
$add->addAttribute('ID', '0'); |
|
63
|
|
|
$a1 = $add->addChild('Address1',$address); |
|
|
|
|
|
|
64
|
|
|
$a2 = $add->addChild('Address2',$address2); |
|
|
|
|
|
|
65
|
|
|
$c = $add->addChild('City',$city); |
|
|
|
|
|
|
66
|
|
|
$s = $add->addChild('State',$state); |
|
|
|
|
|
|
67
|
|
|
$url = self::$service . 'ZipCodeLookup&XML='.$Address->asXML(); |
|
68
|
|
|
$response = simplexml_load_file($url); |
|
69
|
|
|
return $response; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.