Completed
Push — master ( 9fe9e2...c60305 )
by Vincenzo
04:53 queued 02:24
created
api/database/migrations/CreateMatchPlayersTable.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -5,22 +5,22 @@
 block discarded – undo
5 5
 
6 6
 class CreateMatchPlayersTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('match_players');
16
-        Capsule::schema()->create('match_players', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('match_id');
19
-            $table->integer('team_id');
20
-            $table->integer('player_id')->default(0);
21
-            $table->unsignedTinyInteger('goals')->default(0);
22
-            $table->unsignedTinyInteger('vote')->default(6);
23
-            $table->timestamps();
24
-        });
25
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('match_players');
16
+		Capsule::schema()->create('match_players', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('match_id');
19
+			$table->integer('team_id');
20
+			$table->integer('player_id')->default(0);
21
+			$table->unsignedTinyInteger('goals')->default(0);
22
+			$table->unsignedTinyInteger('vote')->default(6);
23
+			$table->timestamps();
24
+		});
25
+	}
26 26
 }
Please login to merge, or discard this patch.
api/tests/ModelsTest.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -8,227 +8,227 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 
11
-    /**
12
-     * @group Player
13
-     */
14
-    public function testGetRandomPlayer()
15
-    {
16
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
17
-        $player = $rndF->getPlayer(null, $rndF->getLocale());
18
-        $array = $player->toArray();
19
-        $this->assertNotEmpty($array);
20
-
21
-        $newPlayer = \App\Lib\DsManager\Models\Player::fromArray($array);
22
-        $this->assertNotEmpty($newPlayer->toArray());
23
-    }
24
-
25
-    /**
26
-     * @group Coach
27
-     */
28
-    public function testGetRandomCoach()
29
-    {
30
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
31
-        $coach = $rndF->getCoach();
32
-        $this->assertNotEmpty($coach->toArray());
33
-    }
34
-
35
-    /**
36
-     * @group Coaches
37
-     */
38
-    public function testGetRandomCoaches()
39
-    {
40
-        foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
41
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
42
-            $coach = $rndF->getCoach();
43
-            $this->assertNotEmpty($coach->toArray());
44
-        }
45
-    }
46
-
47
-    /**
48
-     * @group Players
49
-     */
50
-    public function testGetRandomPlayers()
51
-    {
52
-        foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
53
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
54
-            $player = $rndF->getPlayer();
55
-            $this->assertNotEmpty($player->toArray());
56
-        }
57
-    }
58
-
59
-    /**
60
-     * @group Team
61
-     */
62
-    public function testGetRandomTeam()
63
-    {
64
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
65
-        $team = $rndF->getTeam();
66
-        $this->assertNotEmpty($team);
67
-        $this->assertNotEmpty($team->name);
68
-        $this->assertNotEmpty($team->getAvgSkill());
69
-
70
-        //After Adding a player
71
-        $player = $rndF->getPlayer();
72
-        $this->assertNotEmpty($player->toArray());
73
-        $team->roster[] = $player;
74
-        $this->assertNotEmpty($team->getAvgSkill());
75
-        $this->assertNotEmpty($team->getAvgAge());
76
-
77
-        $this->assertNotEmpty($team->coach->toArray());
78
-
79
-        $teamArray = $team->toArray();
80
-        $this->assertNotEmpty($teamArray);
81
-
82
-        $newTeam = \App\Lib\DsManager\Models\Team::fromArray($teamArray);
83
-        $this->assertNotEmpty($newTeam->toArray());
84
-
85
-    }
86
-
87
-    /**
88
-     * @group Teams
89
-     */
90
-    public function testGetRandomTeams()
91
-    {
92
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
93
-
94
-        for ($i = 1; $i <= 20; $i++) {
95
-            $team = $rndF->getTeam();
96
-            $this->assertGreaterThanOrEqual(
97
-                \App\Lib\Helpers\Config::get('generic.rosters')['min'],
98
-                count($team->roster)
99
-            );
100
-            $this->assertNotEmpty($team->name);
101
-            $this->assertNotEmpty($team->nationality);
102
-            $this->assertNotEmpty($team->getAvgSkill());
103
-            $this->assertNotEmpty($team->getAvgAge());
104
-        }
105
-    }
106
-
107
-    /**
108
-     * @group Match
109
-     */
110
-    public function testGetRandomMatch()
111
-    {
112
-        for ($i = 1; $i <= 30; $i++) {
113
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
114
-            $spanish = $rndF->getTeam();
115
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
116
-            $italian = $rndF->getTeam();
117
-            $this->assertNotEmpty($spanish);
118
-            $this->assertNotEmpty($italian);
119
-            $this->assertNotEmpty($italian->name);
120
-            $this->assertNotEmpty($spanish);
121
-            $this->assertNotEmpty($spanish->name);
122
-
123
-            $this->assertNotEmpty($italian->getAvgSkill());
124
-            $this->assertNotEmpty($spanish->getAvgSkill());
125
-            $result = (new \App\Lib\DsManager\Models\Match($italian, $spanish))->simulate()->toArray();
126
-            $this->assertNotEmpty($result);
127
-            $this->assertGreaterThanOrEqual(0, $result['goal_home']);
128
-            $this->assertGreaterThanOrEqual(0, $result['goal_away']);
129
-
130
-        }
131
-    }
132
-
133
-    /**
134
-     * @group Match
135
-     * @group MatchResult
136
-     * @group matchresultoutput
137
-     */
138
-    public function testMatchFromExistingTeams()
139
-    {
140
-        $teamHome = 1;
141
-        $teamAway = 2;
142
-        $homeOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamHome])->first();
143
-        $awayOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamAway])->first();
144
-        $home = \App\Lib\DsManager\Models\Team::fromArray($homeOrm->toArray());
145
-        $away = \App\Lib\DsManager\Models\Team::fromArray($awayOrm->toArray());
146
-
147
-        $match = new \App\Lib\DsManager\Models\Match($home, $away);
148
-        $result = $match->simulate()->toArray();
149
-        $this->assertNotEmpty($result);
150
-        $this->assertGreaterThanOrEqual(0, $result['goal_away']);
151
-        $this->assertGreaterThanOrEqual(0, $result['goal_home']);
152
-        if ($result['goal_home'] > 0) {
153
-            $this->assertNotEmpty($result['info']['scorers']['home']);
154
-            foreach ($result['info']['scorers']['home'] as $scorerHome) {
155
-                $this->assertEquals($scorerHome->team_id, $teamHome);
156
-            }
157
-        } else {
158
-            $this->assertEmpty($result['info']['scorers']['home']);
159
-        }
160
-        if ($result['goal_away'] > 0) {
161
-            $this->assertNotEmpty($result['info']['scorers']['away']);
162
-            foreach ($result['info']['scorers']['away'] as $scorerAway) {
163
-                $this->assertEquals($scorerAway->team_id, $teamAway);
164
-            }
165
-        } else {
166
-            $this->assertEmpty($result['info']['scorers']['away']);
167
-        }
168
-        if ($result['goal_home'] == $result['goal_away']) {
169
-            $this->assertTrue($result['info']['is_draw']);
170
-        } else {
171
-            $this->assertFalse($result['info']['is_draw']);
172
-        }
173
-    }
174
-
175
-    /**
176
-     * @group Matches
177
-     */
178
-    public function testGetRandomMatchesOneTeam()
179
-    {
180
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
181
-        $myTeam = $rndF->getTeam();
182
-        $myTeam->id = 1000;
183
-        $win = 0;
184
-        $lost = 0;
185
-        $draw = 0;
186
-
187
-        for ($i = 1; $i <= 2; $i++) {
188
-
189
-            $randomLocale = \App\Lib\Helpers\Config::get('generic.localesSmall');
190
-            shuffle($randomLocale);
191
-            $randomLocale = $randomLocale[0];
192
-            $rndF = new \App\Lib\DsManager\Helpers\RandomFiller($randomLocale);
193
-            $opponent = $rndF->getTeam();
194
-            $opponent->id = 6000;
195
-            $result = (new \App\Lib\DsManager\Models\Match($opponent, $myTeam))->simulate()->toArray();
196
-            $this->assertNotEmpty($result);
197
-            $result = $result['info'];
198
-            if (!$result['is_draw']) {
199
-                if ($result['winner_id'] == $myTeam->id) {
200
-                    $win++;
201
-                } else {
202
-                    $lost++;
203
-                }
204
-            } else {
205
-                $draw++;
206
-            }
207
-        }
208
-        $this->assertGreaterThanOrEqual(0, $win);
209
-        $this->assertGreaterThanOrEqual(0, $lost);
210
-        $this->assertGreaterThanOrEqual(0, $draw);
211
-    }
212
-
213
-    /**
214
-     * @group Module
215
-     */
216
-    public function testModule()
217
-    {
218
-        $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
219
-        $team = $rndF->getTeam();
220
-
221
-        $modules = \App\Lib\Helpers\Config::get("modules.modules");
222
-        $modules = array_keys($modules);
223
-        foreach ($modules as $mod) {
224
-            $module = new \App\Lib\DsManager\Models\Module($mod);
225
-            $this->assertNotEmpty($module);
226
-            $this->assertNotNull($module->isDefensive());
227
-            $this->assertNotNull($module->isBalanced());
228
-            $this->assertNotNull($module->isOffensive());
229
-            $this->assertTrue(is_array($module->getRoleNeeded()));
230
-        }
231
-        $this->assertGreaterThan(0, $team->playersPerRoleArray());
232
-    }
11
+	/**
12
+	 * @group Player
13
+	 */
14
+	public function testGetRandomPlayer()
15
+	{
16
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
17
+		$player = $rndF->getPlayer(null, $rndF->getLocale());
18
+		$array = $player->toArray();
19
+		$this->assertNotEmpty($array);
20
+
21
+		$newPlayer = \App\Lib\DsManager\Models\Player::fromArray($array);
22
+		$this->assertNotEmpty($newPlayer->toArray());
23
+	}
24
+
25
+	/**
26
+	 * @group Coach
27
+	 */
28
+	public function testGetRandomCoach()
29
+	{
30
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller();
31
+		$coach = $rndF->getCoach();
32
+		$this->assertNotEmpty($coach->toArray());
33
+	}
34
+
35
+	/**
36
+	 * @group Coaches
37
+	 */
38
+	public function testGetRandomCoaches()
39
+	{
40
+		foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
41
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
42
+			$coach = $rndF->getCoach();
43
+			$this->assertNotEmpty($coach->toArray());
44
+		}
45
+	}
46
+
47
+	/**
48
+	 * @group Players
49
+	 */
50
+	public function testGetRandomPlayers()
51
+	{
52
+		foreach (\App\Lib\Helpers\Config::get('generic.localesSmall') as $nat) {
53
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($nat);
54
+			$player = $rndF->getPlayer();
55
+			$this->assertNotEmpty($player->toArray());
56
+		}
57
+	}
58
+
59
+	/**
60
+	 * @group Team
61
+	 */
62
+	public function testGetRandomTeam()
63
+	{
64
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
65
+		$team = $rndF->getTeam();
66
+		$this->assertNotEmpty($team);
67
+		$this->assertNotEmpty($team->name);
68
+		$this->assertNotEmpty($team->getAvgSkill());
69
+
70
+		//After Adding a player
71
+		$player = $rndF->getPlayer();
72
+		$this->assertNotEmpty($player->toArray());
73
+		$team->roster[] = $player;
74
+		$this->assertNotEmpty($team->getAvgSkill());
75
+		$this->assertNotEmpty($team->getAvgAge());
76
+
77
+		$this->assertNotEmpty($team->coach->toArray());
78
+
79
+		$teamArray = $team->toArray();
80
+		$this->assertNotEmpty($teamArray);
81
+
82
+		$newTeam = \App\Lib\DsManager\Models\Team::fromArray($teamArray);
83
+		$this->assertNotEmpty($newTeam->toArray());
84
+
85
+	}
86
+
87
+	/**
88
+	 * @group Teams
89
+	 */
90
+	public function testGetRandomTeams()
91
+	{
92
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
93
+
94
+		for ($i = 1; $i <= 20; $i++) {
95
+			$team = $rndF->getTeam();
96
+			$this->assertGreaterThanOrEqual(
97
+				\App\Lib\Helpers\Config::get('generic.rosters')['min'],
98
+				count($team->roster)
99
+			);
100
+			$this->assertNotEmpty($team->name);
101
+			$this->assertNotEmpty($team->nationality);
102
+			$this->assertNotEmpty($team->getAvgSkill());
103
+			$this->assertNotEmpty($team->getAvgAge());
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * @group Match
109
+	 */
110
+	public function testGetRandomMatch()
111
+	{
112
+		for ($i = 1; $i <= 30; $i++) {
113
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
114
+			$spanish = $rndF->getTeam();
115
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
116
+			$italian = $rndF->getTeam();
117
+			$this->assertNotEmpty($spanish);
118
+			$this->assertNotEmpty($italian);
119
+			$this->assertNotEmpty($italian->name);
120
+			$this->assertNotEmpty($spanish);
121
+			$this->assertNotEmpty($spanish->name);
122
+
123
+			$this->assertNotEmpty($italian->getAvgSkill());
124
+			$this->assertNotEmpty($spanish->getAvgSkill());
125
+			$result = (new \App\Lib\DsManager\Models\Match($italian, $spanish))->simulate()->toArray();
126
+			$this->assertNotEmpty($result);
127
+			$this->assertGreaterThanOrEqual(0, $result['goal_home']);
128
+			$this->assertGreaterThanOrEqual(0, $result['goal_away']);
129
+
130
+		}
131
+	}
132
+
133
+	/**
134
+	 * @group Match
135
+	 * @group MatchResult
136
+	 * @group matchresultoutput
137
+	 */
138
+	public function testMatchFromExistingTeams()
139
+	{
140
+		$teamHome = 1;
141
+		$teamAway = 2;
142
+		$homeOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamHome])->first();
143
+		$awayOrm = \App\Lib\DsManager\Models\Orm\Team::with('roster', 'coach')->where(['id' => $teamAway])->first();
144
+		$home = \App\Lib\DsManager\Models\Team::fromArray($homeOrm->toArray());
145
+		$away = \App\Lib\DsManager\Models\Team::fromArray($awayOrm->toArray());
146
+
147
+		$match = new \App\Lib\DsManager\Models\Match($home, $away);
148
+		$result = $match->simulate()->toArray();
149
+		$this->assertNotEmpty($result);
150
+		$this->assertGreaterThanOrEqual(0, $result['goal_away']);
151
+		$this->assertGreaterThanOrEqual(0, $result['goal_home']);
152
+		if ($result['goal_home'] > 0) {
153
+			$this->assertNotEmpty($result['info']['scorers']['home']);
154
+			foreach ($result['info']['scorers']['home'] as $scorerHome) {
155
+				$this->assertEquals($scorerHome->team_id, $teamHome);
156
+			}
157
+		} else {
158
+			$this->assertEmpty($result['info']['scorers']['home']);
159
+		}
160
+		if ($result['goal_away'] > 0) {
161
+			$this->assertNotEmpty($result['info']['scorers']['away']);
162
+			foreach ($result['info']['scorers']['away'] as $scorerAway) {
163
+				$this->assertEquals($scorerAway->team_id, $teamAway);
164
+			}
165
+		} else {
166
+			$this->assertEmpty($result['info']['scorers']['away']);
167
+		}
168
+		if ($result['goal_home'] == $result['goal_away']) {
169
+			$this->assertTrue($result['info']['is_draw']);
170
+		} else {
171
+			$this->assertFalse($result['info']['is_draw']);
172
+		}
173
+	}
174
+
175
+	/**
176
+	 * @group Matches
177
+	 */
178
+	public function testGetRandomMatchesOneTeam()
179
+	{
180
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
181
+		$myTeam = $rndF->getTeam();
182
+		$myTeam->id = 1000;
183
+		$win = 0;
184
+		$lost = 0;
185
+		$draw = 0;
186
+
187
+		for ($i = 1; $i <= 2; $i++) {
188
+
189
+			$randomLocale = \App\Lib\Helpers\Config::get('generic.localesSmall');
190
+			shuffle($randomLocale);
191
+			$randomLocale = $randomLocale[0];
192
+			$rndF = new \App\Lib\DsManager\Helpers\RandomFiller($randomLocale);
193
+			$opponent = $rndF->getTeam();
194
+			$opponent->id = 6000;
195
+			$result = (new \App\Lib\DsManager\Models\Match($opponent, $myTeam))->simulate()->toArray();
196
+			$this->assertNotEmpty($result);
197
+			$result = $result['info'];
198
+			if (!$result['is_draw']) {
199
+				if ($result['winner_id'] == $myTeam->id) {
200
+					$win++;
201
+				} else {
202
+					$lost++;
203
+				}
204
+			} else {
205
+				$draw++;
206
+			}
207
+		}
208
+		$this->assertGreaterThanOrEqual(0, $win);
209
+		$this->assertGreaterThanOrEqual(0, $lost);
210
+		$this->assertGreaterThanOrEqual(0, $draw);
211
+	}
212
+
213
+	/**
214
+	 * @group Module
215
+	 */
216
+	public function testModule()
217
+	{
218
+		$rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT");
219
+		$team = $rndF->getTeam();
220
+
221
+		$modules = \App\Lib\Helpers\Config::get("modules.modules");
222
+		$modules = array_keys($modules);
223
+		foreach ($modules as $mod) {
224
+			$module = new \App\Lib\DsManager\Models\Module($mod);
225
+			$this->assertNotEmpty($module);
226
+			$this->assertNotNull($module->isDefensive());
227
+			$this->assertNotNull($module->isBalanced());
228
+			$this->assertNotNull($module->isOffensive());
229
+			$this->assertTrue(is_array($module->getRoleNeeded()));
230
+		}
231
+		$this->assertGreaterThan(0, $team->playersPerRoleArray());
232
+	}
233 233
 
