From dfc3562844d0f58c86cb4afbe67d98514f506f46 Mon Sep 17 00:00:00 2001 From: root-nextdom-lxc Date: Thu, 27 Aug 2020 15:57:01 +0200 Subject: [PATCH] Little refacto and create constant --- src/Market/AlternativeMarketForJeedom.php | 3 +-- src/Market/GitManager.php | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Market/AlternativeMarketForJeedom.php b/src/Market/AlternativeMarketForJeedom.php index d670586eb..f08025e45 100644 --- a/src/Market/AlternativeMarketForJeedom.php +++ b/src/Market/AlternativeMarketForJeedom.php @@ -41,10 +41,9 @@ public static function cmpByOrder($obj1, $obj2) if ($obj1Order == $obj2Order) { $result = 0; } else { + $result = 1; if ($obj1Order < $obj2Order) { $result = -1; - } else { - $result = 1; } } return $result; diff --git a/src/Market/GitManager.php b/src/Market/GitManager.php index 8d4579f4a..0b30cec4b 100644 --- a/src/Market/GitManager.php +++ b/src/Market/GitManager.php @@ -42,7 +42,7 @@ class GitManager * * @var string */ - private $githubApiDomain = 'https://api.github.com'; + const GITHUB_API_DOMAIN = 'https://api.github.com'; /** * Constructeur du gestionnaire Git @@ -99,10 +99,10 @@ public function updateRepositoriesList() protected function downloadRepositoriesList() { $result = false; - $content = DownloadManager::downloadContent($this->githubApiDomain . '/orgs/' . $this->gitId . '/repos?per_page=100'); + $content = DownloadManager::downloadContent(self::GITHUB_API_DOMAIN . '/orgs/' . $this->gitId . '/repos?per_page=100'); // Limite de l'API GitHub atteinte if (strstr($content, 'API rate limit exceeded')) { - $content = DownloadManager::downloadContent($this->githubApiDomain . '/rate_limit'); + $content = DownloadManager::downloadContent(self::GITHUB_API_DOMAIN . '/rate_limit'); $gitHubLimitData = json_decode($content, true); $refreshDate = date('H:i', $gitHubLimitData['resources']['core']['reset']); throw new CoreException('Limite de l\'API GitHub atteinte. Le rafraichissement sera accessible à ' . $refreshDate); @@ -113,7 +113,7 @@ protected function downloadRepositoriesList() // Test si c'est un dépôt d'organisation if (strstr($content, '"message":"Not Found"')) { // Test d'un téléchargement pour un utilisateur - $content = DownloadManager::downloadContent($this->githubApiDomain . '/users/' . $this->gitId . '/repos?per_page=100'); + $content = DownloadManager::downloadContent(self::GITHUB_API_DOMAIN . '/users/' . $this->gitId . '/repos?per_page=100'); // Test si c'est un dépot d'utilisateur if (strstr($content, '"message":"Not Found"') || strlen($content) < 10) { throw new CoreException('Le dépôt ' . $this->gitId . ' n\'existe pas.');