Completed
Push — master ( c60305...7f3e18 )
by Vincenzo
02:47
created
api/database/migrations/CreateLeagueRoundsTable.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 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->integer('day')->default(0);
20
-            $table->timestamps();
21
-        });
22
-    }
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->integer('day')->default(0);
20
+			$table->timestamps();
21
+		});
22
+	}
23 23
 }
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/Models/Orm/LeagueRound.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 class LeagueRound extends DsManagerOrm
10 10
 {
11 11
 
12
-    /**
13
-     * @var string
14
-     */
15
-    protected $table = 'league_rounds';
12
+	/**
13
+	 * @var string
14
+	 */
15
+	protected $table = 'league_rounds';
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    protected $fillable = [
21
-        'league_id',
22
-        'day'
23
-    ];
17
+	/**
18
+	 * @var array
19
+	 */
20
+	protected $fillable = [
21
+		'league_id',
22
+		'day'
23
+	];
24 24
 
25
-    /**
26
-     * @return \Illuminate\Database\Eloquent\Relations\HasOne
27
-     */
28
-    public function league()
29
-    {
30
-        return $this->hasOne(League::class);
31
-    }
25
+	/**
26
+	 * @return \Illuminate\Database\Eloquent\Relations\HasOne
27
+	 */
28
+	public function league()
29
+	{
30
+		return $this->hasOne(League::class);
31
+	}
32 32
 
33
-    /**
34
-     * @return \Illuminate\Database\Eloquent\Relations\HasMany
35
-     */
36
-    public function matches()
37
-    {
38
-        return $this->hasMany(Match::class);
39
-    }
33
+	/**
34
+	 * @return \Illuminate\Database\Eloquent\Relations\HasMany
35
+	 */
36
+	public function matches()
37
+	{
38
+		return $this->hasMany(Match::class);
39
+	}
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Models/Orm/Match.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -9,72 +9,72 @@
 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
-        'info'
35
-    ];
26
+	/**
27
+	 * @var array
28
+	 */
29
+	protected $hidden = [
30
+		'home_team_id',
31
+		'away_team_id',
32
+		'created_at',
33
+		'updated_at',
34
+		'info'
35
+	];
36 36
 
37
-    /**
38
-     * @var array
39
-     */
40
-    protected $casts = [
41
-        'simulated' => 'boolean'
42
-    ];
37
+	/**
38
+	 * @var array
39
+	 */
40
+	protected $casts = [
41
+		'simulated' => 'boolean'
42
+	];
43 43
 
44
-    /**
45
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
46
-     */
47
-    public function homeTeam()
48
-    {
49
-        return $this->belongsTo(Team::class, 'home_team_id');
50
-    }
44
+	/**
45
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
46
+	 */
47
+	public function homeTeam()
48
+	{
49
+		return $this->belongsTo(Team::class, 'home_team_id');
50
+	}
51 51
 
52
-    /**
53
-     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
54
-     */
55
-    public function awayTeam()
56
-    {
57
-        return $this->belongsTo(Team::class, 'away_team_id');
58
-    }
52
+	/**
53
+	 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
54
+	 */
55
+	public function awayTeam()
56
+	{
57
+		return $this->belongsTo(Team::class, 'away_team_id');
58
+	}
59 59
 
60
-    public function scopeTeams($query)
61
-    {
62
-        return $query->with(
63
-            'homeTeam',
64
-            'awayTeam'
65
-        );
66
-    }
60
+	public function scopeTeams($query)
61
+	{
62
+		return $query->with(
63
+			'homeTeam',
64
+			'awayTeam'
65
+		);
66
+	}
67 67
 
68
-    public function scopeComplete($query)
69
-    {
70
-        return $query->with(
71
-            'homeTeam',
72
-            'homeTeam.roster',
73
-            'homeTeam.coach',
74
-            'awayTeam',
75
-            'awayTeam.roster',
76
-            'awayTeam.coach'
77
-        );
78
-    }
68
+	public function scopeComplete($query)
69
+	{
70
+		return $query->with(
71
+			'homeTeam',
72
+			'homeTeam.roster',
73
+			'homeTeam.coach',
74
+			'awayTeam',
75
+			'awayTeam.roster',
76
+			'awayTeam.coach'
77
+		);
78
+	}
79 79
 
80 80
 }