234 234
 }
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/MatchResult.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -13,118 +13,118 @@
 block discarded – undo
13 13
  */
14 14
 class MatchResult extends DsManagerModel
15 15
 {
16
-    /**
17
-     * @var
18
-     */
19
-    private $goalHome;
20
-    /**
21
-     * @var
22
-     */
23
-    private $goalAway;
24
-    /**
25
-     * @var Team
26
-     */
27
-    private $homeTeam;
28
-    /**
29
-     * @var Team
30
-     */
31
-    private $awayTeam;
16
+	/**
17
+	 * @var
18
+	 */
19
+	private $goalHome;
20
+	/**
21
+	 * @var
22
+	 */
23
+	private $goalAway;
24
+	/**
25
+	 * @var Team
26
+	 */
27
+	private $homeTeam;
28
+	/**
29
+	 * @var Team
30
+	 */
31
+	private $awayTeam;
32 32
 
33
-    /**
34
-     * MatchResult constructor.
35
-     * @param $goalHome
36
-     * @param $goalAway
37
-     * @param Team $home
38
-     * @param Team $away
39
-     */
40
-    public function __construct($goalHome, $goalAway, Team $home, Team $away)
41
-    {
42
-        $this->goalHome = $goalHome;
43
-        $this->goalAway = $goalAway;
44
-        $this->homeTeam = $home;
45
-        $this->awayTeam = $away;
46
-    }
33
+	/**
34
+	 * MatchResult constructor.
35
+	 * @param $goalHome
36
+	 * @param $goalAway
37
+	 * @param Team $home
38
+	 * @param Team $away
39
+	 */
40
+	public function __construct($goalHome, $goalAway, Team $home, Team $away)
41
+	{
42
+		$this->goalHome = $goalHome;
43
+		$this->goalAway = $goalAway;
44
+		$this->homeTeam = $home;
45
+		$this->awayTeam = $away;
46
+	}
47 47
 
48
-    /**
49
-     * @return array
50
-     */
51
-    public function getWinnerLoser()
52
-    {
53
-        $isDraw = false;
54
-        $winner = $this->awayTeam;
55
-        $loser = $this->homeTeam;
56
-        if ($this->goalAway == $this->goalHome) {
57
-            $isDraw = true;
58
-        } else if ($this->goalHome < $this->goalAway) {
59
-            $winner = $this->awayTeam;
60
-            $loser = $this->homeTeam;
61
-        }
62
-        return [
63
-            'is_draw' => $isDraw,
64
-            'winner_id' => $winner->id,
65
-            'loser_id' => $loser->id
66
-        ];
67
-    }
48
+	/**
49
+	 * @return array
50
+	 */
51
+	public function getWinnerLoser()
52
+	{
53
+		$isDraw = false;
54
+		$winner = $this->awayTeam;
55
+		$loser = $this->homeTeam;
56
+		if ($this->goalAway == $this->goalHome) {
57
+			$isDraw = true;
58
+		} else if ($this->goalHome < $this->goalAway) {
59
+			$winner = $this->awayTeam;
60
+			$loser = $this->homeTeam;
61
+		}
62
+		return [
63
+			'is_draw' => $isDraw,
64
+			'winner_id' => $winner->id,
65
+			'loser_id' => $loser->id
66
+		];
67
+	}
68 68
 
69
-    /**
70
-     * @return array
71
-     */
72
-    public function toArray()
73
-    {
74
-        $result = [];
75
-        $result['home_team_id'] = $this->homeTeam->id;
76
-        $result['away_team_id'] = $this->awayTeam->id;
77
-        $result['goal_home'] = $this->goalHome;
78
-        $result['goal_away'] = $this->goalAway;
79
-        $result['info'] = $this->getWinnerLoser();
80
-        $result['info']['scorers'] = $this->getScorers();
81
-        $result['simulated'] = true;
82
-        return $result;
83
-    }
84
-    /**
85
-     * @return array
86
-     */
87
-    private function getScorers()
88
-    {
89
-        $scorers = [
90
-            'home' => [],
91
-            'away' => []
92
-        ];
93
-        for ($i = 0; $i < $this->goalHome; $i++) {
94
-            $scorers['home'][] = $this->pickAScorer($this->homeTeam);
95
-        }
96
-        for ($i = 0; $i < $this->goalAway; $i++) {
97
-            $scorers['away'][] = $this->pickAScorer($this->awayTeam);
98
-        }
99
-        return $scorers;
100
-    }
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function toArray()
73
+	{
74
+		$result = [];
75
+		$result['home_team_id'] = $this->homeTeam->id;
76
+		$result['away_team_id'] = $this->awayTeam->id;
77
+		$result['goal_home'] = $this->goalHome;
78
+		$result['goal_away'] = $this->goalAway;
79
+		$result['info'] = $this->getWinnerLoser();
80
+		$result['info']['scorers'] = $this->getScorers();
81
+		$result['simulated'] = true;
82
+		return $result;
83
+	}
84
+	/**
85
+	 * @return array
86
+	 */
87
+	private function getScorers()
88
+	{
89
+		$scorers = [
90
+			'home' => [],
91
+			'away' => []
92
+		];
93
+		for ($i = 0; $i < $this->goalHome; $i++) {
94
+			$scorers['home'][] = $this->pickAScorer($this->homeTeam);
95
+		}
96
+		for ($i = 0; $i < $this->goalAway; $i++) {
97
+			$scorers['away'][] = $this->pickAScorer($this->awayTeam);
98
+		}
99
+		return $scorers;
100
+	}
101 101
 
102
-    /**
103
-     * @param Team $team
104
-     * @return Player
105
-     */
106
-    private function pickAScorer(Team $team)
107
-    {
108
-        $player = null;
109
-        if (Randomizer::boolOnPercentage(70)) {
110
-            $roles = Config::get('modules.roles');
111
-            $forwards = array_splice($roles, count($roles) / 2);
112
-            $pos = array_rand($forwards);
113
-            unset($forwards[$pos]);
114
-            $player = $team->getBestPlayerForRole($pos);
115
-            while (empty($player)) {
116
-                if (!empty($forwards)) {
117
-                    $pos = array_rand($forwards);
118
-                    unset($forwards[$pos]);
119
-                    $player = $team->getBestPlayerForRole($pos);
120
-                } else {
121
-                    $player = $team->roster[array_rand($team->roster)];
122
-                }
123
-            }
124
-        } else {
125
-            $player = $team->roster[array_rand($team->roster)];
126
-        }
127
-        return $player;
128
-    }
102
+	/**
103
+	 * @param Team $team
104
+	 * @return Player
105
+	 */
106
+	private function pickAScorer(Team $team)
107
+	{
108
+		$player = null;
109
+		if (Randomizer::boolOnPercentage(70)) {
110
+			$roles = Config::get('modules.roles');
111
+			$forwards = array_splice($roles, count($roles) / 2);
112
+			$pos = array_rand($forwards);
113
+			unset($forwards[$pos]);
114
+			$player = $team->getBestPlayerForRole($pos);
115
+			while (empty($player)) {
116
+				if (!empty($forwards)) {
117
+					$pos = array_rand($forwards);
118
+					unset($forwards[$pos]);
119
+					$player = $team->getBestPlayerForRole($pos);
120
+				} else {
121
+					$player = $team->roster[array_rand($team->roster)];
122
+				}
123
+			}
124
+		} else {
125
+			$player = $team->roster[array_rand($team->roster)];
126
+		}
127
+		return $player;
128
+	}
129 129
 
130 130
 }
