@@ 132-153 (lines=22) @@ | ||
129 | ||
130 | /** |
|
131 | */ |
|
132 | public function toString(array $options=[]) |
|
133 | { |
|
134 | $operator = self::operator; |
|
135 | if ( ! $this->operands) { |
|
136 | return $this->cache['string'] = "['{$operator}']"; |
|
137 | } |
|
138 | ||
139 | $indent_unit = isset($options['indent_unit']) ? $options['indent_unit'] : ''; |
|
140 | $line_break = $indent_unit ? "\n" : ''; |
|
141 | ||
142 | $out = "['{$operator}',$line_break"; |
|
143 | ||
144 | foreach ($this->operands as $operand) { |
|
145 | $out .= implode("\n", array_map(function($line) use (&$indent_unit) { |
|
146 | return $indent_unit.$line; |
|
147 | }, explode("\n", $operand->toString($options)) )) . ",$line_break"; |
|
148 | } |
|
149 | ||
150 | $out .= ']'; |
|
151 | ||
152 | return $this->cache['string'] = $out; |
|
153 | } |
|
154 | ||
155 | /** |
|
156 | * + if A > 2 && A > 1 <=> A > 2 |
@@ 173-194 (lines=22) @@ | ||
170 | * @param array $options indent_unit |
|
171 | * @return string The rule description |
|
172 | */ |
|
173 | public function toString(array $options=[]) |
|
174 | { |
|
175 | $operator = self::operator; |
|
176 | if ( ! $this->operands) { |
|
177 | return $this->cache['string'] = "['{$operator}']"; |
|
178 | } |
|
179 | ||
180 | $indent_unit = isset($options['indent_unit']) ? $options['indent_unit'] : ''; |
|
181 | $line_break = $indent_unit ? "\n" : ''; |
|
182 | ||
183 | $out = "['{$operator}',$line_break"; |
|
184 | ||
185 | foreach ($this->operands as $operand) { |
|
186 | $out .= implode("\n", array_map(function($line) use (&$indent_unit) { |
|
187 | return $indent_unit.$line; |
|
188 | }, explode("\n", $operand->toString($options)) )) . ",$line_break"; |
|
189 | } |
|
190 | ||
191 | $out .= ']'; |
|
192 | ||
193 | return $this->cache['string'] = $out; |
|
194 | } |
|
195 | ||
196 | /** |
|
197 | * Remove AndRules operands of AndRules |