Completed
Push — master ( 295ac9...0e0f05 )
by Mahmoud
03:34
created

Seeder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 48.65 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 18
loc 37
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 18 21 5

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Port\Seeder\Abstracts;
4
5
use Illuminate\Database\Seeder as LaravelSeeder;
6
7
/**
8
 * Class Seeder.
9
 *
10
 * @author  Mahmoud Zalt <[email protected]>
11
 */
12
abstract class Seeder extends LaravelSeeder
13
{
14
15
    /**
16
     * Default seeders directory in the container
17
     *
18
     * @var  string
19
     */
20
    protected $seedersPath = '/Data/Seeders/';
21
22
    /**
23
     * Run the database seeds.
24
     *
25
     * @return void
26
     */
27
    public function run()
28
    {
29 View Code Duplication
        foreach (\App\Port\Butler\Portals\Facade\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...
30
31
            $containersDirectory = base_path('app/Containers/' . $containerName . $this->seedersPath);
32
33
            if (\File::isDirectory($containersDirectory)) {
34
35
                $files = \File::allFiles($containersDirectory);
36
37
                foreach ($files as $seederClass) {
38
39
                    if (\File::isFile($seederClass)) {
40
                        $this->call($seederClass);
41
                    }
42
43
                }
44
45
            }
46
        }
47
    }
48
}
49