Completed
Push — master ( 3a0efc...84f561 )
by Vincenzo
02:28
created
api/database/migrations/CreateLeagueRoundsTable.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function run()
14 14
     {
15 15
         Capsule::schema()->dropIfExists('league_rounds');
16
-        Capsule::schema()->create('league_rounds', function (Blueprint $table) {
16
+        Capsule::schema()->create('league_rounds', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->integer('league_id');
19 19
             $table->integer('day')->default(0);
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
 
6 6
 class CreateLeagueRoundsTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('league_rounds');
16
-        Capsule::schema()->create('league_rounds', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('league_id');
19
-            $table->boolean('simulated')->default(false);
20
-            $table->integer('day')->default(0);
21
-            $table->timestamps();
22
-        });
23
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('league_rounds');
16
+		Capsule::schema()->create('league_rounds', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('league_id');
19
+			$table->boolean('simulated')->default(false);
20
+			$table->integer('day')->default(0);
21
+			$table->timestamps();
22
+		});
23
+	}
24 24
 }
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/League.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  */
9 9
 class League extends DsManagerOrm
10 10
 {
11
-    /**
12
-     * @var string
13
-     */
14
-    protected $table = 'leagues';
11
+	/**
12
+	 * @var string
13
+	 */
14
+	protected $table = 'leagues';
15 15
 
16
-    /**
17
-     * @var array
18
-     */
19
-    protected $fillable = [
20
-        'name',
21
-        'teams'
22
-    ];
16
+	/**
17
+	 * @var array
18
+	 */
19
+	protected $fillable = [
20
+		'name',
21
+		'teams'
22
+	];
23 23
 
24
-    /**
25
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
26
-     */
27
-    public function rounds()
28
-    {
29
-        return $this->hasMany(LeagueRound::class);
30
-    }
24
+	/**
25
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
26
+	 */
27
+	public function rounds()
28
+	{
29
+		return $this->hasMany(LeagueRound::class);
30
+	}
31 31
 } 
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/LeagueFixtureGenerator.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@
 block discarded – undo
5 5
 
6 6
 class LeagueFixtureGenerator