131 131
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/Randomizer.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,22 +10,22 @@
 block discarded – undo
10 10
  */
11 11
 class Randomizer
12 12
 {
13
-    /**
14
-     * @param $percentage
15
-     * @return bool
16
-     */
17
-    public static function boolOnPercentage($percentage)
18
-    {
19
-        return (rand(0, 100) < $percentage);
20
-    }
13
+	/**
14
+	 * @param $percentage
15
+	 * @return bool
16
+	 */
17
+	public static function boolOnPercentage($percentage)
18
+	{
19
+		return (rand(0, 100) < $percentage);
20
+	}
21 21
 
22
-    /**
23
-     * @param $skill
24
-     * @return int
25
-     */
26
-    public static function voteFromSkill($skill)
27
-    {
28
-        return rand((2 * ($skill - 100) / 25), 10);
29
-    }
22
+	/**
23
+	 * @param $skill
24
+	 * @return int
25
+	 */
26
+	public static function voteFromSkill($skill)
27
+	{
28
+		return rand((2 * ($skill - 100) / 25), 10);
29
+	}
30 30
 
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/MatchResult.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -9,118 +9,118 @@
 block discarded – undo
9 9
  */
10 10
 class MatchResult extends Match
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    protected $fillable = [
16
-        'goal_home',
17
-        'goal_away',
18
-        'info',
19
-        'simulated'
20
-    ];
12
+	/**
13
+	 * @var array
14
+	 */
15
+	protected $fillable = [
16
+		'goal_home',
17
+		'goal_away',
18
+		'info',
19
+		'simulated'
20
+	];
21 21
 
22
-    protected $hidden = [
23
-        'home_team_id',
24
-        'away_team_id',
25
-        'created_at',
26
-        'updated_at'
27
-    ];
22
+	protected $hidden = [
23
+		'home_team_id',
24
+		'away_team_id',
25
+		'created_at',
26
+		'updated_at'
27
+	];
28 28
 
29
-    /**
30
-     * @var array
31
-     */
32
-    protected $casts = [
33
-        'info' => 'json',
34
-        'simulated' => 'boolean'
35
-    ];
29
+	/**
30
+	 * @var array
31
+	 */
32
+	protected $casts = [
33
+		'info' => 'json',
34
+		'simulated' => 'boolean'
35
+	];
36 36
 
37
-    public static function resolveAttributes(array $attributes, $matchId)
38
-    {
39
-        self::generateAppearances(
40
-            [
41
-                $attributes['home_team_id'],
42
-                $attributes['away_team_id']
43
-            ],
44
-            $matchId
45
-        );
46
-        if (array_key_exists('info', $attributes)) {
47
-            if (array_key_exists('scorers', $attributes['info'])) {
48
-                foreach ($attributes['info']['scorers']['home'] as $scorerHome) {
49
-                    self::addScorer($matchId, $attributes['home_team_id'], $scorerHome->id);
50
-                }
51
-                foreach ($attributes['info']['scorers']['away'] as $scorerAway) {
52
-                    self::addScorer($matchId, $attributes['away_team_id'], $scorerAway->id);
53
-                }
54
-                unset($attributes['info']['scorers']);
55
-            }
56
-            $attributes['info'] = json_encode($attributes['info']);
57
-        }
58
-        return $attributes;
59
-    }
37
+	public static function resolveAttributes(array $attributes, $matchId)
38
+	{
39
+		self::generateAppearances(
40
+			[
41
+				$attributes['home_team_id'],
42
+				$attributes['away_team_id']
43
+			],
44
+			$matchId
45
+		);
46
+		if (array_key_exists('info', $attributes)) {
47
+			if (array_key_exists('scorers', $attributes['info'])) {
48
+				foreach ($attributes['info']['scorers']['home'] as $scorerHome) {
49
+					self::addScorer($matchId, $attributes['home_team_id'], $scorerHome->id);
50
+				}
51
+				foreach ($attributes['info']['scorers']['away'] as $scorerAway) {
52
+					self::addScorer($matchId, $attributes['away_team_id'], $scorerAway->id);
53
+				}
54
+				unset($attributes['info']['scorers']);
55
+			}
56
+			$attributes['info'] = json_encode($attributes['info']);
57
+		}
58
+		return $attributes;
59
+	}
60 60
 
61
-    private static function addScorer($matchId, $teamId, $playerId)
62
-    {
63
-        $scorer = MatchPlayer::where(
64
-            [
65
-                'match_id' => $matchId,
66
-                'team_id' => $teamId,
67
-                'player_id' => $playerId
68
-            ]
69
-        )->first();
70
-        if (!empty($scorer)) {
71
-            $scorer->goals = $scorer->goals + 1;
72
-            $scorer->vote = $scorer->vote <= 9 ? $scorer->vote + rand(0, 1) : $scorer->vote;
73
-            $scorer->save();
74
-        } else {
75
-            MatchPlayer::create(
76
-                [
77
-                    'match_id' => $matchId,
78
-                    'team_id' => $teamId,
79
-                    'player_id' => $playerId,
80
-                    'goals' => 1
81
-                ]
82
-            );
83
-        }
84
-    }
61
+	private static function addScorer($matchId, $teamId, $playerId)
62
+	{
63
+		$scorer = MatchPlayer::where(
64
+			[
65
+				'match_id' => $matchId,
66
+				'team_id' => $teamId,
67
+				'player_id' => $playerId
68
+			]
69
+		)->first();
70
+		if (!empty($scorer)) {
71
+			$scorer->goals = $scorer->goals + 1;
72
+			$scorer->vote = $scorer->vote <= 9 ? $scorer->vote + rand(0, 1) : $scorer->vote;
73
+			$scorer->save();
74
+		} else {
75
+			MatchPlayer::create(
76
+				[
77
+					'match_id' => $matchId,
78
+					'team_id' => $teamId,
79
+					'player_id' => $playerId,
80
+					'goals' => 1
81
+				]
82
+			);
83
+		}
84
+	}
85 85
 
86
-    private static function generateAppearances(
87
-        $teamIds,
88
-        $matchId
89
-    )
90
-    {
91
-        foreach ($teamIds as $id) {
92
-            $players = Player::where('team_id', $id)->get()->random(11);
93
-            foreach ($players as $player) {
94
-                MatchPlayer::create(
95
-                    [
96
-                        'match_id' => $matchId,
97
-                        'team_id' => $id,
98
-                        'player_id' => $player->id,
99
-                        'vote' => Randomizer::voteFromSkill($player->skillAvg)
100
-                    ]
101
-                );
102
-            }
103
-        }
104
-    }
86
+	private static function generateAppearances(
87
+		$teamIds,
88
+		$matchId
89
+	)
90
+	{
91
+		foreach ($teamIds as $id) {
92
+			$players = Player::where('team_id', $id)->get()->random(11);
93
+			foreach ($players as $player) {
94
+				MatchPlayer::create(
95
+					[
96
+						'match_id' => $matchId,
97
+						'team_id' => $id,
98
+						'player_id' => $player->id,
99
+						'vote' => Randomizer::voteFromSkill($player->skillAvg)
100
+					]
101
+				);
102
+			}
103
+		}
104
+	}
105 105
 
106
-    public function scorers()
107
-    {
108
-        return $this->belongsToMany(
109
-            Player::class,
110
-            'match_players',
111
-            'match_id'
112
-        )->withPivot(
113
-            'team_id',
114
-            'goals'
115
-        )->where(
116
-            'goals', '>', 0
117
-        );
118
-    }
106
+	public function scorers()
107
+	{
108
+		return $this->belongsToMany(
109
+			Player::class,
110
+			'match_players',
111
+			'match_id'
112
+		)->withPivot(
113
+			'team_id',
114
+			'goals'
115
+		)->where(
116
+			'goals', '>', 0
117
+		);
118
+	}
119 119
 
120
-    public function scopeComplete($query)
121
-    {
122
-        return parent::scopeComplete($query)->with('scorers');
123
-    }
120
+	public function scopeComplete($query)
121
+	{
122
+		return parent::scopeComplete($query)->with('scorers');
123
+	}
124 124
 
125 125
 
126 126
 }
