@@ -5,10 +5,10 @@ |
||
| 5 | 5 | |
| 6 | 6 | class WebTestCase extends BaseWebTestCase |
| 7 | 7 | { |
| 8 | - public function createApplication() |
|
| 9 | - { |
|
| 10 | - $app = require $_SERVER['APP_DIR'] . '/src/app.php'; |
|
| 8 | + public function createApplication() |
|
| 9 | + { |
|
| 10 | + $app = require $_SERVER['APP_DIR'] . '/src/app.php'; |
|
| 11 | 11 | |
| 12 | - return $app; |
|
| 13 | - } |
|
| 12 | + return $app; |
|
| 13 | + } |
|
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | { |
| 18 | 18 | $bindArray = array('param' => 4); |
| 19 | 19 | |
| 20 | - Database::bindParamArray('test', array(4,6,8), $bindArray); |
|
| 20 | + Database::bindParamArray('test', array(4, 6, 8), $bindArray); |
|
| 21 | 21 | |
| 22 | 22 | $expected = array( |
| 23 | 23 | 'param' => 4, |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Import application config |
| 3 | -switch(getenv('env')) { |
|
| 3 | +switch (getenv('env')) { |
|
| 4 | 4 | case 'test': |
| 5 | 5 | $configFile = 'config-test.ini'; |
| 6 | 6 | break; |
@@ -16,6 +16,6 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | $iniArray = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . $configFile); |
| 18 | 18 | |
| 19 | -foreach($iniArray as $key => $val) { |
|
| 19 | +foreach ($iniArray as $key => $val) { |
|
| 20 | 20 | define($key, $val); |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $constituenciesModel = new ConstituenciesModel(new Database()); |
| 24 | 24 | |
| 25 | - if($constituenciesModel->getAllConstituencies()) { |
|
| 25 | + if ($constituenciesModel->getAllConstituencies()) { |
|
| 26 | 26 | return json_encode($constituenciesModel->constituencies); |
| 27 | 27 | } else { |
| 28 | 28 | return ApiResponse::error('NO_CONSTITUENCIES_FOUND'); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $candidatesModel = new CandidatesModel(new Database()); |
| 35 | 35 | |
| 36 | - if($candidatesModel->getCandidatesByConstituencyId($constituencyId)) { |
|
| 36 | + if ($candidatesModel->getCandidatesByConstituencyId($constituencyId)) { |
|
| 37 | 37 | return json_encode($candidatesModel->candidates); |
| 38 | 38 | } else { |
| 39 | 39 | return ApiResponse::error('NO_CANDIDATES_FOUND'); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $userModel = new UserModel(new Database()); |
| 25 | 25 | |
| 26 | - if($userModel->loadUserByEmail($userData->email)) { |
|
| 26 | + if ($userModel->loadUserByEmail($userData->email)) { |
|
| 27 | 27 | return ApiResponse::error('USER_EXISTS'); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $userModel->saveUser($userData->email, $userData->first_name, $userData->surname, $userData->constituency, $userData->voting, $userData->candidate); |
| 32 | 32 | |
| 33 | 33 | return ApiResponse::success('DEFAULT_RESPONSE_SUCCESS'); |
| 34 | - } catch(\Exception $e) { |
|
| 34 | + } catch (\Exception $e) { |
|
| 35 | 35 | return ApiResponse::error('USER_SAVE_FAIL'); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | $resultsModel = new ResultsModel(new Database()); |
| 23 | 23 | |
| 24 | - if($resultsModel->getResults()) { |
|
| 24 | + if ($resultsModel->getResults()) { |
|
| 25 | 25 | return json_encode($resultsModel->results); |
| 26 | 26 | } else { |
| 27 | 27 | return json_encode(array()); |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | { |
| 11 | 11 | public function hydrateObjects($collectionPropertyName, $modelType, $records) |
| 12 | 12 | { |
| 13 | - if(empty($records)) { |
|
| 13 | + if (empty($records)) { |
|
| 14 | 14 | throw new \Exception('No records found'); |
| 15 | 15 | } else { |
| 16 | - foreach($records as $item) { |
|
| 16 | + foreach ($records as $item) { |
|
| 17 | 17 | // Requires a fully qualified namespace |
| 18 | 18 | $doc = new $modelType($this->app); |
| 19 | 19 | |
| 20 | - foreach($item as $key => $val) { |
|
| 20 | + foreach ($item as $key => $val) { |
|
| 21 | 21 | $doc->{$key} = $val; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
| 24 | 24 | |
| 25 | - if(is_array($result) && !empty($result)) { |
|
| 25 | + if (is_array($result) && !empty($result)) { |
|
| 26 | 26 | $this->constituencies = $result; |
| 27 | 27 | |
| 28 | 28 | return $this->constituencies; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $this->db = $db; |
| 25 | 25 | |
| 26 | - if(isset($email)) { |
|
| 26 | + if (isset($email)) { |
|
| 27 | 27 | $this->loadUserByEmail($email); |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
| 45 | 45 | |
| 46 | 46 | // Hydrate model |
| 47 | - if(isset($result[0])) { |
|
| 48 | - foreach($result[0] as $key => $val) { |
|
| 47 | + if (isset($result[0])) { |
|
| 48 | + foreach ($result[0] as $key => $val) { |
|
| 49 | 49 | $this->{$key} = $val; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $stmt->bindValue(':voting', $voting, \PDO::PARAM_BOOL); |
| 74 | 74 | $stmt->execute(); |
| 75 | 75 | |
| 76 | - if(!$voting) { |
|
| 76 | + if (!$voting) { |
|
| 77 | 77 | $this->db->commit(); |
| 78 | 78 | return; |
| 79 | 79 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $this->db->commit(); |
| 94 | 94 | |
| 95 | 95 | return $userId; |
| 96 | - } catch(\PDOException $e) { |
|
| 96 | + } catch (\PDOException $e) { |
|
| 97 | 97 | $this->db->rollback(); |
| 98 | 98 | |
| 99 | 99 | throw new \Exception('There was a problem saving this user: ' . $e->getMessage()); |