81 81
\ 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 1 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/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::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
-    }
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   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -14,190 +14,190 @@
 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
 
130 130
 $api->get('/leagues/{id}/rounds/{roundId}/matches', function ($request, $response, $args) {
131
-    return Responder::getJsonResponse(
132
-        Match::teams()
133
-            ->where(
134
-                [
135
-                    'league_round_id' => $args['roundId'],
136
-                ]
137
-            )->get(),
138
-        $response
139
-    );
131
+	return Responder::getJsonResponse(
132
+		Match::teams()
133
+			->where(
134
+				[
135
+					'league_round_id' => $args['roundId'],
136
+				]
137
+			)->get(),
138
+		$response
139
+	);
140 140
 });
141 141
 
142 142
 $api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
143
-    return Responder::getJsonResponse(
144
-        MatchSimulator::simulateRound(
145
-            $args['roundId']
146
-        ),
147
-        $response
148
-    );
143
+	return Responder::getJsonResponse(
144
+		MatchSimulator::simulateRound(
145
+			$args['roundId']
146
+		),
147
+		$response
148
+	);
149 149
 });
150 150
 
151 151
 $api->get('/matches', function ($request, $response, $args) {
152
-    return Responder::getJsonResponse(
153
-        Match::teams()->get(),
154
-        $response
155
-    );
152
+	return Responder::getJsonResponse(
153
+		Match::teams()->get(),
154
+		$response
155
+	);
156 156
 });
157 157
 
158 158
 $api->post('/matches', function ($request, $response, $args) {
159
-    $json = $request->getBody();
160
-    $json = json_decode($json, true);
161
-    return Responder::getJsonResponse(
162
-        Match::create(
163
-            $json
164
-        ),
165
-        $response
166
-    );
159
+	$json = $request->getBody();
160
+	$json = json_decode($json, true);
161
+	return Responder::getJsonResponse(
162
+		Match::create(
163
+			$json
164
+		),
165
+		$response
166
+	);
167 167
 });
168 168
 
169 169
 $api->get('/matches/{id}', function ($request, $response, $args) {
170
-    return Responder::getJsonResponse(
171
-        Match::complete()
172
-            ->where(
173
-                [
174
-                    'id' => $args['id']
175
-                ]
176
-            )->first(),
177
-        $response
178
-    );
170
+	return Responder::getJsonResponse(
171
+		Match::complete()
172
+			->where(
173
+				[
174
+					'id' => $args['id']
175
+				]
176
+			)->first(),
177
+		$response
178
+	);
179 179
 });
180 180
 
181 181
 $api->get('/matches/{id}/result', function ($request, $response, $args) {
182
-    $result = MatchResult::complete()
183
-        ->where(
184
-            [
185
-                'id' => $args['id']
186
-            ]
187
-        )->first();
182
+	$result = MatchResult::complete()
183
+		->where(
184
+			[
185
+				'id' => $args['id']
186
+			]
187
+		)->first();
188 188
 
189
-    return Responder::getJsonResponse(
190
-        $result,
191
-        $response
192
-    );
189
+	return Responder::getJsonResponse(
190
+		$result,
191
+		$response
192
+	);
193 193
 });
194 194
 
195 195
 $api->put('/matches/{id}/simulate', function ($request, $response, $args) {
196
-    return Responder::getJsonResponse(
197
-        MatchSimulator::simulateCompleteResult(
198
-            $args['id']
199
-        ),
200
-        $response
201
-    );
196
+	return Responder::getJsonResponse(
197
+		MatchSimulator::simulateCompleteResult(
198
+			$args['id']
199
+		),
200
+		$response
201
+	);
202 202
 });
203 203
 $api->run();
204 204
\ No newline at end of file
Please login to merge, or discard this patch.
api/Lib/DsManager/Helpers/MatchSimulator.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -14,92 +14,92 @@
 block discarded – undo
14 14
  */
15 15
 class MatchSimulator
