diff --git a/FoodScanAppService.php b/FoodScanAppService.php index ddabfdd..992b9f7 100644 --- a/FoodScanAppService.php +++ b/FoodScanAppService.php @@ -34,7 +34,7 @@ } } switch ($_REQUEST['Service']) { - /********************* User Functions *********************/ + /********** User Functions **********/ case User::REGISTRATION_ACTION: case User::LOGIN_ACTION: case User::CHANGE_PASSWORD_ACTION: @@ -88,7 +88,7 @@ $secret_key = addslashes($secret_key); $isSecure = (new Security($db))->checkForSecurityNew($access_key, $secret_key); - $isSecure = YES; + $isSecure = YES; if ($isSecure === NO) { $data['status'] = FAILED; @@ -99,7 +99,7 @@ } else { $product = new Product($db); $data = $product->callService($_REQUEST['Service'], $postData); - if ($isSecure !== YES || $isSecure !== YES) { + if ($isSecure !== YES || $isSecure !== YES) { if ($isSecure['key'] === 'Temp') { $data['TempToken'] = $isSecure['value']; } else { @@ -119,6 +119,6 @@ $data['message'] = $_REQUEST['Service']; } } -//(new AllowCors)->init(); // Set CORS headers +// (new AllowCors)->init(); // Set CORS headers header('Content-type: application/json'); echo json_encode($data); diff --git a/src/AllowCors.php b/src/AllowCors.php index f7d5c0b..956c981 100644 --- a/src/AllowCors.php +++ b/src/AllowCors.php @@ -13,6 +13,7 @@ class AllowCors const ALLOW_CORS_METHOD_KEY = 'Access-Control-Allow-Methods'; const ALLOW_CORS_ORIGIN_VALUE = '*'; const ALLOW_CORS_METHOD_VALUE = 'GET, POST, PUT, DELETE, PATCH, OPTIONS'; + /** * Initialize the Cross-Origin Resource Sharing (CORS) headers. * diff --git a/src/Database.php b/src/Database.php index 18e79ce..95be424 100644 --- a/src/Database.php +++ b/src/Database.php @@ -6,7 +6,9 @@ */ declare(strict_types=1); + namespace Lifyzer\Api; + use PDO; class Database extends PDO diff --git a/src/HelperFunctions.php b/src/HelperFunctions.php index 7860119..ce5cd7f 100644 --- a/src/HelperFunctions.php +++ b/src/HelperFunctions.php @@ -1,9 +1,8 @@ $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0, - )); - if ($isParam){ - curl_setopt_array(CURLOPT_POSTFIELDS,$params); + ]); + if ($isParam) { + curl_setopt_array(CURLOPT_POSTFIELDS, $params); } $result = curl_exec($ch); curl_close($ch); $tempArr = json_decode($result, true); return $tempArr; -} \ No newline at end of file +} diff --git a/src/Logger.php b/src/Logger.php index d09202e..286348c 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -1,6 +1,7 @@ getenv('URL_SWISS_FOOD_API'), CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"query\":{\"query_string\":{\"query\":\"" . $product_name . "\"}}}", - CURLOPT_HTTPHEADER => array( + CURLOPT_HTTPHEADER => [ "Authorization: Token token=" . getenv('SWISS_FOOD_KEY'), "Content-ApiProviders: application/vnd.api+json", "Accept: application/json", "Content-ApiProviders: application/json" - ), - )); + ], + ]); $result = curl_exec($ch); curl_close($ch); $tempArr = json_decode($result, true); diff --git a/src/Security.php b/src/Security.php index 2ed9aea..59a4581 100644 --- a/src/Security.php +++ b/src/Security.php @@ -1,6 +1,7 @@ connection; @@ -70,24 +70,23 @@ private function addLogs($userData) { $user_id = addslashes($user_id); $api = validateObject($userData, 'api', ""); - $api = addslashes($api); + $api = addslashes($api); $response = validateObject($userData, 'response', ""); - $response = addslashes($response); + $response = addslashes($response); $user_array = [ - 'api' => $api, - 'response' => $response, - 'user_id' => $user_id - ]; + 'api' => $api, + 'response' => $response, + 'user_id' => $user_id + ]; $user_response = addData($connection, 'Registration', TABLE_LOGS, $user_array); - if ($user_response[STATUS_KEY] === SUCCESS) { + if ($user_response[STATUS_KEY] === SUCCESS) { $status = SUCCESS; $message = "successfully loged"; - } - else{ + } else { $status = FAILED; $message = SOMETHING_WENT_WRONG_TRY_AGAIN_LATER; } @@ -186,7 +185,7 @@ private function registration($userData) ], new Email() ); - } catch (\PHPMailer\PHPMailer\Exception $e) { + } catch (Exception $e) { $status = FAILED; $message = SOMETHING_WENT_WRONG_TRY_AGAIN_LATER; } @@ -456,7 +455,7 @@ private function forgotPassword($userData) * @param array $data * @param Email $email * - * @throws \PHPMailer\PHPMailer\Exception + * @throws Exception */ private function sendWelcomeEmail(array $data, Email $email) { @@ -489,7 +488,7 @@ private function sendWelcomeEmail(array $data, Email $email) * @param array $data * @param Email $email * - * @throws \PHPMailer\PHPMailer\Exception + * @throws Exception */ private function sendForgotPassword(array $data, Email $email) {