for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace IsoCodes;
/**
* Class Abn, Australian Business Number
*
* @link https://en.wikipedia.org/wiki/Australian_Business_Number
* @link https://abr.business.gov.au/
*/
class Abn implements IsoCodeInterface
{
* Validate an Australian Business Number (ABN)
* @author Paul Ferrett, 2009 (http://www.paulferrett.com)
* @param string $abn
* @return bool
public static function validate($abn)
$weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
$sum = 0;
$abn = preg_replace('/[^0-9]/', '', $abn);
$abn = Utils::unDecorate($abn, [' ']);
if (mb_strlen($abn) !== 11) {
return false;
}
$abn[0] = ((int)$abn[0] - 1); // Subtract one from first digit
foreach (str_split($abn) as $key => $digit) {
$sum += ($digit * $weights[$key]);
if (($sum % 89) != 0) {
return true;