Code Duplication    Length = 42-42 lines in 2 locations

src/Laravel/Repository.php 1 location

@@ 8-49 (lines=42) @@
5
use Nwidart\Modules\Json;
6
use Nwidart\Modules\Repository as BaseRepository;
7
8
class Repository extends BaseRepository
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function scan()
14
    {
15
        $paths = $this->getScanPaths();
16
17
        $modules = [];
18
19
        foreach ($paths as $key => $path) {
20
            $manifests = $this->app['files']->glob("{$path}/module.json");
21
22
            is_array($manifests) || $manifests = [];
23
24
            foreach ($manifests as $manifest) {
25
                $name = Json::make($manifest)->get('name');
26
27
                $modules[$name] = new Module($this->app, $name, dirname($manifest));
28
            }
29
        }
30
31
        return $modules;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function formatCached($cached)
38
    {
39
        $modules = [];
40
41
        foreach ($cached as $name => $module) {
42
            $path = $this->config('paths.modules') . '/' . $name;
43
44
            $modules[$name] = new Module($this->app, $name, $path);
45
        }
46
47
        return $modules;
48
    }
49
}
50

src/Lumen/Repository.php 1 location

@@ 8-49 (lines=42) @@
5
use Nwidart\Modules\Json;
6
use Nwidart\Modules\Repository as BaseRepository;
7
8
class Repository extends BaseRepository
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function scan()
14
    {
15
        $paths = $this->getScanPaths();
16
17
        $modules = [];
18
19
        foreach ($paths as $key => $path) {
20
            $manifests = $this->app['files']->glob("{$path}/module.json");
21
22
            is_array($manifests) || $manifests = [];
23
24
            foreach ($manifests as $manifest) {
25
                $name = Json::make($manifest)->get('name');
26
27
                $modules[$name] = new Module($this->app, $name, dirname($manifest));
28
            }
29
        }
30
31
        return $modules;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function formatCached($cached)
38
    {
39
        $modules = [];
40
41
        foreach ($cached as $name => $module) {
42
            $path = $this->config('paths.modules') . '/' . $name;
43
44
            $modules[$name] = new Module($this->app, $name, $path);
45
        }
46
47
        return $modules;
48
    }
49
}
50