diff options
author | 2022-07-01 15:10:30 +0200 | |
---|---|---|
committer | 2022-07-01 15:10:30 +0200 | |
commit | 4f75591060d95208a301bc6bf460d875631b29cc (patch) | |
tree | 4e37d86840e8d990a563ba75d3de6f84a53cc2de /bridges/PhoronixBridge.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/PhoronixBridge.php')
-rw-r--r-- | bridges/PhoronixBridge.php | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/bridges/PhoronixBridge.php b/bridges/PhoronixBridge.php index 76d35f5d..620fda66 100644 --- a/bridges/PhoronixBridge.php +++ b/bridges/PhoronixBridge.php @@ -1,65 +1,69 @@ <?php -class PhoronixBridge extends FeedExpander { - const MAINTAINER = 'IceWreck'; - const NAME = 'Phoronix Bridge'; - const URI = 'https://www.phoronix.com'; - const CACHE_TIMEOUT = 3600; - const DESCRIPTION = 'RSS feed for Linux news website Phoronix'; - const PARAMETERS = array(array( - 'n' => array( - 'name' => 'Limit', - 'type' => 'number', - 'required' => false, - 'title' => 'Maximum number of items to return', - 'defaultValue' => 10 - ), - 'svgAsImg' => array( - 'name' => 'SVG in "image" tag', - 'type' => 'checkbox', - 'title' => 'Some benchmarks are exported as SVG with "object" tag, +class PhoronixBridge extends FeedExpander +{ + const MAINTAINER = 'IceWreck'; + const NAME = 'Phoronix Bridge'; + const URI = 'https://www.phoronix.com'; + const CACHE_TIMEOUT = 3600; + const DESCRIPTION = 'RSS feed for Linux news website Phoronix'; + const PARAMETERS = [[ + 'n' => [ + 'name' => 'Limit', + 'type' => 'number', + 'required' => false, + 'title' => 'Maximum number of items to return', + 'defaultValue' => 10 + ], + 'svgAsImg' => [ + 'name' => 'SVG in "image" tag', + 'type' => 'checkbox', + 'title' => 'Some benchmarks are exported as SVG with "object" tag, but some RSS readers don\'t support this. "img" tag are supported by most browsers', - 'defaultValue' => false - ), - )); + 'defaultValue' => false + ], + ]]; - public function collectData(){ - $this->collectExpandableDatas('https://www.phoronix.com/rss.php', $this->getInput('n')); - } + public function collectData() + { + $this->collectExpandableDatas('https://www.phoronix.com/rss.php', $this->getInput('n')); + } - protected function parseItem($newsItem){ - $item = parent::parseItem($newsItem); - // $articlePage gets the entire page's contents - $articlePage = getSimpleHTMLDOM($newsItem->link); - $articlePage = defaultLinkTo($articlePage, $this->getURI()); - // Extract final link. From Facebook's like plugin. - parse_str(parse_url($articlePage->find('iframe[src^=//www.facebook.com/plugins]', 0), PHP_URL_QUERY), $facebookQuery); - if (array_key_exists('href', $facebookQuery)) { - $newsItem->link = $facebookQuery['href']; - } - $item['content'] = $this->extractContent($articlePage); + protected function parseItem($newsItem) + { + $item = parent::parseItem($newsItem); + // $articlePage gets the entire page's contents + $articlePage = getSimpleHTMLDOM($newsItem->link); + $articlePage = defaultLinkTo($articlePage, $this->getURI()); + // Extract final link. From Facebook's like plugin. + parse_str(parse_url($articlePage->find('iframe[src^=//www.facebook.com/plugins]', 0), PHP_URL_QUERY), $facebookQuery); + if (array_key_exists('href', $facebookQuery)) { + $newsItem->link = $facebookQuery['href']; + } + $item['content'] = $this->extractContent($articlePage); - $pages = $articlePage->find('.pagination a[!title]'); - foreach ($pages as $page) { - $pageURI = urljoin($newsItem->link, html_entity_decode($page->href)); - $page = getSimpleHTMLDOM($pageURI); - $item['content'] .= $this->extractContent($page); - } - return $item; - } + $pages = $articlePage->find('.pagination a[!title]'); + foreach ($pages as $page) { + $pageURI = urljoin($newsItem->link, html_entity_decode($page->href)); + $page = getSimpleHTMLDOM($pageURI); + $item['content'] .= $this->extractContent($page); + } + return $item; + } - private function extractContent($page){ - $content = $page->find('.content', 0); - $objects = $content->find('script[src^=//openbenchmarking.org]'); - foreach ($objects as $object) { - $objectSrc = preg_replace('/p=0/', 'p=2', $object->src); - if ($this->getInput('svgAsImg')) { - $object->outertext = '<a href="' . $objectSrc . '"><img src="' . $objectSrc . '"/></a>'; - } else { - $object->outertext = '<object data="' . $objectSrc . '" type="image/svg+xml"></object>'; - } - } - $content = stripWithDelimiters($content, '<script', '</script>'); - return $content; - } + private function extractContent($page) + { + $content = $page->find('.content', 0); + $objects = $content->find('script[src^=//openbenchmarking.org]'); + foreach ($objects as $object) { + $objectSrc = preg_replace('/p=0/', 'p=2', $object->src); + if ($this->getInput('svgAsImg')) { + $object->outertext = '<a href="' . $objectSrc . '"><img src="' . $objectSrc . '"/></a>'; + } else { + $object->outertext = '<object data="' . $objectSrc . '" type="image/svg+xml"></object>'; + } + } + $content = stripWithDelimiters($content, '<script', '</script>'); + return $content; + } } |