Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
normalizer.php
1
<?php
8
namespace
Bitrix\Sender\Recipient
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Main\PhoneNumber
;
12
13
Loc::loadMessages
(__FILE__);
14
19
class
Normalizer
20
{
28
public
static
function
normalize
($code, $typeId = Type::EMAIL)
29
{
30
if
(!$code)
31
{
32
return
null
;
33
34
}
35
switch
($typeId)
36
{
37
case
Type::IM:
38
return
self::normalizeIm
($code);
39
40
case
Type::PHONE:
41
return
self::normalizePhone
($code);
42
43
case
Type::CRM_COMPANY_ID:
44
case
Type::CRM_CONTACT_ID:
45
case
Type::CRM_LEAD_ID:
46
return
self::normalizeCrmEntityId
($code);
47
48
case
Type::EMAIL:
49
default
:
50
return
self::normalizeEmail
($code);
51
}
52
}
53
60
public
static
function
normalizeEmail
($code)
61
{
62
return
trim(mb_strtolower($code));
63
}
64
71
public
static
function
normalizePhone
($phone)
72
{
73
return
PhoneNumber\Parser::getInstance()
74
->parse($phone)
75
->format(
PhoneNumber
\
Format::E164
);
76
}
77
84
public
static
function
normalizeIm
($code)
85
{
86
$code = trim($code);
87
if
(mb_strpos($code,
'imol|'
) === 0)
88
{
89
$code = mb_substr($code, 5);
90
}
91
92
return
$code;
93
}
94
101
public
static
function
normalizeCrmEntityId
($code)
102
{
103
return
preg_replace(
"/[^0-9]/"
,
''
, $code);
104
}
105
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\PhoneNumber\Format\E164
const E164
Definition
format.php:7
Bitrix\Main\PhoneNumber\PhoneNumber
Definition
phonenumber.php:6
Bitrix\Sender\Recipient\Normalizer
Definition
normalizer.php:20
Bitrix\Sender\Recipient\Normalizer\normalizePhone
static normalizePhone($phone)
Definition
normalizer.php:71
Bitrix\Sender\Recipient\Normalizer\normalizeCrmEntityId
static normalizeCrmEntityId($code)
Definition
normalizer.php:101
Bitrix\Sender\Recipient\Normalizer\normalizeIm
static normalizeIm($code)
Definition
normalizer.php:84
Bitrix\Sender\Recipient\Normalizer\normalize
static normalize($code, $typeId=Type::EMAIL)
Definition
normalizer.php:28
Bitrix\Sender\Recipient\Normalizer\normalizeEmail
static normalizeEmail($code)
Definition
normalizer.php:60
Bitrix\Main\PhoneNumber
Definition
format.php:3
Bitrix\Sender\Recipient
Definition
agent.php:8
modules
sender
lib
recipient
normalizer.php
Создано системой
1.10.0