Skip to content

Commit b22a4cf

Browse files
committed
Re-organised Namespace
1 parent 37644bc commit b22a4cf

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
namespace Dfcplc\PostcodeAnywhere\InternationalBankValidation;
3+
4+
class Validate
5+
{
6+
7+
//Credit: Thanks to Stuart Sillitoe (http://stu.so/me) for the original PHP that these samples are based on.
8+
9+
private $Key; //The key to use to authenticate to the service.
10+
private $IBAN; //The international bank account number to validate.
11+
private $Data; //Holds the results of the query
12+
13+
public function __construct($Key, $IBAN)
14+
{
15+
$this->Key = $Key;
16+
$this->IBAN = $IBAN;
17+
}
18+
19+
public function MakeRequest()
20+
{
21+
$url = "http://services.postcodeanywhere.co.uk/InternationalBankValidation/Interactive/Validate/v1.00/xmla.ws?";
22+
$url .= "&Key=" . urlencode($this->Key);
23+
$url .= "&IBAN=" . urlencode($this->IBAN);
24+
25+
//Make the request to Postcode Anywhere and parse the XML returned
26+
$file = simplexml_load_file($url);
27+
28+
//Check for an error, if there is one then throw an exception
29+
if ($file->Columns->Column->attributes()->Name == "Error")
30+
{
31+
throw new Exception("[ID] " . $file->Rows->Row->attributes()->Error . " [DESCRIPTION] " . $file->Rows->Row->attributes()->Description . " [CAUSE] " . $file->Rows->Row->attributes()->Cause . " [RESOLUTION] " . $file->Rows->Row->attributes()->Resolution);
32+
}
33+
34+
//Copy the data
35+
if ( !empty($file->Rows) )
36+
{
37+
foreach ($file->Rows->Row as $item)
38+
{
39+
$this->Data[] = array('IsCorrect'=>$item->attributes()->IsCorrect);
40+
}
41+
}
42+
}
43+
44+
public function HasData()
45+
{
46+
if ( !empty($this->Data) )
47+
{
48+
return $this->Data;
49+
}
50+
return false;
51+
}
52+
}

src/Dfcplc/PostcodeAnywhere/Lookup.php renamed to src/Dfcplc/PostcodeAnywhere/PostcodeAnywhere/Find.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Dfcplc\PostcodeAnywhere;
2+
namespace Dfcplc\PostcodeAnywhere\PostcodeAnywhere;
33

44
class Lookup
55
{

src/Dfcplc/PostcodeAnywhere/FindByParts.php renamed to src/Dfcplc/PostcodeAnywhere/PostcodeAnywhere/FindByParts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Dfcplc\PostcodeAnywhere;
2+
namespace Dfcplc\PostcodeAnywhere\PostcodeAnywhere;
33

44
class FindByParts
55
{

src/Dfcplc/PostcodeAnywhere/Retrieve.php renamed to src/Dfcplc/PostcodeAnywhere/PostcodeAnywhere/Retrieve.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Dfcplc\PostcodeAnywhere;
2+
namespace Dfcplc\PostcodeAnywhere\PostcodeAnywhere;
33

44
class Retrieve
55
{

0 commit comments

Comments
 (0)