2017 © Pedro PelĂĄez
 

library identity

Validation and property parsing of identity numbers

image

komakino/identity

Validation and property parsing of identity numbers

  • Tuesday, January 26, 2016
  • by komakino
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4,014 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 39 % Grown

The README.md

Identity

Identity is a composer package to validate, parse, format and extract various information from national identity numbers., (*1)

Current implementations: * Swedish personnummer/organisationsnummer * Danish personnummer/CPR-nummer * Finnish henkilötunnus/personbeteckning * Norwegian fÞdselsnummer, (*2)

Installation

To add this package as a dependency to your project, simply add a dependency on komakino/identity to your project's composer.json file., (*3)

    {
        "require": {
            "komakino/identity": "*"
        }
    }

Usage

use Komakino\Identity\National\SwedishIdentity;
use Komakino\Identity\National\DanishIdentity;

$swedishIdentity = new SwedishIdentity('011017-2721');
$danishIdentity = new DanishIdentity('170583-7315');

Common methods

Upon construction, the number is parsed and validated., (*4)

If number does not comply to the allowed input formats of the implementation, an IdentityInvalidFormatException will be thrown., (*5)

Public properties

  • bool $valid, (*6)

    • The validity of the identity number
  • mixed **getters**, (*7)

    • All number properties are accessible as properties on the instance

Public methods

  • array listProperties(), (*8)

    • Returns all number properties
  • bool hasProperty(string $property), (*9)

    • Checks if the identity's implementation has a property
  • string __toString(), (*10)

    • Output the formatted identity number

Static methods

  • static array parse(string $number), (*11)

    • Creates an instance and returns all number properties
  • static bool validate(string $number), (*12)

    • Creates an instance and returns the validity of the number
  • static string format(string $number), (*13)

    • Output the formatted identity number

Swedish personnummer/organisationsnummer

Allowed input formats

  • 0110172721
  • 011017-2721
  • 011017+2721
  • 200110172721
  • 20011017-2721
  • 20011017+2721

Formatted output

011017-2721, (*14)

Number properties

  • type
    • organization or person
  • century
    • Sources for century:
      • Provided in number as OOxxxxxx-xxxx
      • The separator is a +, which denotes a person is over 100
      • By logical guessing. Pseudo: year > current_year ? 19 : 20
  • year
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • day
    • xxxxOO-xxxx
  • centuryHint
    • xxxxx-xxxx
    • Defaults to -
  • locality
    • xxxxxx-OOxx
  • county
    • Only available for people born before 1990
  • number
    • xxxxxx-xxOx
  • gender
    • male or female
  • checkdigit
    • xxxxxx-xxxO
  • birthday
    • A DateTime object
  • temporary
    • If the number is of a temporary nature

Danish personnummer/CPR-nummer

Allowed input formats

  • 1705837315
  • 170583-7315

Formatted output

170583-7315, (*15)

Number properties

  • century
    • Calculated from year and centuryHint
  • day
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • year
    • xxxxOO-xxxx
  • centuryHint
    • xxxxxx-Oxxx
  • sequence
    • xxxxxx-OOO0
  • gender
    • male or female
  • birthday
    • A DateTime object

Finnish personnummer/CPR-nummer

Allowed input formats

  • 311280-888Y

Formatted output

311280-888Y, (*16)

Number properties

  • century
    • Defined by centuryHint
  • day
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • year
    • xxxxOO-xxxx
  • centuryHint
    • xxxxx-xxxx
    • -/+/A
  • number
    • xxxxxx-OOOx
  • checkdigit
    • xxxxxx-xxxO
  • gender
    • male or female
  • birthday
    • A DateTime object

Norwegian fĂždselsnummer

Allowed input formats

  • 17058332143

Formatted output

17058332143, (*17)

Number properties

  • century
    • Calculated from year and number
  • day
    • OOxxxxxxxxx
  • month
    • xxOOxxxxxxx
  • year
    • xxxxOOxxxxx
  • number
    • xxxxxxOOOxx
  • checkdigits
    • xxxxxxxxxOO
  • gender
    • male or female
  • birthday
    • A DateTime object
  • D-number
    • bool Whether or not this is a D-number. Temporary number provided to immigrants etc.
  • H-number
    • bool Whether or not this is a H-number. Temporary number used by health care etc.

Changelog

v1.3.0

  • Will now throw an exception if number does'nt comply to the implementations allowed input format.

v1.2.1

  • Fixed issues with parsing zeros.

v1.2.0

  • Added implementation for Norwegian fĂždselsnummer

v1.1.0

  • Added implementation for Finnish henkilötunnus/personbeteckning

v1.0.0

  • Initial public release
  • Added implementation for Swedish personnummer/organisationsnummer
  • Added implementation for Danish personnummer/CPR-nummer

The Versions

26/01 2016

dev-master

9999999-dev http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn organisationsnummer social security number finnish ssn pno norwegian danish cpr-nummer henkilötunnus personbeteckning fÞdselsnummer

26/01 2016

v1.3.0

1.3.0.0 http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn organisationsnummer social security number finnish ssn pno norwegian danish cpr-nummer henkilötunnus personbeteckning fÞdselsnummer

25/01 2016

v1.2.1

1.2.1.0 http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn social security number ssn pno

21/01 2016

v1.2.0

1.2.0.0 http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn social security number ssn pno

15/01 2016

v1.1.0

1.1.0.0 http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn social security number ssn pno

14/01 2016

v1.0.0

1.0.0.0 http://www.github.com/komakino/identity

Validation and property parsing of identity numbers

  Sources   Download

The Requires

 

The Development Requires

validate swedish identity personnummer number luhn social security number ssn pno