From eb5dc544bef9a9136e1214bf5f9679be8c29c734 Mon Sep 17 00:00:00 2001 From: Marco Rieger Date: Mon, 22 Dec 2014 17:15:47 +0100 Subject: [PATCH] changed methods return directly --- .../Service/RepositoryRetriever.php | 45 +++++-------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/module/Application/src/Application/Service/RepositoryRetriever.php b/module/Application/src/Application/Service/RepositoryRetriever.php index 2d3ccaff..0b50d7e1 100644 --- a/module/Application/src/Application/Service/RepositoryRetriever.php +++ b/module/Application/src/Application/Service/RepositoryRetriever.php @@ -23,51 +23,39 @@ public function __construct(Client $githubClient) /** * Return MetaData from User Repository - * * @param $user * @param $module - * @return bool|mixed + * @return array|null */ public function getUserRepositoryMetadata($user, $module) { - try { - $apiResponse = $this->githubClient->api('repos')->show($user, $module); - return json_decode($apiResponse); - } catch (RuntimeException $e) { - return false; - } + return json_decode($this->githubClient->api('repos')->show($user, $module)); } /** * Get all Repositories from GitHub User - * * @param $user * @param array $params + * @return RepositoryCollection */ public function getUserRepositories($user, $params = array()) { - $repositoryCollection = $this->githubClient->api('user')->repos($user, $params); - if ($repositoryCollection instanceof RepositoryCollection) { - foreach ($repositoryCollection as $repository) { - yield $repository; - } - } + return $this->githubClient->api('user')->repos($user, $params); } /** * Get File Content from User Repository - * * @param $user * @param $module * @param $filePath - * @return bool|string + * @return string|null */ public function getRepositoryFileContent($user, $module, $filePath) { $contentResponse = $this->getRepositoryFileMetadata($user, $module, $filePath); if (!isset($contentResponse->content)) { - return false; + return null; } return base64_decode($contentResponse->content); @@ -75,36 +63,23 @@ public function getRepositoryFileContent($user, $module, $filePath) /** * Return File MetaData from User Repository - * * @param $user * @param $module * @param $filePath - * @return bool|mixed + * @return mixed */ public function getRepositoryFileMetadata($user, $module, $filePath) { - try { - $apiResponse = $this->githubClient->api('repos')->content($user, $module, $filePath); - $apiResponse = json_decode($apiResponse); - return $apiResponse; - - } catch (RuntimeException $e) { - return false; - } + return json_decode($this->githubClient->api('repos')->content($user, $module, $filePath)); } /** * Return all Repositories from current authenticated GitHub User - * * @param array $params + * @return RepositoryCollection */ public function getAuthenticatedUserRepositories($params = array()) { - $repositoryCollection = $this->githubClient->api('current_user')->repos($params); - if ($repositoryCollection instanceof RepositoryCollection) { - foreach ($repositoryCollection as $repository) { - yield $repository; - } - } + return $this->githubClient->api('current_user')->repos($params); } }