silotech / validate-sl-number
A simple function to validate a Sierra Leone Number with the present NDC's
v1.0.1
2025-09-24 13:56 UTC
Requires (Dev)
- pestphp/pest: 4.x-dev
This package is auto-updated.
Last update: 2025-09-24 16:26:44 UTC
README
A PHP package to validate Sierra Leone phone numbers and return them in a fully qualified format with country code.
π¦ Installation
Install via Composer:
composer require silotech/validate-sl-number
If your package is in development and you want to allow unstable versions, you can specify:
composer require silotech/validate-sl-number:dev-main
βοΈ Usage
Include Composerβs autoload file and call the function:
<?php require __DIR__ . "/vendor/autoload.php"; $phone = "0023273111222"; $result = isPhoneNumberAValidSLNumber($phone); if ($result !== false) { echo "Valid SL Number: " . $result; } else { echo "Invalid SL Number"; }
π Function
isPhoneNumberAValidSLNumber(string $phone_number): bool|string
Validates a Sierra Leone phone number and returns it in fully qualified format with +232
if valid.
Parameters:
$phone_number (string)
β The phone number to validate.
Acceptable formats:
+232xxxxxxxx
00232xxxxxxxx
- Local format:
0xxxxxxxx
Returns:
string
β Fully qualified phone number if valid (e.g.,+23276111222
)false
if invalid
π Examples
isPhoneNumberAValidSLNumber("+23273111222"); // "+23273111222" isPhoneNumberAValidSLNumber("0023232111222"); // "+23232111222" isPhoneNumberAValidSLNumber("033111222"); // "+23233111222" isPhoneNumberAValidSLNumber("070111222"); // false
π Requirements
- PHP >= 7.4
- Composer
π Development
If you are developing or updating this package:
git clone https://github.com/sepolly/validate-sl-number.git
cd validate-sl-number
composer install
π License
MIT License. See the LICENSE file for details.
π’ Author
Simeon Michael
GitHub Profile