From 2031165afc04fd37531df60ea87c10af12374ae3 Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Sun, 5 Jan 2025 06:10:22 +0000 Subject: [PATCH] add method to format phones --- src/Libs/Libs.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Libs/Libs.php b/src/Libs/Libs.php index da82a44..bdf470a 100644 --- a/src/Libs/Libs.php +++ b/src/Libs/Libs.php @@ -61,4 +61,12 @@ class Libs return null; } + public static function Phone(string $phone): string + { + $phone = preg_replace('/[^0-9]/', '', $phone); + if(strlen($phone) > 10 && substr($phone, 0, 1) == '1') { + $phone = substr($phone, 1); + } + return $phone; + } }