Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
LogicLib.php
1<?php
2
4
7
8class 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}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29