Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/skyweb24.popuppro/lib/Helper/ |
Upload File : |
<?php namespace Skyweb24\Popuppro\Helper; class HelperPhone { public static function isValid(string $phone): bool { $phoneFormat = preg_replace('![^0-9]+!', '', $phone); return is_numeric($phoneFormat); } public static function formatting($phone) { $phone = preg_replace('![^0-9]+!', '', $phone); if (!is_numeric($phone)) { return false; } return $phone; } /** * ����������� � �������������� ������ �������� * @param string $phone */ public static function formatMask(string $phone) { $parsedPhone = \Bitrix\Main\PhoneNumber\Parser::getInstance()->parse($phone); return $parsedPhone->format(\Bitrix\Main\PhoneNumber\Format::E164); } public static function phoneFormatMask($phone, $format, $mask = '#') { $phone = preg_replace('![^0-9]+!', '', $phone); if (is_array($format)) { if (array_key_exists(strlen($phone), $format)) { $format = $format[strlen($phone)]; } else { return false; } } $pattern = '/' . str_repeat('([0-9])?', substr_count($format, $mask)) . '(.*)/'; $format = preg_replace_callback( str_replace('#', $mask, '/([#])/'), function () use (&$counter) { return '${' . (++$counter) . '}'; }, $format ); return ($phone) ? trim(preg_replace($pattern, $format, $phone, 1)) : false; } }