add projet

This commit is contained in:
root
2026-03-05 12:29:37 -05:00
parent 8d1eef8ba8
commit 23b7db1107
9109 changed files with 1106501 additions and 73 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Services;
class PhoneFormatterService
{
/**
* Normalize a phone number by stripping non-digits and formatting US numbers.
*/
public function formatPhoneNumber(string $phone): string
{
$digits = preg_replace('/\D+/', '', $phone);
if ($digits === null || $digits === '') {
return '';
}
if (strlen($digits) === 10) {
return sprintf('(%s) %s-%s', substr($digits, 0, 3), substr($digits, 3, 3), substr($digits, 6));
}
return $digits;
}
/**
* Determine if a phone string contains any digits.
*/
public function hasDigits(string $phone): bool
{
return preg_match('/\d/', $phone) === 1;
}
}