All Projects → brick → postcode

brick / postcode

Licence: MIT license
A PHP library to validate and format postcodes

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to postcode

Node Format Microformat
Formats a Microformat JSON representation into eg. a Jekyll post
Stars: ✭ 11 (-81.97%)
Mutual labels:  formatting
Lint Action
✨ GitHub Action for detecting and auto-fixing lint errors
Stars: ✭ 161 (+163.93%)
Mutual labels:  formatting
Nginx Config Formatter
nginx config file formatter/beautifier written in Python.
Stars: ✭ 222 (+263.93%)
Mutual labels:  formatting
Vse Formatdocumentonsave
Visual Studio - Format Document on Save
Stars: ✭ 61 (+0%)
Mutual labels:  formatting
Fmt
A modern formatting library
Stars: ✭ 12,698 (+20716.39%)
Mutual labels:  formatting
Cmt
Write consistent git commit messages based on a custom template
Stars: ✭ 179 (+193.44%)
Mutual labels:  formatting
Intl Tel Input
A JavaScript plugin for entering and validating international telephone numbers
Stars: ✭ 5,963 (+9675.41%)
Mutual labels:  formatting
idea-uroborosql-formatter
Beautiful SQL Formatter for IntelliJ Platform
Stars: ✭ 18 (-70.49%)
Mutual labels:  formatting
Autohooks
Library for managing git hooks
Stars: ✭ 126 (+106.56%)
Mutual labels:  formatting
Juliaformatter.jl
An opinionated code formatter for Julia. Plot twist - the opinion is your own.
Stars: ✭ 217 (+255.74%)
Mutual labels:  formatting
Swiftymarkdown
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
Stars: ✭ 1,274 (+1988.52%)
Mutual labels:  formatting
Editorconfig Netbeans
A NetBeans IDE plugin supporting the EditorConfig standard. ⛺
Stars: ✭ 123 (+101.64%)
Mutual labels:  formatting
Grandcentrix Androidcodestyle
Android code style settings for Android Studio at grandcentrix
Stars: ✭ 203 (+232.79%)
Mutual labels:  formatting
Clc
Tiny bash utility for coloring terminal output and prompt
Stars: ✭ 58 (-4.92%)
Mutual labels:  formatting
Sublime-uroboroSQL-formatter
Beautiful SQL Formatter for Sublime Text 3
Stars: ✭ 25 (-59.02%)
Mutual labels:  formatting
Numbro
A JS library for number formatting
Stars: ✭ 790 (+1195.08%)
Mutual labels:  formatting
Textwrap
An efficient and powerful Rust library for word wrapping text.
Stars: ✭ 164 (+168.85%)
Mutual labels:  formatting
slackdown
A simple Slack message text formatting to HTML code converter.
Stars: ✭ 27 (-55.74%)
Mutual labels:  formatting
leveldb-cli
CLI for LevelDB
Stars: ✭ 86 (+40.98%)
Mutual labels:  formatting
Bluestyle
A Julia style guide that lives in a blue world
Stars: ✭ 210 (+244.26%)
Mutual labels:  formatting

Brick\Postcode

A PHP library to validate and format postcodes.

Build Status Coverage Status Latest Stable Version Total Downloads License

Introduction

This library can format and validate postcodes for all countries having a postcode system.

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

Installation

This library is installable via Composer:

composer require brick/postcode

Requirements

This library requires PHP 7.1 or later.

Project status & release process

This library is still under development.

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.

When a breaking change is introduced, a new 0.x version cycle is always started.

It is therefore safe to lock your project to a given release cycle, such as 0.2.*.

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.

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:

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

    $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.

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

    $formatter->format('GB', 'ABCDEFG'); // InvalidPostcodeException
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].