Completed
Push — master ( c60305...7f3e18 )
by Vincenzo
02:47
created
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 2 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.
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.
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.