2017 © Pedro Peláez
 

library postcode

A library to format and validate postcodes

image

brick/postcode

A library to format and validate postcodes

  • Thursday, May 31, 2018
  • by BenMorel
  • Repository
  • 1 Watchers
  • 8 Stars
  • 106 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 108 % Grown

The README.md

Brick\Postcode

, (*1)

A PHP library to validate and format postcodes., (*2)

Build Status Coverage Status Latest Stable Version Total Downloads License, (*3)

Introduction

This library can format and validate postcodes for all countries having a postcode system., (*4)

Contributions are welcome, please feel free to open an issue or a pull request if you notice any mistake., (*5)

Installation

This library is installable via Composer:, (*6)

composer require brick/postcode

Requirements

This library requires PHP 8.1 or later., (*7)

Project status & release process

This library is still under development., (*8)

The current releases are numbered 0.x.y. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), y is incremented., (*9)

When a breaking change is introduced, a new 0.x version cycle is always started., (*10)

It is therefore safe to lock your project to a given release cycle, such as 0.5.*., (*11)

If you need to upgrade to a newer release cycle, check the release history for a list of changes introduced by each further 0.x.0 version., (*12)

How to use it

use Brick\Postcode\PostcodeFormatter;

$formatter = new PostcodeFormatter();

$formatter->format('GB', 'WC2E9RZ'); // WC2E 9RZ
$formatter->format('US', '337014313'); // 33701-4313

Notes

  • Postcodes are cleaned from optional separators (spaces and dashes) before validation. Misplaced or mismatched separators are not considered an error and will be ignored:, (*13)

    $formatter->format('GB', 'WC-2E9RZ'); // WC2E 9RZ
    
  • If format() is called with an unknown country code, an UnknownCountryException is thrown:, (*14)

    $formatter->format('XX', '12345'); // UnknownCountryException
    

    Note that a country with no postcode system is considered as unknown, even if the country code is a valid ISO 3166 code., (*15)

  • If format() is called with an invalid postcode for the given country, an InvalidPostcodeException is thrown:, (*16)

    $formatter->format('GB', 'ABCDEFG'); // InvalidPostcodeException
    

The Versions

31/05 2018

dev-master

9999999-dev

A library to format and validate postcodes

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

postcode brick

01/03 2018

0.2.1

0.2.1.0

A library to format and validate postcodes

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

postcode brick

26/01 2018

0.2.0

0.2.0.0

A library to format and validate postcodes

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

postcode brick

22/11 2017

0.1.1

0.1.1.0

A library to format and validate postcodes

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

postcode brick

22/11 2017

0.1.0

0.1.0.0

A library to format and validate postcodes

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

postcode brick