Code Duplication    Length = 20-20 lines in 2 locations

src/Loaders/Filters/OkFileFilter.php 1 location

@@ 226-245 (lines=20) @@
223
     * @return string The resolved pattern value
224
     * @throws \InvalidArgumentException Is thrown, if the element value can not be loaded from the file resolver configuration
225
     */
226
    protected function resolvePatternValue(string $element) : string
227
    {
228
229
        // query whether or not matches has been found OR the counter element has been passed
230
        if ($this->countMatches() === 0 || BunchKeys::COUNTER === $element) {
231
            // prepare the method name for the callback to load the pattern value with
232
            $methodName = sprintf('get%s', ucfirst($element));
233
234
            // load the pattern value
235
            if (in_array($methodName, get_class_methods($this->getFileResolverConfiguration()))) {
236
                return call_user_func(array($this->getFileResolverConfiguration(), $methodName));
237
            }
238
239
            // stop processing and throw an exception
240
            throw new \InvalidArgumentException('Can\'t load pattern value for element "%s" from file resolver configuration', $element);
241
        }
242
243
        // try to load the pattern value from the matches
244
        return $this->getMatch($element);
245
    }
246
247
    /**
248
     * Returns the values to create the regex pattern from.

src/Loaders/ProposedOkFilenameLoader.php 1 location

@@ 267-286 (lines=20) @@
264
     * @todo Refactorig required, because of duplicate method
265
     * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::resolvePatternValue()
266
     */
267
    protected function resolvePatternValue(string $element) : string
268
    {
269
270
        // query whether or not matches has been found OR the counter element has been passed
271
        if ($this->getLoader()->countMatches() === 0 || BunchKeys::COUNTER === $element) {
272
            // prepare the method name for the callback to load the pattern value with
273
            $methodName = sprintf('get%s', ucfirst($element));
274
275
            // load the pattern value
276
            if (in_array($methodName, get_class_methods($this->getFileResolverConfiguration()))) {
277
                return call_user_func(array($this->getFileResolverConfiguration(), $methodName));
278
            }
279
280
            // stop processing and throw an exception
281
            throw new \InvalidArgumentException('Can\'t load pattern value for element "%s" from file resolver configuration', $element);
282
        }
283
284
        // try to load the pattern value from the matches
285
        return $this->getLoader()->getMatch($element);
286
    }
287
288
    /**
289
     * Returns the values to create the regex pattern from.