DatabaseSeeder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 82.35%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 55
ccs 28
cts 34
cp 0.8235
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 46 5
1
<?php
2
3
class DatabaseSeeder extends Seeder {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	/**
6
	 * Run the database seeds.
7
	 *
8
	 * @return void
9
	 */
10 9
	public function run()
11
	{
12
		// But seriously no
13 9
		if(App::environment() == 'production') {
14
			echo 'No, seriously';
15
16
			return;
17
		}
18 9
		$disableForeignKeyChecks = in_array(DB::connection()->getDriverName(), ['mysql']);
19
20 9
		Eloquent::unguard();
21 9
		if ($disableForeignKeyChecks) {
22
			DB::statement('SET FOREIGN_KEY_CHECKS=0;');
23
		}
24
25
		// Cleanup
26
		$tables = [
27 9
			'league_admins',
28 9
			'league_team_movies',
29 9
			'league_movies',
30 9
			'league_team_user',
31 9
			'league_teams',
32 9
			'leagues',
33 9
			'movie_earnings',
34 9
			'movies',
35
			'users'
36 9
		];
37 9
		foreach($tables as $table) {
38 9
			DB::table($table)->truncate();
39 9
		}
40
41 9
		if ($disableForeignKeyChecks) {
42
			DB::statement('SET FOREIGN_KEY_CHECKS=1;');
43
		}
44
45
		// Seeding
46 9
		$this->call('UserTableSeeder');
47 9
		$this->call('LeagueTableSeeder');
48 9
		$this->call('LeagueAdminsTableSeeder');
49 9
		$this->call('MovieTableSeeder');
50 9
		$this->call('MovieEarningsTableSeeder');
51 9
		$this->call('LeagueMoviesTableSeeder');
52 9
		$this->call('LeagueTeamsTableSeeder');
53 9
		$this->call('LeagueTeamUsersTableSeeder');
54 9
		$this->call('LeagueTeamMoviesTableSeeder');
55 9
	}
56
57
}
58