127 127
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/Player.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -9,70 +9,70 @@
 block discarded – undo
9 9
 class Player extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'players';
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'players';
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'name',
22
-        'surname',
23
-        'age',
24
-        'nationality',
25
-        'skillAvg',
26
-        'wageReq',
27
-        'val',
28
-        'role',
29
-        'team_id'
30
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'name',
22
+		'surname',
23
+		'age',
24
+		'nationality',
25
+		'skillAvg',
26
+		'wageReq',
27
+		'val',
28
+		'role',
29
+		'team_id'
30
+	];
31 31
 
32
-    /**
33
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
34
-     */
35
-    public function team()
36
-    {
37
-        return $this->belongsTo(Team::class);
38
-    }
32
+	/**
33
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
34
+	 */
35
+	public function team()
36
+	{
37
+		return $this->belongsTo(Team::class);
38
+	}
39 39
 
40
-    public function lastMatches()
41
-    {
42
-        return $this->hasMany(MatchPlayer::class)
43
-            ->orderBy('updated_at', 'DESC')
44
-            ->limit(5);
45
-    }
40
+	public function lastMatches()
41
+	{
42
+		return $this->hasMany(MatchPlayer::class)
43
+			->orderBy('updated_at', 'DESC')
44
+			->limit(5);
45
+	}
46 46
 
