1 | <?php |
||
11 | class Fight extends Model |
||
12 | { |
||
13 | /** |
||
14 | * Fight constructor. |
||
15 | */ |
||
16 | public function __construct($userId1 = null, $userId2 = null) |
||
22 | |||
23 | protected $table = 'fight'; |
||
24 | public $timestamps = true; |
||
25 | |||
26 | protected $fillable = [ |
||
27 | 'tree_id', |
||
28 | 'c1', |
||
29 | 'c2' |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * @param Championship $championship |
||
34 | * @return mixed |
||
35 | */ |
||
36 | private static function getActorsToFights(Championship $championship, Round $round = null) |
||
52 | |||
53 | /** |
||
54 | * Get First Fighter |
||
55 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
56 | */ |
||
57 | public function competitor1() |
||
61 | |||
62 | /** |
||
63 | * Get Second Fighter |
||
64 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
65 | */ |
||
66 | public function competitor2() |
||
70 | |||
71 | /** |
||
72 | * Get First Fighter |
||
73 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
74 | */ |
||
75 | public function team1() |
||
79 | |||
80 | /** |
||
81 | * Get Second Fighter |
||
82 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
83 | */ |
||
84 | public function team2() |
||
88 | |||
89 | /** |
||
90 | * Save a Fight. |
||
91 | * @param $rounds |
||
92 | * @param int $numRound |
||
93 | */ |
||
94 | public static function savePreliminaryFightRound($rounds, $numRound = 1) |
||
133 | |||
134 | |||
135 | // public static function saveRoundRobinFight(Championship $championship, $tree) |
||
136 | // { |
||
137 | // $championship->category->isTeam |
||
138 | // ? $fighters = $championship->teams |
||
139 | // : $fighters = $championship->users; |
||
140 | // |
||
141 | // $reverseFighters = $fighters->reverse(); |
||
142 | // $order = 0; |
||
143 | // foreach ($reverseFighters as $reverse) { |
||
144 | // foreach ($fighters as $fighter) { |
||
145 | // if ($fighter->id != $reverse->id) { |
||
146 | // $fight = new Fight(); |
||
147 | // $fight->tree_id = $tree[0]->id; |
||
148 | // $fight->c1 = $fighter->id; |
||
149 | // $fight->c2 = $reverse->id; |
||
150 | // $fight->order = $order++; |
||
151 | // $fight->area = 1; |
||
152 | // $fight->save(); |
||
153 | // $order++; |
||
154 | // } |
||
155 | // } |
||
156 | // } |
||
157 | // } |
||
158 | |||
159 | public static function saveRoundRobinFights(Championship $championship, $rounds) |
||
201 | |||
202 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.