84 return $compositeBuilder->create($nodes);
97 $this->expressions = $manufacturer->match($this->condition);
110 $this->operators = $manufacturer->match($this->condition);
123 $this->condition = preg_replace($manufacturer->getPattern(),
'n',
$this->condition);
125 $this->condition = preg_replace($manufacturer->getPattern(),
'o',
$this->condition);
126 $this->condition = preg_replace(
"/no/",
"n o", $this->condition);
127 $this->condition = preg_replace(
"/on/",
"o n", $this->condition);
129 for ($i = 0; $i < strlen($this->condition); $i++) {
138 $num_brackets_open = substr_count($this->condition,
"(");
139 $num_brackets_close = substr_count($this->condition,
")");
141 if ($num_brackets_open > $num_brackets_close) {
144 if ($num_brackets_open < $num_brackets_close) {
173 $expected = [
"n",
"(",
"!"];
177 while ($this->index < strlen($this->condition)) {
179 if (trim($this->condition[$this->index]) !=
"" && in_array($this->condition[$this->index], $expected)) {
180 if ($this->condition[$this->index] ==
')') {
182 } elseif ($this->condition[$this->index] ==
'n') {
183 $group[] = [
'type' =>
'expression',
'value' => array_shift($this->expressions)];
184 $expected = [
"o",
")"];
185 } elseif ($this->condition[$this->index] ==
'o') {
186 $group[] = [
'type' =>
'operator',
'value' => array_shift($this->operators)];
187 $expected = [
"n",
"(",
"!"];
188 } elseif ($this->condition[$this->index] ==
'(') {
191 $group[] = [
'type' =>
"group",
"negated" => $negation,
'nodes' => $elements];
193 $expected = [
"o",
")"];
194 } elseif ($this->condition[$this->index] ==
"!") {
197 } elseif (trim($this->condition[$this->index]) !=
"") {
205 return [
'type' =>
'group',
"negated" => $negation,
'nodes' => $group];
221 $start = strpos($this->condition,
"n",
$index + 1);
224 if ($start !==
false) {
225 $end = strpos($this->condition,
"n", $start + 1);
228 if ($start !==
false && $end !==
false) {
229 $this->condition = substr_replace($this->condition,
"(n o n)", $start, $end - $start + 1);
240 $next_bracket = strpos($this->condition,
"(",
$index + 1);
241 $next_expression = strpos($this->condition,
"n",
$index + 1);
243 return $next_bracket !==
false && $next_bracket < $next_expression;
cannonicalizeCondition()
Cannonicalize the condition into a more general form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createNodeArray()
Creates an array representing all Nodes in a condition based on the fetched expressions and operators...
static _getInstance()
Get an Instance of ExpressionManufacturer.
isNegationSurroundedByBrackets($index)
fetchOperators()
Matches all operators in the current condition and assign these to the class attribute ConditionParse...
fetchExpressions()
Matches all expressions in the current condition and assign these to the class attribute ConditionPar...
surroundNegationExpression($index)
static _getInstance()
Get an Instance of OperationManufacturer.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
parse($condition)
Parses the delivered condition and creates a composite tree Structure.