@@ -25,11 +25,13 @@ |
||
25 | 25 | $user_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
26 | 26 | $user_stmt->bindParam(1, $email); |
27 | 27 | |
28 | - if (!$user_stmt->execute()) |
|
29 | - throw new UsernameNotFoundException(sprintf('Email "%s" does not exist.', $email)); |
|
28 | + if (!$user_stmt->execute()) { |
|
29 | + throw new UsernameNotFoundException(sprintf('Email "%s" does not exist.', $email)); |
|
30 | + } |
|
30 | 31 | |
31 | - if (!$user_stmt->fetch()) |
|
32 | - throw new UsernameNotFoundException(sprintf('Email "%s" does not exist.', $email)); |
|
32 | + if (!$user_stmt->fetch()) { |
|
33 | + throw new UsernameNotFoundException(sprintf('Email "%s" does not exist.', $email)); |
|
34 | + } |
|
33 | 35 | |
34 | 36 | return new PhpDraftSecurityUser($user->email, |
35 | 37 | $user->name, |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -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 |
@@ -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; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $trade->manager1 = $this->app['phpdraft.ManagerRepository']->Load($trade->manager1_id); |
32 | 32 | $trade->manager2 = $this->app['phpdraft.ManagerRepository']->Load($trade->manager2_id); |
33 | 33 | $trade->trade_assets = $this->GetAssets($trade, $trade->manager1, $trade->manager2); |
34 | - }catch(\Exception $e) { |
|
34 | + } catch(\Exception $e) { |
|
35 | 35 | throw new \Exception("Unable to load managers or trade assets: " . $e->getMessage()); |
36 | 36 | } |
37 | 37 | |
@@ -58,19 +58,22 @@ discard block |
||
58 | 58 | while ($asset = $stmt->fetch()) { |
59 | 59 | /* @var $asset trade_asset_object */ |
60 | 60 | //We must use the protected $newmanager_id and $oldmanager_id because we have just pulled from DB, objs aren't automatic: |
61 | - if ($asset->newmanager_id != $manager1->manager_id && $asset->newmanager_id != $manager2->manager_id) |
|
62 | - throw new \Exception('Invalid manager ID for asset: ' . $asset->newmanager_id); |
|
61 | + if ($asset->newmanager_id != $manager1->manager_id && $asset->newmanager_id != $manager2->manager_id) { |
|
62 | + throw new \Exception('Invalid manager ID for asset: ' . $asset->newmanager_id); |
|
63 | + } |
|
63 | 64 | |
64 | - if ($asset->oldmanager_id != $manager1->manager_id && $asset->oldmanager_id != $manager2->manager_id) |
|
65 | - throw new \Exception('Invalid manager ID for asset: ' . $asset->oldmanager_id); |
|
65 | + if ($asset->oldmanager_id != $manager1->manager_id && $asset->oldmanager_id != $manager2->manager_id) { |
|
66 | + throw new \Exception('Invalid manager ID for asset: ' . $asset->oldmanager_id); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | //Use passed in manager_objects to prevent unneccessary SELECTs to the db: |
68 | 70 | $asset->player = $this->app['phpdraft.PickRepository']->Load($asset->player_id); |
69 | 71 | $asset->newmanager = $asset->newmanager_id == $manager1->manager_id ? $manager1 : $manager2; |
70 | 72 | $asset->oldmanager = $asset->oldmanager_id == $manager1->manager_id ? $manager1 : $manager2; |
71 | 73 | |
72 | - if ($asset->player == false || $asset->newmanager == false || $asset->oldmanager == false) |
|
73 | - throw new \Exception('Invalid asset loaded.'); |
|
74 | + if ($asset->player == false || $asset->newmanager == false || $asset->oldmanager == false) { |
|
75 | + throw new \Exception('Invalid asset loaded.'); |
|
76 | + } |
|
74 | 77 | |
75 | 78 | $assets[] = $asset; |
76 | 79 | } |
@@ -89,8 +92,9 @@ discard block |
||
89 | 92 | |
90 | 93 | $trades = array(); |
91 | 94 | |
92 | - while ($trade = $draft_trade_stmt->fetch()) |
|
93 | - $trades[] = $trade; |
|
95 | + while ($trade = $draft_trade_stmt->fetch()) { |
|
96 | + $trades[] = $trade; |
|
97 | + } |
|
94 | 98 | |
95 | 99 | $delete_assets_stmt = $this->app['db']->prepare("DELETE FROM trade_assets WHERE trade_id = :trade_id"); |
96 | 100 | $delete_trade_stmt = $this->app['db']->prepare("DELETE FROM trades WHERE trade_id = :trade_id"); |
@@ -98,13 +102,15 @@ discard block |
||
98 | 102 | foreach ($trades as $trade) { |
99 | 103 | $delete_assets_stmt->bindValue(":trade_id", $trade->trade_id); |
100 | 104 | |
101 | - if (!$delete_assets_stmt->execute()) |
|
102 | - throw new \Exception("Unable to delete trade assets for $draft_id."); |
|
105 | + if (!$delete_assets_stmt->execute()) { |
|
106 | + throw new \Exception("Unable to delete trade assets for $draft_id."); |
|
107 | + } |
|
103 | 108 | |
104 | 109 | $delete_trade_stmt->bindValue(":trade_id", $trade->trade_id); |
105 | 110 | |
106 | - if (!$delete_trade_stmt->execute()) |
|
107 | - throw new \Exception("Unable to delete trade assets for $draft_id."); |
|
111 | + if (!$delete_trade_stmt->execute()) { |
|
112 | + throw new \Exception("Unable to delete trade assets for $draft_id."); |
|
113 | + } |
|
108 | 114 | } |
109 | 115 | |
110 | 116 | return; |
@@ -20,11 +20,13 @@ discard block |
||
20 | 20 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
21 | 21 | $load_stmt->bindParam(1, strtolower($email)); |
22 | 22 | |
23 | - if (!$load_stmt->execute()) |
|
24 | - throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
23 | + if (!$load_stmt->execute()) { |
|
24 | + throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
25 | + } |
|
25 | 26 | |
26 | - if (!$load_stmt->fetch()) |
|
27 | - throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
27 | + if (!$load_stmt->fetch()) { |
|
28 | + throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | return $user; |
30 | 32 | } |
@@ -38,11 +40,13 @@ discard block |
||
38 | 40 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
39 | 41 | $load_stmt->bindParam(1, $id); |
40 | 42 | |
41 | - if (!$load_stmt->execute()) |
|
42 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
43 | + if (!$load_stmt->execute()) { |
|
44 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
45 | + } |
|
43 | 46 | |
44 | - if (!$load_stmt->fetch()) |
|
45 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
47 | + if (!$load_stmt->fetch()) { |
|
48 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
49 | + } |
|
46 | 50 | |
47 | 51 | return $user; |
48 | 52 | } |
@@ -56,11 +60,13 @@ discard block |
||
56 | 60 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
57 | 61 | $load_stmt->bindParam(1, $id); |
58 | 62 | |
59 | - if (!$load_stmt->execute()) |
|
60 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
63 | + if (!$load_stmt->execute()) { |
|
64 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
65 | + } |
|
61 | 66 | |
62 | - if (!$load_stmt->fetch()) |
|
63 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
67 | + if (!$load_stmt->fetch()) { |
|
68 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
69 | + } |
|
64 | 70 | |
65 | 71 | unset($user->enabled); |
66 | 72 | unset($user->email); |