From 4f75591060d95208a301bc6bf460d875631b29cc Mon Sep 17 00:00:00 2001 From: Dag Date: Fri, 1 Jul 2022 15:10:30 +0200 Subject: Reformat codebase v4 (#2872) Reformat code base to PSR12 Co-authored-by: rssbridge --- bridges/UnraidCommunityApplicationsBridge.php | 121 ++++++++++++++------------ 1 file changed, 66 insertions(+), 55 deletions(-) (limited to 'bridges/UnraidCommunityApplicationsBridge.php') diff --git a/bridges/UnraidCommunityApplicationsBridge.php b/bridges/UnraidCommunityApplicationsBridge.php index c2cb3ace..5acd5049 100644 --- a/bridges/UnraidCommunityApplicationsBridge.php +++ b/bridges/UnraidCommunityApplicationsBridge.php @@ -1,70 +1,81 @@ apps = getContents(self::APPSURI); - $this->apps = json_decode($this->apps, true)['applist']; - } + private $apps = []; - private function sortApps() { - Debug::log('Sorting applications/plugins'); - usort($this->apps, function($app1, $app2) { - return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1; - }); - } + private function fetchApps() + { + Debug::log('Fetching all applications/plugins'); + $this->apps = getContents(self::APPSURI); + $this->apps = json_decode($this->apps, true)['applist']; + } - public function collectData() { - $this->fetchApps(); - $this->sortApps(); + private function sortApps() + { + Debug::log('Sorting applications/plugins'); + usort($this->apps, function ($app1, $app2) { + return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1; + }); + } - Debug::log('Building RSS feed'); - foreach($this->apps as $app) { - if(!array_key_exists('Language', $app)) { - $item = array(); - $item['title'] = $app['Name']; - $item['timestamp'] = $app['FirstSeen']; - $item['author'] = explode('\'', $app['Repo'])[0]; - $item['categories'] = explode(' ', $app['Category']); - $item['content'] = ''; + public function collectData() + { + $this->fetchApps(); + $this->sortApps(); - if(array_key_exists('Icon', $app)) - $item['content'] .= ''; + Debug::log('Building RSS feed'); + foreach ($this->apps as $app) { + if (!array_key_exists('Language', $app)) { + $item = []; + $item['title'] = $app['Name']; + $item['timestamp'] = $app['FirstSeen']; + $item['author'] = explode('\'', $app['Repo'])[0]; + $item['categories'] = explode(' ', $app['Category']); + $item['content'] = ''; - if(array_key_exists('Overview', $app)) - $item['content'] .= '

' - . $app['Overview'] - . '

'; + if (array_key_exists('Icon', $app)) { + $item['content'] .= ''; + } - if(array_key_exists('Project', $app)) - $item['uri'] = $app['Project']; + if (array_key_exists('Overview', $app)) { + $item['content'] .= '

' + . $app['Overview'] + . '

'; + } - if(array_key_exists('Registry', $app)) - $item['content'] .= '
Docker Hub'; + if (array_key_exists('Project', $app)) { + $item['uri'] = $app['Project']; + } - if(array_key_exists('Support', $app)) - $item['content'] .= '
Support'; + if (array_key_exists('Registry', $app)) { + $item['content'] .= '
Docker Hub'; + } - $this->items[] = $item; + if (array_key_exists('Support', $app)) { + $item['content'] .= '
Support'; + } - if(count($this->items) >= 15) - break; - } - } - } + $this->items[] = $item; + + if (count($this->items) >= 15) { + break; + } + } + } + } } -- cgit v1.2.3