Completed
Push — master ( 01ad84...898da4 )
by Vincenzo
02:22
created
api/Lib/DsManager/Models/MatchResult.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -12,141 +12,141 @@
 block discarded – undo
12 12
  */
13 13
 class MatchResult
14 14
 {
15
-    /**
16
-     * @var
17
-     */
18
-    private $goalHome;
19
-    /**
20
-     * @var
21
-     */
22
-    private $goalAway;
23
-    /**
24
-     * @var Team
25
-     */
26
-    private $homeTeam;
27
-    /**
28
-     * @var Team
29
-     */
30
-    private $awayTeam;
15
+	/**
16
+	 * @var
17
+	 */
18
+	private $goalHome;
19
+	/**
20
+	 * @var
21
+	 */
22
+	private $goalAway;
23
+	/**
24
+	 * @var Team
25
+	 */
26
+	private $homeTeam;
27
+	/**
28
+	 * @var Team
29
+	 */
30
+	private $awayTeam;
31 31
 
32
-    /**
33
-     * MatchResult constructor.
34
-     * @param $goalHome
35
-     * @param $goalAway
36
-     * @param Team $home
37
-     * @param Team $away
38
-     */
39
-    public function __construct($goalHome, $goalAway, Team $home, Team $away)
40
-    {
41
-        $this->goalHome = $goalHome;
42
-        $this->goalAway = $goalAway;
43
-        $this->homeTeam = $home;
44
-        $this->awayTeam = $away;
45
-    }
32
+	/**
33
+	 * MatchResult constructor.
34
+	 * @param $goalHome
35
+	 * @param $goalAway
36
+	 * @param Team $home
37
+	 * @param Team $away
38
+	 */
39
+	public function __construct($goalHome, $goalAway, Team $home, Team $away)
40
+	{
41
+		$this->goalHome = $goalHome;
42
+		$this->goalAway = $goalAway;
43
+		$this->homeTeam = $home;
44
+		$this->awayTeam = $away;
45
+	}
46 46
 
47
-    /**
48
-     * @return array
49
-     */
50
-    public function getWinnerLoser()
51
-    {
52
-        $isDraw = false;
53
-        $winner = null;
54
-        $loser = null;
55
-        if ($this->goalAway == $this->goalHome) {
56
-            $isDraw = true;
57
-            $winner = $this->homeTeam;
58
-            $loser = $this->awayTeam;
59
-        } else if ($this->goalHome > $this->goalAway) {
60
-            $winner = $this->homeTeam;
61
-            $loser = $this->awayTeam;
62
-        } else {
63
-            $winner = $this->awayTeam;
64
-            $loser = $this->homeTeam;
65
-        }
47
+	/**
48
+	 * @return array
49
+	 */
50
+	public function getWinnerLoser()
51
+	{
52
+		$isDraw = false;
53
+		$winner = null;
54
+		$loser = null;
55
+		if ($this->goalAway == $this->goalHome) {
56
+			$isDraw = true;
57
+			$winner = $this->homeTeam;
58
+			$loser = $this->awayTeam;
59
+		} else if ($this->goalHome > $this->goalAway) {
60
+			$winner = $this->homeTeam;
61
+			$loser = $this->awayTeam;
62
+		} else {
63
+			$winner = $this->awayTeam;
64
+			$loser = $this->homeTeam;
65
+		}
66 66
 
67
-        return [
68
-            'isDraw' => $isDraw,
69
-            'winner' => $this->cleanTeam($winner->toArray()),
70
-            'loser' => $this->cleanTeam($loser->toArray())
71
-        ];
72
-    }
67
+		return [
68
+			'isDraw' => $isDraw,
69
+			'winner' => $this->cleanTeam($winner->toArray()),
70
+			'loser' => $this->cleanTeam($loser->toArray())
71
+		];
72
+	}
73 73
 
74
-    /**
75
-     * @return array
76
-     */
77
-    public function toArray()
78
-    {
79
-        $result = [];
80
-        $result["goalHome"] = $this->goalHome;
81
-        $result["goalAway"] = $this->goalAway;
82
-        $result['info'] = $this->getWinnerLoser();
83
-        $result['info']['scorers'] = $this->getScorers();
84
-        return $result;
85
-    }
74
+	/**
75
+	 * @return array
76
+	 */
77
+	public function toArray()
78
+	{
79
+		$result = [];
80
+		$result["goalHome"] = $this->goalHome;
81
+		$result["goalAway"] = $this->goalAway;
82
+		$result['info'] = $this->getWinnerLoser();
83
+		$result['info']['scorers'] = $this->getScorers();
84
+		return $result;
85
+	}
86 86
 
87
-    /**
88
-     * @param array $team
89
-     * @return array
90
-     */
91
-    private function cleanTeam(array $team)
92
-    {
93
-        $fieldsToClean = [
94
-            'coach',
95
-            'roster',
96
-        ];
87
+	/**
88
+	 * @param array $team
89
+	 * @return array
90
+	 */
91
+	private function cleanTeam(array $team)
92
+	{
93
+		$fieldsToClean = [
94
+			'coach',
95
+			'roster',
96
+		];
97 97
 
98
-        foreach ($fieldsToClean as $field) {
99
-            if (array_key_exists($field, $team)) {
100
-                unset($team[$field]);
101
-            }
102
-        }
103
-        return $team;
104
-    }
98
+		foreach ($fieldsToClean as $field) {
99
+			if (array_key_exists($field, $team)) {
100
+				unset($team[$field]);
101
+			}
102
+		}
103
+		return $team;
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    private function getScorers()
110
-    {
111
-        $scorers = [
112
-            'home' => [],
113
-            'away' => []
114
-        ];
115
-        for ($i = 0; $i < $this->goalHome; $i++) {
116
-            $scorers['home'][] = $this->pickAScorer($this->homeTeam);
117
-        }
118
-        for ($i = 0; $i < $this->goalAway; $i++) {
119
-            $scorers['away'][] = $this->pickAScorer($this->awayTeam);
120
-        }
121
-        return $scorers;
122
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	private function getScorers()
110
+	{
111
+		$scorers = [
112
+			'home' => [],
113
+			'away' => []
114
+		];
115
+		for ($i = 0; $i < $this->goalHome; $i++) {
116
+			$scorers['home'][] = $this->pickAScorer($this->homeTeam);
117
+		}
118
+		for ($i = 0; $i < $this->goalAway; $i++) {
119
+			$scorers['away'][] = $this->pickAScorer($this->awayTeam);
120
+		}
121
+		return $scorers;
122
+	}
123 123
 
124
-    /**
125
-     * @param Team $team
126
-     * @return Player
127
-     */
128
-    private function pickAScorer(Team $team)
129
-    {
130
-        $player = null;
131
-        if (Randomizer::boolOnPercentage(70)) {
132
-            $roles = Config::get('modules.roles');
133
-            $forwards = array_splice($roles, count($roles) / 2);
134
-            $pos = array_rand($forwards);
135
-            unset($forwards[$pos]);
136
-            $player = $team->getBestPlayerForRole($pos);
137
-            while (empty($player)) {
138
-                if (!empty($forwards)) {
139
-                    $pos = array_rand($forwards);
140
-                    unset($forwards[$pos]);
141
-                    $player = $team->getBestPlayerForRole($pos);
142
-                } else {
143
-                    $player = $team->roster[array_rand($team->roster)];
144
-                }
145
-            }
146
-        } else {
147
-            $player = $team->roster[array_rand($team->roster)];
148
-        }
149
-        return $player;
150
-    }
124
+	/**
125
+	 * @param Team $team
126
+	 * @return Player
127
+	 */
128
+	private function pickAScorer(Team $team)
129
+	{
130
+		$player = null;
131
+		if (Randomizer::boolOnPercentage(70)) {
132
+			$roles = Config::get('modules.roles');
133
+			$forwards = array_splice($roles, count($roles) / 2);
134
+			$pos = array_rand($forwards);
135
+			unset($forwards[$pos]);
136
+			$player = $team->getBestPlayerForRole($pos);
137
+			while (empty($player)) {
138
+				if (!empty($forwards)) {
139
+					$pos = array_rand($forwards);
140
+					unset($forwards[$pos]);
141
+					$player = $team->getBestPlayerForRole($pos);
142
+				} else {
143
+					$player = $team->roster[array_rand($team->roster)];
144
+				}
145
+			}
146
+		} else {
147
+			$player = $team->roster[array_rand($team->roster)];
148
+		}
149
+		return $player;
150
+	}
151 151
 
152 152
 }
153 153
\ No newline at end of file
Please login to merge, or discard this patch.