47
-    public function goals()
48
-    {
49
-        return $this->hasOne(MatchPlayer::class)
50
-            ->selectRaw('player_id, sum(goals) as count')
51
-            ->groupBy('player_id');
52
-    }
47
+	public function goals()
48
+	{
49
+		return $this->hasOne(MatchPlayer::class)
50
+			->selectRaw('player_id, sum(goals) as count')
51
+			->groupBy('player_id');
52
+	}
53 53
 
54
-    public function appearances()
55
-    {
56
-        return $this->hasOne(MatchPlayer::class)
57
-            ->selectRaw('player_id, count(match_id) as count')
58
-            ->groupBy('player_id');
59
-    }
54
+	public function appearances()
55
+	{
56
+		return $this->hasOne(MatchPlayer::class)
57
+			->selectRaw('player_id, count(match_id) as count')
58
+			->groupBy('player_id');
59
+	}
60 60
 
61
-    public function avg()
62
-    {
63
-        return $this->hasOne(MatchPlayer::class)
64
-            ->selectRaw('player_id, round(avg(vote),2) as avg')
65
-            ->groupBy('player_id');
66
-    }
61
+	public function avg()
62
+	{
63
+		return $this->hasOne(MatchPlayer::class)
64
+			->selectRaw('player_id, round(avg(vote),2) as avg')
65
+			->groupBy('player_id');
66
+	}
67 67
 
