From cae28f03a53248090473a1b913859a3bcadbe725 Mon Sep 17 00:00:00 2001 From: Thilina Hasantha Date: Sun, 28 Jul 2019 10:23:45 +0200 Subject: [PATCH] Fix code style issues --- .../Rest/AttendanceRestEndPoint.php | 19 +++++++++++++------ core/src/Company/Common/Model/Timezone.php | 12 +++++++----- .../Settings/Rest/SettingsRestEndPoint.php | 1 - core/src/Utils/NetworkUtils.php | 15 ++++++++------- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/core/src/Attendance/Rest/AttendanceRestEndPoint.php b/core/src/Attendance/Rest/AttendanceRestEndPoint.php index 61433d12..84183665 100644 --- a/core/src/Attendance/Rest/AttendanceRestEndPoint.php +++ b/core/src/Attendance/Rest/AttendanceRestEndPoint.php @@ -90,9 +90,9 @@ class AttendanceRestEndPoint extends RestEndPoint } if ($user->user_level !== 'Admin' && !PermissionManager::manipulationAllowed( - BaseService::getInstance()->getCurrentProfileId(), - $this->getModelObject($parameter) - ) + BaseService::getInstance()->getCurrentProfileId(), + $this->getModelObject($parameter) + ) ) { return new IceResponse(IceResponse::ERROR, self::RESPONSE_ERR_PERMISSION_DENIED, 403); } @@ -277,8 +277,16 @@ class AttendanceRestEndPoint extends RestEndPoint } } - protected function savePunch($employeeId, $inDateTime, $note = null, $outDateTime = null, $id = null, $latitude = null, $longitude = null, $ip = null) - { + protected function savePunch( + $employeeId, + $inDateTime, + $note = null, + $outDateTime = null, + $id = null, + $latitude = null, + $longitude = null, + $ip = null + ) { $employee = BaseService::getInstance()->getElement( 'Employee', $employeeId, @@ -399,6 +407,5 @@ class AttendanceRestEndPoint extends RestEndPoint } return null; - } } diff --git a/core/src/Company/Common/Model/Timezone.php b/core/src/Company/Common/Model/Timezone.php index 74703eac..6de54e88 100644 --- a/core/src/Company/Common/Model/Timezone.php +++ b/core/src/Company/Common/Model/Timezone.php @@ -35,25 +35,27 @@ class Timezone extends BaseModel $modifiedTimeZones[] = $tz; } catch (\Exception $e) { } - } - usort($modifiedTimeZones, function ($a, $b) { return strcmp($a->details, $b->details); }); + usort($modifiedTimeZones, function ($a, $b) { + return strcmp($a->details, $b->details); + }); return $modifiedTimeZones; } - public function formatOffset($offset) { + public function formatOffset($offset) + { $hours = $offset / 3600; $remainder = $offset % 3600; $sign = $hours > 0 ? '+' : '-'; $hour = (int) abs($hours); $minutes = (int) abs($remainder / 60); - if ($hour == 0 AND $minutes == 0) { + if ($hour == 0 and $minutes == 0) { $sign = ' '; } return 'GMT' . $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) - .':'. str_pad($minutes,2, '0'); + .':'. str_pad($minutes, 2, '0'); } public function fieldValueMethods() diff --git a/core/src/Settings/Rest/SettingsRestEndPoint.php b/core/src/Settings/Rest/SettingsRestEndPoint.php index 0ce466a0..aa9d41e5 100644 --- a/core/src/Settings/Rest/SettingsRestEndPoint.php +++ b/core/src/Settings/Rest/SettingsRestEndPoint.php @@ -3,7 +3,6 @@ namespace Settings\Rest; - use Classes\IceResponse; use Classes\RestEndPoint; use Classes\SettingsManager; diff --git a/core/src/Utils/NetworkUtils.php b/core/src/Utils/NetworkUtils.php index b61e3b4d..7a0bb1cd 100644 --- a/core/src/Utils/NetworkUtils.php +++ b/core/src/Utils/NetworkUtils.php @@ -7,20 +7,21 @@ class NetworkUtils public static function getClientIp() { $ipaddress = ''; - if (isset($_SERVER['HTTP_CLIENT_IP'])) + if (isset($_SERVER['HTTP_CLIENT_IP'])) { $ipaddress = $_SERVER['HTTP_CLIENT_IP']; - else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) + } elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; - else if(isset($_SERVER['HTTP_X_FORWARDED'])) + } elseif (isset($_SERVER['HTTP_X_FORWARDED'])) { $ipaddress = $_SERVER['HTTP_X_FORWARDED']; - else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) + } elseif (isset($_SERVER['HTTP_FORWARDED_FOR'])) { $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; - else if(isset($_SERVER['HTTP_FORWARDED'])) + } elseif (isset($_SERVER['HTTP_FORWARDED'])) { $ipaddress = $_SERVER['HTTP_FORWARDED']; - else if(isset($_SERVER['REMOTE_ADDR'])) + } elseif (isset($_SERVER['REMOTE_ADDR'])) { $ipaddress = $_SERVER['REMOTE_ADDR']; - else + } else { $ipaddress = 'UNKNOWN'; + } return $ipaddress; } }