djekl / nhs-number-validation
A simple PHP class to validate a NHS Number and return a correctly formatted version.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:class
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-10-20 19:23:47 UTC
README
A simple PHP class to validate a NHS Number and return a correctly formatted version.
Requirements
- PHP >= 5.3.3
Example
<?php // include the autoloader include __DIR__ . '/vendor/autoload.php'; // setup our validator $nhsValidator = new \djekl\NHSNumberValidation\Validator; // start with our test NHS number (usually taken via user input) $nhs_no = '401 023 2137'; try { $valid_nhs_no = $nhsValidator->valdate($nhs_no); } catch (\djekl\NHSNumberValidation\InvalidNumberException $e) { die($e->getMessage() . PHP_EOL); } if (!empty($valid_nhs_no)) { print "YAY! {$valid_nhs_no} is a valid NHS Number\r\n"; }