Code Duplication    Length = 20-25 lines in 2 locations

src/Gobie/Regex/Wrappers/Mb/MbRegex.php 2 locations

@@ 113-132 (lines=20) @@
110
     * @link http://php.net/function.mb-ereg-replace.php
111
     * @link http://php.net/function.mb-ereg-replace-callback.php
112
     */
113
    public static function replace($pattern, $replacement, $subject, $option = '')
114
    {
115
        static::setUp($pattern);
116
117
        $replaceMap = self::prepareReplaceMap($pattern, $replacement);
118
119
        $result = array();
120
        foreach ((array) $subject as $key => $subjectPart) {
121
            foreach ($replaceMap as $item) {
122
                list($pattern, $replacement) = $item;
123
124
                $subjectPart = self::execReplace($pattern, $replacement, $subjectPart, $option);
125
            }
126
            $result[$key] = $subjectPart;
127
        }
128
129
        static::tearDown();
130
131
        return (\is_array($subject) ? $result : \reset($result)) ? : $subject;
132
    }
133
134
    /**
135
     * Regular expression split and return all parts.
@@ 219-243 (lines=25) @@
216
     * @link http://php.net/function.mb-ereg-replace.php
217
     * @link http://php.net/function.mb-ereg-replace-callback.php
218
     */
219
    public static function filter($pattern, $replacement, $subject, $option = '')
220
    {
221
        static::setUp($pattern);
222
223
        $replaceMap = self::prepareReplaceMap($pattern, $replacement);
224
225
        $result = array();
226
        foreach ((array) $subject as $key => $subjectPart) {
227
            foreach ($replaceMap as $item) {
228
                list($pattern, $replacement) = $item;
229
230
                \mb_ereg_search_init($subjectPart, $pattern, $option);
231
                if (!\mb_ereg_search()) {
232
                    continue;
233
                }
234
235
                $subjectPart  = self::execReplace($pattern, $replacement, $subjectPart, $option);
236
                $result[$key] = $subjectPart;
237
            }
238
        }
239
240
        static::tearDown();
241
242
        return $result;
243
    }
244
245
    /**
246
     * Prepare error handler for catching compilation errors.