From 794d594ca98c57a73758b7a8ca5fd985dcd96e00 Mon Sep 17 00:00:00 2001 From: Domingo Oropeza Date: Mon, 16 Oct 2017 14:12:00 -0400 Subject: [PATCH] refactor(endpoint): update code standards for EndPointHandler --- src/GlpiProject/API/Rest/EndPointHandler.php | 39 ++++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/GlpiProject/API/Rest/EndPointHandler.php b/src/GlpiProject/API/Rest/EndPointHandler.php index 7c1c0bc..8d1c357 100644 --- a/src/GlpiProject/API/Rest/EndPointHandler.php +++ b/src/GlpiProject/API/Rest/EndPointHandler.php @@ -4,9 +4,6 @@ namespace GlpiProject\API\Rest; - -use GlpiProject\API\Rest\Exception\InsufficientArgumentsException; - class EndPointHandler { @@ -25,7 +22,10 @@ public function __construct(Client $client) { */ public function getMyProfiles() { $response = $this->client->request('get', 'getMyProfiles'); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; } /** @@ -34,7 +34,10 @@ public function getMyProfiles() { */ public function getActiveProfile() { $response = $this->client->request('get', 'getActiveProfile'); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; } /** @@ -45,9 +48,12 @@ public function getActiveProfile() { * @return array */ public function changeActiveProfile($profiles_id) { - $options['body'] = json_encode(['profiles_id' => $profiles_id]); + $options['body'] = ['profiles_id' => $profiles_id]; $response = $this->client->request('post', 'changeActiveProfile', $options); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; } /** @@ -55,9 +61,12 @@ public function changeActiveProfile($profiles_id) { * @param array $options * @return array */ - public function getMyEntities(array $options = array()) { + public function getMyEntities(array $options = []) { $response = $this->client->request('get', 'getMyEntities', $options); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; } /** @@ -66,7 +75,10 @@ public function getMyEntities(array $options = array()) { */ public function getActiveEntities() { $response = $this->client->request('get', 'getActiveEntities'); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; } /** @@ -76,9 +88,12 @@ public function getActiveEntities() { * @param array $options * @return array */ - public function changeActiveEntities(array $options = array()) { + public function changeActiveEntities(array $options = []) { $response = $this->client->request('post', 'changeActiveEntities', $options); - return ['statusCode' => $response->getStatusCode(), 'body' => json_decode($response->getBody()->getContents())]; + return [ + 'statusCode' => $response->getStatusCode(), + 'body' => $response->getBody()->getContents(), + ]; }