Code Duplication    Length = 22-22 lines in 2 locations

src/Rule/AndRule.php 1 location

@@ 167-188 (lines=22) @@
164
165
    /**
166
     */
167
    public function toString(array $options=[])
168
    {
169
        $operator = self::operator;
170
        if ( ! $this->operands) {
171
            return $this->cache['string'] = "['{$operator}']";
172
        }
173
174
        $indent_unit = isset($options['indent_unit']) ? $options['indent_unit'] : '';
175
        $line_break  = $indent_unit ? "\n" : '';
176
177
        $out = "['{$operator}',$line_break";
178
179
        foreach ($this->operands as $operand) {
180
            $out .= implode("\n", array_map(function($line) use (&$indent_unit) {
181
                return $indent_unit.$line;
182
            }, explode("\n", $operand->toString($options)) )) . ",$line_break";
183
        }
184
185
        $out .= ']';
186
187
        return $this->cache['string'] = $out;
188
    }
189
190
    /**
191
     * Remove AndRules operands of AndRules

src/Rule/OrRule.php 1 location

@@ 131-152 (lines=22) @@
128
129
    /**
130
     */
131
    public function toString(array $options=[])
132
    {
133
        $operator = self::operator;
134
        if ( ! $this->operands) {
135
            return $this->cache['string'] = "['{$operator}']";
136
        }
137
138
        $indent_unit = isset($options['indent_unit']) ? $options['indent_unit'] : '';
139
        $line_break  = $indent_unit ? "\n" : '';
140
141
        $out = "['{$operator}',$line_break";
142
143
        foreach ($this->operands as $operand) {
144
            $out .= implode("\n", array_map(function($line) use (&$indent_unit) {
145
                return $indent_unit.$line;
146
            }, explode("\n", $operand->toString($options)) )) . ",$line_break";
147
        }
148
149
        $out .= ']';
150
151
        return $this->cache['string'] = $out;
152
    }
153
154
    /**
155
     * + if A > 2 && A > 1 <=> A > 2