68
-    public function scopeStatistics($query)
69
-    {
70
-        return $query->with(
71
-            'goals',
72
-            'appearances',
73
-            'avg',
74
-            'lastMatches',
75
-            'team'
76
-        );
77
-    }
68
+	public function scopeStatistics($query)
69
+	{
70
+		return $query->with(
71
+			'goals',
72
+			'appearances',
73
+			'avg',
74
+			'lastMatches',
75
+			'team'
76
+		);
77
+	}
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
api/database/seeds/A000TeamsSeeder.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,20 +3,20 @@
 block discarded – undo
3 3
 
4 4
 class ATeamsSeeder
5 5
 {
6
-    function run()
7
-    {
8
-        $teamNumber = 16;
9
-        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
10
-        for ($i = 1; $i <= $teamNumber; $i++) {
11
-            $team = $rndFiller->getTeam($rndFiller->getLocale());
12
-            $teamArray = $team->toArray();
13
-            $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
14
-            foreach ($teamArray['roster'] as $player) {
15
-                $player['team_id'] = $teamO->id;
16
-                \App\Lib\DsManager\Models\Orm\Player::create($player);
17
-            }
18
-            $teamArray['coach']['team_id'] = $teamO->id;
19
-            \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
20
-        }
21
-    }
6
+	function run()
7
+	{
8
+		$teamNumber = 16;
9
+		$rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
10
+		for ($i = 1; $i <= $teamNumber; $i++) {
11
+			$team = $rndFiller->getTeam($rndFiller->getLocale());
12
+			$teamArray = $team->toArray();
13
+			$teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
14
+			foreach ($teamArray['roster'] as $player) {
15
+				$player['team_id'] = $teamO->id;
16
+				\App\Lib\DsManager\Models\Orm\Player::create($player);
17
+			}
18
+			$teamArray['coach']['team_id'] = $teamO->id;
19
+			\App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
20
+		}
21
+	}
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
api/tests/HelpersTest.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -8,71 +8,71 @@
 block discarded – undo
8 8
 {
9 9
 
10 10
 
11
-    /**
12
-     * @group Helpers
13
-     * @group FixtureGenerator
14
-     * @group generatefixture
15
-     */
16
-    public function testFixtureGenerator()
17
-    {
18
-        $teams = \App\Lib\DsManager\Models\Orm\Team::all();
19
-        $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate(
20
-            $teams->toArray()
21
-        );
22
-        //Number of rounds
23
-        $this->assertCount($teams->count() - 1, $rounds);
24
-        //Matches for each round
25
-        foreach ($rounds as $round) {
26
-            $this->assertCount($teams->count() / 2, $round);
27
-        }
28
-    }
11
+	/**
12
+	 * @group Helpers
13
+	 * @group FixtureGenerator
14
+	 * @group generatefixture
15
+	 */
16
+	public function testFixtureGenerator()
17
+	{
18
+		$teams = \App\Lib\DsManager\Models\Orm\Team::all();
19
+		$rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate(
20
+			$teams->toArray()
21
+		);
22
+		//Number of rounds
23
+		$this->assertCount($teams->count() - 1, $rounds);
24
+		//Matches for each round
25
+		foreach ($rounds as $round) {
26
+			$this->assertCount($teams->count() / 2, $round);
27
+		}
28
+	}
29 29
 
30
-    /**
31
-     * @group Helpers
32
-     * @group MatchSimulator
33
-     */
34
-    public function testMatchSimulator()
35
-    {
36
-        $match = \App\Lib\DsManager\Models\Orm\Match::where(
37
-            [
38
-                'simulated' => false
39
-            ]
40
-        )->get()->random(1);
41
-        $this->assertNotEmpty($match);
42
-        $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulate($match->id);
43
-        $this->assertNotEmpty($result);
44
-        $match = \App\Lib\DsManager\Models\Orm\Match::where(
45
-            [
46
-                'id' => $match->id,
47
-                'simulated' => true
48
-            ]
49
-        )->first();
50
-        $this->assertNotEmpty($match);
51
-    }
30
+	/**
31
+	 * @group Helpers
32
+	 * @group MatchSimulator
33
+	 */
34
+	public function testMatchSimulator()
35
+	{
36
+		$match = \App\Lib\DsManager\Models\Orm\Match::where(
37
+			[
38
+				'simulated' => false
39
+			]
40
+		)->get()->random(1);
41
+		$this->assertNotEmpty($match);
42
+		$result = \App\Lib\DsManager\Helpers\MatchSimulator::simulate($match->id);
43
+		$this->assertNotEmpty($result);
44
+		$match = \App\Lib\DsManager\Models\Orm\Match::where(
45
+			[
46
+				'id' => $match->id,
47
+				'simulated' => true
48
+			]
49
+		)->first();
50
+		$this->assertNotEmpty($match);
51
+	}
52 52
 
53
-    /**
54
-     * @group Helpers
55
-     * @group RoundSimulator
56
-     */
57
-    public function testRoundSimulator()
58
-    {
59
-        $match = \App\Lib\DsManager\Models\Orm\Match::where(
60
-            [
61
-                'simulated' => false
62
-            ]
63
-        )->whereNotNull(
64
-            'league_round_id'
65
-        )->get()->random(1);
66
-        $this->assertNotEmpty($match);
67
-        $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id);
68
-        $this->assertNotEmpty($result);
69
-        $match = \App\Lib\DsManager\Models\Orm\Match::where(
70
-            [
71
-                'id' => $match->id,
72
-                'simulated' => true
73
-            ]
74
-        )->first();
75
-        $this->assertNotEmpty($match);
76
-    }
53
+	/**
54
+	 * @group Helpers
55
+	 * @group RoundSimulator
56
+	 */
57
+	public function testRoundSimulator()
58
+	{
59
+		$match = \App\Lib\DsManager\Models\Orm\Match::where(
60
+			[
61
+				'simulated' => false
62
+			]
63
+		)->whereNotNull(
64
+			'league_round_id'
65
+		)->get()->random(1);
66
+		$this->assertNotEmpty($match);
67
+		$result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id);
68
+		$this->assertNotEmpty($result);
69
+		$match = \App\Lib\DsManager\Models\Orm\Match::where(
70
+			[
71
+				'id' => $match->id,
72
+				'simulated' => true
73
+			]
74
+		)->first();
75
+		$this->assertNotEmpty($match);
76
+	}
77 77
 
