Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
betweenoperator.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Activity\Operator
;
4
5
use
Bitrix\Bizproc\FieldType
;
6
use
Bitrix\Main\Localization\Loc
;
7
8
class
BetweenOperator
extends
BaseOperator
9
{
10
public
static
function
getCode
(): string
11
{
12
return
'between'
;
13
}
14
15
public
static
function
getTitle
(): string
16
{
17
return
Loc::getMessage
(
'BIZPROC_ACTIVITY_CONDITION_OPERATORS_BETWEEN_OPERATOR_TITLE'
) ??
''
;
18
}
19
20
public
function
__construct
(
$toCheck
,
$value
,
FieldType
$fieldType
)
21
{
22
parent::__construct(
$toCheck
,
$value
,
$fieldType
);
23
24
$this->toCheck = is_array($this->toCheck) ? $this->toCheck : [
$this->toCheck
];
25
$this->value = is_array($this->value) ? $this->value : [
$this->value
];
26
}
27
28
public
function
check
(): bool
29
{
30
$greaterThen = is_array($this->value[0]) ? $this->value[0] : [$this->value[0]];
31
$lessThen = is_array($this->value[1]) ? $this->value[1] : [$this->value[1]];
32
$toCheck
=
$this->toCheck
;
33
34
reset($greaterThen);
35
reset($lessThen);
36
reset(
$toCheck
);
37
38
$firstGreaterThen = current($greaterThen);
39
$firstLessThen = current($lessThen);
40
$checkValue = current(
$toCheck
);
41
42
return
$this->
compare
($checkValue, [$firstGreaterThen, $firstLessThen]);
43
}
44
45
protected
function
compare
(
$toCheck
,
$value
): bool
46
{
47
$classType = $this->fieldType->getTypeClass();
48
[$greaterThen, $lessThen] =
$value
;
49
50
// $firstGreaterThen <= $checkValue <= $firstLessThen
51
return
(
52
$classType::compareValues(
$toCheck
, $greaterThen) >= 0
53
&& $classType::compareValues(
$toCheck
, $lessThen) <= 0
54
);
55
}
56
}
Bitrix\Bizproc\Activity\Operator\BaseOperator
Definition
baseoperator.php:8
Bitrix\Bizproc\Activity\Operator\BaseOperator\$value
$value
Definition
baseoperator.php:10
Bitrix\Bizproc\Activity\Operator\BaseOperator\$fieldType
FieldType $fieldType
Definition
baseoperator.php:11
Bitrix\Bizproc\Activity\Operator\BaseOperator\$toCheck
$toCheck
Definition
baseoperator.php:9
Bitrix\Bizproc\Activity\Operator\BetweenOperator
Definition
betweenoperator.php:9
Bitrix\Bizproc\Activity\Operator\BetweenOperator\getCode
static getCode()
Definition
betweenoperator.php:10
Bitrix\Bizproc\Activity\Operator\BetweenOperator\check
check()
Definition
betweenoperator.php:28
Bitrix\Bizproc\Activity\Operator\BetweenOperator\compare
compare($toCheck, $value)
Definition
betweenoperator.php:45
Bitrix\Bizproc\Activity\Operator\BetweenOperator\__construct
__construct($toCheck, $value, FieldType $fieldType)
Definition
betweenoperator.php:20
Bitrix\Bizproc\Activity\Operator\BetweenOperator\getTitle
static getTitle()
Definition
betweenoperator.php:15
Bitrix\Bizproc\FieldType
Definition
fieldtype.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Bizproc\Activity\Operator
Definition
baseoperator.php:3
modules
bizproc
lib
activity
operator
betweenoperator.php
Создано системой
1.10.0