7 7
 {
8
-    public static function generate(array $teams)
9
-    {
10
-        $numTeams = count($teams);
11
-        $numRounds = ($numTeams - 1);
12
-        $halfSize = $numTeams / 2;
8
+	public static function generate(array $teams)
9
+	{
10
+		$numTeams = count($teams);
11
+		$numRounds = ($numTeams - 1);
12
+		$halfSize = $numTeams / 2;
13 13
 
14
-        $away = array_splice($teams, $halfSize);
15
-        $home = $teams;
16
-        $rounds = [];
17
-        for ($i = 0; $i < $numRounds; $i++) {
18
-            $homeCount = count($home);
19
-            for ($j = 0; $j < $homeCount; $j++) {
20
-                $rounds[$i][$j]["home_team_id"] = $home[$j]['id'];
21
-                $rounds[$i][$j]["away_team_id"] = $away[$j]['id'];
22
-            }
23
-            if (count($home) + count($away) - 1 > 2) {
24
-                $spliced = array_splice($home, 1, 1);
25
-                $shifted = array_shift($spliced);
26
-                array_unshift($away, $shifted);
27
-                array_push($home, array_pop($away));
28
-            }
29
-        }
30
-        return $rounds;
31
-    }
14
+		$away = array_splice($teams, $halfSize);
15
+		$home = $teams;
16
+		$rounds = [];
17
+		for ($i = 0; $i < $numRounds; $i++) {
18
+			$homeCount = count($home);
19
+			for ($j = 0; $j < $homeCount; $j++) {
20
+				$rounds[$i][$j]["home_team_id"] = $home[$j]['id'];
21
+				$rounds[$i][$j]["away_team_id"] = $away[$j]['id'];
22
+			}
23
+			if (count($home) + count($away) - 1 > 2) {
24
+				$spliced = array_splice($home, 1, 1);
25
+				$shifted = array_shift($spliced);
26
+				array_unshift($away, $shifted);
27
+				array_push($home, array_pop($away));
28
+			}
29
+		}
30
+		return $rounds;
31
+	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
api/database/migrations/CreateLeagueTeamsTable.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     public function run()
14 14
     {
15 15
         Capsule::schema()->dropIfExists('leagues');
16
-        Capsule::schema()->create('league_teams', function (Blueprint $table) {
16
+        Capsule::schema()->create('league_teams', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->integer('league_id');
19 19
             $table->integer('team_id');
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@
 block discarded – undo
5 5
 
6 6
 class CreateLeagueTeamsTable
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function run()
14
-    {
15
-        Capsule::schema()->dropIfExists('league_teams');
16
-        Capsule::schema()->create('league_teams', function (Blueprint $table) {
17
-            $table->increments('id');
18
-            $table->integer('league_id');
19
-            $table->integer('team_id');
20
-            $table->unsignedTinyInteger('points')->default(0);
21
-            $table->unsignedTinyInteger('played')->default(0);
22
-            $table->unsignedTinyInteger('won')->default(0);
23
-            $table->unsignedTinyInteger('draw')->default(0);
24
-            $table->unsignedTinyInteger('lost')->default(0);
25
-            $table->timestamps();
26
-        });
27
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function run()
14
+	{
15
+		Capsule::schema()->dropIfExists('league_teams');
16
+		Capsule::schema()->create('league_teams', function (Blueprint $table) {
17
+			$table->increments('id');
18
+			$table->integer('league_id');
19
+			$table->integer('team_id');
20
+			$table->unsignedTinyInteger('points')->default(0);
21
+			$table->unsignedTinyInteger('played')->default(0);
22
+			$table->unsignedTinyInteger('won')->default(0);
23
+			$table->unsignedTinyInteger('draw')->default(0);
24
+			$table->unsignedTinyInteger('lost')->default(0);
25
+			$table->timestamps();
26
+		});
27
+	}
28 28
 }
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/MatchSimulator.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 namespace App\Lib\DsManager\Helpers;
5 5
 
6 6
 
7
-use App\Lib\DsManager\Models\Orm\Match;
8 7
 use App\Lib\DsManager\Models\Orm\Match as MatchOrm;
9 8
 use App\Lib\DsManager\Models\Orm\MatchResult;
10 9
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     /**
36 36
      * @param $matchId
37
-     * @return mixed
37
+     * @return MatchResult
38 38
      */
39 39
     public static function simulateCompleteResult($matchId)
40 40
     {
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     /**
52 52
      * @param $matchId
53
-     * @return mixed
53
+     * @return MatchResult
54 54
      */
55 55
     public static function simulateSimpleResult($matchId)
56 56
     {
Please login to merge, or discard this patch.
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -15,129 +15,129 @@
 block discarded – undo
15 15
  */
16 16
 class MatchSimulator
17 17
 {
18
-    /**
19
-     * @param $roundId
20
-     * @return string
21
-     */
22
-    public static function simulateRound($roundId)
23
-    {
24
-        $result = self::getCompleteRound($roundId);
25
-        if (!empty($result)
26
-            &&
27
-            !$result->simulated
28
-        ) {
29
-            $matches = Match::where(
30
-                [
31
-                    'league_round_id' => $roundId
32
-                ]
33
-            )->get();
34
-            foreach ($matches as $match) {
35
-                self::simulateSimpleResult($match->id)->toArray();
36
-            }
37
-            LeagueRound::find($roundId)->update(['simulated' => true]);
38
-            $result = self::getCompleteRound($roundId);
39
-        }
40
-        return $result;
41
-    }
18
+	/**
19
+	 * @param $roundId
20
+	 * @return string
21
+	 */
22
+	public static function simulateRound($roundId)
23
+	{
24
+		$result = self::getCompleteRound($roundId);
25
+		if (!empty($result)
26
+			&&
27
+			!$result->simulated
28
+		) {
29
+			$matches = Match::where(
30
+				[
31
+					'league_round_id' => $roundId
32
+				]
33
+			)->get();
34
+			foreach ($matches as $match) {
35
+				self::simulateSimpleResult($match->id)->toArray();
36
+			}
37
+			LeagueRound::find($roundId)->update(['simulated' => true]);
38
+			$result = self::getCompleteRound($roundId);
39
+		}
40
+		return $result;
41
+	}
42 42
 
43
-    /**
44
-     * @param $matchId
45
-     * @return mixed
46
-     */
47
-    public static function simulateCompleteResult($matchId)
48
-    {
49
-        $result = self::getCompleteResult($matchId);
50
-        if (!empty($result)
51
-            && !$result->simulated
52
-            && self::simulate($matchId) === 1
53
-        ) {
54
-            $result = self::getCompleteResult($matchId);
55
-        }
56
-        return $result;
57
-    }
43
+	/**
44
+	 * @param $matchId
45
+	 * @return mixed
46
+	 */
47
+	public static function simulateCompleteResult($matchId)
48
+	{
49
+		$result = self::getCompleteResult($matchId);
50
+		if (!empty($result)
51
+			&& !$result->simulated
52
+			&& self::simulate($matchId) === 1
53
+		) {
54
+			$result = self::getCompleteResult($matchId);
55
+		}
56
+		return $result;
57
+	}
58 58
 
59
-    /**
60
-     * @param $matchId
61
-     * @return mixed
62
-     */
63
-    public static function simulateSimpleResult($matchId)
64
-    {
65
-        $result = self::getSimpleResult($matchId);
66
-        if (!empty($result)
67
-            && !$result->simulated
68
-            && self::simulate($matchId) === 1
69
-        ) {
70
-            $result = self::getSimpleResult($matchId);
71
-        }
72
-        return $result;
73
-    }
59
+	/**
60
+	 * @param $matchId
61
+	 * @return mixed
62
+	 */
63
+	public static function simulateSimpleResult($matchId)
64
+	{
65
+		$result = self::getSimpleResult($matchId);
66
+		if (!empty($result)
67
+			&& !$result->simulated
68
+			&& self::simulate($matchId) === 1
69
+		) {
70
+			$result = self::getSimpleResult($matchId);
71
+		}
72
+		return $result;
73
+	}
74 74
 
75
-    /**
76
-     * @param $matchId
77
-     * @return mixed
78
-     */
79
-    private static function simulate($matchId)
80
-    {
81
-        $match = \App\Lib\DsManager\Models\Match::fromArray(
82
-            MatchOrm::complete()
83
-                ->where(
84
-                    [
85
-                        'id' => $matchId
86
-                    ]
87
-                )->first()->toArray()
88
-        );
89
-        $matchResult = $match->simulate()->toArray();
90
-        $result = MatchResult::where(
91
-            [
92
-                'id' => $matchId
93
-            ]
94
-        )->update(
95
-            MatchResult::resolveAttributes(
96
-                $matchResult,
97
-                $matchId
98
-            )
99
-        );
100
-        return $result;
101
-    }
75
+	/**
76
+	 * @param $matchId
77
+	 * @return mixed
78
+	 */
79
+	private static function simulate($matchId)
80
+	{
81
+		$match = \App\Lib\DsManager\Models\Match::fromArray(
82
+			MatchOrm::complete()
83
+				->where(
84
+					[
85
+						'id' => $matchId
86
+					]
87
+				)->first()->toArray()
88
+		);
89
+		$matchResult = $match->simulate()->toArray();
90
+		$result = MatchResult::where(
91
+			[
92
+				'id' => $matchId
93
+			]
94
+		)->update(
95
+			MatchResult::resolveAttributes(
96
+				$matchResult,
97
+				$matchId
98
+			)
99
+		);
100
+		return $result;
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * @param $matchId
106
-     * @return MatchResult
107
-     */
108
-    private static function getCompleteResult($matchId)
109
-    {
110
-        return MatchResult::complete()->where(
111
-            [
112
-                'id' => $matchId
113
-            ]
114
-        )->first();
115
-    }
104
+	/**
105
+	 * @param $matchId
106
+	 * @return MatchResult
107
+	 */
108
+	private static function getCompleteResult($matchId)
109
+	{
110
+		return MatchResult::complete()->where(
111
+			[
112
+				'id' => $matchId
113
+			]
114
+		)->first();
115
+	}
116 116
 
117
-    /**
118
-     * @param $matchId
119
-     * @return MatchResult
120
-     */
121
-    private static function getSimpleResult($matchId)
122
-    {
123
-        return MatchResult::teams()->where(
124
-            [
125
-                'id' => $matchId
126
-            ]
127
-        )->first();
128
-    }
117
+	/**
118
+	 * @param $matchId
119
+	 * @return MatchResult
120
+	 */
121
+	private static function getSimpleResult($matchId)
122
+	{
123
+		return MatchResult::teams()->where(
124
+			[
125
+				'id' => $matchId
126
+			]
127
+		)->first();
128
+	}
129 129
 
130
-    /**
131
-     * @param $roundId
132
-     * @return mixed
133
-     */
134
-    private static function getCompleteRound($roundId)
135
-    {
136
-        return LeagueRound::complete()->where(
137
-            [
138
-                'id' => $roundId
139
-            ]
140
-        )->first();
141
-    }
130
+	/**
131
+	 * @param $roundId
132
+	 * @return mixed
133
+	 */
134
+	private static function getCompleteRound($roundId)
135
+	{
136
+		return LeagueRound::complete()->where(
137
+			[
138
+				'id' => $roundId
139
+			]
140
+		)->first();
141
+	}
142 142
 
143 143
 }
144 144
\ No newline at end of file
Please login to merge, or discard this patch.
api/index.php 3 patches
Unused Use Statements   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@
 block discarded – undo
4 4
 require_once("vendor/autoload.php");
5 5
 
6 6
 
7
-use App\Lib\DsManager\Helpers\MatchSimulator;
8
-use App\Lib\DsManager\Models\Orm\League;
9
-use App\Lib\DsManager\Models\Orm\LeagueRound;
10
-use App\Lib\DsManager\Models\Orm\Match;
7
+use App\Lib\DsManager\Helpers\MatchSimulator;
8
+use App\Lib\DsManager\Models\Orm\League;
9
+use App\Lib\DsManager\Models\Orm\LeagueRound;
10
+use App\Lib\DsManager\Models\Orm\Match;
11 11
 use App\Lib\DsManager\Models\Orm\MatchResult;
12 12
 use \App\Lib\Helpers\Responder;
13 13
 use \App\Lib\DsManager\Models\Orm\Player;
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -15,187 +15,187 @@
 block discarded – undo
15 15
 use \App\Lib\DsManager\Models\Orm\Coach;
16 16
 
17 17
 $configuration = [
18
-    'settings' => [
19
-        'displayErrorDetails' => true,
20
-    ],
18
+	'settings' => [
19
+		'displayErrorDetails' => true,
20
+	],
21 21
 ];
22 22
 $c = new \Slim\Container($configuration);
23 23
 $api = new \Slim\App($c);
24 24
 
25 25
 $api->get('/ping', function ($request, $response, $args) {
26
-    $jsonResp = json_encode(
27
-        [
28
-            "status" => "service up",
29
-            "message" => "in a bottle"
30
-        ]
31
-    );
32
-    return Responder::getJsonResponse($jsonResp, $response);
26
+	$jsonResp = json_encode(
27
+		[
28
+			"status" => "service up",
29
+			"message" => "in a bottle"
30
+		]
31
+	);
32
+	return Responder::getJsonResponse($jsonResp, $response);
33 33
 });
34 34
 
35 35
 $api->get('/statistics', function ($request, $response, $args) {
36
-    return Responder::getJsonResponse(
37
-        json_encode([
38
-            'players' => Player::getBest(),
39
-            'teams' => Team::getBest()
40
-        ]),
41
-        $response
42
-    );
36
+	return Responder::getJsonResponse(
37
+		json_encode([
38
+			'players' => Player::getBest(),
39
+			'teams' => Team::getBest()
40
+		]),
41
+		$response
42
+	);
43 43
 });
44 44
 
45 45
 $api->get('/coaches', function ($request, $response, $args) {
46
-    return Responder::getJsonResponse(
47
-        Coach::all(),
48
-        $response
49
-    );
46
+	return Responder::getJsonResponse(
47
+		Coach::all(),
48
+		$response
49
+	);
50 50
 });
51 51
 
52 52
 $api->get('/teams', function ($request, $response, $args) {
53
-    return Responder::getJsonResponse(
54
-        Team::all(),
55
-        $response
56
-    );
53
+	return Responder::getJsonResponse(
54
+		Team::all(),
55
+		$response
56
+	);
57 57
 });
58 58
 
59 59
 $api->get('/teams/{id}', function ($request, $response, $args) {
60
-    return Responder::getJsonResponse(
61
-        Team::complete()
62
-            ->where(
63
-                [
64
-                    'id' => $args['id']
65
-                ]
66
-            )->get(),
67
-        $response
68
-    );
60
+	return Responder::getJsonResponse(
61
+		Team::complete()
62
+			->where(
63
+				[
64
+					'id' => $args['id']
65
+				]
66
+			)->get(),
67
+		$response
68
+	);
69 69
 });
70 70
 
71 71
 $api->get('/teams/{id}/players', function ($request, $response, $args) {
72
-    return Responder::getJsonResponse(
73
-        Team::with(
74
-            'roster'
75
-        )->where(
76
-            [
77
-                'id' => $args['id']
78
-            ]
79
-        )->get(),
80
-        $response
81
-    );
72
+	return Responder::getJsonResponse(
73
+		Team::with(
74
+			'roster'
75
+		)->where(
76
+			[
77
+				'id' => $args['id']
78
+			]
79
+		)->get(),
80
+		$response
81
+	);
82 82
 });
83 83
 
84 84
 $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
85
-    return Responder::getJsonResponse(
86
-        Player::statistics()->where(
87
-            [
88
-                'id' => $args['playerId'],
89
-                'team_id' => $args['id']
90
-            ]
91
-        )->get(),
92
-        $response
93
-    );
85
+	return Responder::getJsonResponse(
86
+		Player::statistics()->where(
87
+			[
88
+				'id' => $args['playerId'],
89
+				'team_id' => $args['id']
90
+			]
91
+		)->get(),
92
+		$response
93
+	);
94 94
 });
95 95
 
96 96
 $api->get('/teams/{id}/coach', function ($request, $response, $args) {
97
-    return Responder::getJsonResponse(
98
-        Team::with(
99
-            'coach'
100
-        )->where(
101
-            [
102
-                'id' => $args['id']
103
-            ]
104
-        )->get(),
105
-        $response
106
-    );
97
+	return Responder::getJsonResponse(
98
+		Team::with(
99
+			'coach'
100
+		)->where(
101
+			[
102
+				'id' => $args['id']
103
+			]
104
+		)->get(),
105
+		$response
106
+	);
107 107
 });
108 108
 
109 109
 $api->get('/leagues', function ($request, $response, $args) {
110
-    return Responder::getJsonResponse(
111
-        League::all(),
112
-        $response
113
-    );
110
+	return Responder::getJsonResponse(
111
+		League::all(),
112
+		$response
113
+	);
114 114
 });
115 115
 
116 116
 $api->get('/leagues/{id}', function ($request, $response, $args) {
117
-    return Responder::getJsonResponse(
118
-        League::with('rounds')
119
-            ->where(
120
-                [
121
-                    'id' => $args['id']
122
-                ]
123
-            )->first(),
124
-        $response
125
-    );
117
+	return Responder::getJsonResponse(
118
+		League::with('rounds')
119
+			->where(
120
+				[
121
+					'id' => $args['id']
122
+				]
123
+			)->first(),
124
+		$response
125
+	);
126 126
 });
127 127
 
128 128
 $api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
129
-    return Responder::getJsonResponse(
130
-        LeagueRound::complete()
131
-            ->where(
132
-                [
133
-                    'id' => $args['roundId'],
134
-                ]
135
-            )->first(),
136
-        $response
137
-    );
129
+	return Responder::getJsonResponse(
130
+		LeagueRound::complete()
131
+			->where(
132
+				[
133
+					'id' => $args['roundId'],
134
+				]
135
+			)->first(),
136
+		$response
137
+	);
138 138
 });
139 139
 
140 140
 $api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
141
-    return Responder::getJsonResponse(
142
-        MatchSimulator::simulateRound(
143
-            $args['roundId']
144
-        ),
145
-        $response
146
-    );
141
+	return Responder::getJsonResponse(
142
+		MatchSimulator::simulateRound(
143
+			$args['roundId']
144
+		),
145
+		$response
146
+	);
147 147
 });
148 148
 
149 149
 $api->get('/matches', function ($request, $response, $args) {
150
-    return Responder::getJsonResponse(
151
-        Match::teams()->get(),
152
-        $response
153
-    );
150
+	return Responder::getJsonResponse(
151
+		Match::teams()->get(),
152
+		$response
153
+	);
154 154
 });
155 155
 
156 156
 $api->post('/matches', function ($request, $response, $args) {
157
-    $json = $request->getBody();
158
-    $json = json_decode($json, true);
159
-    return Responder::getJsonResponse(
160
-        Match::create(
161
-            $json
162
-        ),
163
-        $response
164
-    );
157
+	$json = $request->getBody();
158
+	$json = json_decode($json, true);
159
+	return Responder::getJsonResponse(
160
+		Match::create(
161
+			$json
162
+		),
163
+		$response
164
+	);
165 165
 });
166 166
 
167 167
 $api->get('/matches/{id}', function ($request, $response, $args) {
168
-    return Responder::getJsonResponse(
169
-        Match::complete()
170
-            ->where(
171
-                [
172
-                    'id' => $args['id']
173
-                ]
174
-            )->first(),
175
-        $response
176
-    );
168
+	return Responder::getJsonResponse(
169
+		Match::complete()
170
+			->where(
171
+				[
172
+					'id' => $args['id']
173
+				]
174
+			)->first(),
175
+		$response
176
+	);
177 177
 });
178 178
 
179 179
 $api->get('/matches/{id}/result', function ($request, $response, $args) {
180
-    $result = MatchResult::complete()
181
-        ->where(
182
-            [
183
-                'id' => $args['id']
184
-            ]
185
-        )->first();
180
+	$result = MatchResult::complete()
181
+		->where(
182
+			[
183
+				'id' => $args['id']
184
+			]
185
+		)->first();
186 186
 
187
-    return Responder::getJsonResponse(
188
-        $result,
189
-        $response
190
-    );
187
+	return Responder::getJsonResponse(
188
+		$result,
189
+		$response
190
+	);
191 191
 });
192 192
 
193 193
 $api->put('/matches/{id}/simulate', function ($request, $response, $args) {
194
-    return Responder::getJsonResponse(
195
-        MatchSimulator::simulateCompleteResult(
196
-            $args['id']
197
-        ),
198
-        $response
199
-    );
194
+	return Responder::getJsonResponse(
195
+		MatchSimulator::simulateCompleteResult(
196
+			$args['id']
197
+		),
198
+		$response
199
+	);
200 200
 });
201 201
 $api->run();
202 202
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $c = new \Slim\Container($configuration);
23 23
 $api = new \Slim\App($c);
24 24
 
25
-$api->get('/ping', function ($request, $response, $args) {
25
+$api->get('/ping', function($request, $response, $args) {
26 26
     $jsonResp = json_encode(
27 27
         [
28 28
             "status" => "service up",
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     return Responder::getJsonResponse($jsonResp, $response);
33 33
 });
34 34
 
35
-$api->get('/statistics', function ($request, $response, $args) {
35
+$api->get('/statistics', function($request, $response, $args) {
36 36
     return Responder::getJsonResponse(
37 37
         json_encode([
38 38
             'players' => Player::getBest(),
@@ -42,21 +42,21 @@  discard block
 block discarded – undo
42 42
     );
43 43
 });
44 44
 
45
-$api->get('/coaches', function ($request, $response, $args) {
45
+$api->get('/coaches', function($request, $response, $args) {
46 46
     return Responder::getJsonResponse(
47 47
         Coach::all(),
48 48
         $response
49 49
     );
50 50
 });
51 51
 
52
-$api->get('/teams', function ($request, $response, $args) {
52
+$api->get('/teams', function($request, $response, $args) {
53 53
     return Responder::getJsonResponse(
54 54
         Team::all(),
55 55
         $response
56 56
     );
57 57
 });
58 58
 
59
-$api->get('/teams/{id}', function ($request, $response, $args) {
59
+$api->get('/teams/{id}', function($request, $response, $args) {
60 60
     return Responder::getJsonResponse(
61 61
         Team::complete()
62 62
             ->where(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     );
69 69
 });
70 70
 
71
-$api->get('/teams/{id}/players', function ($request, $response, $args) {
71
+$api->get('/teams/{id}/players', function($request, $response, $args) {
72 72
     return Responder::getJsonResponse(
73 73
         Team::with(
74 74
             'roster'
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     );
82 82
 });
83 83
 
84
-$api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
84
+$api->get('/teams/{id}/players/{playerId}', function($request, $response, $args) {
85 85
     return Responder::getJsonResponse(
86 86
         Player::statistics()->where(
87 87
             [
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     );
94 94
 });
95 95
 
96
-$api->get('/teams/{id}/coach', function ($request, $response, $args) {
96
+$api->get('/teams/{id}/coach', function($request, $response, $args) {
97 97
     return Responder::getJsonResponse(
98 98
         Team::with(
99 99
             'coach'
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
     );
107 107
 });
108 108
 
109
-$api->get('/leagues', function ($request, $response, $args) {
109
+$api->get('/leagues', function($request, $response, $args) {
110 110
     return Responder::getJsonResponse(
111 111
         League::all(),
112 112
         $response
113 113
     );
114 114
 });
115 115
 
116
-$api->get('/leagues/{id}', function ($request, $response, $args) {
116
+$api->get('/leagues/{id}', function($request, $response, $args) {
117 117
     return Responder::getJsonResponse(
118 118
         League::with('rounds')
119 119
             ->where(
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     );
126 126
 });
127 127
 
128
-$api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
128
+$api->get('/leagues/{id}/rounds/{roundId}', function($request, $response, $args) {
129 129
     return Responder::getJsonResponse(
130 130
         LeagueRound::complete()
131 131
             ->where(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     );
138 138
 });
139 139
 
140
-$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
140
+$api->put('/leagues/{id}/rounds/{roundId}/simulate', function($request, $response, $args) {
141 141
     return Responder::getJsonResponse(
142 142
         MatchSimulator::simulateRound(
143 143
             $args['roundId']
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
     );
147 147
 });
148 148
 
149
-$api->get('/matches', function ($request, $response, $args) {
149
+$api->get('/matches', function($request, $response, $args) {
150 150
     return Responder::getJsonResponse(
151 151
         Match::teams()->get(),
152 152
         $response
153 153
     );
154 154
 });
155 155
 
156
-$api->post('/matches', function ($request, $response, $args) {
156
+$api->post('/matches', function($request, $response, $args) {
157 157
     $json = $request->getBody();
158 158
     $json = json_decode($json, true);
159 159
     return Responder::getJsonResponse(
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
     );
165 165
 });
166 166
 
167
-$api->get('/matches/{id}', function ($request, $response, $args) {
167
+$api->get('/matches/{id}', function($request, $response, $args) {
168 168
     return Responder::getJsonResponse(
169 169
         Match::complete()
170 170
             ->where(
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     );
177 177
 });
178 178
 
179
-$api->get('/matches/{id}/result', function ($request, $response, $args) {
179
+$api->get('/matches/{id}/result', function($request, $response, $args) {
180 180
     $result = MatchResult::complete()
181 181
         ->where(
182 182
             [
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     );
191 191
 });
192 192
 
193
-$api->put('/matches/{id}/simulate', function ($request, $response, $args) {
193
+$api->put('/matches/{id}/simulate', function($request, $response, $args) {
194 194
     return Responder::getJsonResponse(
195 195
         MatchSimulator::simulateCompleteResult(
196 196
             $args['id']
Please login to merge, or discard this patch.
api/tests/HelpersTest.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -8,74 +8,74 @@
 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::simulateCompleteResult($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::simulateCompleteResult($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
-        $round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id);
77
-        $this->assertNotEmpty($round);
78
-        $this->assertTrue($round->simulated);
79
-    }
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
+		$round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id);
77
+		$this->assertNotEmpty($round);
78
+		$this->assertTrue($round->simulated);
79
+	}
80 80
 
81 81
 }
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/LeagueRound.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -9,54 +9,54 @@
 block discarded – undo
9 9
 class LeagueRound extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'league_rounds';
16
-
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'league_id',
22
-        'day',
23
-        'simulated'
24
-    ];
25
-
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $casts = [
30
-        'simulated' => 'boolean'
31
-    ];
32
-
33
-    /**
34
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
35
-     */
36
-    public function league()
37
-    {
38
-        return $this->belongsTo(League::class);
39
-    }
40
-
41
-    /**
42
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
43
-     */
44
-    public function matches()
45
-    {
46
-        return $this->hasMany(Match::class);
47
-    }
48
-
49
-    /**
50
-     * @param $query
51
-     * @return mixed
52
-     */
53
-    public function scopeComplete($query)
54
-    {
55
-        return $query->with(
56
-            'league',
57
-            'matches',
58
-            'matches.homeTeam',
59
-            'matches.AwayTeam'
60
-        );
61
-    }
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'league_rounds';
16
+
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'league_id',
22
+		'day',
23
+		'simulated'
24
+	];
25
+
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $casts = [
30
+		'simulated' => 'boolean'
31
+	];
32
+
33
+	/**
34
+	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
35
+	 */
36
+	public function league()
37
+	{
38
+		return $this->belongsTo(League::class);
39
+	}
40
+
41
+	/**
42
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
43
+	 */
44
+	public function matches()
45
+	{
46
+		return $this->hasMany(Match::class);
47
+	}
48
+
49
+	/**
50
+	 * @param $query
51
+	 * @return mixed
52
+	 */
53
+	public function scopeComplete($query)
54
+	{
55
+		return $query->with(
56
+			'league',
57
+			'matches',
58
+			'matches.homeTeam',
59
+			'matches.AwayTeam'
60
+		);
61
+	}
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/Match.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -9,74 +9,74 @@
 block discarded – undo
9 9
 class Match extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'matches';
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'matches';
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'home_team_id',
22
-        'away_team_id',
23
-        'league_round_id'
24
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'home_team_id',
22
+		'away_team_id',
23
+		'league_round_id'
24
+	];
25 25
 
26
-    /**
27
-     * @var array
28
-     */
29
-    protected $hidden = [
30
-        'home_team_id',
31
-        'away_team_id',
32
-        'created_at',
33
-        'updated_at',
34
-        'winner_id',
35
-        'loser_id',
36
-        'is_draw',
37
-    ];
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $hidden = [
30
+		'home_team_id',
31
+		'away_team_id',
32
+		'created_at',
33
+		'updated_at',
34
+		'winner_id',
35
+		'loser_id',
36
+		'is_draw',
37
+	];
38 38
 
39
-    /**
40
-     * @var array
41
-     */
42
-    protected $casts = [
43
-        'simulated' => 'boolean'
44
-    ];
39
+	/**
40
+	 * @var array
41
+	 */
42
+	protected $casts = [
43
+		'simulated' => 'boolean'
44
+	];
45 45
 
46
-    /**
47
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
48
-     */
49
-    public function homeTeam()
50
-    {
51
-        return $this->belongsTo(Team::class, 'home_team_id');
52
-    }
46
+	/**
47
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
48
+	 */
49
+	public function homeTeam()
50
+	{
51
+		return $this->belongsTo(Team::class, 'home_team_id');
52
+	}
53 53
 
54
-    /**
55
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
-     */
57
-    public function awayTeam()
58
-    {
59
-        return $this->belongsTo(Team::class, 'away_team_id');
60
-    }
54
+	/**
55
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
+	 */
57
+	public function awayTeam()
58
+	{
59
+		return $this->belongsTo(Team::class, 'away_team_id');
60
+	}
61 61
 
62
-    public function scopeTeams($query)
63
-    {
64
-        return $query->with(
65
-            'homeTeam',
66
-            'awayTeam'
67
-        );
68
-    }
62
+	public function scopeTeams($query)
63
+	{
64
+		return $query->with(
65
+			'homeTeam',
66
+			'awayTeam'
67
+		);
68
+	}
69 69
 
70
-    public function scopeComplete($query)
71
-    {
72
-        return $query->with(
73
-            'homeTeam',
74
-            'homeTeam.roster',
75
-            'homeTeam.coach',
76
-            'awayTeam',
77
-            'awayTeam.roster',
78
-            'awayTeam.coach'
79
-        );
80
-    }
70
+	public function scopeComplete($query)
71
+	{
72
+		return $query->with(
73
+			'homeTeam',
74
+			'homeTeam.roster',
75
+			'homeTeam.coach',
76
+			'awayTeam',
77
+			'awayTeam.roster',
78
+			'awayTeam.coach'
79
+		);
80
+	}
81 81
 
82 82
 }
83 83
\ No newline at end of file
Please login to merge, or discard this patch.