16 16
 {
17
-    public static function simulateRound($roundId)
18
-    {
19
-        $matches = Match::where(
20
-            [
21
-                'league_round_id' => $roundId
22
-            ]
23
-        )->get();
24
-        $result = [];
25
-        foreach ($matches as $match) {
26
-            $result[] = self::simulateSimpleResult($match->id)->toArray();
27
-        }
28
-        return json_encode($result);
29
-    }
17
+	public static function simulateRound($roundId)
18
+	{
19
+		$matches = Match::where(
20
+			[
21
+				'league_round_id' => $roundId
22
+			]
23
+		)->get();
24
+		$result = [];
25
+		foreach ($matches as $match) {
26
+			$result[] = self::simulateSimpleResult($match->id)->toArray();
27
+		}
28
+		return json_encode($result);
29
+	}
30 30
 
31
-    /**
32
-     * @param $matchId
33
-     * @return mixed
34
-     */
35
-    public static function simulateCompleteResult($matchId)
36
-    {
37
-        $result = MatchResult::complete()->where(
38
-            [
39
-                'id' => $matchId
40
-            ]
41
-        )->first();
31
+	/**
32
+	 * @param $matchId
33
+	 * @return mixed
34
+	 */
35
+	public static function simulateCompleteResult($matchId)
36
+	{
37
+		$result = MatchResult::complete()->where(
38
+			[
39
+				'id' => $matchId
40
+			]
41
+		)->first();
42 42
 
43
-        if (!empty($result)
44
-            && !$result->simulated
45
-            && self::simulate($matchId) === 1
46
-        ) {
47
-            $result = MatchResult::complete()
48
-                ->where(
49
-                    [
50
-                        'id' => $matchId
51
-                    ]
52
-                )->first();
53
-        }
43
+		if (!empty($result)
44
+			&& !$result->simulated
45
+			&& self::simulate($matchId) === 1
46
+		) {
47
+			$result = MatchResult::complete()
48
+				->where(
49
+					[
50
+						'id' => $matchId
51
+					]
52
+				)->first();
53
+		}
54 54
 
55
-        return $result;
56
-    }
55
+		return $result;
56
+	}
57 57
 
58
-    public
59
-    static function simulateSimpleResult($matchId)
60
-    {
61
-        $result = MatchResult::teams()->where(
62
-            [
63
-                'id' => $matchId
64
-            ]
65
-        )->first();
58
+	public
59
+	static function simulateSimpleResult($matchId)
60
+	{
61
+		$result = MatchResult::teams()->where(
62
+			[
63
+				'id' => $matchId
64
+			]
65
+		)->first();
66 66
 
67
-        if (!empty($result)
68
-            && !$result->simulated
69
-            && self::simulate($matchId) === 1
70
-        ) {
71
-            $result = MatchResult::teams()
72
-                ->where(
73
-                    [
74
-                        'id' => $matchId
75
-                    ]
76
-                )->first();
77
-        }
78
-        return $result;
79
-    }
67
+		if (!empty($result)
68
+			&& !$result->simulated
69
+			&& self::simulate($matchId) === 1
70
+		) {
71
+			$result = MatchResult::teams()
72
+				->where(
73
+					[
74
+						'id' => $matchId
75
+					]
76
+				)->first();
77
+		}
78
+		return $result;
79
+	}
80 80
 
81
-    private
82
-    static function simulate($matchId)
83
-    {
84
-        $match = \App\Lib\DsManager\Models\Match::fromArray(
85
-            MatchOrm::complete()
86
-                ->where(
87
-                    [
88
-                        'id' => $matchId
89
-                    ]
90
-                )->first()->toArray()
91
-        );
92
-        $matchResult = $match->simulate()->toArray();
93
-        $result = MatchResult::where(
94
-            [
95
-                'id' => $matchId
96
-            ]
97
-        )->update(
98
-            MatchResult::resolveAttributes(
99
-                $matchResult,
100
-                $matchId
101
-            )
102
-        );
103
-        return $result;
104
-    }
81
+	private
82
+	static function simulate($matchId)
83
+	{
84
+		$match = \App\Lib\DsManager\Models\Match::fromArray(
85
+			MatchOrm::complete()
86
+				->where(
87
+					[
88
+						'id' => $matchId
89
+					]
90
+				)->first()->toArray()
91
+		);
92
+		$matchResult = $match->simulate()->toArray();
93
+		$result = MatchResult::where(
94
+			[
95
+				'id' => $matchId
96
+			]
97
+		)->update(
98
+			MatchResult::resolveAttributes(
99
+				$matchResult,
100
+				$matchId
101
+			)
102
+		);
103
+		return $result;
104
+	}
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.