78 78
 }
Please login to merge, or discard this patch.
api/index.php 1 patch
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -14,179 +14,179 @@
 block discarded – undo
14 14
 use \App\Lib\DsManager\Models\Orm\Coach;
15 15
 
16 16
 $configuration = [
17
-    'settings' => [
18
-        'displayErrorDetails' => true,
19
-    ],
17
+	'settings' => [
18
+		'displayErrorDetails' => true,
19
+	],
20 20
 ];
21 21
 $c = new \Slim\Container($configuration);
22 22
 $api = new \Slim\App($c);
23 23
 
24 24
 $api->get('/ping', function ($request, $response, $args) {
25
-    $jsonResp = json_encode(
26
-        [
27
-            "status" => "service up",
28
-            "message" => "in a bottle"
29
-        ]
30
-    );
31
-    return Responder::getJsonResponse($jsonResp, $response);
25
+	$jsonResp = json_encode(
26
+		[
27
+			"status" => "service up",
28
+			"message" => "in a bottle"
29
+		]
30
+	);
31
+	return Responder::getJsonResponse($jsonResp, $response);
32 32
 });
33 33
 
34 34
 $api->get('/players', function ($request, $response, $args) {
35
-    $json = json_encode(Player::all());
36
-    return Responder::getJsonResponse($json, $response);
35
+	$json = json_encode(Player::all());
36
+	return Responder::getJsonResponse($json, $response);
37 37
 });
38 38
 
39 39
 
40 40
 $api->get('/players/{id}', function ($request, $response, $args) {
41
-    return Responder::getJsonResponse(
42
-        Player::findOrFail($args['id']),
43
-        $response
44
-    );
41
+	return Responder::getJsonResponse(
42
+		Player::findOrFail($args['id']),
43
+		$response
44
+	);
45 45
 });
46 46
 
47 47
 $api->get('/coaches', function ($request, $response, $args) {
48
-    return Responder::getJsonResponse(
49
-        Coach::all(),
50
-        $response
51
-    );
48
+	return Responder::getJsonResponse(
49
+		Coach::all(),
50
+		$response
51
+	);
52 52
 });
53 53
 
