diff options
author | 2022-07-01 15:10:30 +0200 | |
---|---|---|
committer | 2022-07-01 15:10:30 +0200 | |
commit | 4f75591060d95208a301bc6bf460d875631b29cc (patch) | |
tree | 4e37d86840e8d990a563ba75d3de6f84a53cc2de /bridges/HardwareInfoBridge.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/HardwareInfoBridge.php')
-rw-r--r-- | bridges/HardwareInfoBridge.php | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/bridges/HardwareInfoBridge.php b/bridges/HardwareInfoBridge.php index ae79e0fd..e295984c 100644 --- a/bridges/HardwareInfoBridge.php +++ b/bridges/HardwareInfoBridge.php @@ -1,66 +1,67 @@ <?php + class HardwareInfoBridge extends FeedExpander { - const NAME = 'Hardware Info Bridge'; - const URI = 'https://nl.hardware.info/'; - const DESCRIPTION = 'Tech news from hardware.info (Dutch)'; - const MAINTAINER = 't0stiman'; - - public function collectData() - { - $this->collectExpandableDatas('https://nl.hardware.info/updates/all.rss', 20); - } - - protected function parseItem($feedItem) - { - $item = parent::parseItem($feedItem); + const NAME = 'Hardware Info Bridge'; + const URI = 'https://nl.hardware.info/'; + const DESCRIPTION = 'Tech news from hardware.info (Dutch)'; + const MAINTAINER = 't0stiman'; - //get full article - $articlePage = getSimpleHTMLDOMCached($feedItem->link); + public function collectData() + { + $this->collectExpandableDatas('https://nl.hardware.info/updates/all.rss', 20); + } - $article = $articlePage->find('div.article__content', 0); + protected function parseItem($feedItem) + { + $item = parent::parseItem($feedItem); - //everything under the social bar is not part of the article, remove it - $reachedEndOfArticle = false; + //get full article + $articlePage = getSimpleHTMLDOMCached($feedItem->link); - foreach($article->find('*') as $child) { + $article = $articlePage->find('div.article__content', 0); - if(!$reachedEndOfArticle && isset($child->attr['class']) - && $child->attr['class'] == 'article__content__social-bar') { - $reachedEndOfArticle = true; - } + //everything under the social bar is not part of the article, remove it + $reachedEndOfArticle = false; - if($reachedEndOfArticle) { - $child->outertext = ''; - } - } + foreach ($article->find('*') as $child) { + if ( + !$reachedEndOfArticle && isset($child->attr['class']) + && $child->attr['class'] == 'article__content__social-bar' + ) { + $reachedEndOfArticle = true; + } - //get rid of some more elements we don't need - $to_remove_selectors = array( - 'script', - 'div.incontent', - 'div.article__content__social-bar', - 'div#revealNewsTip', - 'div.article__previous_next' - ); + if ($reachedEndOfArticle) { + $child->outertext = ''; + } + } - foreach($to_remove_selectors as $selector) { - foreach($article->find($selector) as $found) { - $found->outertext = ''; - } - } + //get rid of some more elements we don't need + $to_remove_selectors = [ + 'script', + 'div.incontent', + 'div.article__content__social-bar', + 'div#revealNewsTip', + 'div.article__previous_next' + ]; - // convert iframes to links. meant for embedded YouTube videos. - foreach($article->find('iframe') as $found) { + foreach ($to_remove_selectors as $selector) { + foreach ($article->find($selector) as $found) { + $found->outertext = ''; + } + } - $iframeUrl = $found->getAttribute('src'); + // convert iframes to links. meant for embedded YouTube videos. + foreach ($article->find('iframe') as $found) { + $iframeUrl = $found->getAttribute('src'); - if ($iframeUrl) { - $found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>'; - } - } + if ($iframeUrl) { + $found->outertext = '<a href="' . $iframeUrl . '">' . $iframeUrl . '</a>'; + } + } - $item['content'] = $article; - return $item; - } + $item['content'] = $article; + return $item; + } } |