diff --git a/lib/PayPal/Cache/AuthorizationCache.php b/lib/PayPal/Cache/AuthorizationCache.php index 46e86fd..83910d3 100644 --- a/lib/PayPal/Cache/AuthorizationCache.php +++ b/lib/PayPal/Cache/AuthorizationCache.php @@ -20,7 +20,9 @@ abstract class AuthorizationCache public static function pull($config = null, $clientId = null) { // Return if not enabled - if (!self::isEnabled($config)) { return null; } + if (!self::isEnabled($config)) { + return null; + } $tokens = null; $cachePath = self::cachePath($config); @@ -32,7 +34,7 @@ abstract class AuthorizationCache if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) { // If client Id is found, just send in that data only return $tokens[$clientId]; - } else if ($clientId) { + } elseif ($clientId) { // If client Id is provided, but no key in persisted data found matching it. return null; } @@ -54,7 +56,9 @@ abstract class AuthorizationCache public static function push($config = null, $clientId, $accessToken, $tokenCreateTime, $tokenExpiresIn) { // Return if not enabled - if (!self::isEnabled($config)) { return; } + if (!self::isEnabled($config)) { + return; + } $cachePath = self::cachePath($config); if (!is_dir(dirname($cachePath))) { @@ -74,7 +78,7 @@ abstract class AuthorizationCache 'tokenExpiresIn' => $tokenExpiresIn ); } - if(!file_put_contents($cachePath, json_encode($tokens))) { + if (!file_put_contents($cachePath, json_encode($tokens))) { throw new \Exception("Failed to write cache"); }; } @@ -116,6 +120,4 @@ abstract class AuthorizationCache $config = ($config && is_array($config)) ? $config : PayPalConfigManager::getInstance()->getConfigHashmap(); return (array_key_exists($key, $config)) ? trim($config[$key]) : null; } - - } diff --git a/lib/PayPal/Common/PayPalModel.php b/lib/PayPal/Common/PayPalModel.php index fdfaba8..78734ef 100644 --- a/lib/PayPal/Common/PayPalModel.php +++ b/lib/PayPal/Common/PayPalModel.php @@ -1,6 +1,7 @@ $v) { if ($v instanceof PayPalModel) { $ret[$k] = $v->toArray(); - } else if (sizeof($v) <= 0 && is_array($v)) { + } elseif (sizeof($v) <= 0 && is_array($v)) { $ret[$k] = array(); - } else if (is_array($v)) { + } elseif (is_array($v)) { $ret[$k] = $this->_convertToArray($v); } else { $ret[$k] = $v; @@ -204,9 +207,9 @@ class PayPalModel // If the value is an array, it means, it is an object after conversion if (is_array($v)) { // Determine the class of the object - if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null){ + if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) { // If the value is an associative array, it means, its an object. Just make recursive call to it. - if (empty($v)){ + if (empty($v)) { if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) { // It means, it is an array of objects. $this->assignValue($k, array()); diff --git a/lib/PayPal/Common/PayPalResourceModel.php b/lib/PayPal/Common/PayPalResourceModel.php index 18ddb38..927a379 100644 --- a/lib/PayPal/Common/PayPalResourceModel.php +++ b/lib/PayPal/Common/PayPalResourceModel.php @@ -115,4 +115,4 @@ class PayPalResourceModel extends PayPalModel implements IResource $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); $apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken); } -} +} diff --git a/lib/PayPal/Common/PayPalUserAgent.php b/lib/PayPal/Common/PayPalUserAgent.php index d072b2f..c3131ed 100644 --- a/lib/PayPal/Common/PayPalUserAgent.php +++ b/lib/PayPal/Common/PayPalUserAgent.php @@ -21,7 +21,6 @@ class PayPalUserAgent */ public static function getValue($sdkName, $sdkVersion) { - $featureList = array( 'platform-ver=' . PHP_VERSION, 'bit=' . self::_getPHPBit(), diff --git a/lib/PayPal/Common/ReflectionUtil.php b/lib/PayPal/Common/ReflectionUtil.php index 0b92a5c..f7b397a 100644 --- a/lib/PayPal/Common/ReflectionUtil.php +++ b/lib/PayPal/Common/ReflectionUtil.php @@ -1,6 +1,7 @@ getDocComment(), $annots, @@ -120,7 +121,7 @@ class ReflectionUtil return null; } foreach ($annots[1] as $i => $annot) { - $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)"); + $annotations[strtolower($annot)] = empty($annots[2][$i]) ? true : rtrim($annots[2][$i], " \t\n\r)"); } return $annotations; diff --git a/lib/PayPal/Converter/FormatConverter.php b/lib/PayPal/Converter/FormatConverter.php index e564742..a237766 100644 --- a/lib/PayPal/Converter/FormatConverter.php +++ b/lib/PayPal/Converter/FormatConverter.php @@ -53,7 +53,7 @@ class FormatConverter throw new \InvalidArgumentException("value cannot have decimals for $currency currency"); } $decimals = $currencyDecimals[$currency]; - } else if (strpos($value, ".") === false) { + } elseif (strpos($value, ".") === false) { // Check if value has decimal values. If not no need to assign 2 decimals with .00 at the end $decimals = 0; } diff --git a/lib/PayPal/Core/PayPalConfigManager.php b/lib/PayPal/Core/PayPalConfigManager.php index f884df4..a7ee1ca 100644 --- a/lib/PayPal/Core/PayPalConfigManager.php +++ b/lib/PayPal/Core/PayPalConfigManager.php @@ -95,7 +95,6 @@ class PayPalConfigManager */ public function get($searchKey) { - if (array_key_exists($searchKey, $this->configs)) { return $this->configs[$searchKey]; } else { @@ -108,7 +107,6 @@ class PayPalConfigManager return $arr; } - } /** @@ -123,7 +121,6 @@ class PayPalConfigManager */ public function getIniPrefix($userId = null) { - if ($userId == null) { $arr = array(); foreach ($this->configs as $key => $value) { @@ -157,7 +154,4 @@ class PayPalConfigManager { trigger_error('Clone is not allowed.', E_USER_ERROR); } - } - - diff --git a/lib/PayPal/Core/PayPalCredentialManager.php b/lib/PayPal/Core/PayPalCredentialManager.php index 77a884e..8f1edd6 100644 --- a/lib/PayPal/Core/PayPalCredentialManager.php +++ b/lib/PayPal/Core/PayPalCredentialManager.php @@ -113,7 +113,6 @@ class PayPalCredentialManager $suffix++; $key = $prefix . $suffix; } - } /** @@ -146,7 +145,7 @@ class PayPalCredentialManager { if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$this->defaultAccountName]; - } else if (array_key_exists($userId, $this->credentialHashmap)) { + } elseif (array_key_exists($userId, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$userId]; } @@ -164,5 +163,4 @@ class PayPalCredentialManager { trigger_error('Clone is not allowed.', E_USER_ERROR); } - } diff --git a/lib/PayPal/Core/PayPalHttpConfig.php b/lib/PayPal/Core/PayPalHttpConfig.php index 6bd4454..8a2b2a3 100644 --- a/lib/PayPal/Core/PayPalHttpConfig.php +++ b/lib/PayPal/Core/PayPalHttpConfig.php @@ -21,7 +21,7 @@ class PayPalHttpConfig public static $defaultCurlOptions = array( CURLOPT_SSLVERSION => 6, CURLOPT_CONNECTTIMEOUT => 10, - CURLOPT_RETURNTRANSFER => TRUE, + CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute CURLOPT_USERAGENT => 'PayPal-PHP-SDK', CURLOPT_HTTPHEADER => array(), diff --git a/lib/PayPal/Core/PayPalHttpConnection.php b/lib/PayPal/Core/PayPalHttpConnection.php index ea0dffd..7e809ec 100644 --- a/lib/PayPal/Core/PayPalHttpConnection.php +++ b/lib/PayPal/Core/PayPalHttpConnection.php @@ -55,7 +55,6 @@ class PayPalHttpConnection */ private function getHttpHeaders() { - $ret = array(); foreach ($this->httpConfig->getHeaders() as $k => $v) { $ret[] = "$k: $v"; @@ -78,8 +77,8 @@ class PayPalHttpConnection //Initialize Curl Options $ch = curl_init($this->httpConfig->getUrl()); $options = $this->httpConfig->getCurlOptions(); - if(empty($options[CURLOPT_HTTPHEADER])) { - unset ($options[CURLOPT_HTTPHEADER]); + if (empty($options[CURLOPT_HTTPHEADER])) { + unset($options[CURLOPT_HTTPHEADER]); } curl_setopt_array($ch, $options); curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl()); @@ -101,7 +100,7 @@ class PayPalHttpConnection } //Default Option if Method not of given types in switch case - if ($this->httpConfig->getMethod() != NULL) { + if ($this->httpConfig->getMethod() != null) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod()); } @@ -174,14 +173,14 @@ class PayPalHttpConnection "Retried $retries times." . $result); $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n"); throw $ex; - } else if ($httpStatus < 200 || $httpStatus >= 300) { + } elseif ($httpStatus < 200 || $httpStatus >= 300) { $ex = new PayPalConnectionException( $this->httpConfig->getUrl(), "Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.", $httpStatus ); $ex->setData($result); - $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result ); + $this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result); $this->logger->debug("\n\n" . str_repeat('=', 128) . "\n"); throw $ex; } @@ -191,5 +190,4 @@ class PayPalHttpConnection //Return result object return $result; } - } diff --git a/lib/PayPal/Core/PayPalLoggingManager.php b/lib/PayPal/Core/PayPalLoggingManager.php index b9e5892..90521a8 100644 --- a/lib/PayPal/Core/PayPalLoggingManager.php +++ b/lib/PayPal/Core/PayPalLoggingManager.php @@ -116,5 +116,4 @@ class PayPalLoggingManager $this->logger->debug($message); } } - } diff --git a/lib/PayPal/Exception/PayPalInvalidCredentialException.php b/lib/PayPal/Exception/PayPalInvalidCredentialException.php index 2531f5b..09ad27a 100644 --- a/lib/PayPal/Exception/PayPalInvalidCredentialException.php +++ b/lib/PayPal/Exception/PayPalInvalidCredentialException.php @@ -32,5 +32,4 @@ class PayPalInvalidCredentialException extends \Exception . ': ' . $this->getMessage() . ''; return $errorMsg; } - } diff --git a/lib/PayPal/Exception/PayPalMissingCredentialException.php b/lib/PayPal/Exception/PayPalMissingCredentialException.php index 9fac996..6ace3b4 100644 --- a/lib/PayPal/Exception/PayPalMissingCredentialException.php +++ b/lib/PayPal/Exception/PayPalMissingCredentialException.php @@ -33,5 +33,4 @@ class PayPalMissingCredentialException extends \Exception return $errorMsg; } - } diff --git a/lib/PayPal/Handler/OauthHandler.php b/lib/PayPal/Handler/OauthHandler.php index f281eb0..5411508 100644 --- a/lib/PayPal/Handler/OauthHandler.php +++ b/lib/PayPal/Handler/OauthHandler.php @@ -78,9 +78,9 @@ class OauthHandler implements IPayPalHandler { if (isset($config['oauth.EndPoint'])) { $baseEndpoint = $config['oauth.EndPoint']; - } else if (isset($config['service.EndPoint'])) { + } elseif (isset($config['service.EndPoint'])) { $baseEndpoint = $config['service.EndPoint']; - } else if (isset($config['mode'])) { + } elseif (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': $baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT; diff --git a/lib/PayPal/Handler/RestHandler.php b/lib/PayPal/Handler/RestHandler.php index ad581d7..ec5298d 100644 --- a/lib/PayPal/Handler/RestHandler.php +++ b/lib/PayPal/Handler/RestHandler.php @@ -47,7 +47,6 @@ class RestHandler implements IPayPalHandler */ public function handle($httpConfig, $request, $options) { - $credential = $this->apiContext->getCredential(); $config = $this->apiContext->getConfig(); @@ -105,7 +104,7 @@ class RestHandler implements IPayPalHandler { if (isset($config['service.EndPoint'])) { return $config['service.EndPoint']; - } else if (isset($config['mode'])) { + } elseif (isset($config['mode'])) { switch (strtoupper($config['mode'])) { case 'SANDBOX': return PayPalConstants::REST_SANDBOX_ENDPOINT; diff --git a/lib/PayPal/Log/PayPalDefaultLogFactory.php b/lib/PayPal/Log/PayPalDefaultLogFactory.php index 1ac894f..3066810 100644 --- a/lib/PayPal/Log/PayPalDefaultLogFactory.php +++ b/lib/PayPal/Log/PayPalDefaultLogFactory.php @@ -23,4 +23,4 @@ class PayPalDefaultLogFactory implements PayPalLogFactory { return new PayPalLogger($className); } -} \ No newline at end of file +} diff --git a/lib/PayPal/Log/PayPalLogFactory.php b/lib/PayPal/Log/PayPalLogFactory.php index ef77318..986adf2 100644 --- a/lib/PayPal/Log/PayPalLogFactory.php +++ b/lib/PayPal/Log/PayPalLogFactory.php @@ -13,5 +13,4 @@ interface PayPalLogFactory * @return LoggerInterface instance of logger object implementing LoggerInterface */ public function getLogger($className); - -} \ No newline at end of file +} diff --git a/lib/PayPal/Log/PayPalLogger.php b/lib/PayPal/Log/PayPalLogger.php index 17cd229..ed7a80c 100644 --- a/lib/PayPal/Log/PayPalLogger.php +++ b/lib/PayPal/Log/PayPalLogger.php @@ -6,7 +6,6 @@ use PayPal\Core\PayPalConfigManager; use Psr\Log\AbstractLogger; use Psr\Log\LogLevel; - class PayPalLogger extends AbstractLogger { @@ -75,11 +74,11 @@ class PayPalLogger extends AbstractLogger public function log($level, $message, array $context = array()) { - if($this->isLoggingEnabled) { + if ($this->isLoggingEnabled) { // Checks if the message is at level below configured logging level if (array_search($level, $this->loggingLevels) <= array_search($this->loggingLevel, $this->loggingLevels)) { error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . " : " . strtoupper($level) . ": $message\n", 3, $this->loggerFile); } } } -} \ No newline at end of file +} diff --git a/lib/PayPal/Security/Cipher.php b/lib/PayPal/Security/Cipher.php index 3b7b5a8..f95f21b 100644 --- a/lib/PayPal/Security/Cipher.php +++ b/lib/PayPal/Security/Cipher.php @@ -18,7 +18,7 @@ class Cipher */ const IV_SIZE = 16; - function __construct($secretKey) + public function __construct($secretKey) { $this->secretKey = $secretKey; } @@ -29,7 +29,7 @@ class Cipher * @param $input * @return string */ - function encrypt($input) + public function encrypt($input) { // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it. $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE); @@ -45,7 +45,7 @@ class Cipher * @param $input * @return string */ - function decrypt($input) + public function decrypt($input) { // Decode the IV + data $input = base64_decode($input); diff --git a/lib/PayPal/Transport/PayPalRestCall.php b/lib/PayPal/Transport/PayPalRestCall.php index e80f5ec..f9edf03 100644 --- a/lib/PayPal/Transport/PayPalRestCall.php +++ b/lib/PayPal/Transport/PayPalRestCall.php @@ -52,7 +52,6 @@ class PayPalRestCall */ public function execute($handlers = array(), $path, $method, $data = '', $headers = array()) { - $config = $this->apiContext->getConfig(); $httpConfig = new PayPalHttpConfig(null, $method, $config); $headers = $headers ? $headers : array(); @@ -75,5 +74,4 @@ class PayPalRestCall return $response; } - } diff --git a/lib/PayPal/Validation/ArgumentValidator.php b/lib/PayPal/Validation/ArgumentValidator.php index 5f2d3bf..29e7fa3 100644 --- a/lib/PayPal/Validation/ArgumentValidator.php +++ b/lib/PayPal/Validation/ArgumentValidator.php @@ -23,7 +23,7 @@ class ArgumentValidator if ($argument === null) { // Error if Object Null throw new \InvalidArgumentException("$argumentName cannot be null"); - } else if (gettype($argument) == 'string' && trim($argument) == ''){ + } elseif (gettype($argument) == 'string' && trim($argument) == '') { // Error if String Empty throw new \InvalidArgumentException("$argumentName string cannot be empty"); } diff --git a/lib/PayPal/Validation/JsonValidator.php b/lib/PayPal/Validation/JsonValidator.php index 1159237..5522ff2 100644 --- a/lib/PayPal/Validation/JsonValidator.php +++ b/lib/PayPal/Validation/JsonValidator.php @@ -32,4 +32,4 @@ class JsonValidator } return true; } -} +} diff --git a/lib/PayPal/Validation/NumericValidator.php b/lib/PayPal/Validation/NumericValidator.php index 6744528..62fa560 100644 --- a/lib/PayPal/Validation/NumericValidator.php +++ b/lib/PayPal/Validation/NumericValidator.php @@ -21,7 +21,6 @@ class NumericValidator { if (trim($argument) != null && !is_numeric($argument)) { throw new \InvalidArgumentException("$argumentName is not a valid numeric value"); - } return true; } diff --git a/lib/PayPal/Validation/UrlValidator.php b/lib/PayPal/Validation/UrlValidator.php index ffd195c..1b423f2 100644 --- a/lib/PayPal/Validation/UrlValidator.php +++ b/lib/PayPal/Validation/UrlValidator.php @@ -23,4 +23,4 @@ class UrlValidator throw new \InvalidArgumentException("$urlName is not a fully qualified URL"); } } -} \ No newline at end of file +}