54 54
 $api->get('/teams', function ($request, $response, $args) {
55
-    return Responder::getJsonResponse(
56
-        Team::all(),
57
-        $response
58
-    );
55
+	return Responder::getJsonResponse(
56
+		Team::all(),
57
+		$response
58
+	);
59 59
 });
60 60
 
61 61
 $api->get('/teams/{id}', function ($request, $response, $args) {
62
-    return Responder::getJsonResponse(
63
-        Team::complete()
64
-            ->where(
65
-                [
66
-                    'id' => $args['id']
67
-                ]
68
-            )->get(),
69
-        $response
70
-    );
62
+	return Responder::getJsonResponse(
63
+		Team::complete()
64
+			->where(
65
+				[
66
+					'id' => $args['id']
67
+				]
68
+			)->get(),
69
+		$response
70
+	);
71 71
 });
72 72
 
73 73
 $api->get('/teams/{id}/players', function ($request, $response, $args) {
74
-    return Responder::getJsonResponse(
75
-        Team::with(
76
-            'roster'
77
-        )->where(
78
-            [
79
-                'id' => $args['id']
80
-            ]
81
-        )->get(),
82
-        $response
83
-    );
74
+	return Responder::getJsonResponse(
75
+		Team::with(
76
+			'roster'
77
+		)->where(
78
+			[
79
+				'id' => $args['id']
80
+			]
81
+		)->get(),
82
+		$response
83
+	);
84 84
 });
85 85
 
86 86
 $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
87
-    return Responder::getJsonResponse(
88
-        Player::statistics()->where(
89
-            [
90
-                'id' => $args['playerId'],
91
-                'team_id' => $args['id']
92
-            ]
93
-        )->get(),
94
-        $response
95
-    );
87
+	return Responder::getJsonResponse(
88
+		Player::statistics()->where(
89
+			[
90
+				'id' => $args['playerId'],
91
+				'team_id' => $args['id']
92
+			]
93
+		)->get(),
94
+		$response
95
+	);
96 96
 });
97 97
 
98 98
 $api->get('/teams/{id}/coach', function ($request, $response, $args) {
99
-    return Responder::getJsonResponse(
100
-        Team::with(
101
-            'coach'
102
-        )->where(
103
-            [
104
-                'id' => $args['id']
105
-            ]
106
-        )->get(),
107
-        $response
108
-    );
99
+	return Responder::getJsonResponse(
100
+		Team::with(
101
+			'coach'
102
+		)->where(
103
+			[
104
+				'id' => $args['id']
105
+			]
106
+		)->get(),
107
+		$response
108
+	);
109 109
 });
110 110
 
111 111
 $api->get('/leagues', function ($request, $response, $args) {
112
-    return Responder::getJsonResponse(
113
-        League::all(),
114
-        $response
115
-    );
112
+	return Responder::getJsonResponse(
113
+		League::all(),
114
+		$response
115
+	);
116 116
 });
117 117
 
118 118
 $api->get('/leagues/{id}', function ($request, $response, $args) {
119
-    return Responder::getJsonResponse(
120
-        League::with('rounds')
121
-            ->where(
122
-                [
123
-                    'id' => $args['id']
124
-                ]
125
-            )->first(),
126
-        $response
127
-    );
119
+	return Responder::getJsonResponse(
120
+		League::with('rounds')
121
+			->where(
122
+				[
123
+					'id' => $args['id']
124
+				]
125
+			)->first(),
126
+		$response
127
+	);
128 128
 });
129 129
 $api->get('/leagues/{id}/rounds/{roundId}/matches', function ($request, $response, $args) {
130
-    return Responder::getJsonResponse(
131
-        Match::teams()
132
-            ->where(
133
-                [
134
-                    'league_round_id' => $args['roundId'],
135
-                ]
136
-            )->get(),
137
-        $response
138
-    );
130
+	return Responder::getJsonResponse(
131
+		Match::teams()
132
+			->where(
133
+				[
134
+					'league_round_id' => $args['roundId'],
135
+				]
136
+			)->get(),
137
+		$response
138
+	);
139 139
 });
140 140
 $api->get('/matches', function ($request, $response, $args) {
141
-    return Responder::getJsonResponse(
142
-        Match::teams()->get(),
143
-        $response
144
-    );
141
+	return Responder::getJsonResponse(
142
+		Match::teams()->get(),
143
+		$response
144
+	);
145 145
 });
146 146
 
147 147
 $api->post('/matches', function ($request, $response, $args) {
148
-    $json = $request->getBody();
149
-    $json = json_decode($json, true);
150
-    return Responder::getJsonResponse(
151
-        Match::create(
152
-            $json
153
-        ),
154
-        $response
155
-    );
148
+	$json = $request->getBody();
149
+	$json = json_decode($json, true);
150
+	return Responder::getJsonResponse(
151
+		Match::create(
152
+			$json
153
+		),
154
+		$response
155
+	);
156 156
 });
157 157
 
158 158
 $api->get('/matches/{id}', function ($request, $response, $args) {
159
-    return Responder::getJsonResponse(
160
-        Match::complete()
161
-            ->where(
162
-                [
163
-                    'id' => $args['id']
164
-                ]
165
-            )->first(),
166
-        $response
167
-    );
159
+	return Responder::getJsonResponse(
160
+		Match::complete()
161
+			->where(
162
+				[
163
+					'id' => $args['id']
164
+				]
165
+			)->first(),
166
+		$response
167
+	);
168 168
 });
169 169
 
170 170
 $api->get('/matches/{id}/result', function ($request, $response, $args) {
171
-    $result = MatchResult::complete()
172
-        ->where(
173
-            [
174
-                'id' => $args['id']
175
-            ]
176
-        )->first();
171
+	$result = MatchResult::complete()
172
+		->where(
173
+			[
174
+				'id' => $args['id']
175
+			]
176
+		)->first();
177 177
 
178
-    return Responder::getJsonResponse(
179
-        $result,
180
-        $response
181
-    );
178
+	return Responder::getJsonResponse(
179
+		$result,
180
+		$response
181
+	);
182 182
 });
183 183
 
184 184
 $api->put('/matches/{id}/simulate', function ($request, $response, $args) {
185
-    return Responder::getJsonResponse(
186
-        MatchSimulator::simulate(
187
-            $args['id']
188
-        ),
189
-        $response
190
-    );
185
+	return Responder::getJsonResponse(
186
+		MatchSimulator::simulate(
187
+			$args['id']
188
+		),
189
+		$response
190
+	);
191 191
 });
192 192
 $api->run();
193 193
\ No newline at end of file
Please login to merge, or discard this patch.