@@ -30,19 +30,19 @@ |
||
| 30 | 30 | |
| 31 | 31 | $unassignedPicks = array(); |
| 32 | 32 | |
| 33 | - foreach($allManagerPicks as $pick) { |
|
| 34 | - if(is_null($pick->depth_chart_position_id)) { |
|
| 33 | + foreach ($allManagerPicks as $pick) { |
|
| 34 | + if (is_null($pick->depth_chart_position_id)) { |
|
| 35 | 35 | $unassignedPicks[] = $pick; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $response->depthChartPositions[] = new DepthChartDisplayModel(null, 'Unassigned', null, $unassignedPicks); |
| 40 | 40 | |
| 41 | - foreach($depthChartPositions as $position) { |
|
| 41 | + foreach ($depthChartPositions as $position) { |
|
| 42 | 42 | $picks = array(); |
| 43 | 43 | |
| 44 | - foreach($allManagerPicks as $pick) { |
|
| 45 | - if($pick->depth_chart_position_id == $position->id) { |
|
| 44 | + foreach ($allManagerPicks as $pick) { |
|
| 45 | + if ($pick->depth_chart_position_id == $position->id) { |
|
| 46 | 46 | $picks[] = $pick; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | $this->mailer->Host = MAIL_SERVER; |
| 24 | 24 | $this->mailer->Port = MAIL_PORT; |
| 25 | 25 | |
| 26 | - if(MAIL_DEVELOPMENT != true) { |
|
| 26 | + if (MAIL_DEVELOPMENT != true) { |
|
| 27 | 27 | $this->mailer->SMTPAuth = true; |
| 28 | 28 | $this->mailer->Username = MAIL_USER; |
| 29 | 29 | $this->mailer->Password = MAIL_PASS; |
| 30 | 30 | |
| 31 | - if(MAIL_USE_ENCRYPTION == true) { |
|
| 31 | + if (MAIL_USE_ENCRYPTION == true) { |
|
| 32 | 32 | $this->mailer->SMTPSecure = MAIL_ENCRYPTION; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function SendMail(MailMessage $message) { |
| 41 | - foreach($message->to_addresses as $address => $name) { |
|
| 41 | + foreach ($message->to_addresses as $address => $name) { |
|
| 42 | 42 | $this->mailer->addAddress($address, $name); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $this->mailer->Body = $message->body; |
| 50 | 50 | |
| 51 | - if(!$this->mailer->send()) { |
|
| 51 | + if (!$this->mailer->send()) { |
|
| 52 | 52 | throw new \Exception("Unable to send mail: " . $this->mailer->ErrorInfo); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -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 | |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function GetCurrentUser() { |
| 20 | 20 | $token = $this->app['security.token_storage']->getToken(); |
| 21 | 21 | |
| 22 | - if($token == null) { |
|
| 22 | + if ($token == null) { |
|
| 23 | 23 | //In public actions, this isn't an exception - we're just not logged in. |
| 24 | 24 | return null; |
| 25 | 25 | //throw new \Exception("Username not found."); |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | //This is a hack to make accessing logged in user info from anonymous routes possible: |
| 34 | 34 | public function GetUserFromHeaderToken(Request $request) { |
| 35 | - $request_token = $request->headers->get(AUTH_KEY_HEADER,''); |
|
| 35 | + $request_token = $request->headers->get(AUTH_KEY_HEADER, ''); |
|
| 36 | 36 | |
| 37 | - if(empty($request_token)) { |
|
| 37 | + if (empty($request_token)) { |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $email = $decoded->name; |
| 45 | 45 | |
| 46 | 46 | return $this->app['phpdraft.LoginUserRepository']->Load($email); |
| 47 | - }catch(\Exception $ex) { |
|
| 47 | + } catch (\Exception $ex) { |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | try { |
| 56 | 56 | $response->commissioners = $this->app['phpdraft.LoginUserRepository']->SearchCommissioners($searchTerm); |
| 57 | 57 | $response->success = true; |
| 58 | - } catch(\Exception $ex) { |
|
| 58 | + } catch (\Exception $ex) { |
|
| 59 | 59 | $message = $ex->getMessage(); |
| 60 | 60 | $response->success = false; |
| 61 | 61 | $response->errors[] = $message; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | try { |
| 71 | 71 | $response->commissioner = $this->app['phpdraft.LoginUserRepository']->LoadPublicById($commish_id); |
| 72 | 72 | $response->success = true; |
| 73 | - } catch(\Exception $ex) { |
|
| 73 | + } catch (\Exception $ex) { |
|
| 74 | 74 | $message = $ex->getMessage(); |
| 75 | 75 | $response->success = false; |
| 76 | 76 | $response->errors[] = $message; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $response->users = $this->app['phpdraft.LoginUserRepository']->LoadAll(); |
| 87 | 87 | $response->roles = $this->app['phpdraft.LoginUserRepository']->GetRoles(); |
| 88 | 88 | $response->success = true; |
| 89 | - } catch(\Exception $e) { |
|
| 89 | + } catch (\Exception $e) { |
|
| 90 | 90 | $message = $e->getMessage(); |
| 91 | 91 | $response->success = false; |
| 92 | 92 | $response->errors[] = $message; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $message = new MailMessage(); |
| 111 | 111 | |
| 112 | - $message->to_addresses = array ( |
|
| 112 | + $message->to_addresses = array( |
|
| 113 | 113 | $user->email => $user->name |
| 114 | 114 | ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $this->app['phpdraft.EmailService']->SendMail($message); |
| 129 | 129 | |
| 130 | 130 | $response->success = true; |
| 131 | - }catch(\Exception $e) { |
|
| 131 | + } catch (\Exception $e) { |
|
| 132 | 132 | //$this->app['db']->rollback(); |
| 133 | 133 | |
| 134 | 134 | $response->success = false; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $user->verificationKey = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 152 | 152 | |
| 153 | 153 | //Found out that forward slashes are no good for URLs. Go figure. |
| 154 | - while(strpos($user->verificationKey, '/') != 0) { |
|
| 154 | + while (strpos($user->verificationKey, '/') != 0) { |
|
| 155 | 155 | $user->verificationKey = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $message = new MailMessage(); |
| 166 | 166 | |
| 167 | - $message->to_addresses = array ( |
|
| 167 | + $message->to_addresses = array( |
|
| 168 | 168 | $user->email => $user->name |
| 169 | 169 | ); |
| 170 | 170 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $response->success = true; |
| 188 | 188 | |
| 189 | 189 | $this->app['db']->commit(); |
| 190 | - }catch(\Exception $e) { |
|
| 190 | + } catch (\Exception $e) { |
|
| 191 | 191 | $this->app['db']->rollback(); |
| 192 | 192 | |
| 193 | 193 | $response->success = false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $response->success = true; |
| 213 | 213 | |
| 214 | 214 | $this->app['db']->commit(); |
| 215 | - }catch(\Exception $e) { |
|
| 215 | + } catch (\Exception $e) { |
|
| 216 | 216 | $this->app['db']->rollback(); |
| 217 | 217 | |
| 218 | 218 | $response->success = false; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $user->name = $name; |
| 235 | 235 | |
| 236 | 236 | //Update user email, invalidate login |
| 237 | - if(!empty($email) && !StringUtils::equals($email, $user->email)) { |
|
| 237 | + if (!empty($email) && !StringUtils::equals($email, $user->email)) { |
|
| 238 | 238 | $user->email = $email; |
| 239 | 239 | $user->enabled = false; |
| 240 | 240 | $invalidateLogin = true; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $sendEmail = true; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if(!empty($newPassword)) { |
|
| 245 | + if (!empty($newPassword)) { |
|
| 246 | 246 | $invalidateLogin = true; |
| 247 | 247 | $user->salt = $this->app['phpdraft.SaltService']->GenerateSalt(); |
| 248 | 248 | $user->password = $this->app['security.encoder.digest']->encodePassword($newPassword, $user->salt); |
@@ -250,15 +250,15 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | $response = new PhpDraftResponse(); |
| 252 | 252 | |
| 253 | - try{ |
|
| 253 | + try { |
|
| 254 | 254 | $this->app['db']->beginTransaction(); |
| 255 | 255 | |
| 256 | 256 | $user = $this->app['phpdraft.LoginUserRepository']->Update($user); |
| 257 | 257 | |
| 258 | - if($sendEmail) { |
|
| 258 | + if ($sendEmail) { |
|
| 259 | 259 | $message = new MailMessage(); |
| 260 | 260 | |
| 261 | - $message->to_addresses = array ( |
|
| 261 | + $message->to_addresses = array( |
|
| 262 | 262 | $user->email => $user->name |
| 263 | 263 | ); |
| 264 | 264 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $response->sendEmail = $sendEmail; |
| 283 | 283 | |
| 284 | 284 | $this->app['db']->commit(); |
| 285 | - }catch(\Exception $e) { |
|
| 285 | + } catch (\Exception $e) { |
|
| 286 | 286 | $this->app['db']->rollback(); |
| 287 | 287 | |
| 288 | 288 | $response->success = false; |
@@ -298,16 +298,16 @@ discard block |
||
| 298 | 298 | try { |
| 299 | 299 | //Find all drafts this user owns |
| 300 | 300 | $drafts = $this->app['phpdraft.DraftRepository']->GetAllDraftsByCommish($user->id); |
| 301 | - foreach($drafts as $draft) { |
|
| 301 | + foreach ($drafts as $draft) { |
|
| 302 | 302 | $response = $this->app['phpdraft.DraftService']->DeleteDraft($draft); |
| 303 | - if(!$response->success) { |
|
| 303 | + if (!$response->success) { |
|
| 304 | 304 | throw new \Exception("Unable to recursively delete draft or one of its children."); |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | $this->app['phpdraft.LoginUserRepository']->Delete($user); |
| 308 | 308 | |
| 309 | 309 | $response->success = true; |
| 310 | - } catch(\Exception $e) { |
|
| 310 | + } catch (\Exception $e) { |
|
| 311 | 311 | $message = $e->getMessage(); |
| 312 | 312 | $response->success = false; |
| 313 | 313 | $response->errors[] = $message; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $email = $decoded->name; |
| 45 | 45 | |
| 46 | 46 | return $this->app['phpdraft.LoginUserRepository']->Load($email); |
| 47 | - }catch(\Exception $ex) { |
|
| 47 | + } catch(\Exception $ex) { |
|
| 48 | 48 | return null; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $this->app['phpdraft.EmailService']->SendMail($message); |
| 129 | 129 | |
| 130 | 130 | $response->success = true; |
| 131 | - }catch(\Exception $e) { |
|
| 131 | + } catch(\Exception $e) { |
|
| 132 | 132 | //$this->app['db']->rollback(); |
| 133 | 133 | |
| 134 | 134 | $response->success = false; |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $response->success = true; |
| 188 | 188 | |
| 189 | 189 | $this->app['db']->commit(); |
| 190 | - }catch(\Exception $e) { |
|
| 190 | + } catch(\Exception $e) { |
|
| 191 | 191 | $this->app['db']->rollback(); |
| 192 | 192 | |
| 193 | 193 | $response->success = false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $response->success = true; |
| 213 | 213 | |
| 214 | 214 | $this->app['db']->commit(); |
| 215 | - }catch(\Exception $e) { |
|
| 215 | + } catch(\Exception $e) { |
|
| 216 | 216 | $this->app['db']->rollback(); |
| 217 | 217 | |
| 218 | 218 | $response->success = false; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $response->sendEmail = $sendEmail; |
| 283 | 283 | |
| 284 | 284 | $this->app['db']->commit(); |
| 285 | - }catch(\Exception $e) { |
|
| 285 | + } catch(\Exception $e) { |
|
| 286 | 286 | $this->app['db']->rollback(); |
| 287 | 287 | |
| 288 | 288 | $response->success = false; |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public $success; |
| 14 | 14 | public $errors; |
| 15 | 15 | |
| 16 | - public function responseType($successResponse = Response::HTTP_OK){ |
|
| 16 | + public function responseType($successResponse = Response::HTTP_OK) { |
|
| 17 | 17 | return $this->success |
| 18 | 18 | ? $successResponse |
| 19 | 19 | : Response::HTTP_BAD_REQUEST; |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | $timerStmt->setFetchMode(\PDO::FETCH_CLASS, '\PhpDraft\Domain\Entities\RoundTime'); |
| 28 | 28 | $timerStmt->bindParam(1, $draftId); |
| 29 | 29 | |
| 30 | - if(!$timerStmt->execute()) { |
|
| 30 | + if (!$timerStmt->execute()) { |
|
| 31 | 31 | throw new \Exception("Unable to load round times."); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $timers = array(); |
| 35 | 35 | |
| 36 | - while($timer = $timerStmt->fetch()) { |
|
| 36 | + while ($timer = $timerStmt->fetch()) { |
|
| 37 | 37 | $timers[] = $timer; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $isStaticTime = false; |
| 41 | 41 | |
| 42 | - if(count($timers) == 1 && $timers[0]->is_static_time) { |
|
| 42 | + if (count($timers) == 1 && $timers[0]->is_static_time) { |
|
| 43 | 43 | $isStaticTime = true; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if(empty($timers) || count($timers) != $draft->draft_rounds) { |
|
| 46 | + if (empty($timers) || count($timers) != $draft->draft_rounds) { |
|
| 47 | 47 | $timers = $this->_CoalesceDraftTimers($draft, $timers, $isStaticTime); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -53,15 +53,15 @@ discard block |
||
| 53 | 53 | private function _CoalesceDraftTimers(Draft $draft, $existing_timers, $isStaticTime) { |
| 54 | 54 | $coalescedTimers = array(); |
| 55 | 55 | |
| 56 | - for($i = 0; $i < $draft->draft_rounds; $i++) { |
|
| 57 | - if($isStaticTime && $i == 0) { |
|
| 56 | + for ($i = 0; $i < $draft->draft_rounds; $i++) { |
|
| 57 | + if ($isStaticTime && $i == 0) { |
|
| 58 | 58 | $timer = $existing_timers[$i]; |
| 59 | 59 | $timer->draft_round = $i + 1; |
| 60 | 60 | $coalescedTimers[] = $timer; |
| 61 | 61 | continue; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if(array_key_exists($i, $existing_timers)) { |
|
| 64 | + if (array_key_exists($i, $existing_timers)) { |
|
| 65 | 65 | $coalescedTimers[] = $existing_timers[$i]; |
| 66 | 66 | } else { |
| 67 | 67 | $newTimer = new RoundTime(); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $deleteRoundTime = $this->app['db']->prepare("DELETE FROM round_times WHERE draft_id = ?"); |
| 106 | 106 | $deleteRoundTime->bindParam(1, $draftId); |
| 107 | 107 | |
| 108 | - if(!$deleteRoundTime->execute()) { |
|
| 108 | + if (!$deleteRoundTime->execute()) { |
|
| 109 | 109 | throw new \Exception("Unable to delete round times: " . $this->app['db']->errorInfo()); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | $staticRoundTimeStmt->setFetchMode(\PDO::FETCH_INTO, $roundTime); |
| 120 | 120 | $staticRoundTimeStmt->bindParam(1, $draft->draft_id); |
| 121 | 121 | |
| 122 | - if(!$staticRoundTimeStmt->execute()) { |
|
| 122 | + if (!$staticRoundTimeStmt->execute()) { |
|
| 123 | 123 | throw new \Exception("Unable to get static round time."); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if($staticRoundTimeStmt->rowCount() == 1) { |
|
| 126 | + if ($staticRoundTimeStmt->rowCount() == 1) { |
|
| 127 | 127 | $staticRoundTimeStmt->fetch(); |
| 128 | 128 | |
| 129 | 129 | return $roundTime; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | throw new \Exception("Unable to load round time:" . $this->app['db']->errorInfo()); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if($roundTimeStmt->rowCount() == 0) { |
|
| 141 | + if ($roundTimeStmt->rowCount() == 0) { |
|
| 142 | 142 | return null; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -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 | |
@@ -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; |