LeagueMoviesTableSeeder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 37
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 30 2
1
<?php
2
3
class LeagueMoviesTableSeeder 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
	 * league_movies table seeding
7
	 */
8 9
	public function run() {
9
10
		/** @var League $league */
11 9
		$league = League::find(1);
12 9
		$movies = Movie::all();
13
14
		$went_for = [
15 9
			1  => 14, 2 => 20, 3 => 46, 4 => 17, 5 => 48,
16 9
			6  => 15, 7 => 36, 8 => 26, 9 => 10, 10 => 33,
17 9
			11 => 17, 12 => 25, 13 => 36, 14 => 28, 15 => 30,
18 9
			16 => 15, 17 => 11, 18 => 20, 19 => 18, 20 => 14,
19 9
			21 => 22, 22 => 9, 23 => 9, 24 => 16, 25 => 10,
20 9
			26 => 12, 27 => 7, 28 => 7, 29 => 7, 30 => 6
21 9
		];
22
23 9
		foreach ($went_for as $movie_id => $price) {
24
			/** @var Movie $movie */
25 9
			$movie = $movies->find($movie_id);
26
27 9
			$league_movie = new LeagueMovie();
28
29 9
			$league_movie->movie_id = $movie_id;
30 9
			$league_movie->price = $price;
31 9
			$league_movie->latest_earnings_id = $movie->latest_earnings_id;
32
33 9
			$league->movies()->save($league_movie);
34 9
		}
35
36
37 9
	}
38
39
}