Download the PHP package olssonm/swedish-entity without Composer

On this page you can find all versions of the php package olssonm/swedish-entity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swedish-entity

Swedish Entity

Latest Version on Packagist PHP version Build Status

Validate, format and extract data for Swedish personnummer (social security numbers) and organisationsnummer (organizational numbers).

This package also handles the temporary personal identity number known as "Samordningsnummer" (a.k.a. coordination number).

Also includes validators for Laravel.

The benefits of this package – while not always strictly according to the standard – is the ability to format using both short/long (10 or 12 characters) without or with a separator (i.e. 11/13 characters).

Note that companies always consists of 10/11 characters (with or without an optional separator).

This package use the excellent personnummer/php-package as it's basis for the social security-handling, but with some additional attributes and methods.

Installation

Usage

Validation

Automatically detect the entity type:

⚠️ If the detect-method fails, an Olssonm\SwedishEntity\Exceptions\DetectException will be thrown.

Formatting

⚠️ Formatting an invalid entity will result in an exception. You should make sure to validate it beforehand.

Person

Organization

Laravel validators

The package registrers the "entity" rule, which accepts the parameters any, organization or person.

You may also omit the parameter and the validator will fallback to any

Custom messages

Implicit validation

For the validator to run when the social security/organizational number is missing or an empty string (note, does not apply to null) you will need to implicitly state so with a required rule, i.e:

or

Attributes

Person

Attribute Comment type
ssn The SSN of the entity string
century Birthyear century string
year Birthyear string
month Birthmonth string
day Birthday string
num The "last four digits" string
check The checksum verifier string
age Age string
birthday Entitys birthday DateTime
gender Gender (Male/Female) string
type Type of ssn * string

Either "Samordningsnummer" or "Personnummer"*

Example

Organization

Attribute Comment type
org_no The org. no. of the entity string
check The checksum verifier string
type Type of organisation* string

One of the following: "Dödsbon", "Stat, landsting och kommuner", "Aktiebolag", "Enkelt bolag", "Ekonomiska föreningar", "Ideella föreningar och stiftelser" and "Handelsbolag, kommanditbolag och enkla bolag". Note: Organizations starting with 0, 3 and 4, while technically a valid number – it is uncertain if they exist, and will return and empty string.*

Example

Clean-helper

The Entity-class contains a clean-helper that can be useful for removing illegal characters from a social security- or organisational number:

Note that this is not automatically applied, so you will need to clean the string before validation.

Gotcha moments

Enskild firma

EF (Enskild firma) – while technically a company/organization, uses the proprietors personnummer. Therefore that number will not validate as company/organization. Instead of using a custom solution for this (as Creditsafe, Bisnode and others do – by adding additional numbers/characters to the organizational number/social security number), a way to handle this would be:

If you need to after the validation check type;

License

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

© 2022 Marcus Olsson.


All versions of swedish-entity with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
personnummer/personnummer Version ^3.0.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package olssonm/swedish-entity contains the following files

Loading the files please wait ....