@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | 'deploy:prepare', |
| 8 | 8 | 'deploy:lock', |
| 9 | 9 | 'deploy:release', |
| 10 | - 'phpdraft:upload_files', |
|
| 11 | - 'phpdraft:remote_yarn', |
|
| 10 | + 'phpdraft:upload_files', |
|
| 11 | + 'phpdraft:remote_yarn', |
|
| 12 | 12 | 'phpdraft:remote_composer', |
| 13 | 13 | 'phpdraft:breakpoint', |
| 14 | 14 | 'phpdraft:migrate', |
| 15 | - 'deploy:symlink', |
|
| 16 | - //'phpdraft:restart_fpm', |
|
| 15 | + 'deploy:symlink', |
|
| 16 | + //'phpdraft:restart_fpm', |
|
| 17 | 17 | 'deploy:unlock', |
| 18 | 18 | 'cleanup', |
| 19 | 19 | 'success' |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | $settings_location = ask("What is the absolute (local) path of where your settings files are located?", |
| 33 | 33 | "~/phpdraft_settings"); |
| 34 | 34 | |
| 35 | - runLocally("cp $settings_location/.htaccess .htaccess"); |
|
| 35 | + runLocally("cp $settings_location/.htaccess .htaccess"); |
|
| 36 | 36 | runLocally("cp $settings_location/appsettings.php appsettings.php"); |
| 37 | - runLocally("cp $settings_location/config.js js/config.js"); |
|
| 37 | + runLocally("cp $settings_location/config.js js/config.js"); |
|
| 38 | 38 | runLocally("cp $settings_location/deploy.php deploy.php"); |
| 39 | - runLocally("cp $settings_location/index.html index.html"); |
|
| 40 | - runLocally("cp $settings_location/phinx.yml phinx.yml"); |
|
| 41 | - runLocally("cp $settings_location/web.config web.config"); |
|
| 39 | + runLocally("cp $settings_location/index.html index.html"); |
|
| 40 | + runLocally("cp $settings_location/phinx.yml phinx.yml"); |
|
| 41 | + runLocally("cp $settings_location/web.config web.config"); |
|
| 42 | 42 | |
| 43 | 43 | writeln("\n\n<info>Success! I imported those settings for you, you should be ready to deploy now.</info>\n"); |
| 44 | 44 | }); |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | 'db', |
| 76 | 76 | 'fonts', |
| 77 | 77 | 'images', |
| 78 | - 'js', |
|
| 78 | + 'js', |
|
| 79 | 79 | '.htaccess', |
| 80 | 80 | 'appsettings.php', |
| 81 | 81 | 'composer.json', |
| 82 | - 'composer.lock', |
|
| 83 | - 'package.json', |
|
| 82 | + 'composer.lock', |
|
| 83 | + 'package.json', |
|
| 84 | 84 | 'phinx.yml', |
| 85 | 85 | 'deploy', |
| 86 | 86 | 'index.html', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | desc('Install NPM dependencies remotely'); |
| 97 | 97 | task('phpdraft:remote_yarn', function() { |
| 98 | - cd('{{release_path}}'); |
|
| 98 | + cd('{{release_path}}'); |
|
| 99 | 99 | |
| 100 | 100 | run('yarn --production'); |
| 101 | 101 | |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | desc('Run Phinx migrations'); |
| 145 | 145 | task('phpdraft:migrate', function() { |
| 146 | - cd('{{release_path}}'); |
|
| 146 | + cd('{{release_path}}'); |
|
| 147 | 147 | |
| 148 | - set('phpdraft_rollback_required', true); |
|
| 148 | + set('phpdraft_rollback_required', true); |
|
| 149 | 149 | |
| 150 | 150 | run('php deploy/phinx.phar migrate -e production'); |
| 151 | 151 | |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | task('phpdraft:rollback', function() { |
| 157 | 157 | writeln('<comment>Rolling back database migrations...</comment>'); |
| 158 | 158 | if(get("phpdraft_rollback_required") == true) { |
| 159 | - cd('{{release_path}}'); |
|
| 160 | - run('php deploy/phinx.phar rollback -e production'); |
|
| 161 | - cd('{{deploy_path}}'); |
|
| 159 | + cd('{{release_path}}'); |
|
| 160 | + run('php deploy/phinx.phar rollback -e production'); |
|
| 161 | + cd('{{deploy_path}}'); |
|
| 162 | 162 | } |
| 163 | 163 | })->setPrivate(); |
| 164 | 164 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | 'vendor' |
| 56 | 56 | ]; |
| 57 | 57 | |
| 58 | - foreach($items_required_for_deploy as $file) { |
|
| 59 | - if(file_exists($file) !== true) { |
|
| 58 | + foreach ($items_required_for_deploy as $file) { |
|
| 59 | + if (file_exists($file) !== true) { |
|
| 60 | 60 | writeln("<error>File or directory $file does not exist, cannot deploy.</error>\n"); |
| 61 | 61 | writeln("<comment>Ensure you have downloaded a compiled release from https://github.com/mattheworres/phpdraft/releases</comment>\n"); |
| 62 | 62 | writeln("<comment>Or, if you are building from sourcecode, consult the wiki on how to properly prepare a release.</comment>\n"); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | desc('Rollback migrations on failure'); |
| 156 | 156 | task('phpdraft:rollback', function() { |
| 157 | 157 | writeln('<comment>Rolling back database migrations...</comment>'); |
| 158 | - if(get("phpdraft_rollback_required") == true) { |
|
| 158 | + if (get("phpdraft_rollback_required") == true) { |
|
| 159 | 159 | cd('{{release_path}}'); |
| 160 | 160 | run('php deploy/phinx.phar rollback -e production'); |
| 161 | 161 | cd('{{deploy_path}}'); |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | desc('PHP Draft: Offer to backup current settings for future upgrade imports'); |
| 15 | 15 | task('backup', function() { |
| 16 | - if (file_exists("js/config.js") == false) { |
|
| 17 | - writeln("<error>Looks like js/config.js doesn't exist - I can't back up your settings.</error>\n"); |
|
| 18 | - writeln("<comment>Ensure you have downloaded a compiled release from https://github.com/mattheworres/phpdraft/releases</comment>\n"); |
|
| 19 | - writeln("<comment>Or, if you are building from sourcecode, consult the wiki on how to properly prepare a release.</comment>\n"); |
|
| 20 | - throw new \Exception("PHP Draft is not in a exportable state (use downloads from Releases on Github)"); |
|
| 21 | - } |
|
| 16 | + if (file_exists("js/config.js") == false) { |
|
| 17 | + writeln("<error>Looks like js/config.js doesn't exist - I can't back up your settings.</error>\n"); |
|
| 18 | + writeln("<comment>Ensure you have downloaded a compiled release from https://github.com/mattheworres/phpdraft/releases</comment>\n"); |
|
| 19 | + writeln("<comment>Or, if you are building from sourcecode, consult the wiki on how to properly prepare a release.</comment>\n"); |
|
| 20 | + throw new \Exception("PHP Draft is not in a exportable state (use downloads from Releases on Github)"); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | writeln("\n\n<info>Looking great! Hey, if you want I can back up these snazzy settings files " |
| 24 | 24 | ."I just created for you. This will make it WAY easier to update PHP Draft in the future!</info>\n"); |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | runLocally("cp js/config.js $backup_location/config.js"); |
| 36 | 36 | runLocally("cp phinx.yml $backup_location/phinx.yml"); |
| 37 | 37 | runLocally("cp deploy.php $backup_location/deploy.php"); |
| 38 | - runLocally("cp .htaccess $backup_location/.htaccess"); |
|
| 39 | - runLocally("cp index.html $backup_location/index.html"); |
|
| 38 | + runLocally("cp .htaccess $backup_location/.htaccess"); |
|
| 39 | + runLocally("cp index.html $backup_location/index.html"); |
|
| 40 | 40 | runLocally("cp web.config $backup_location/web.config"); |
| 41 | 41 | } |
| 42 | 42 | }); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | ."I just created for you. This will make it WAY easier to update PHP Draft in the future!</info>\n"); |
| 25 | 25 | $answer = askConfirmation("Should I back up your settings for you?", false); |
| 26 | 26 | |
| 27 | - if($answer == true) { |
|
| 27 | + if ($answer == true) { |
|
| 28 | 28 | writeln("\n\n<info>Awesome! Wherever you tell me to back your settings up to, you should make sure " |
| 29 | 29 | ."that only your user has permissions to view the file (if the server you're installing on " |
| 30 | 30 | ."is more important, you should probably ensure your disk is encrypted, too).</info>\n"); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $answer = askConfirmation($message, false); |
| 50 | 50 | |
| 51 | - if($answer == false) { |
|
| 51 | + if ($answer == false) { |
|
| 52 | 52 | throw new \Exception("Quitting setup at the user's request. BYE FELICIA."); |
| 53 | 53 | } |
| 54 | 54 | })->setPrivate(); |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | 'deploy.php' |
| 147 | 147 | ]; |
| 148 | 148 | |
| 149 | - foreach(get('phpdraft_setup_variables') as $property => $value) { |
|
| 150 | - foreach($files_to_replace_in as $file) { |
|
| 149 | + foreach (get('phpdraft_setup_variables') as $property => $value) { |
|
| 150 | + foreach ($files_to_replace_in as $file) { |
|
| 151 | 151 | //TODO: Is there something more platform agnostic we can use? |
| 152 | 152 | runLocally("sed -i '' 's|{phpdraft.$property}|$value|g' $file $file"); |
| 153 | 153 | } |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once dirname(__FILE__).'/../../vendor/autoload.php'; |
|
| 3 | +require_once dirname(__FILE__) . '/../../vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | 5 | $app = new Silex\Application(); |
| 6 | 6 | |
| 7 | 7 | //Handles settings users can define |
| 8 | 8 | //Please see README.md for instructions on how to setup |
| 9 | -require_once dirname(__FILE__).'/../../appsettings.php'; |
|
| 9 | +require_once dirname(__FILE__) . '/../../appsettings.php'; |
|
| 10 | 10 | |
| 11 | 11 | $app['debug'] = DEBUG_MODE; |
| 12 | 12 | |
| 13 | -require_once dirname(__FILE__).'/_database.php'; //Sets up database connections |
|
| 14 | -require_once dirname(__FILE__).'/_log.php'; //Sets up logging |
|
| 13 | +require_once dirname(__FILE__) . '/_database.php'; //Sets up database connections |
|
| 14 | +require_once dirname(__FILE__) . '/_log.php'; //Sets up logging |
|
| 15 | 15 | |
| 16 | 16 | //Registrations with Pimple DI |
| 17 | -require_once dirname(__FILE__).'/_registerServices.php'; |
|
| 18 | -require_once dirname(__FILE__).'/_registerRepositories.php'; |
|
| 19 | -require_once dirname(__FILE__).'/_registerValidators.php'; |
|
| 20 | -require_once dirname(__FILE__).'/_registerFactories.php'; |
|
| 21 | - |
|
| 22 | -require_once dirname(__FILE__).'/_middlewares.php'; //Defines middleware handlers for shared logic, like ensuring a draft is editable |
|
| 23 | -require_once dirname(__FILE__).'/_router.php'; //Sets up controller routing |
|
| 24 | -require_once dirname(__FILE__).'/_security.php'; //Sets up Symfony-based security & user authentication |
|
| 17 | +require_once dirname(__FILE__) . '/_registerServices.php'; |
|
| 18 | +require_once dirname(__FILE__) . '/_registerRepositories.php'; |
|
| 19 | +require_once dirname(__FILE__) . '/_registerValidators.php'; |
|
| 20 | +require_once dirname(__FILE__) . '/_registerFactories.php'; |
|
| 21 | + |
|
| 22 | +require_once dirname(__FILE__) . '/_middlewares.php'; //Defines middleware handlers for shared logic, like ensuring a draft is editable |
|
| 23 | +require_once dirname(__FILE__) . '/_router.php'; //Sets up controller routing |
|
| 24 | +require_once dirname(__FILE__) . '/_security.php'; //Sets up Symfony-based security & user authentication |
|
| 25 | 25 | |
| 26 | 26 | return $app; |
| 27 | 27 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $valid = true; |
| 20 | 20 | $errors = array(); |
| 21 | 21 | |
| 22 | - if($draft->draft_id != $manager->draft_id) { |
|
| 22 | + if ($draft->draft_id != $manager->draft_id) { |
|
| 23 | 23 | $errors[] = "Manager does not belong to draft #$draft->draft_id"; |
| 24 | 24 | $valid = false; |
| 25 | 25 | } |
@@ -33,37 +33,37 @@ discard block |
||
| 33 | 33 | $assetCount = count($trade->trade_assets); |
| 34 | 34 | $uniqueAssetCount = count(array_unique($trade->trade_assets)); |
| 35 | 35 | |
| 36 | - if(empty($trade->trade_round) || $trade->trade_round < 0 || $trade->trade_round > $draft->draft_rounds) { |
|
| 36 | + if (empty($trade->trade_round) || $trade->trade_round < 0 || $trade->trade_round > $draft->draft_rounds) { |
|
| 37 | 37 | $errors[] = "Invalid value for trade round."; |
| 38 | 38 | $valid = false; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - foreach($trade->trade_assets as $trade_asset) { |
|
| 42 | - if($trade_asset->oldmanager_id != $trade->manager1_id |
|
| 41 | + foreach ($trade->trade_assets as $trade_asset) { |
|
| 42 | + if ($trade_asset->oldmanager_id != $trade->manager1_id |
|
| 43 | 43 | && $trade_asset->oldmanager_id != $trade->manager2_id) { |
| 44 | 44 | $player_id = $trade_asset->player->player_id; |
| 45 | 45 | $errors[] = "Asset #$player_id does not belong to either manager."; |
| 46 | 46 | $valid = false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if($trade_asset->player->draft_id != $draft->draft_id) { |
|
| 49 | + if ($trade_asset->player->draft_id != $draft->draft_id) { |
|
| 50 | 50 | $player_id = $trade_asset->player->player_id; |
| 51 | 51 | $errors[] = "Asset #$player_id does not belong to draft #$draft->draft_id"; |
| 52 | 52 | $valid = false; |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if($assetCount != $uniqueAssetCount) { |
|
| 56 | + if ($assetCount != $uniqueAssetCount) { |
|
| 57 | 57 | $errors[] = "One or more of the trade assets are duplicate."; |
| 58 | 58 | $valid = false; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if($draft->draft_id != $trade->manager1->draft_id) { |
|
| 61 | + if ($draft->draft_id != $trade->manager1->draft_id) { |
|
| 62 | 62 | $errors[] = "Manager 1 does not belong to draft #$draft->draft_id"; |
| 63 | 63 | $valid = false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if($draft->draft_id != $trade->manager2->draft_id) { |
|
| 66 | + if ($draft->draft_id != $trade->manager2->draft_id) { |
|
| 67 | 67 | $errors[] = "Manager 2 does not belong to draft #$draft->draft_id"; |
| 68 | 68 | $valid = false; |
| 69 | 69 | } |
@@ -21,19 +21,19 @@ |
||
| 21 | 21 | $errors = array(); |
| 22 | 22 | $sports = $this->app['phpdraft.DraftDataRepository']->GetSports(); |
| 23 | 23 | |
| 24 | - if(empty($sport)) { |
|
| 24 | + if (empty($sport)) { |
|
| 25 | 25 | $errors[] = "One or more missing fields."; |
| 26 | 26 | $valid = false; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if(!array_key_exists($sport, $sports)) { |
|
| 29 | + if (!array_key_exists($sport, $sports)) { |
|
| 30 | 30 | $errors[] = "Sport $sport is an invalid value."; |
| 31 | 31 | $valid = false; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | if (!isset($file)) { |
| 35 | 35 | $valid = false; |
| 36 | - $errors[] = "Must upload a CSV file"; |
|
| 36 | + $errors[] = "Must upload a CSV file"; |
|
| 37 | 37 | } else { |
| 38 | 38 | $fileErrorCode = $file->getError(); |
| 39 | 39 | |
@@ -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; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $stats); |
| 23 | 23 | |
| 24 | - if(!$load_stmt->execute()) { |
|
| 24 | + if (!$load_stmt->execute()) { |
|
| 25 | 25 | throw new \Exception("Unable to load draft stats"); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | return null; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if(!$load_stmt->fetch()) { |
|
| 32 | + if (!$load_stmt->fetch()) { |
|
| 33 | 33 | throw new \Exception("Error while loading draft stats"); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $insert_stmt->bindValue(':least_drafted_position', $draft_stats->least_drafted_position); |
| 104 | 104 | $insert_stmt->bindValue(':least_drafted_position_count', $draft_stats->least_drafted_position_count); |
| 105 | 105 | |
| 106 | - if(!$insert_stmt->execute()) { |
|
| 106 | + if (!$insert_stmt->execute()) { |
|
| 107 | 107 | throw new \Exception("Unable to insert new draft stats row."); |
| 108 | 108 | } |
| 109 | 109 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $delete_stmt = $this->app['db']->prepare("DELETE FROM draft_stats WHERE draft_id = ?"); |
| 119 | 119 | $delete_stmt->bindParam(1, $draft_id); |
| 120 | 120 | |
| 121 | - if(!$delete_stmt->execute()) { |
|
| 121 | + if (!$delete_stmt->execute()) { |
|
| 122 | 122 | throw new \Exception("Unable to delete existing stats rows."); |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $row = $stmt->fetch(); |
| 171 | 171 | |
| 172 | 172 | $stats->shortest_avg_pick_manager_name = $row['manager_name']; |
| 173 | - $stats->shortest_avg_pick_seconds = (int) $row['pick_average']; |
|
| 173 | + $stats->shortest_avg_pick_seconds = (int)$row['pick_average']; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | private function _LoadSlowestPick($draft_id, DraftStats &$stats) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $row = $stmt->fetch(); |
| 191 | 191 | |
| 192 | 192 | $stats->longest_single_pick_manager_name = $row['manager_name']; |
| 193 | - $stats->longest_single_pick_seconds = (int) $row['pick_max']; |
|
| 193 | + $stats->longest_single_pick_seconds = (int)$row['pick_max']; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | private function _LoadFastestPick($draft_id, DraftStats &$stats) { |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $row = $stmt->fetch(); |
| 211 | 211 | |
| 212 | 212 | $stats->shortest_single_pick_manager_name = $row['manager_name']; |
| 213 | - $stats->shortest_single_pick_seconds = (int) $row['pick_min']; |
|
| 213 | + $stats->shortest_single_pick_seconds = (int)$row['pick_min']; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | private function _LoadAveragePickTime($draft_id, DraftStats &$stats) { |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | $row = $stmt->fetch(); |
| 227 | 227 | |
| 228 | - $stats->average_pick_seconds = (int) $row['pick_average']; |
|
| 228 | + $stats->average_pick_seconds = (int)$row['pick_average']; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | private function _LoadRoundTimes(Draft $draft, DraftStats &$stats) { |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $row = $stmt->fetch(); |
| 245 | 245 | |
| 246 | - $stats->longest_round = (int) $row['player_round']; |
|
| 247 | - $stats->longest_round_seconds = (int) $row['round_time']; |
|
| 246 | + $stats->longest_round = (int)$row['player_round']; |
|
| 247 | + $stats->longest_round_seconds = (int)$row['round_time']; |
|
| 248 | 248 | |
| 249 | 249 | //Stupid that I can't just re-use the above statement. All that changes is DESC to ASC. Stupid. |
| 250 | 250 | $stmt = $this->app['db']->prepare("SELECT DISTINCT p.player_round, sum( p.pick_duration ) AS round_time |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $row = $stmt->fetch(); |
| 263 | 263 | |
| 264 | - $stats->shortest_round = (int) $row['player_round']; |
|
| 265 | - $stats->shortest_round_seconds = (int) $row['round_time']; |
|
| 264 | + $stats->shortest_round = (int)$row['player_round']; |
|
| 265 | + $stats->shortest_round_seconds = (int)$row['round_time']; |
|
| 266 | 266 | |
| 267 | 267 | $stmt = $this->app['db']->prepare("SELECT p.player_round, sum( p.pick_duration ) / ? AS avg_round_time |
| 268 | 268 | FROM players p |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $row = $stmt->fetch(); |
| 281 | 281 | |
| 282 | - $stats->average_round_seconds = (int) $row['avg_round_time']; |
|
| 282 | + $stats->average_round_seconds = (int)$row['avg_round_time']; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | private function _LoadTeamSuperlatives($draft_id, DraftStats &$stats, $teams) { |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $row = $stmt->fetch(); |
| 299 | 299 | |
| 300 | 300 | $stats->most_drafted_team = isset($row['team']) ? $teams[$row['team']] : ""; |
| 301 | - $stats->most_drafted_team_count = (int) $row['team_occurences']; |
|
| 301 | + $stats->most_drafted_team_count = (int)$row['team_occurences']; |
|
| 302 | 302 | |
| 303 | 303 | $stmt = $this->app['db']->prepare("SELECT DISTINCT p.team, count(team) as team_occurences |
| 304 | 304 | FROM players p |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $row = $stmt->fetch(); |
| 316 | 316 | |
| 317 | 317 | $stats->least_drafted_team = isset($row['team']) ? $teams[$row['team']] : ""; |
| 318 | - $stats->least_drafted_team_count = (int) $row['team_occurences']; |
|
| 318 | + $stats->least_drafted_team_count = (int)$row['team_occurences']; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | private function _LoadPositionSuperlatives($draft_id, DraftStats &$stats, $positions) { |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $row = $stmt->fetch(); |
| 335 | 335 | |
| 336 | 336 | $stats->most_drafted_position = isset($row['position']) ? $positions[$row['position']] : ""; |
| 337 | - $stats->most_drafted_position_count = (int) $row['position_occurences']; |
|
| 337 | + $stats->most_drafted_position_count = (int)$row['position_occurences']; |
|
| 338 | 338 | |
| 339 | 339 | $stmt = $this->app['db']->prepare("SELECT DISTINCT p.position, count(position) as position_occurences |
| 340 | 340 | FROM players p |
@@ -351,6 +351,6 @@ discard block |
||
| 351 | 351 | $row = $stmt->fetch(); |
| 352 | 352 | |
| 353 | 353 | $stats->least_drafted_position = isset($row['position']) ? $positions[$row['position']] : ""; |
| 354 | - $stats->least_drafted_position_count = (int) $row['position_occurences']; |
|
| 354 | + $stats->least_drafted_position_count = (int)$row['position_occurences']; |
|
| 355 | 355 | } |
| 356 | 356 | } |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | $users = array(); |
| 87 | 87 | |
| 88 | - if(!$load_stmt->execute()) { |
|
| 88 | + if (!$load_stmt->execute()) { |
|
| 89 | 89 | throw new \Exception("Unable to load users."); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - while($user = $load_stmt->fetch()) { |
|
| 92 | + while ($user = $load_stmt->fetch()) { |
|
| 93 | 93 | |
| 94 | 94 | $users[] = $this->_ScrubUser($user); |
| 95 | 95 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | throw new \Exception("Unable to create user."); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $user->id = (int) $this->app['db']->lastInsertId(); |
|
| 120 | + $user->id = (int)$this->app['db']->lastInsertId(); |
|
| 121 | 121 | |
| 122 | 122 | return $user; |
| 123 | 123 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $result = $update_stmt->execute(); |
| 157 | 157 | |
| 158 | - if($result == false) { |
|
| 158 | + if ($result == false) { |
|
| 159 | 159 | throw new \Exception("Unable to erase verification key for user."); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $delete_stmt = $this->app['db']->prepare("DELETE FROM users WHERE id = ?"); |
| 167 | 167 | $delete_stmt->bindParam(1, $user->id); |
| 168 | 168 | |
| 169 | - if(!$delete_stmt->execute()) { |
|
| 169 | + if (!$delete_stmt->execute()) { |
|
| 170 | 170 | throw new \Exception("Unable to delete user #$user->id"); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | public function NameIsUnique($name, $id = null) { |
| 177 | 177 | $name = strtolower($name); |
| 178 | - if($id == null) { |
|
| 178 | + if ($id == null) { |
|
| 179 | 179 | $name_stmt = $this->app['db']->prepare("SELECT name FROM users WHERE name LIKE ?"); |
| 180 | 180 | $name_stmt->bindParam(1, $name); |
| 181 | 181 | } else { |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | $name_stmt->bindParam(2, $id); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if(!$name_stmt->execute()) { |
|
| 187 | + if (!$name_stmt->execute()) { |
|
| 188 | 188 | throw new \Exception(sprintf('Name %s is invalid', $name)); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | public function EmailExists($email, $id = null) { |
| 195 | - if($id == null) { |
|
| 195 | + if ($id == null) { |
|
| 196 | 196 | $email_stmt = $this->app['db']->prepare("SELECT email FROM users WHERE email = ?"); |
| 197 | 197 | $email_stmt->bindParam(1, $email); |
| 198 | 198 | } else { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $email_stmt = $this->app['db']->prepare("SELECT email FROM users WHERE email = ? LIMIT 1"); |
| 214 | 214 | $email_stmt->bindParam(1, $email); |
| 215 | 215 | |
| 216 | - if(!$email_stmt->execute()) { |
|
| 216 | + if (!$email_stmt->execute()) { |
|
| 217 | 217 | throw new \Exception(sprintf('Email %s is invalid', $email)); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | $users = array(); |
| 231 | 231 | |
| 232 | - if(!$search_stmt->execute()) { |
|
| 232 | + if (!$search_stmt->execute()) { |
|
| 233 | 233 | throw new \Exception("Unable to load users"); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - while($user = $search_stmt->fetch()) { |
|
| 236 | + while ($user = $search_stmt->fetch()) { |
|
| 237 | 237 | unset($user->enabled); |
| 238 | 238 | unset($user->email); |
| 239 | 239 | unset($user->password); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $verification_stmt->bindParam(1, $email); |
| 254 | 254 | $verification_stmt->bindParam(2, $verificationKey); |
| 255 | 255 | |
| 256 | - if(!$verification_stmt->execute()) { |
|
| 256 | + if (!$verification_stmt->execute()) { |
|
| 257 | 257 | throw new \Exception('Verification is invalid.'); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -25,11 +25,13 @@ discard block |
||
| 25 | 25 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
| 26 | 26 | $load_stmt->bindParam(1, $email); |
| 27 | 27 | |
| 28 | - if (!$load_stmt->execute()) |
|
| 29 | - throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
| 28 | + if (!$load_stmt->execute()) { |
|
| 29 | + throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
| 30 | + } |
|
| 30 | 31 | |
| 31 | - if (!$load_stmt->fetch()) |
|
| 32 | - throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
| 32 | + if (!$load_stmt->fetch()) { |
|
| 33 | + throw new \Exception(sprintf('Email "%s" does not exist.', $email)); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | return $user; |
| 35 | 37 | } |
@@ -43,11 +45,13 @@ discard block |
||
| 43 | 45 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
| 44 | 46 | $load_stmt->bindParam(1, $id); |
| 45 | 47 | |
| 46 | - if (!$load_stmt->execute()) |
|
| 47 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 48 | + if (!$load_stmt->execute()) { |
|
| 49 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 50 | + } |
|
| 48 | 51 | |
| 49 | - if (!$load_stmt->fetch()) |
|
| 50 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 52 | + if (!$load_stmt->fetch()) { |
|
| 53 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 54 | + } |
|
| 51 | 55 | |
| 52 | 56 | return $user; |
| 53 | 57 | } |
@@ -61,11 +65,13 @@ discard block |
||
| 61 | 65 | $load_stmt->setFetchMode(\PDO::FETCH_INTO, $user); |
| 62 | 66 | $load_stmt->bindParam(1, $id); |
| 63 | 67 | |
| 64 | - if (!$load_stmt->execute()) |
|
| 65 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 68 | + if (!$load_stmt->execute()) { |
|
| 69 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 70 | + } |
|
| 66 | 71 | |
| 67 | - if (!$load_stmt->fetch()) |
|
| 68 | - throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 72 | + if (!$load_stmt->fetch()) { |
|
| 73 | + throw new \Exception(sprintf('User #%s does not exist.', $id)); |
|
| 74 | + } |
|
| 69 | 75 | |
| 70 | 76 | unset($user->enabled); |
| 71 | 77 | unset($user->email); |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | class RoundTimeValidatorTest extends TestCase { |
| 10 | 10 | function setUp() { |
| 11 | - $this->app = require dirname(__FILE__).'/../../../../api/config/_app.php'; |
|
| 11 | + $this->app = require dirname(__FILE__) . '/../../../../api/config/_app.php'; |
|
| 12 | 12 | $this->roundTimeCreateModel = new RoundTimeCreateModel(); |
| 13 | 13 | $this->sut = new RoundTimeValidator($this->app); |
| 14 | 14 | } |