Code Duplication    Length = 40-51 lines in 4 locations

src/Installer/Console/Command/LoadExtensionInstallers.php 1 location

@@ 18-57 (lines=40) @@
15
 * @author        Ryan Thompson <[email protected]>
16
 * @package       Anomaly\Streams\Platform\Installer\Console\Command
17
 */
18
class LoadExtensionInstallers implements SelfHandling
19
{
20
21
    /**
22
     * The installer collection.
23
     *
24
     * @var InstallerCollection
25
     */
26
    protected $installers;
27
28
    /**
29
     * Create a new LoadExtensionInstallers instance.
30
     *
31
     * @param InstallerCollection $installers
32
     */
33
    public function __construct(InstallerCollection $installers)
34
    {
35
        $this->installers = $installers;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @param ExtensionCollection $extensions
42
     */
43
    public function handle(ExtensionCollection $extensions)
44
    {
45
        /* @var Extension $extension */
46
        foreach ($extensions as $extension) {
47
            $this->installers->add(
48
                new Installer(
49
                    trans('streams::installer.installing', ['installing' => trans($extension->getName())]),
50
                    function (Kernel $console) use ($extension) {
51
                        $console->call('extension:install', ['extension' => $extension->getNamespace()]);
52
                    }
53
                )
54
            );
55
        }
56
    }
57
}
58

src/Installer/Console/Command/LoadModuleInstallers.php 1 location

@@ 18-62 (lines=45) @@
15
 * @author        Ryan Thompson <[email protected]>
16
 * @package       Anomaly\Streams\Platform\Installer\Console\Command
17
 */
18
class LoadModuleInstallers implements SelfHandling
19
{
20
21
    /**
22
     * The installer collection.
23
     *
24
     * @var InstallerCollection
25
     */
26
    protected $installers;
27
28
    /**
29
     * Create a new LoadModuleInstallers instance.
30
     *
31
     * @param InstallerCollection $installers
32
     */
33
    public function __construct(InstallerCollection $installers)
34
    {
35
        $this->installers = $installers;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @param ModuleCollection $modules
42
     */
43
    public function handle(ModuleCollection $modules)
44
    {
45
        /* @var Module $module */
46
        foreach ($modules as $module) {
47
48
            if ($module->getNamespace() == 'anomaly.module.installer') {
49
                continue;
50
            }
51
52
            $this->installers->add(
53
                new Installer(
54
                    trans('streams::installer.installing', ['installing' => trans($module->getName())]),
55
                    function (Kernel $console) use ($module) {
56
                        $console->call('module:install', ['module' => $module->getNamespace()]);
57
                    }
58
                )
59
            );
60
        }
61
    }
62
}
63

src/Installer/Console/Command/LoadExtensionSeeders.php 1 location

@@ 18-63 (lines=46) @@
15
 * @author        Ryan Thompson <[email protected]>
16
 * @package       Anomaly\Streams\Platform\Installer\Console\Command
17
 */
18
class LoadExtensionSeeders implements SelfHandling
19
{
20
21
    /**
22
     * The installer collection.
23
     *
24
     * @var InstallerCollection
25
     */
26
    protected $installers;
27
28
    /**
29
     * Create a new LoadExtensionSeeders instance.
30
     *
31
     * @param InstallerCollection $installers
32
     */
33
    public function __construct(InstallerCollection $installers)
34
    {
35
        $this->installers = $installers;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @param ExtensionCollection $extensions
42
     */
43
    public function handle(ExtensionCollection $extensions)
44
    {
45
        /* @var Extension $extension */
46
        foreach ($extensions as $extension) {
47
            $this->installers->add(
48
                new Installer(
49
                    trans('streams::installer.seeding', ['seeding' => trans($extension->getName())]),
50
                    function (Kernel $console) use ($extension) {
51
                        $console->call(
52
                            'db:seed',
53
                            [
54
                                '--addon' => $extension->getNamespace(),
55
                                '--force' => true
56
                            ]
57
                        );
58
                    }
59
                )
60
            );
61
        }
62
    }
63
}
64

src/Installer/Console/Command/LoadModuleSeeders.php 1 location

@@ 18-68 (lines=51) @@
15
 * @author        Ryan Thompson <[email protected]>
16
 * @package       Anomaly\Streams\Platform\Installer\Console\Command
17
 */
18
class LoadModuleSeeders implements SelfHandling
19
{
20
21
    /**
22
     * The installer collection.
23
     *
24
     * @var InstallerCollection
25
     */
26
    protected $installers;
27
28
    /**
29
     * Create a new LoadModuleSeeders instance.
30
     *
31
     * @param InstallerCollection $installers
32
     */
33
    public function __construct(InstallerCollection $installers)
34
    {
35
        $this->installers = $installers;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @param ModuleCollection $modules
42
     */
43
    public function handle(ModuleCollection $modules)
44
    {
45
        /* @var Module $module */
46
        foreach ($modules as $module) {
47
48
            if ($module->getNamespace() == 'anomaly.module.installer') {
49
                continue;
50
            }
51
52
            $this->installers->add(
53
                new Installer(
54
                    trans('streams::installer.seeding', ['seeding' => trans($module->getName())]),
55
                    function (Kernel $console) use ($module) {
56
                        $console->call(
57
                            'db:seed',
58
                            [
59
                                '--addon' => $module->getNamespace(),
60
                                '--force' => true
61
                            ]
62
                        );
63
                    }
64
                )
65
            );
66
        }
67
    }
68
}
69