@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Repositories; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use PhpDraft\Domain\Entities\Trade; |
|
| 6 | -use PhpDraft\Domain\Entities\TradeAsset; |
|
| 7 | 5 | |
| 8 | 6 | class DraftDataRepository { |
| 9 | 7 | private $app; |
@@ -388,7 +388,7 @@ |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | public function GetHistoricalTeams($pro_league) { |
| 391 | - switch(strtolower($pro_league)) { |
|
| 391 | + switch (strtolower($pro_league)) { |
|
| 392 | 392 | case 'nhl': |
| 393 | 393 | case'hockey': |
| 394 | 394 | return $this->historical_nhl_teams; |
@@ -465,6 +465,9 @@ |
||
| 465 | 465 | return; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | + /** |
|
| 469 | + * @param integer $draft_id |
|
| 470 | + */ |
|
| 468 | 471 | private function ResetDraftCache($draft_id) { |
| 469 | 472 | $draft = $this->Load($draft_id, true); |
| 470 | 473 | } |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use Silex\Application; |
| 5 | 5 | use Symfony\Component\HttpFoundation\Request; |
| 6 | 6 | use PhpDraft\Domain\Entities\Draft; |
| 7 | -use PhpDraft\Domain\Entities\Pick; |
|
| 8 | 7 | |
| 9 | 8 | class DraftRepository { |
| 10 | 9 | private $app; |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | /*$draft_stmt->bindParam(1, $startIndex, \PDO::PARAM_INT); |
| 37 | 37 | $draft_stmt->bindParam(2, $pageSize, \PDO::PARAM_INT);*/ |
| 38 | 38 | |
| 39 | - if(!$draft_stmt->execute()) { |
|
| 39 | + if (!$draft_stmt->execute()) { |
|
| 40 | 40 | throw new \Exception("Unable to load drafts."); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $drafts = array(); |
| 44 | 44 | |
| 45 | - while($draft = $draft_stmt->fetch()) { |
|
| 45 | + while ($draft = $draft_stmt->fetch()) { |
|
| 46 | 46 | $currentUserOwnsIt = !empty($current_user) && $draft->commish_id == $current_user->id; |
| 47 | 47 | $currentUserIsAdmin = !empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user); |
| 48 | 48 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time); |
| 58 | 58 | $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time); |
| 59 | 59 | |
| 60 | - if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 60 | + if (!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 61 | 61 | $draft->is_locked = true; |
| 62 | 62 | $draft = $this->ProtectPrivateDraft($draft); |
| 63 | 63 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft'); |
| 83 | 83 | $draft_stmt->bindParam(1, $commish_id); |
| 84 | 84 | |
| 85 | - if(!$draft_stmt->execute()) { |
|
| 85 | + if (!$draft_stmt->execute()) { |
|
| 86 | 86 | throw new \Exception("Unable to load drafts."); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | $drafts = array(); |
| 92 | 92 | |
| 93 | - while($draft = $draft_stmt->fetch()) { |
|
| 93 | + while ($draft = $draft_stmt->fetch()) { |
|
| 94 | 94 | $currentUserOwnsIt = !empty($current_user) && $draft->commish_id == $current_user->id; |
| 95 | 95 | $currentUserIsAdmin = !empty($current_user) && $this->app['phpdraft.LoginUserService']->CurrentUserIsAdmin($current_user); |
| 96 | 96 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time); |
| 106 | 106 | $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time); |
| 107 | 107 | |
| 108 | - if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 108 | + if (!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 109 | 109 | $draft->is_locked = true; |
| 110 | 110 | $draft = $this->ProtectPrivateDraft($draft); |
| 111 | 111 | } |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft'); |
| 132 | 132 | $draft_stmt->bindParam(1, $commish_id); |
| 133 | 133 | |
| 134 | - if(!$draft_stmt->execute()) { |
|
| 134 | + if (!$draft_stmt->execute()) { |
|
| 135 | 135 | throw new \Exception("Unable to load drafts."); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | $drafts = array(); |
| 139 | 139 | |
| 140 | - while($draft = $draft_stmt->fetch()) { |
|
| 140 | + while ($draft = $draft_stmt->fetch()) { |
|
| 141 | 141 | $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time); |
| 142 | 142 | $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time); |
| 143 | 143 | $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $draft_stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Draft'); |
| 160 | 160 | |
| 161 | - if(!$draft_stmt->execute()) { |
|
| 161 | + if (!$draft_stmt->execute()) { |
|
| 162 | 162 | throw new \Exception("Unable to load drafts."); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $drafts = array(); |
| 166 | 166 | |
| 167 | - while($draft = $draft_stmt->fetch()) { |
|
| 167 | + while ($draft = $draft_stmt->fetch()) { |
|
| 168 | 168 | $draft->draft_create_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_create_time); |
| 169 | 169 | $draft->draft_start_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_start_time); |
| 170 | 170 | $draft->draft_end_time = $this->app['phpdraft.UtilityService']->ConvertTimeForClientDisplay($draft->draft_end_time); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $cachedDraft = $this->GetCachedDraft($id); |
| 182 | 182 | |
| 183 | - if($cachedDraft != null) { |
|
| 183 | + if ($cachedDraft != null) { |
|
| 184 | 184 | $draft = $cachedDraft; |
| 185 | 185 | } else { |
| 186 | 186 | $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $draft_stmt->bindParam(1, $id, \PDO::PARAM_INT); |
| 193 | 193 | |
| 194 | - if(!$draft_stmt->execute() || !$draft_stmt->fetch()) { |
|
| 194 | + if (!$draft_stmt->execute() || !$draft_stmt->fetch()) { |
|
| 195 | 195 | throw new \Exception("Unable to load draft"); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -216,21 +216,21 @@ discard block |
||
| 216 | 216 | $draft->in_progress = $this->app['phpdraft.DraftService']->DraftInProgress($draft); |
| 217 | 217 | $draft->complete = $this->app['phpdraft.DraftService']->DraftComplete($draft); |
| 218 | 218 | |
| 219 | - if($getDraftData) { |
|
| 219 | + if ($getDraftData) { |
|
| 220 | 220 | $draft->sports = $this->app['phpdraft.DraftDataRepository']->GetSports(); |
| 221 | 221 | $draft->styles = $this->app['phpdraft.DraftDataRepository']->GetStyles(); |
| 222 | 222 | $draft->statuses = $this->app['phpdraft.DraftDataRepository']->GetStatuses(); |
| 223 | 223 | $draft->teams = $this->app['phpdraft.DraftDataRepository']->GetTeams($draft->draft_sport); |
| 224 | 224 | $draft->historical_teams = $this->app['phpdraft.DraftDataRepository']->GetHistoricalTeams($draft->draft_sport); |
| 225 | 225 | $draft->positions = $this->app['phpdraft.DraftDataRepository']->GetPositions($draft->draft_sport); |
| 226 | - if($draft->using_depth_charts) { |
|
| 226 | + if ($draft->using_depth_charts) { |
|
| 227 | 227 | $draft->depthChartPositions = $this->app['phpdraft.DepthChartPositionRepository']->LoadAll($draft->draft_id); |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $draft->is_locked = false; |
| 232 | 232 | |
| 233 | - if(!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 233 | + if (!$currentUserOwnsIt && !$currentUserIsAdmin && !$draft->draft_visible && $password != $draft->draft_password) { |
|
| 234 | 234 | $draft->is_locked = true; |
| 235 | 235 | $draft = $this->ProtectPrivateDraft($draft); |
| 236 | 236 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $cachedDraft = $this->GetCachedDraft($id); |
| 251 | 251 | |
| 252 | - if($bustCache || $cachedDraft == null) { |
|
| 252 | + if ($bustCache || $cachedDraft == null) { |
|
| 253 | 253 | $draft_stmt = $this->app['db']->prepare("SELECT d.*, u.Name AS commish_name FROM draft d |
| 254 | 254 | LEFT OUTER JOIN users u |
| 255 | 255 | ON d.commish_id = u.id |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | $draft_stmt->bindParam(1, $id, \PDO::PARAM_INT); |
| 261 | 261 | |
| 262 | - if(!$draft_stmt->execute() || !$draft_stmt->fetch()) { |
|
| 262 | + if (!$draft_stmt->execute() || !$draft_stmt->fetch()) { |
|
| 263 | 263 | throw new \Exception("Unable to load draft"); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $draft->using_depth_charts = $draft->using_depth_charts == 1; |
| 267 | 267 | |
| 268 | - if($bustCache) { |
|
| 268 | + if ($bustCache) { |
|
| 269 | 269 | $this->UnsetCachedDraft($draft->draft_id); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $insert_stmt->bindParam(7, $draft->draft_password); |
| 295 | 295 | $insert_stmt->bindParam(8, $draft->using_depth_charts); |
| 296 | 296 | |
| 297 | - if(!$insert_stmt->execute()) { |
|
| 297 | + if (!$insert_stmt->execute()) { |
|
| 298 | 298 | throw new \Exception("Unable to create draft."); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $update_stmt->bindParam(7, $draft->using_depth_charts); |
| 327 | 327 | $update_stmt->bindParam(8, $draft->draft_id); |
| 328 | 328 | |
| 329 | - if(!$update_stmt->execute()) { |
|
| 329 | + if (!$update_stmt->execute()) { |
|
| 330 | 330 | throw new \Exception("Unable to update draft."); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $status_stmt->bindParam(1, $draft->draft_status); |
| 343 | 343 | $status_stmt->bindParam(2, $draft->draft_id); |
| 344 | 344 | |
| 345 | - if(!$status_stmt->execute()) { |
|
| 345 | + if (!$status_stmt->execute()) { |
|
| 346 | 346 | throw new \Exception("Unable to update draft status."); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | $status_stmt->bindParam(1, $draft->draft_id); |
| 359 | 359 | |
| 360 | - if(!$status_stmt->execute()) { |
|
| 360 | + if (!$status_stmt->execute()) { |
|
| 361 | 361 | throw new \Exception("Unable to update draft's stats timestamp."); |
| 362 | 362 | } |
| 363 | 363 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $increment_stmt->bindParam(1, $incrementedCounter); |
| 376 | 376 | $increment_stmt->bindParam(2, $draft->draft_id); |
| 377 | 377 | |
| 378 | - if(!$increment_stmt->execute()) { |
|
| 378 | + if (!$increment_stmt->execute()) { |
|
| 379 | 379 | throw new \Exception("Unable to increment draft counter."); |
| 380 | 380 | } |
| 381 | 381 | |
@@ -387,8 +387,8 @@ discard block |
||
| 387 | 387 | //$next_pick can't be type-hinted - can be null |
| 388 | 388 | public function MoveDraftForward(Draft $draft, $next_pick) { |
| 389 | 389 | if ($next_pick !== null) { |
| 390 | - $draft->draft_current_pick = (int) $next_pick->player_pick; |
|
| 391 | - $draft->draft_current_round = (int) $next_pick->player_round; |
|
| 390 | + $draft->draft_current_pick = (int)$next_pick->player_pick; |
|
| 391 | + $draft->draft_current_round = (int)$next_pick->player_round; |
|
| 392 | 392 | |
| 393 | 393 | $stmt = $this->app['db']->prepare("UPDATE draft SET draft_current_pick = ?, draft_current_round = ? WHERE draft_id = ?"); |
| 394 | 394 | $stmt->bindParam(1, $draft->draft_current_pick); |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | $reset_stmt->bindParam(1, $draft->draft_id); |
| 428 | 428 | |
| 429 | - if(!$reset_stmt->execute()) { |
|
| 429 | + if (!$reset_stmt->execute()) { |
|
| 430 | 430 | throw new \Exception("Unable to set draft to in progress."); |
| 431 | 431 | } |
| 432 | 432 | |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | public function NameIsUnique($name, $id = null) { |
| 439 | - if(!empty($id)) { |
|
| 439 | + if (!empty($id)) { |
|
| 440 | 440 | $name_stmt = $this->app['db']->prepare("SELECT draft_name FROM draft WHERE draft_name LIKE ? AND draft_id <> ?"); |
| 441 | 441 | $name_stmt->bindParam(1, $name); |
| 442 | 442 | $name_stmt->bindParam(2, $id); |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | $name_stmt->bindParam(1, $name); |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - if(!$name_stmt->execute()) { |
|
| 448 | + if (!$name_stmt->execute()) { |
|
| 449 | 449 | throw new \Exception("Draft name '%s' is invalid", $name); |
| 450 | 450 | } |
| 451 | 451 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $delete_stmt = $this->app['db']->prepare("DELETE FROM draft WHERE draft_id = ?"); |
| 457 | 457 | $delete_stmt->bindParam(1, $draft_id); |
| 458 | 458 | |
| 459 | - if(!$delete_stmt->execute()) { |
|
| 459 | + if (!$delete_stmt->execute()) { |
|
| 460 | 460 | throw new \Exception("Unable to delete draft $draft_id."); |
| 461 | 461 | } |
| 462 | 462 | |
@@ -324,6 +324,9 @@ discard block |
||
| 324 | 324 | return $picks; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | + /** |
|
| 328 | + * @param integer $draft_round |
|
| 329 | + */ |
|
| 327 | 330 | public function LoadRoundPicks(Draft $draft, $draft_round, $sort_ascending = true, $selected = true) { |
| 328 | 331 | $picks = array(); |
| 329 | 332 | $sortOrder = $sort_ascending ? "ASC" : "DESC"; |
@@ -361,7 +364,6 @@ discard block |
||
| 361 | 364 | |
| 362 | 365 | /** |
| 363 | 366 | * Searches for picks with strict criteria, using the MATCH() and score method. Sorts by score ASC first, then pick DESC last. |
| 364 | - * @param int $draft_id |
|
| 365 | 367 | */ |
| 366 | 368 | public function SearchStrict(PickSearchModel $searchModel) { |
| 367 | 369 | $draft_id = (int) $searchModel->draft_id; |
@@ -411,7 +413,6 @@ discard block |
||
| 411 | 413 | |
| 412 | 414 | /** |
| 413 | 415 | * Search picks by a loose criteria that uses a LIKE %% query. Used if strict query returns 0 results. Sorts by pick DESC. |
| 414 | - * @param int $draft_id |
|
| 415 | 416 | */ |
| 416 | 417 | public function SearchLoose(PickSearchModel $searchModel) { |
| 417 | 418 | $draft_id = (int) $searchModel->draft_id; |
@@ -475,7 +476,6 @@ discard block |
||
| 475 | 476 | |
| 476 | 477 | /** |
| 477 | 478 | * Search picks by assuming a first + last combo was entered. Used if strict and loose queries return 0 and theres a space in the name. Sorts by pick DESC. |
| 478 | - * @param int $draft_id |
|
| 479 | 479 | */ |
| 480 | 480 | public function SearchSplit(PickSearchModel $searchModel, $first_name, $last_name) { |
| 481 | 481 | $draft_id = (int) $searchModel->draft_id; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | $pick_stmt->setFetchMode(\PDO::FETCH_INTO, $pick); |
| 47 | 47 | |
| 48 | - if(!$pick_stmt->execute() || !$pick_stmt->fetch()) { |
|
| 48 | + if (!$pick_stmt->execute() || !$pick_stmt->fetch()) { |
|
| 49 | 49 | throw new \Exception("Unable to load pick " . $id); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function LoadUpdatedPicks($draft_id, $pick_counter) { |
| 75 | 75 | $picks = array(); |
| 76 | 76 | |
| 77 | - $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name FROM players p ". |
|
| 77 | + $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name FROM players p " . |
|
| 78 | 78 | "LEFT OUTER JOIN managers m " . |
| 79 | 79 | "ON m.manager_id = p.manager_id " . |
| 80 | 80 | "WHERE p.draft_id = ? " . |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Pick'); |
| 87 | 87 | |
| 88 | - if(!$stmt->execute()) { |
|
| 88 | + if (!$stmt->execute()) { |
|
| 89 | 89 | throw new \Exception("Unable to load updated picks."); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - while($pick = $stmt->fetch()) { |
|
| 92 | + while ($pick = $stmt->fetch()) { |
|
| 93 | 93 | $pick->selected = strlen($pick->pick_time) > 0 && $pick->pick_duration > 0; |
| 94 | 94 | $picks[] = $pick; |
| 95 | 95 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $update_stmt->bindParam(8, $pick->player_counter); |
| 112 | 112 | $update_stmt->bindParam(9, $pick->player_id); |
| 113 | 113 | |
| 114 | - if(!$update_stmt->execute()) { |
|
| 114 | + if (!$update_stmt->execute()) { |
|
| 115 | 115 | throw new \Exception("Unable to update pick #$pick->player_id"); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $update_stmt->bindParam(2, $pick->position_eligibility); |
| 127 | 127 | $update_stmt->bindParam(3, $pick->player_id); |
| 128 | 128 | |
| 129 | - if(!$update_stmt->execute()) { |
|
| 129 | + if (!$update_stmt->execute()) { |
|
| 130 | 130 | throw new \Exception("Unable to update pick #$pick->player_id for depth chart."); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | public function LoadLastPicks($draft_id, $amount) { |
| 236 | 236 | $picks = array(); |
| 237 | 237 | |
| 238 | - $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name, m.manager_id FROM players p ". |
|
| 238 | + $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name, m.manager_id FROM players p " . |
|
| 239 | 239 | "LEFT OUTER JOIN managers m " . |
| 240 | 240 | "ON m.manager_id = p.manager_id " . |
| 241 | 241 | "WHERE p.draft_id = ? " . |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Pick'); |
| 251 | 251 | |
| 252 | - if(!$stmt->execute()) { |
|
| 252 | + if (!$stmt->execute()) { |
|
| 253 | 253 | throw new Exception("Unable to load last $amount picks."); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - while($pick = $stmt->fetch()) { |
|
| 256 | + while ($pick = $stmt->fetch()) { |
|
| 257 | 257 | $pick->selected = strlen($pick->pick_time) > 0 && $pick->pick_duration > 0; |
| 258 | 258 | $picks[] = $pick; |
| 259 | 259 | } |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | public function LoadNextPicks($draft_id, $currentPick, $amount) { |
| 265 | 265 | $picks = array(); |
| 266 | 266 | |
| 267 | - $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name, m.manager_id FROM players p ". |
|
| 267 | + $stmt = $this->app['db']->prepare("SELECT p.*, m.manager_name, m.manager_id FROM players p " . |
|
| 268 | 268 | "LEFT OUTER JOIN managers m " . |
| 269 | 269 | "ON m.manager_id = p.manager_id " . |
| 270 | 270 | "WHERE p.draft_id = ? " . |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | $stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Pick'); |
| 280 | 280 | |
| 281 | - if(!$stmt->execute()) { |
|
| 281 | + if (!$stmt->execute()) { |
|
| 282 | 282 | throw new Exception("Unable to load next $amount picks."); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - while($pick = $stmt->fetch()) { |
|
| 285 | + while ($pick = $stmt->fetch()) { |
|
| 286 | 286 | $pick->selected = strlen($pick->pick_time) > 0 && $pick->pick_duration > 0; |
| 287 | 287 | $pick->on_the_clock = $pick->player_pick == $currentPick; |
| 288 | 288 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | public function LoadManagerPicks($manager_id, $draft = null, $selected = true) { |
| 296 | - $manager_id = (int) $manager_id; |
|
| 296 | + $manager_id = (int)$manager_id; |
|
| 297 | 297 | |
| 298 | 298 | if ($manager_id == 0) { |
| 299 | 299 | throw new \Exception("Unable to get manager #" . $manager_id . "'s picks."); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param int $draft_id |
| 365 | 365 | */ |
| 366 | 366 | public function SearchStrict(PickSearchModel $searchModel) { |
| 367 | - $draft_id = (int) $searchModel->draft_id; |
|
| 367 | + $draft_id = (int)$searchModel->draft_id; |
|
| 368 | 368 | $param_number = 4; |
| 369 | 369 | $players = array(); |
| 370 | 370 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | * @param int $draft_id |
| 415 | 415 | */ |
| 416 | 416 | public function SearchLoose(PickSearchModel $searchModel) { |
| 417 | - $draft_id = (int) $searchModel->draft_id; |
|
| 417 | + $draft_id = (int)$searchModel->draft_id; |
|
| 418 | 418 | $players = array(); |
| 419 | 419 | $param_number = 2; |
| 420 | 420 | $loose_search_score = -1; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param int $draft_id |
| 479 | 479 | */ |
| 480 | 480 | public function SearchSplit(PickSearchModel $searchModel, $first_name, $last_name) { |
| 481 | - $draft_id = (int) $searchModel->draft_id; |
|
| 481 | + $draft_id = (int)$searchModel->draft_id; |
|
| 482 | 482 | $players = array(); |
| 483 | 483 | $param_number = 4; |
| 484 | 484 | $loose_search_score = -1; |
@@ -541,11 +541,11 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | $stmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\Pick'); |
| 543 | 543 | |
| 544 | - if(!$stmt->execute()) { |
|
| 544 | + if (!$stmt->execute()) { |
|
| 545 | 545 | throw new \Exception("Unable to check to see if $first_name $last_name was already drafted."); |
| 546 | 546 | } |
| 547 | 547 | |
| 548 | - while($pick = $stmt->fetch()) { |
|
| 548 | + while ($pick = $stmt->fetch()) { |
|
| 549 | 549 | $pick->selected = strlen($pick->pick_time) > 0 && $pick->pick_duration > 0; |
| 550 | 550 | $picks[] = $pick; |
| 551 | 551 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $delete_stmt = $this->app['db']->prepare("DELETE FROM players WHERE draft_id = ?"); |
| 558 | 558 | $delete_stmt->bindParam(1, $draft_id); |
| 559 | 559 | |
| 560 | - if(!$delete_stmt->execute()) { |
|
| 560 | + if (!$delete_stmt->execute()) { |
|
| 561 | 561 | throw new \Exception("Unable to delete picks for $draft_id."); |
| 562 | 562 | } |
| 563 | 563 | |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $managers = $ascending_managers; |
| 578 | 578 | $even = false; |
| 579 | 579 | } else { |
| 580 | - if($descending_managers == null) { |
|
| 580 | + if ($descending_managers == null) { |
|
| 581 | 581 | throw new \Exception("Descending managers list is empty - unable to setup draft."); |
| 582 | 582 | } |
| 583 | 583 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | $insert_stmt->bindParam(3, $pick->player_round); |
| 620 | 620 | $insert_stmt->bindParam(4, $pick->player_pick); |
| 621 | 621 | |
| 622 | - if(!$insert_stmt->execute()) { |
|
| 622 | + if (!$insert_stmt->execute()) { |
|
| 623 | 623 | throw new \Exception("Unable to insert pick #$pick->player_pick for draft $pick->draft_id"); |
| 624 | 624 | } |
| 625 | 625 | |
@@ -371,11 +371,13 @@ discard block |
||
| 371 | 371 | $sql = "SELECT p.*, m.manager_name, MATCH (p.first_name, p.last_name) AGAINST (?) as search_score " . |
| 372 | 372 | "FROM players p LEFT OUTER JOIN managers m ON m.manager_id = p.manager_id WHERE MATCH (p.first_name, p.last_name) AGAINST (?) AND p.draft_id = ? "; |
| 373 | 373 | |
| 374 | - if ($searchModel->hasTeam()) |
|
| 375 | - $sql .= "AND p.team = ? "; |
|
| 374 | + if ($searchModel->hasTeam()) { |
|
| 375 | + $sql .= "AND p.team = ? "; |
|
| 376 | + } |
|
| 376 | 377 | |
| 377 | - if ($searchModel->hasPosition()) |
|
| 378 | - $sql .= "AND p.position = ? "; |
|
| 378 | + if ($searchModel->hasPosition()) { |
|
| 379 | + $sql .= "AND p.position = ? "; |
|
| 380 | + } |
|
| 379 | 381 | |
| 380 | 382 | $sql .= "AND p.pick_time IS NOT NULL ORDER BY search_score ASC, p.player_pick $searchModel->sort"; |
| 381 | 383 | |
@@ -421,14 +423,17 @@ discard block |
||
| 421 | 423 | |
| 422 | 424 | $sql = "SELECT p.*, m.manager_name FROM players p LEFT OUTER JOIN managers m ON m.manager_id = p.manager_id WHERE p.draft_id = ? "; |
| 423 | 425 | |
| 424 | - if ($searchModel->hasName()) |
|
| 425 | - $sql .= "AND (p.first_name LIKE ? OR p.last_name LIKE ?)"; |
|
| 426 | + if ($searchModel->hasName()) { |
|
| 427 | + $sql .= "AND (p.first_name LIKE ? OR p.last_name LIKE ?)"; |
|
| 428 | + } |
|
| 426 | 429 | |
| 427 | - if ($searchModel->hasTeam()) |
|
| 428 | - $sql .= "AND p.team = ? "; |
|
| 430 | + if ($searchModel->hasTeam()) { |
|
| 431 | + $sql .= "AND p.team = ? "; |
|
| 432 | + } |
|
| 429 | 433 | |
| 430 | - if ($searchModel->hasPosition()) |
|
| 431 | - $sql .= "AND p.position = ? "; |
|
| 434 | + if ($searchModel->hasPosition()) { |
|
| 435 | + $sql .= "AND p.position = ? "; |
|
| 436 | + } |
|
| 432 | 437 | |
| 433 | 438 | $sql .= "AND p.pick_time IS NOT NULL ORDER BY p.player_pick $searchModel->sort"; |
| 434 | 439 | |
@@ -584,9 +589,9 @@ discard block |
||
| 584 | 589 | $managers = $descending_managers; |
| 585 | 590 | $even = true; |
| 586 | 591 | } |
| 592 | + } else { |
|
| 593 | + $managers = $ascending_managers; |
|
| 587 | 594 | } |
| 588 | - else |
|
| 589 | - $managers = $ascending_managers; |
|
| 590 | 595 | |
| 591 | 596 | foreach ($managers as $manager) { |
| 592 | 597 | $new_pick = new Pick(); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * Delete existing players for a given league, upload new players |
| 123 | - * @param array $players Array of pro_player_object's |
|
| 123 | + * @param array $proPlayers Array of pro_player_object's |
|
| 124 | 124 | */ |
| 125 | 125 | public function SaveProPlayers($league, $proPlayers) { |
| 126 | 126 | $delete_sql = "DELETE FROM pro_players WHERE league = '" . $league . "'"; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * Adds a new pro player to the DB |
| 143 | - * @return boolean success whether or not the database operation succeeded. |
|
| 143 | + * @return ProPlayer success whether or not the database operation succeeded. |
|
| 144 | 144 | */ |
| 145 | 145 | private function _saveProPlayer(ProPlayer $proPlayer) { |
| 146 | 146 | if ($proPlayer->pro_player_id > 0) { |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Repositories; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | -use PhpDraft\Domain\Entities\Draft; |
|
| 7 | 5 | use PhpDraft\Domain\Entities\ProPlayer; |
| 8 | 6 | |
| 9 | 7 | class ProPlayerRepository { |
@@ -138,10 +138,10 @@ |
||
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Adds a new pro player to the DB |
|
| 143 | - * @return boolean success whether or not the database operation succeeded. |
|
| 144 | - */ |
|
| 141 | + /** |
|
| 142 | + * Adds a new pro player to the DB |
|
| 143 | + * @return boolean success whether or not the database operation succeeded. |
|
| 144 | + */ |
|
| 145 | 145 | private function _saveProPlayer(ProPlayer $proPlayer) { |
| 146 | 146 | if ($proPlayer->pro_player_id > 0) { |
| 147 | 147 | throw new \Exception("Unable to save pro player: invalid ID."); |
@@ -161,7 +161,7 @@ |
||
| 161 | 161 | throw new \Exception("Unable to save pro player."); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - $proPlayer->draft_id = (int) $this->app['db']->lastInsertId(); |
|
| 164 | + $proPlayer->draft_id = (int)$this->app['db']->lastInsertId(); |
|
| 165 | 165 | |
| 166 | 166 | return $proPlayer; |
| 167 | 167 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Services; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | 5 | use PhpDraft\Domain\Entities\Draft; |
| 7 | 6 | use PhpDraft\Domain\Models\PhpDraftResponse; |
| 8 | 7 | use PhpDraft\Domain\Models\DepthChartPositionCreateModel; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $response->success = true; |
| 36 | 36 | $response->draft = $draft; |
| 37 | - }catch(\Exception $e) { |
|
| 37 | + } catch(\Exception $e) { |
|
| 38 | 38 | $response->success = false; |
| 39 | 39 | $response->errors = array($e->getMessage()); |
| 40 | 40 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $response->success = true; |
| 57 | 57 | $response->draft = $draft; |
| 58 | - }catch(\Exception $e) { |
|
| 58 | + } catch(\Exception $e) { |
|
| 59 | 59 | $response->success = false; |
| 60 | 60 | $response->errors = array($e->getMessage()); |
| 61 | 61 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $response->success = true; |
| 87 | 87 | $response->draft = $draft; |
| 88 | - }catch(\Exception $e) { |
|
| 88 | + } catch(\Exception $e) { |
|
| 89 | 89 | $response->success = false; |
| 90 | 90 | $response->errors = array($e->getMessage()); |
| 91 | 91 | } |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | try { |
| 29 | 29 | $draft = $this->app['phpdraft.DraftRepository']->Create($draft); |
| 30 | 30 | |
| 31 | - if($draft->using_depth_charts) { |
|
| 31 | + if ($draft->using_depth_charts) { |
|
| 32 | 32 | $depth_charts = $this->app['phpdraft.DepthChartPositionRepository']->Save($depthChartModel, $draft->draft_id); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $response->success = true; |
| 36 | 36 | $response->draft = $draft; |
| 37 | - }catch(\Exception $e) { |
|
| 37 | + } catch (\Exception $e) { |
|
| 38 | 38 | $response->success = false; |
| 39 | 39 | $response->errors = array($e->getMessage()); |
| 40 | 40 | } |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | try { |
| 49 | 49 | $draft = $this->app['phpdraft.DraftRepository']->Update($draft); |
| 50 | 50 | |
| 51 | - if($draft->using_depth_charts == 1) { |
|
| 51 | + if ($draft->using_depth_charts == 1) { |
|
| 52 | 52 | $this->app['phpdraft.DepthChartPositionRepository']->DeleteAllDepthChartPositions($draft->draft_id); |
| 53 | 53 | $depth_charts = $this->app['phpdraft.DepthChartPositionRepository']->Save($depthChartModel, $draft->draft_id); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $response->success = true; |
| 57 | 57 | $response->draft = $draft; |
| 58 | - }catch(\Exception $e) { |
|
| 58 | + } catch (\Exception $e) { |
|
| 59 | 59 | $response->success = false; |
| 60 | 60 | $response->errors = array($e->getMessage()); |
| 61 | 61 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $draft = $this->app['phpdraft.DraftRepository']->UpdateStatus($draft); |
| 71 | 71 | |
| 72 | 72 | //If we know we're moving from undrafted to in progress, perform the necessary setup steps: |
| 73 | - if($draft->draft_status != $old_status && $draft->draft_status == "in_progress") { |
|
| 73 | + if ($draft->draft_status != $old_status && $draft->draft_status == "in_progress") { |
|
| 74 | 74 | //Delete all trades |
| 75 | 75 | $this->app['phpdraft.TradeRepository']->DeleteAllTrades($draft->draft_id); |
| 76 | 76 | //Delete all picks |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $response->success = true; |
| 87 | 87 | $response->draft = $draft; |
| 88 | - }catch(\Exception $e) { |
|
| 88 | + } catch (\Exception $e) { |
|
| 89 | 89 | $response->success = false; |
| 90 | 90 | $response->errors = array($e->getMessage()); |
| 91 | 91 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $this->app['phpdraft.DraftRepository']->DeleteDraft($draft->draft_id); |
| 112 | 112 | |
| 113 | 113 | $response->success = true; |
| 114 | - } catch(\Exception $e) { |
|
| 114 | + } catch (\Exception $e) { |
|
| 115 | 115 | $response->success = false; |
| 116 | 116 | $response->errors = array($e->getMessage()); |
| 117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | try { |
| 126 | 126 | $response->draft_statistics = $this->app['phpdraft.DraftStatsRepository']->LoadDraftStats($draft_id); |
| 127 | 127 | $response->success = true; |
| 128 | - } catch(\Exception $e) { |
|
| 128 | + } catch (\Exception $e) { |
|
| 129 | 129 | $message = $e->getMessage(); |
| 130 | 130 | $response->success = false; |
| 131 | 131 | $response->errors[] = $message; |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Services; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | 5 | use PhpDraft\Domain\Entities\Manager; |
| 7 | 6 | use PhpDraft\Domain\Models\PhpDraftResponse; |
| 8 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $response->success = true; |
| 23 | 23 | $response->manager = $manager; |
| 24 | - }catch(\Exception $e) { |
|
| 24 | + } catch (\Exception $e) { |
|
| 25 | 25 | $response->success = false; |
| 26 | 26 | $response->errors = array($e->getMessage()); |
| 27 | 27 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $response->success = true; |
| 39 | 39 | $response->managers = $managers; |
| 40 | - }catch(\Exception $e) { |
|
| 40 | + } catch (\Exception $e) { |
|
| 41 | 41 | $response->success = false; |
| 42 | 42 | $response->errors = array($e->getMessage()); |
| 43 | 43 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->app['phpdraft.ManagerRepository']->ReorderManagers($managersIdArray); |
| 53 | 53 | |
| 54 | 54 | $response->success = true; |
| 55 | - }catch(\Exception $e) { |
|
| 55 | + } catch (\Exception $e) { |
|
| 56 | 56 | $response->success = false; |
| 57 | 57 | $response->errors = array($e->getMessage()); |
| 58 | 58 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $managers = $this->app['phpdraft.ManagerRepository']->GetManagersByDraftOrder($draft_id); |
| 88 | 88 | $managersIdArray = array(); |
| 89 | 89 | |
| 90 | - foreach($managers as $manager) { |
|
| 90 | + foreach ($managers as $manager) { |
|
| 91 | 91 | $managersIdArray[] = $manager->manager_id; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $response->managers = $managers; |
| 99 | 99 | $response->success = true; |
| 100 | - } catch(\Exception $e) { |
|
| 100 | + } catch (\Exception $e) { |
|
| 101 | 101 | $response->success = false; |
| 102 | 102 | $response->errors = array($e->getMessage()); |
| 103 | 103 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $response->success = true; |
| 23 | 23 | $response->manager = $manager; |
| 24 | - }catch(\Exception $e) { |
|
| 24 | + } catch(\Exception $e) { |
|
| 25 | 25 | $response->success = false; |
| 26 | 26 | $response->errors = array($e->getMessage()); |
| 27 | 27 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $response->success = true; |
| 39 | 39 | $response->managers = $managers; |
| 40 | - }catch(\Exception $e) { |
|
| 40 | + } catch(\Exception $e) { |
|
| 41 | 41 | $response->success = false; |
| 42 | 42 | $response->errors = array($e->getMessage()); |
| 43 | 43 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $this->app['phpdraft.ManagerRepository']->ReorderManagers($managersIdArray); |
| 53 | 53 | |
| 54 | 54 | $response->success = true; |
| 55 | - }catch(\Exception $e) { |
|
| 55 | + } catch(\Exception $e) { |
|
| 56 | 56 | $response->success = false; |
| 57 | 57 | $response->errors = array($e->getMessage()); |
| 58 | 58 | } |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Services; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | 5 | use PhpDraft\Domain\Entities\Draft; |
| 7 | 6 | use PhpDraft\Domain\Entities\Pick; |
| 8 | 7 | use PhpDraft\Domain\Models\PhpDraftResponse; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | try { |
| 30 | 30 | $response->allPicks = $this->app['phpdraft.PickRepository']->LoadAll($draft); |
| 31 | 31 | $response->success = true; |
| 32 | - } catch(\Exception $e) { |
|
| 32 | + } catch (\Exception $e) { |
|
| 33 | 33 | $response->success = false; |
| 34 | 34 | $message = $e->getMessage(); |
| 35 | 35 | $response->errors[] = "Unable to load picks: $message"; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | try { |
| 45 | 45 | $response->pick = $this->app['phpdraft.PickRepository']->GetCurrentPick($draft); |
| 46 | 46 | |
| 47 | - if($include_data) { |
|
| 47 | + if ($include_data) { |
|
| 48 | 48 | $response->teams = $this->app['phpdraft.DraftDataRepository']->GetTeams($draft->draft_sport); |
| 49 | 49 | $response->historical_teams = $this->app['phpdraft.DraftDataRepository']->GetHistoricalTeams($draft->draft_sport); |
| 50 | 50 | $response->positions = $this->app['phpdraft.DraftDataRepository']->GetPositions($draft->draft_sport); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $response->success = true; |
| 56 | - } catch(\Exception $e) { |
|
| 56 | + } catch (\Exception $e) { |
|
| 57 | 57 | //Rather than unset all of the 1-5 properties from the try above, just grab a new Response object: |
| 58 | 58 | $response = new PhpDraftResponse(false, array()); |
| 59 | 59 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $response->draft_is_complete = $this->app['phpdraft.DraftService']->DraftComplete($draft); |
| 85 | 85 | |
| 86 | - if($response->draft_is_complete == 1) { |
|
| 86 | + if ($response->draft_is_complete == 1) { |
|
| 87 | 87 | $response->draft_statistics = $this->app['phpdraft.DraftStatsRepository']->CalculateDraftStatistics($draft); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $response->next_5_picks = $this->app['phpdraft.PickRepository']->LoadNextPicks($draft->draft_id, $draft->draft_current_pick, 5); |
| 94 | 94 | |
| 95 | 95 | $response->success = true; |
| 96 | - } catch(\Exception $e) { |
|
| 96 | + } catch (\Exception $e) { |
|
| 97 | 97 | $response = new PhpDraftResponse(false, array()); |
| 98 | 98 | |
| 99 | 99 | $errorMessage = $e->getMessage(); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | $response->pick = $pick; |
| 119 | 119 | $response->success = true; |
| 120 | - } catch(\Exception $e) { |
|
| 120 | + } catch (\Exception $e) { |
|
| 121 | 121 | $response = new PhpDraftResponse(false, array()); |
| 122 | 122 | |
| 123 | 123 | $errorMessage = $e->getMessage(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $response->pick = $pick; |
| 139 | 139 | $response->success = true; |
| 140 | - } catch(\Exception $e) { |
|
| 140 | + } catch (\Exception $e) { |
|
| 141 | 141 | $response->success = false; |
| 142 | 142 | $errorMessage = $e->getMessage(); |
| 143 | 143 | $response->errors[] = "Unable to update pick depth chart: $errorMessage"; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | $response->matches = $this->app['phpdraft.PickRepository']->SearchAlreadyDrafted($draft_id, $first_name, $last_name); |
| 154 | 154 | $response->possibleMatchExists = count($response->matches) > 0; |
| 155 | 155 | $response->success = true; |
| 156 | - } catch(\Exception $e) { |
|
| 156 | + } catch (\Exception $e) { |
|
| 157 | 157 | $response = new PhpDraftResponse(false, array()); |
| 158 | 158 | $errorMessage = $e->getMessage(); |
| 159 | 159 | $response->errors[] = "Unable to check for already drafted: $errorMessage"; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | try { |
| 169 | 169 | $draft = $this->app['phpdraft.DraftRepository']->Load($draft_id); |
| 170 | 170 | |
| 171 | - if($pick_counter < $draft->draft_counter) { |
|
| 171 | + if ($pick_counter < $draft->draft_counter) { |
|
| 172 | 172 | $response->updated_picks = $this->app['phpdraft.PickRepository']->LoadUpdatedPicks($draft_id, $pick_counter); |
| 173 | 173 | $response->current_pick = $this->app['phpdraft.PickRepository']->GetCurrentPick($draft); |
| 174 | 174 | $response->previous_pick = $this->app['phpdraft.PickRepository']->GetPreviousPick($draft); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | $response->draft_counter = $draft->draft_counter; |
| 183 | 183 | $response->success = true; |
| 184 | - } catch(\Exception $e) { |
|
| 184 | + } catch (\Exception $e) { |
|
| 185 | 185 | $response->success = false; |
| 186 | 186 | $errorMessage = $e->getMessage(); |
| 187 | 187 | $response->errors[] = "Unable to get updated picks: $errorMessage"; |
@@ -200,10 +200,11 @@ |
||
| 200 | 200 | $pick->pick_time = $now_utc->format('Y-m-d H:i:s'); |
| 201 | 201 | |
| 202 | 202 | //Calculate the pick duration |
| 203 | - if ($pick->player_pick == 1 || $previous_pick == null) |
|
| 204 | - $start_time = new \DateTime($draft->draft_start_time, new \DateTimeZone("UTC")); |
|
| 205 | - else |
|
| 206 | - $start_time = new \DateTime($previous_pick->pick_time, new \DateTimeZone("UTC")); |
|
| 203 | + if ($pick->player_pick == 1 || $previous_pick == null) { |
|
| 204 | + $start_time = new \DateTime($draft->draft_start_time, new \DateTimeZone("UTC")); |
|
| 205 | + } else { |
|
| 206 | + $start_time = new \DateTime($previous_pick->pick_time, new \DateTimeZone("UTC")); |
|
| 207 | + } |
|
| 207 | 208 | |
| 208 | 209 | $start_time_timestamp = $start_time->getTimestamp(); |
| 209 | 210 | |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Services; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | -use PhpDraft\Domain\Entities\Draft; |
|
| 7 | 5 | use PhpDraft\Domain\Entities\ProPlayer; |
| 8 | 6 | use PhpDraft\Domain\Models\PhpDraftResponse; |
| 9 | 7 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | #If there's a space and no matches so far, create another searches where we manually split them firstname/lastname by sace automatically |
| 40 | 40 | $split_name_automatically = count($players) == 0 && strpos($searchTerm, " ") != false; |
| 41 | 41 | |
| 42 | - if($split_name_automatically) { |
|
| 42 | + if ($split_name_automatically) { |
|
| 43 | 43 | $names = explode(" ", $searchTerm, 2); |
| 44 | 44 | $players = $this->app['phpdraft.ProPlayerRepository']->SearchPlayersByAssumedName($league, $names[0], $names[1]); |
| 45 | 45 | } |
@@ -67,12 +67,14 @@ |
||
| 67 | 67 | return $response; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (SET_CSV_TIMEOUT) |
|
| 71 | - set_time_limit(0); |
|
| 70 | + if (SET_CSV_TIMEOUT) { |
|
| 71 | + set_time_limit(0); |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) { |
| 74 | - if ($data[0] == "Player") |
|
| 75 | - continue; |
|
| 75 | + if ($data[0] == "Player") { |
|
| 76 | + continue; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | $new_player = new ProPlayer(); |
| 78 | 80 | |
@@ -2,9 +2,7 @@ |
||
| 2 | 2 | namespace PhpDraft\Domain\Services; |
| 3 | 3 | |
| 4 | 4 | use Silex\Application; |
| 5 | -use Symfony\Component\HttpFoundation\Request; |
|
| 6 | 5 | use PhpDraft\Domain\Entities\Draft; |
| 7 | -use PhpDraft\Domain\Entities\RoundTime; |
|
| 8 | 6 | use PhpDraft\Domain\Models\PhpDraftResponse; |
| 9 | 7 | use PhpDraft\Domain\Models\RoundTimeCreateModel; |
| 10 | 8 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $response->success = true; |
| 26 | 26 | $response->roundTimes = $roundTimes; |
| 27 | - }catch(\Exception $e) { |
|
| 27 | + } catch (\Exception $e) { |
|
| 28 | 28 | $response->success = false; |
| 29 | 29 | $response->errors = array($e->getMessage()); |
| 30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $current_pick = $this->app['phpdraft.PickRepository']->GetCurrentPick($draft); |
| 40 | 40 | $last_pick = $this->app['phpdraft.PickRepository']->GetPreviousPick($draft); |
| 41 | 41 | $current_round_picktime = $this->app['phpdraft.RoundTimeRepository']->LoadByRound($draft); |
| 42 | - } catch(\Exception $e) { |
|
| 42 | + } catch (\Exception $e) { |
|
| 43 | 43 | $response->success = false; |
| 44 | 44 | $response->errors = array($e->getMessage()); |
| 45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $response->success = true; |
| 48 | 48 | $response->timer_enabled = $current_round_picktime != null; |
| 49 | 49 | |
| 50 | - if(!$response->timer_enabled) { |
|
| 50 | + if (!$response->timer_enabled) { |
|
| 51 | 51 | return $response; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | $response->success = true; |
| 26 | 26 | $response->roundTimes = $roundTimes; |
| 27 | - }catch(\Exception $e) { |
|
| 27 | + } catch(\Exception $e) { |
|
| 28 | 28 | $response->success = false; |
| 29 | 29 | $response->errors = array($e->getMessage()); |
| 30 | 30 | } |