DatabaseSeeder::run()   B
last analyzed

Complexity

Conditions 5
Paths 9

Size

Total Lines 46
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 5.1374

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 28
cts 34
cp 0.8235
rs 8.4751
c 0
b 0
f 0
cc 5
eloc 31
nc 9
nop 0
crap 5.1374
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