PHP code example of cdburgess / addressing-standards

1. Go to this page and download the library: Download cdburgess/addressing-standards 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/ */

    

cdburgess / addressing-standards example snippets


use Cdburgess\AddressingStandards\Address;

$address = Address::normalize(
    "123 south main street apt 4b\nspringfield va 22162"
);

echo $address->deliveryAddressLine(); // 123 S MAIN ST APT 4B
echo $address->lastLine();            // SPRINGFIELD VA 22162
echo $address->toBlock();

use Cdburgess\AddressingStandards\Contracts\AddressNormalizer;

$normalizer = app(AddressNormalizer::class);
$address = $normalizer->normalize([...]);

use Cdburgess\AddressingStandards\Address;

$address = Address::normalize([
    'street_line' => '456 North Oak Avenue Suite 200',
    'city'        => 'Richmond',
    'state'       => 'Virginia',
    'zip'         => '23219-1234',
]);

$report = $address->completenessReport();

// [
//     'is_complete' => true,
//     'is_fully_qualified' => true,
//     'has_incomplete_secondary' => false,
//     'missing' => [],
//     'corrections' => [
//         ['field' => 'state', 'from' => 'Virginia', 'to' => 'VA'],
//     ],
// ]
bash
php artisan vendor:publish --tag=addressing-standards-config