Handles and formats swedish personnummer

v2.0 2018-02-06 10:35 UTC

This package is auto-updated.

Last update: 2024-10-27 23:33:26 UTC


README

This package let's you format Swedish national identification numbers.

Install

Via Composer

$ composer require adaptivemedia/pnr

Usage

require_once 'vendor/autoload.php';

// Short format...
$pnr = '198306030217';
$pnrService = new SwedishPersonalNumber($pnr);
$formattedIdentificationNumber = $pnrService->format(); // 830603-0217

// Long format...
$formatter = SwedishPersonalNumber::FORMAT_LONG;
$pnrService = new SwedishPersonalNumber('830603-0217', new $formatter);

$formattedIdentificationNumber = $pnrService->format(); // 19830603-0217

Testing

$ phpunit

License

The MIT License (MIT). Please see License File for more information.