Completed
Push — dev ( 6a93ce...82e8fe )
by Zach
03:22
created

PagesTableSeeder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 22
loc 22
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 14 14 2

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 Larafolio\database\seeds;
4
5
use Larafolio\Models\Link;
6
use Larafolio\Models\Page;
7
use Illuminate\Database\Seeder;
8
use Larafolio\Models\TextBlock;
9
10 View Code Duplication
class PagesTableSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
11
{
12
    /**
13
     * Run the database seeds.
14
     *
15
     * @return void
16
     */
17
    public function run()
18
    {
19
        foreach (range(1, 5) as $i) {
20
            $name = 'Page'.$i;
21
22
            factory(Page::class)
23
                ->create(['name' => $name])
24
                ->each(function (Page $project) {
25
                    $project->blocks()->save(factory(TextBlock::class)->make());
26
27
                    $project->links()->save(factory(Link::class)->make());
28
                });
29
        }
30
    }
31
}