From 8b2c45c75c881d0f33db659775bc57dcc136801c Mon Sep 17 00:00:00 2001 From: Doug Miller Date: Fri, 21 Feb 2020 16:40:45 -0600 Subject: [PATCH] Fixing phpcs complaints --- lib/recurly/base_client.php | 6 +++--- lib/recurly/http_adapter.php | 31 ++++++++++++++++++------------- lib/recurly/recurly_traits.php | 14 +++++++++++++- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lib/recurly/base_client.php b/lib/recurly/base_client.php index 6562e723..78d0dabe 100644 --- a/lib/recurly/base_client.php +++ b/lib/recurly/base_client.php @@ -8,7 +8,7 @@ abstract class BaseClient private $_baseUrl = 'https://v3.recurly.com'; private $_api_key; - protected $_http; + protected $http; /** * Constructor @@ -18,7 +18,7 @@ abstract class BaseClient public function __construct(string $api_key) { $this->_api_key = $api_key; - $this->_http = new HttpAdapter; + $this->http = new HttpAdapter; } /** @@ -61,7 +61,7 @@ private function _getResponse(string $method, string $path, ?array $body = [], ? $request = new \Recurly\Request($method, $path, $body, $params); $url = $this->_buildPath($path, $params); - list($result, $response_header) = $this->_http->execute($method, $url, $body, $this->_headers()); + list($result, $response_header) = $this->http->execute($method, $url, $body, $this->_headers()); // TODO: The $request should be added to the $response $response = new \Recurly\Response($result); diff --git a/lib/recurly/http_adapter.php b/lib/recurly/http_adapter.php index 4ec87411..ae7c9480 100644 --- a/lib/recurly/http_adapter.php +++ b/lib/recurly/http_adapter.php @@ -1,13 +1,13 @@ $method, 'content' => $body, - ]); + ] + ); $headers_str = ""; - foreach ($headers as $k => $v) - { + foreach ($headers as $k => $v) { $headers_str .= "$k: $v\r\n"; } $options['header'] = $headers_str; diff --git a/lib/recurly/recurly_traits.php b/lib/recurly/recurly_traits.php index bf4770df..4e5f00bd 100644 --- a/lib/recurly/recurly_traits.php +++ b/lib/recurly/recurly_traits.php @@ -4,13 +4,25 @@ trait RecurlyTraits { + /** + * Generates User-Agent for API requests + * + * @return string Recurly client User-Agent string + */ protected static function getUserAgent(): string { $php_version = phpversion(); return "Recurly/" . \Recurly\Version::CURRENT . "; php " . $php_version; } - protected static function encodeApiKey($key): string + /** + * Base64 encodes the API key + * + * @param string $key The API key to encode + * + * @return string base64 encoded API key + */ + protected static function encodeApiKey(string $key): string { return base64_encode($key); }