public function test_it_can_validate_an_invalid_postcodeproto_object()
 {
     $postcodeUtil = new PostcodeUtil();
     $proto = $this->getMockBuilder('gdragffy\\libpostcode\\PostcodeProto')->getMock();
     $proto->method('getPostcode')->willReturn('12345');
     $proto->method('getCountryCode')->willReturn('GE');
     $proto->method('getValidationRegex')->willReturn('\\d{4}');
     $this->assertFalse($postcodeUtil->isValidPostcode($proto));
     $proto->method('getPostcode')->willReturn('abcd');
     $this->assertFalse($postcodeUtil->isValidPostcode($proto));
     $proto->method('getPostcode')->willReturn('123');
     $this->assertFalse($postcodeUtil->isValidPostcode($proto));
 }
<?php

require __DIR__ . "/../vendor/autoload.php";
use gdragffy\libpostcode\PostcodeUtil;
# Adding something to POST array to simulate user form submission
$_POST = array('postcode' => 'BH11 5XB', 'country_code' => 'GB');
$postcode = $_POST['postcode'];
$countryCode = $_POST['country_code'];
$postcodeUtil = new PostcodeUtil();
$postcodeProto = $postcodeUtil->parse($postcode, $countryCode);
if ($postcodeUtil->isValidPostcode($postcodeProto)) {
    echo "The postcode is valid. So do something here.";
} else {
    echo "The postcode is not valid for the given country. Do something else here.";
}