Completed
Push — master ( d03d4d...9527ea )
by Mahmoud
02:48
created

SeederLoaderAbstract::run()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 27
Code Lines 10

Duplication

Lines 23
Ratio 85.19 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 23
loc 27
rs 8.439
c 1
b 0
f 0
cc 5
eloc 10
nc 5
nop 0
1
<?php
2
3
namespace App\Port\Seeder\Loaders;
4
5
use App\Port\Butler\Portals\Facade\PortButler;
6
use Illuminate\Database\Seeder as LaravelSeeder;
7
8
/**
9
 * Class Seeder.
10
 *
11
 * @author  Mahmoud Zalt <[email protected]>
12
 */
13
abstract class SeederLoaderAbstract extends LaravelSeeder
14
{
15
16
    /**
17
     * Default seeders directory in the container
18
     *
19
     * @var  string
20
     */
21
    protected $seedersPath = '/Data/Seeders';
22
23
    /**
24
     * Run the database seeds.
25
     * Then Automatically register all Seeders from Containers.
26
     *
27
     * @return void
28
     */
29
    public function run()
30
    {
31
32 View Code Duplication
        foreach (PortButler::getContainersNames() as $containerName) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
34
            $containersDirectory = base_path('app/Containers/' . $containerName . $this->seedersPath);
35
36
            if (\File::isDirectory($containersDirectory)) {
37
38
                $files = \File::allFiles($containersDirectory);
39
40
                foreach ($files as $seederClass) {
41
42
                    if (\File::isFile($seederClass)) {
43
44
                        $pathName = $seederClass->getPathname();
45
46
                        $class = PortButler::getClassFullNameFromFile($pathName);
47
48
                        $this->call($class);
49
                    }
50
51
                }
52
53
            }
54
        }
55
    }
56
57
}
58