silotech/validate-sl-number 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

silotech/validate-sl-number

最新稳定版本:v1.0.1

Composer 安装命令:

composer require silotech/validate-sl-number

包简介

A simple function to validate a Sierra Leone Number with the present NDC's

README 文档

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

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-06