Conditions | 4 |
Paths | 4 |
Total Lines | 42 |
Code Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
12 | function run() |
||
13 | { |
||
14 | $leagues = [ |
||
15 | 'friendly' => 16, |
||
16 | 'europa league' => 8 |
||
17 | ]; |
||
18 | $teams = Team::all()->toArray(); |
||
19 | foreach ($leagues as $league => $teamsNum) { |
||
20 | |||
21 | $teamCopy = $teams; |
||
22 | $league = League::create( |
||
23 | [ |
||
24 | 'name' => $league, |
||
25 | 'teams' => $teamsNum |
||
26 | ] |
||
27 | ); |
||
28 | |||
29 | //Create Rounds |
||
30 | shuffle($teamCopy); |
||
31 | $teamCopy = array_splice($teamCopy, 0, $teamsNum); |
||
32 | $rounds = LeagueFixtureGenerator::generate($teamCopy); |
||
33 | foreach ($rounds as $i => $round) { |
||
34 | |||
35 | $leagueRound = LeagueRound::create( |
||
36 | [ |
||
37 | 'league_id' => $league->id, |
||
38 | 'day' => $i + 1 |
||
39 | ] |
||
40 | ); |
||
41 | |||
42 | foreach ($round as $match) { |
||
43 | $newMatch = Match::create( |
||
44 | [ |
||
45 | 'home_team_id' => $match['home_team_id'], |
||
46 | 'away_team_id' => $match['away_team_id'], |
||
47 | 'league_round_id' => $leagueRound->id |
||
48 | ] |
||
49 | ); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.