diff options
author | 2022-07-01 15:10:30 +0200 | |
---|---|---|
committer | 2022-07-01 15:10:30 +0200 | |
commit | 4f75591060d95208a301bc6bf460d875631b29cc (patch) | |
tree | 4e37d86840e8d990a563ba75d3de6f84a53cc2de /bridges/HashnodeBridge.php | |
parent | 66568e3a39c61546c09a47a5688914a0bdf3c60c (diff) | |
download | rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.tar.gz rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.tar.zst rss-bridge-4f75591060d95208a301bc6bf460d875631b29cc.zip |
Reformat codebase v4 (#2872)
Reformat code base to PSR12
Co-authored-by: rssbridge <noreply@github.com>
Diffstat (limited to 'bridges/HashnodeBridge.php')
-rw-r--r-- | bridges/HashnodeBridge.php | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/bridges/HashnodeBridge.php b/bridges/HashnodeBridge.php index 159510fb..ccfea547 100644 --- a/bridges/HashnodeBridge.php +++ b/bridges/HashnodeBridge.php @@ -1,46 +1,48 @@ <?php -class HashnodeBridge extends BridgeAbstract { +class HashnodeBridge extends BridgeAbstract +{ + const MAINTAINER = 'liamka'; + const NAME = 'Hashnode'; + const URI = 'https://hashnode.com'; + const CACHE_TIMEOUT = 3600; // 1hr + const DESCRIPTION = 'See trending or latest posts in Hashnode community.'; + const LATEST_POSTS = 'https://hashnode.com/api/stories/recent?page='; - const MAINTAINER = 'liamka'; - const NAME = 'Hashnode'; - const URI = 'https://hashnode.com'; - const CACHE_TIMEOUT = 3600; // 1hr - const DESCRIPTION = 'See trending or latest posts in Hashnode community.'; - const LATEST_POSTS = 'https://hashnode.com/api/stories/recent?page='; + public function collectData() + { + $this->items = []; + for ($i = 0; $i < 5; $i++) { + $url = self::LATEST_POSTS . $i; + $content = getContents($url); + $array = json_decode($content, true); - public function collectData(){ - $this->items = []; - for ($i = 0; $i < 5; $i++) { - $url = self::LATEST_POSTS . $i; - $content = getContents($url); - $array = json_decode($content, true); + if ($array['posts'] != null) { + foreach ($array['posts'] as $post) { + $item = []; + $item['title'] = $post['title']; + $item['content'] = nl2br(htmlspecialchars($post['brief'])); + $item['timestamp'] = $post['dateAdded']; + if ($post['partOfPublication'] === true) { + $item['uri'] = sprintf( + 'https://%s.hashnode.dev/%s', + $post['publication']['username'], + $post['slug'] + ); + } else { + $item['uri'] = sprintf('https://hashnode.com/post/%s', $post['slug']); + } + if (!isset($item['uri'])) { + continue; + } + $this->items[] = $item; + } + } + } + } - if($array['posts'] != null) { - foreach($array['posts'] as $post) { - $item = []; - $item['title'] = $post['title']; - $item['content'] = nl2br(htmlspecialchars($post['brief'])); - $item['timestamp'] = $post['dateAdded']; - if($post['partOfPublication'] === true) { - $item['uri'] = sprintf( - 'https://%s.hashnode.dev/%s', - $post['publication']['username'], - $post['slug'] - ); - } else { - $item['uri'] = sprintf('https://hashnode.com/post/%s', $post['slug']); - } - if(!isset($item['uri'])) { - continue; - } - $this->items[] = $item; - } - } - } - } - - public function getName(){ - return self::NAME . ': Recent posts'; - } + public function getName() + { + return self::NAME . ': Recent posts'; + } } |