Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
LogicLib.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Calc\Libs
;
4
5
use
Bitrix\Bizproc\Calc\Arguments
;
6
use
Bitrix\Main\Localization\Loc
;
7
8
class
LogicLib
extends
BaseLib
9
{
10
public
function
getFunctions
(): array
11
{
12
return
[
13
'true'
=> [
14
'args'
=>
false
,
15
'func'
=>
'callTrue'
,
16
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_TRUE_DESCRIPTION'
),
17
],
18
'false'
=> [
19
'args'
=>
false
,
20
'func'
=>
'callFalse'
,
21
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_FALSE_DESCRIPTION'
),
22
],
23
'if'
=> [
24
'args'
=>
true
,
25
'func'
=>
'callIf'
,
26
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_IF_DESCRIPTION'
),
27
],
28
'and'
=> [
29
'args'
=>
true
,
30
'func'
=>
'callAnd'
,
31
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_AND_DESCRIPTION'
),
32
],
33
'not'
=> [
34
'args'
=>
true
,
35
'func'
=>
'callNot'
,
36
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_NOT_DESCRIPTION'
),
37
],
38
'or'
=> [
39
'args'
=>
true
,
40
'func'
=>
'callOr'
,
41
'description'
=>
Loc::getMessage
(
'BIZPROC_CALC_FUNCTION_OR_DESCRIPTION'
),
42
],
43
];
44
}
45
46
public
function
callTrue
()
47
{
48
return
true
;
49
}
50
51
public
function
callFalse
()
52
{
53
return
false
;
54
}
55
56
public
function
callIf
(
Arguments
$args)
57
{
58
$expression = (boolean)$args->
getFirst
();
59
$ifTrue = $args->
getSecond
();
60
$ifFalse = $args->
getThird
();
61
62
return
$expression ? $ifTrue : $ifFalse;
63
}
64
65
public
function
callNot
(
Arguments
$args)
66
{
67
return
!$args->
getFirst
();
68
}
69
70
public
function
callAnd
(
Arguments
$args)
71
{
72
$array = $args->
getFlatArray
();
73
74
return
count(array_filter($array)) === count($array);
75
}
76
77
public
function
callOr
(
Arguments
$args)
78
{
79
$array = $args->
getFlatArray
();
80
81
return
count(array_filter($array)) > 0;
82
}
83
}
Bitrix\Bizproc\Calc\Arguments
Definition
Arguments.php:6
Bitrix\Bizproc\Calc\Arguments\getFlatArray
getFlatArray()
Definition
Arguments.php:33
Bitrix\Bizproc\Calc\Arguments\getSecond
getSecond()
Definition
Arguments.php:57
Bitrix\Bizproc\Calc\Arguments\getFirst
getFirst()
Definition
Arguments.php:41
Bitrix\Bizproc\Calc\Arguments\getThird
getThird()
Definition
Arguments.php:73
Bitrix\Bizproc\Calc\Libs\BaseLib
Definition
BaseLib.php:6
Bitrix\Bizproc\Calc\Libs\LogicLib
Definition
LogicLib.php:9
Bitrix\Bizproc\Calc\Libs\LogicLib\callNot
callNot(Arguments $args)
Definition
LogicLib.php:65
Bitrix\Bizproc\Calc\Libs\LogicLib\getFunctions
getFunctions()
Definition
LogicLib.php:10
Bitrix\Bizproc\Calc\Libs\LogicLib\callIf
callIf(Arguments $args)
Definition
LogicLib.php:56
Bitrix\Bizproc\Calc\Libs\LogicLib\callOr
callOr(Arguments $args)
Definition
LogicLib.php:77
Bitrix\Bizproc\Calc\Libs\LogicLib\callTrue
callTrue()
Definition
LogicLib.php:46
Bitrix\Bizproc\Calc\Libs\LogicLib\callFalse
callFalse()
Definition
LogicLib.php:51
Bitrix\Bizproc\Calc\Libs\LogicLib\callAnd
callAnd(Arguments $args)
Definition
LogicLib.php:70
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\Calc\Libs
Definition
ArrayLib.php:3
modules
bizproc
lib
Calc
Libs
LogicLib.php
Создано системой
1.10.0