refactor: if / else / elseif statements

- Change If Else Value Assign To Early Return
- Change Nested Ifs To Early Return
- Remove Always Else
This commit is contained in:
HDVinnie
2020-02-12 12:34:34 -05:00
parent 8607387023
commit 611fcd6bc1
57 changed files with 1065 additions and 1341 deletions
+6 -6
View File
@@ -251,11 +251,12 @@ class AnnounceController extends Controller
// Flag is tripped if new session is created but client reports up/down > 0
$ghost = false;
// Creates a new peer if not existing
if ($peer === null && $event == 'completed') {
return response(Bencode::bencode(['failure reason' => 'Torrent is complete but no record found.']))->withHeaders(['Content-Type' => 'text/plain']);
} elseif ($peer === null) {
}
// Creates a new peer if not existing
if ($peer === null) {
if ($uploaded > 0 || $downloaded > 0) {
$ghost = true;
$event = 'started';
@@ -506,13 +507,12 @@ class AnnounceController extends Controller
}
}
}
return $pcomp;
} elseif ($no_peer_id) {
}
if ($no_peer_id) {
foreach ($peers as &$p) {
unset($p['peer_id']);
}
return $peers;
} else {
return $peers;