PHPackages                             miladk/bekrafta - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. miladk/bekrafta

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

miladk/bekrafta
===============

Validate Personal Numbers

v1.2.1(8y ago)120.4kMITPHPPHP &gt;=7.0.0

Since Feb 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Milad/bekrafta)[ Packagist](https://packagist.org/packages/miladk/bekrafta)[ RSS](/packages/miladk-bekrafta/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (3)Dependencies (3)Versions (12)Used By (0)

Bekräfta [![Build Status](https://camo.githubusercontent.com/cd7e154ddcf3c1414044fa64ed90bedc39a6deffe6beb495f702828dcbfe4dbd/68747470733a2f2f7472617669732d63692e6f72672f4d696c61642f62656b72616674612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Milad/bekrafta)
==================================================================================================================================================================================================================================================================================

[](#bekräfta-)

[Bekräfta](https://en.wiktionary.org/wiki/bekr%C3%A4fta#Swedish): A PHP library to perform common operations on Personal Identification Numbers, like: Validation, censoring the individual digits, calculating age and detecting gender.

### Supported Countries

[](#supported-countries)

- Denmark (CPR-Nummer)
- Finland (Henkilötunnus, Personbeteckning)
- Poland (PESEL)
- Netherlands (Burgerservicenummer) *Validation only*
- Norway (Fødselsnummer)
- Sweden (Personnummer)

[![Supported Countries](./chart.jpg)](./chart.jpg)

### Supported PHP Versions

[](#supported-php-versions)

- PHP 7.0
- PHP 7.1
- PHP 7.2

### Installation

[](#installation)

```
composer require miladk/bekrafta

```

### Usage

[](#usage)

This library offers one interface for all supported countries. Developers don't have to use specific countries' classes, instead there is one class that detects and uses the country and serves the appropriate values.

```
use Bekrafta\PersonalNumber;

$oPN = new PersonalNumber('811228-9874');

// True on successful detection, false otherwise.
// True also means a valid personal number.
$oPN->detect();

// 811228-****
$oPN->getCensored();

// 35
$oPN->getAge();

// m
$oPN->getGender();

// 1981
$oPM->getYear();

// 1981-12-28
$oPM->getBirthday()
```

Or you can use a specific country if you only need that.

```
use Bekrafta\Sweden;

$oSweden = new Sweden('811228-9874');

// True on valid personal number, false otherwise.
$oSweden->validate();

// 811228-****
$oSweden->getCensored();

// 35
$oSweden->getAge();

// m
$oSweden->getGender();

// 1981
$oSweden->getYear();

// 1981-12-28
$oSweden->getBirthday();
```

### Sweden Extended

[](#sweden-extended)

In Sweden, some companies add the century digits as a part of the personal number, or remove the symbol between the date of birth and the four other digits. These changes are not part of the standard of the official standard. So I included to classes for Sweden:

- Sweden: Supports the official standard format.
- SwedenExtended: Supports the popular non-standard formats. This has two more functions:
    - removeLeadingCenturies() it removes the leading 19 or 20 from the personal number.
    - removeNonNumbers() Removes non-numeric characters form personal number.

### Denmark Strict

[](#denmark-strict)

> However, in 2007 the available sequence numbers under this system for males born on 1 January 1965 ran out, and since October 2007 personal identification numbers do not always validate using the check digit. This had been predicted and announced several years in advance. Thus, most IT systems are presumed updated to accept numbers that fail the check-digit validation. — [Wikipedia](https://en.wikipedia.org/wiki/Personal_identification_number_(Denmark))

Therefore, I see no use for performing a checksum on Danish personal numbers, because we will get false negatives. However, if you want to use the checksum, you can use the class DenmarkStrict which performs the checksum on the personal number, you will get false positives though.

### License

[](#license)

MIT

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~27 days

Total

12

Last Release

3102d ago

Major Versions

v0.3.4 → v1.0.02017-09-22

PHP version history (2 changes)0.2.1PHP &gt;=5.6.0

v0.3.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d1dfbd1d434196e2be0e764e41f5a58a52c0218a5c7a248636a29ce7cd11693?d=identicon)[MiladK](/maintainers/MiladK)

---

Top Contributors

[![Milad](https://avatars.githubusercontent.com/u/94392?v=4)](https://github.com/Milad "Milad (66 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/miladk-bekrafta/health.svg)

```
[![Health](https://phpackages.com/badges/miladk-bekrafta/health.svg)](https://phpackages.com/packages/miladk-bekrafta)
```

###  Alternatives

[chaoswey/taiwan-id-validator

台灣身分證、統一編號驗證

319.9k](/packages/chaoswey-taiwan-id-validator)

PHPackages © 2026

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