PHPackages                             labrodev/postal-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. labrodev/postal-formatter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

labrodev/postal-formatter
=========================

PHP utility library that provides robust formatting for European postal codes, following official formatting standards country-by-country.

v1.0.3(10mo ago)03MITPHPPHP &gt;=8.1

Since Jun 27Pushed 10mo agoCompare

[ Source](https://github.com/labrodev/postal-formatter)[ Packagist](https://packagist.org/packages/labrodev/postal-formatter)[ Docs](https://github.com/labrodev/postal-formatter)[ RSS](/packages/labrodev-postal-formatter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

PHP Postal Formatter
====================

[](#php-postal-formatter)

**Labrodev\\PostalFormatter** is a strict PHP 8.1+ utility library that provides robust formatting for European postal codes, following official formatting standards country-by-country.

Features
--------

[](#features)

- Cleans and standardizes postal codes (removes spaces, symbols, lowercases)
- Supports most of the **European countries** (45+ ISO 3166-1 alpha-2 codes)
- Automatically formats codes to the standard of each country (e.g. `12345` → `123 45` for CZ, `sw1a1aa` → `SW1A 1AA` for GB)
- Ready-to-go static formatter
- Fully typed with strict mode (`declare(strict_types=1)`)
- Includes PHPUnit and PHPStan support for testing and analysis

Installation
------------

[](#installation)

```
composer require labrodev/postal-formatter

```

Usage
-----

[](#usage)

```
use Labrodev\PostalFormatter\Utilities\PostalFormatter;

// Default usage: just clean and normalize
echo PostalFormatter::format(' 12345 '); // "12345"

// With country-specific formatting:
echo PostalFormatter::format('12345', 'CZ'); // "123 45"
echo PostalFormatter::format('sw1a1aa', 'GB'); // "SW1A 1AA"
echo PostalFormatter::format('1050', 'LV'); // "LV-1050"
```

List of available country codes you may find in CountryCode Enum (Labrodev/PostalFormatter/Enums/CountryCode).

Testing
-------

[](#testing)

To run tests:

```
composer install
composer test

```

Static Analysis
---------------

[](#static-analysis)

To run static analysis using PHPStan:

```
composer install
composer analyse

```

> Configuration is located in `phpstan.neon.dist`

Security
--------

[](#security)

If you discover a security vulnerability within this package, **please contact us immediately at **. All security-related issues will be handled privately and promptly.

Credits
-------

[](#credits)

This package is maintained by **Labrodev** — Laravel &amp; PHP development studio.

Feedback
--------

[](#feedback)

If you have any questions, suggestions, or have found an error — feel free to open an issue or contact us:
📬 ****

**License:** MIT

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance53

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

325d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b29c2afb9bfe2502125a5403436be931d78a8be09fffd77d4225664b1c13d7ed?d=identicon)[labrodev](/maintainers/labrodev)

---

Tags

helperlaravelphpphp-functionsphp-libraryphp-packagephp-toolsphp-utilityphp8postal-codespostalswebphphelperutilitytype-hintstaticstrict typeslabrodevpostal-formatter

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/labrodev-postal-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/labrodev-postal-formatter/health.svg)](https://phpackages.com/packages/labrodev-postal-formatter)
```

###  Alternatives

[zjkal/time-helper

一个简单快捷的PHP日期时间助手类库。 a smart PHP datetime helper library.

21128.6k1](/packages/zjkal-time-helper)[strictus/strictus

Strict Typing for local variables in PHP

1606.9k](/packages/strictus-strictus)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
