Skip to content

Commit

Permalink
Importation de la première version
Browse files Browse the repository at this point in the history
  • Loading branch information
roukmoute committed Mar 11, 2022
0 parents commit fdebf2d
Show file tree
Hide file tree
Showing 26 changed files with 1,140 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
53 changes: 53 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Static analysis

on:
push:
pull_request:

defaults:
run:
shell: bash

jobs:

tests:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1
php-version: "8.0"
extensions: "${{ env.extensions }}"
tools: flex

- name: Validate composer.json
run: composer validate --strict

- name: Install dependencies
run: |
composer install
- name: Run psalm
run: |
php vendor/bin/psalm --output-format=github --no-progress
- name: Run PHP Coding Standards Fixer
run: |
php vendor/bin/php-cs-fixer fix --diff --dry-run -v
- name: Run PHPStan
run: |
php vendor/bin/phpstan analyze src
- name: Run phpmd
run: |
php vendor/bin/phpmd src xml pmd-ruleset.xml
49 changes: 49 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Unit tests

on:
push:
pull_request:

defaults:
run:
shell: bash

jobs:

tests:
name: Tests
runs-on: ubuntu-latest

strategy:
matrix:
include:
- php: '7.3'
mode: low-deps
- php: '7.3'
- php: '8.0'
mode: low-deps
- php: '8.0'
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
ini-values: date.timezone=Europe/Paris,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1
php-version: "${{ matrix.php }}"
extensions: "${{ env.extensions }}"
tools: flex

- name: Install dependencies
run: |
composer update --prefer-dist --no-progress $([ '${{ matrix.mode }}' = low-deps ] && echo '--prefer-lowest')
- name: Run phpspec tests
run: |
php vendor/bin/phpspec run
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###> cnamts/nir-validation ###
/vendor/
/composer.lock
/.php-cs-fixer.cache
###< cnamts/nir-validation ###
75 changes: 75 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/')
->exclude('vendor')
;

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
->setRules(
[
'@DoctrineAnnotation' => true,
'@PHP73Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,

// @Symfony code styles rules blacklisting:
'method_chaining_indentation' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_trailing_comma_in_list_call' => false,
'php_unit_fqcn_annotation' => false,
'phpdoc_align' => false,
'phpdoc_annotation_without_dot' => false,
'phpdoc_indent' => false,
'phpdoc_inline_tag_normalizer' => false,
'phpdoc_no_access' => false,
'phpdoc_no_alias_tag' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_no_package' => false,
'phpdoc_no_useless_inheritdoc' => false,
'phpdoc_return_self_reference' => false,
'phpdoc_scalar' => false,
'phpdoc_separation' => false,
'phpdoc_single_line_var_spacing' => false,
'phpdoc_summary' => false,
'phpdoc_to_comment' => false,
'phpdoc_trim' => false,
'phpdoc_types' => false,
'phpdoc_var_without_name' => false,
'error_suppression' => false,
'standardize_not_equals' => false,

// @Symfony customised rules
'concat_space' => ['spacing' => 'one'],
'native_function_invocation' => false,
'single_quote' => ['strings_containing_single_quote_chars' => true],
'visibility_required' => ['elements' => ['property', 'method', 'const']],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],

// Additional code style rules whitelisting:
'align_multiline_comment' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_issets' => true,
'declare_strict_types' => true,
'explicit_indirect_variable' => true,
'explicit_string_variable' => true,
'fully_qualified_strict_types' => true,
'linebreak_after_opening_tag' => true,
'list_syntax' => ['syntax' => 'short'],
'mb_str_functions' => true,
'multiline_comment_opening_closing' => true,
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
'no_alternative_syntax' => true,
'no_superfluous_elseif' => true,
'ordered_imports' => true,
'ordered_interfaces' => true,
]
)
->setRiskyAllowed(true)
->setFinder($finder)
->setUsingCache(true)
;

return $config;
151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Règles de validation pour un NIR

Ce dépôt à pour but de proposer des contraintes sur la représentation des
données d'identification française.

Nous proposons plusieurs règles :

- Numéro d'Inscription au Répertoire (NIR)
- Numéro National Provisoire (NNP)
- Migrant de passage (MIG)
- Numéro Identifiant d'Attente (NIA)

## Utilisation

### PHP natif

Cette partie explique comment utiliser les fonctionnalités du validateur.

L'exemple suivant montre comment valider un NIR :

```php
use Cnamts\Nir\Constraints\Nir;
use Symfony\Component\Validator\Validation;

$validator = Validation::createValidator();
$violations = $validator->validate('2 84 05 88 321 025 30', [new Nir()]);

if (count($violations) !== 0) {
echo '<ul>';
foreach ($violations as $violation) {
echo '<li>'.$violation->getMessage().'</li>';
}
echo '</ul>';
}
```

### Symfony

Toutes les contraintes ont été intégrées pour pouvoir être utilisées dans
tous les formats supportés par Symfony :

#### Annotations

```php
// src/Entity/User.php
namespace App\Entity;

// ...
use Cnamts\Nir\Constraints as Assert;

class User
{
/**
* @Assert\Nir
*/
private $identifier;
}
```

#### Attributs

```php
// src/Entity/User.php
namespace App\Entity;

// ...
use Cnamts\Nir\Constraints as Assert;

class User
{
#[Assert\Nir]
private $identifier;
}
```

#### YAML

```yml
# config/validator/validation.yaml
App\Entity\User:
properties:
identifier:
- Nir: ~
```
#### XML
```xml
<!-- config/validator/validation.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="App\Entity\User">
<property name="identifier">
<constraint name="Nir"/>
</property>
</class>
</constraint-mapping>
```

#### PHP

```php
// src/Entity/User.php
namespace App\Entity;

// ...
use Cnamts\Nir\Constraints\Nir;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class User
{
private $identifier;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('identifier', new Nir());
}
}
```

## Contraintes

### Numéro d'Inscription au Répertoire (NIR)

Le NIR est un numéro à treize caractères dont la composition est précisée dans
l'article 4 du décret n° 82-103 du 22 janvier 1982.

### Numéro National Provisoire (NNP)

Le NPP est attribué aux personnes nées à l'étranger, qui n'ont jamais
été immatriculées.

### Migrant de passage (MIG)

Afin de créer au Référentiel Individus (RFI) les individus présents en
Bases de Données Opérantes (BDO) en tant que membre de la famille du migrant
de passage, il est nécessaire de leur attribuer un numéro de type Migrant
unique nationalement.

### NIA

L'objectif du NIA est de mettre fin aux numéros provisoires - NNP -
créés de manière autonome par les caisses.

Il s'agit de perfectionner la gestion de l'identification par la mise en place
d'un numéro provisoire partageable entre tous les Organismes de la
Protection Sociale.
40 changes: 40 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "assurance-maladie/nir-validation",
"description": "Ce composant fournit une validation des valeurs selon les données d'identification française",
"type": "project",
"license": "MIT",
"minimum-stability": "stable",
"require": {
"php": "^7.3||^8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/validator": "^4.4||^5.3"
},
"require-dev": {
"assurance-maladie/qualytou": "^2.0",
"phpspec/phpspec": "^7.1",
"roave/security-advisories": "dev-latest"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true,
"phpro/grumphp": true,
"assurance-maladie/qualytou": true
}
},
"autoload": {
"psr-4": {
"Cnamts\\Nir\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Spec\\": "tests/Spec"
}
}
}
Loading

0 comments on commit fdebf2d

Please sign in to comment.