Code Duplication    Length = 27-28 lines in 2 locations

system/Inji/Module.php 2 locations

@@ 326-353 (lines=28) @@
323
     *
324
     * @return array
325
     */
326
    public function getObjects($filterNamespace = '') {
327
        $moduleName = $this->moduleName;
328
        $modulePaths = Module::getModulePaths($moduleName);
329
        $modulePaths = array_reverse($modulePaths);
330
        $scanFn = function ($path, $namespace, &$files = []) use (&$scanFn, $filterNamespace) {
331
            if (file_exists($path)) {
332
                foreach (scandir($path) as $item) {
333
                    if (in_array($item, ['..', '.'])) {
334
                        continue;
335
                    }
336
                    $filename = pathinfo($item)['filename'];
337
                    if (is_dir($path . '/' . $item)) {
338
                        $scanFn($path . '/' . $item, $namespace . '\\' . $filename, $files);
339
                    } else {
340
                        if (!$filterNamespace || strpos($namespace, $filterNamespace) === 0) {
341
                            $files[$path . '/' . $item] = $namespace . '\\' . $filename;
342
                        }
343
                    }
344
                }
345
            }
346
            return $files;
347
        };
348
        $files = [];
349
        foreach ($modulePaths as $path) {
350
            $scanFn($path . '/objects', $moduleName, $files);
351
        }
352
        return $files;
353
    }
354
355
    /**
356
     * Return module models
@@ 360-386 (lines=27) @@
357
     *
358
     * @return array
359
     */
360
    public static function getModels($moduleName, $filterNamespace = '') {
361
        $modulePaths = Module::getModulePaths($moduleName);
362
        $modulePaths = array_reverse($modulePaths);
363
        $scanFn = function ($path, $namespace, &$files = []) use (&$scanFn, $filterNamespace) {
364
            if (file_exists($path)) {
365
                foreach (scandir($path) as $item) {
366
                    if (in_array($item, ['..', '.'])) {
367
                        continue;
368
                    }
369
                    $filename = pathinfo($item)['filename'];
370
                    if (is_dir($path . '/' . $item)) {
371
                        $scanFn($path . '/' . $item, $namespace . '\\' . $filename, $files);
372
                    } else {
373
                        if (!$filterNamespace || strpos($namespace, $filterNamespace) === 0) {
374
                            $files[$path . '/' . $item] = $namespace . '\\' . $filename;
375
                        }
376
                    }
377
                }
378
            }
379
            return $files;
380
        };
381
        $files = [];
382
        foreach ($modulePaths as $path) {
383
            $scanFn($path . '/models', $moduleName, $files);
384
        }
385
        return $files;
386
    }
387
388
    /**
389
     * Return extensions for type