Completed
Push — master ( c27acc...5e9888 )
by Vincenzo
02:27
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 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   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -14,109 +14,109 @@
 block discarded – undo
14 14
  */
15 15
 class MatchSimulator
16 16
 {
17
-    /**
18
-     * @param $roundId
19
-     * @return string
20
-     */
21
-    public static function simulateRound($roundId)
22
-    {
23
-        $matches = Match::where(
24
-            [
25
-                'league_round_id' => $roundId
26
-            ]
27
-        )->get();
28
-        $result = [];
29
-        foreach ($matches as $match) {
30
-            $result[] = self::simulateSimpleResult($match->id)->toArray();
31
-        }
32
-        return json_encode($result);
33
-    }
17
+	/**
18
+	 * @param $roundId
19
+	 * @return string
20
+	 */
21
+	public static function simulateRound($roundId)
22
+	{
23
+		$matches = Match::where(
24
+			[
25
+				'league_round_id' => $roundId
26
+			]
27
+		)->get();
28
+		$result = [];
29
+		foreach ($matches as $match) {
30
+			$result[] = self::simulateSimpleResult($match->id)->toArray();
31
+		}
32
+		return json_encode($result);
33
+	}
34 34
 
35
-    /**
36
-     * @param $matchId
37
-     * @return mixed
38
-     */
39
-    public static function simulateCompleteResult($matchId)
40
-    {
41
-        $result = self::getCompleteResult($matchId);
42
-        if (!empty($result)
43
-            && !$result->simulated
44
-            && self::simulate($matchId) === 1
45
-        ) {
46
-            $result = self::getCompleteResult($matchId);
47
-        }
48
-        return $result;
49
-    }
35
+	/**
36
+	 * @param $matchId
37
+	 * @return mixed
38
+	 */
39
+	public static function simulateCompleteResult($matchId)
40
+	{
41
+		$result = self::getCompleteResult($matchId);
42
+		if (!empty($result)
43
+			&& !$result->simulated
44
+			&& self::simulate($matchId) === 1
45
+		) {
46
+			$result = self::getCompleteResult($matchId);
47
+		}
48
+		return $result;
49
+	}
50 50
 
51
-    /**
52
-     * @param $matchId
53
-     * @return mixed
54
-     */
55
-    public static function simulateSimpleResult($matchId)
56
-    {
57
-        $result = self::getSimpleResult($matchId);
58
-        if (!empty($result)
59
-            && !$result->simulated
60
-            && self::simulate($matchId) === 1
61
-        ) {
62
-            $result = self::getSimpleResult($matchId);
63
-        }
64
-        return $result;
65
-    }
51
+	/**
52
+	 * @param $matchId
53
+	 * @return mixed
54
+	 */
55
+	public static function simulateSimpleResult($matchId)
56
+	{
57
+		$result = self::getSimpleResult($matchId);
58
+		if (!empty($result)
59
+			&& !$result->simulated
60
+			&& self::simulate($matchId) === 1
61
+		) {
62
+			$result = self::getSimpleResult($matchId);
63
+		}
64
+		return $result;
65
+	}
66 66
 
67
-    /**
68
-     * @param $matchId
69
-     * @return mixed
70
-     */
71
-    private static function simulate($matchId)
72
-    {
73
-        $match = \App\Lib\DsManager\Models\Match::fromArray(
74
-            MatchOrm::complete()
75
-                ->where(
76
-                    [
77
-                        'id' => $matchId
78
-                    ]
79
-                )->first()->toArray()
80
-        );
81
-        $matchResult = $match->simulate()->toArray();
82
-        $result = MatchResult::where(
83
-            [
84
-                'id' => $matchId
85
-            ]
86
-        )->update(
87
-            MatchResult::resolveAttributes(
88
-                $matchResult,
89
-                $matchId
90
-            )
91
-        );
92
-        return $result;
93
-    }
67
+	/**
68
+	 * @param $matchId
69
+	 * @return mixed
70
+	 */
71
+	private static function simulate($matchId)
72
+	{
73
+		$match = \App\Lib\DsManager\Models\Match::fromArray(
74
+			MatchOrm::complete()
75
+				->where(
76
+					[
77
+						'id' => $matchId
78
+					]
79
+				)->first()->toArray()
80
+		);
81
+		$matchResult = $match->simulate()->toArray();
82
+		$result = MatchResult::where(
83
+			[
84
+				'id' => $matchId
85
+			]
86
+		)->update(
87
+			MatchResult::resolveAttributes(
88
+				$matchResult,
89
+				$matchId
90
+			)
91
+		);
92
+		return $result;
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * @param $matchId
98
-     * @return MatchResult
99
-     */
100
-    private static function getCompleteResult($matchId)
101
-    {
102
-        return MatchResult::complete()->where(
103
-            [
104
-                'id' => $matchId
105
-            ]
106
-        )->first();
107
-    }
96
+	/**
97
+	 * @param $matchId
98
+	 * @return MatchResult
99
+	 */
100
+	private static function getCompleteResult($matchId)
101
+	{
102
+		return MatchResult::complete()->where(
103
+			[
104
+				'id' => $matchId
105
+			]
106
+		)->first();
107
+	}
108 108
 
109
-    /**
110
-     * @param $matchId
111
-     * @return MatchResult
112
-     */
113
-    private static function getSimpleResult($matchId)
114
-    {
115
-        return MatchResult::teams()->where(
116
-            [
117
-                'id' => $matchId
118
-            ]
119
-        )->first();
120
-    }
109
+	/**
110
+	 * @param $matchId
111
+	 * @return MatchResult
112
+	 */
113
+	private static function getSimpleResult($matchId)
114
+	{
115
+		return MatchResult::teams()->where(
116
+			[
117
+				'id' => $matchId
118
+			]
119
+		)->first();
120
+	}
121 121
 
122 122
 }
123 123
\ 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.