Code Duplication    Length = 33-33 lines in 2 locations

src/Controller/AbstractController.php 1 location

@@ 214-246 (lines=33) @@
211
     * @return AbstractPlugin
212
     * @throws PluginException
213
     */
214
    public function __call($name, $arguments)
215
    {
216
        // Search in core view helpers first
217
        $corePlugin = 'Faulancer\Plugin\\' . ucfirst($name);
218
219
        if (class_exists($corePlugin)) {
220
221
            $class = new $corePlugin;
222
            array_unshift($arguments, $this);
223
224
            return call_user_func_array($class, $arguments);
225
226
        }
227
228
        // No core implementations found; search in custom view helpers
229
230
        /** @var Config $config */
231
        $config = ServiceLocator::instance()->get(Config::class);
232
        $namespace = '\\' . $config->get('namespacePrefix');
233
234
        $customPlugin = $namespace . '\Plugin\\' . ucfirst($name);
235
236
        if (class_exists($customPlugin)) {
237
238
            $class = new $customPlugin;
239
            array_unshift($arguments, $this);
240
241
            return call_user_func_array($class, $arguments);
242
243
        }
244
245
        throw new PluginException('No plugin for "' . $name . '" found.');
246
    }
247
248
}

src/View/ViewController.php 1 location

@@ 312-344 (lines=33) @@
309
     * @return AbstractViewHelper
310
     * @throws ViewHelperException
311
     */
312
    public function __call($name, $arguments)
313
    {
314
        // Search in core view helpers first
315
        $coreViewHelper = __NAMESPACE__ . '\Helper\\' . ucfirst($name);
316
317
        if (class_exists($coreViewHelper)) {
318
319
            $class = new $coreViewHelper;
320
            array_unshift($arguments, $this);
321
322
            return call_user_func_array($class, $arguments);
323
324
        }
325
326
        // No core implementations found; search in custom view helpers
327
328
        /** @var Config $config */
329
        $config = ServiceLocator::instance()->get(Config::class);
330
        $namespace = '\\' . $config->get('namespacePrefix');
331
332
        $customViewHelper = $namespace . '\\View\\Helper\\' . ucfirst($name);
333
334
        if (class_exists($customViewHelper)) {
335
336
            $class = new $customViewHelper;
337
            array_unshift($arguments, $this);
338
339
            return call_user_func_array($class, $arguments);
340
341
        }
342
343
        throw new ViewHelperException('No view helper for "' . $name . '" found.');
344
    }
345
346
    /**
347
     * Destructor