1. Go to this page and download the library: Download hyraiq/abnlookup library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hyraiq / abnlookup example snippets
class VerifyAbnController extends AbtractController
{
public function __construct(
private AbnClientInterface $abnClient,
) {
}
// ...
}
use Hyra\AbnLookup\Dependencies;
use Hyra\AbnLookup\AbnClient;
$abrGuid = '<insert your ABR GUID here>'
// Whichever http client you choose
$httpClient = new HttpClient();
$denormalizer = Dependencies::serializer();
$validator = Dependencies::validator();
$abnClient = new AbnClient($denormalizer, $validator, $httpClient, $abrGuid);
use Hyra\AbnLookup\Stubs\AbnFaker;
use Hyra\AbnLookup\Stubs\StubAbnClient;
$stubClient = new StubAbnClient();
$stubClient->lookupAbn(AbnFaker::invalidAbn()); // InvalidAbnException - Note, the stub still uses the validator
$stubClient->lookupAbn(AbnFaker::validAbn()); // LogicException - You need to tell the stub how to respond to specific queries
$abn = AbnFaker::validAbn();
$stubClient->addNotFoundAbns($abn);
$stubClient->lookupAbn($abn); // AbnNotFoundException
$abn = AbnFaker::validAbn();
$mockResponse = new AbnResponse();
$response->abn = $abn;
$response->abnStatus = 'active';
$response->abnStatusEffectiveFrom = new \DateTimeImmutable('2 years ago');
$response->entityTypeCode = 'PRV';
$response->entityTypeName = 'Australian Private Company';
$stubClient->addMockResponse($mockResponse);
$abnResponse = $stubClient->lookupAbn($abn); // $abnResponse === $mockResponse
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.