diff options
author | 2022-07-01 15:10:30 +0200 | |
---|---|---|
committer | 2022-07-01 15:10:30 +0200 | |
commit | 4f75591060d95208a301bc6bf460d875631b29cc (patch) | |
tree | 4e37d86840e8d990a563ba75d3de6f84a53cc2de /bridges/UsenixBridge.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/UsenixBridge.php')
-rw-r--r-- | bridges/UsenixBridge.php | 109 |
1 files changed, 55 insertions, 54 deletions
diff --git a/bridges/UsenixBridge.php b/bridges/UsenixBridge.php index 4f785a0e..659f012d 100644 --- a/bridges/UsenixBridge.php +++ b/bridges/UsenixBridge.php @@ -1,68 +1,69 @@ <?php + declare(strict_types=1); final class UsenixBridge extends BridgeAbstract { - const NAME = 'USENIX'; - const URI = 'https://www.usenix.org/publications'; - const DESCRIPTION = 'Digital publications from USENIX (usenix.org)'; - const MAINTAINER = 'dvikan'; - const PARAMETERS = [ - 'USENIX ;login:' => [ - ], - ]; + const NAME = 'USENIX'; + const URI = 'https://www.usenix.org/publications'; + const DESCRIPTION = 'Digital publications from USENIX (usenix.org)'; + const MAINTAINER = 'dvikan'; + const PARAMETERS = [ + 'USENIX ;login:' => [ + ], + ]; - public function collectData() - { - if ($this->queriedContext === 'USENIX ;login:') { - $this->collectLoginOnlineItems(); - return; - } - returnClientError('Illegal Context'); - } + public function collectData() + { + if ($this->queriedContext === 'USENIX ;login:') { + $this->collectLoginOnlineItems(); + return; + } + returnClientError('Illegal Context'); + } - private function collectLoginOnlineItems(): void - { - $url = 'https://www.usenix.org/publications/loginonline'; - $dom = getSimpleHTMLDOMCached($url); - $items = $dom->find('div.view-content > div'); + private function collectLoginOnlineItems(): void + { + $url = 'https://www.usenix.org/publications/loginonline'; + $dom = getSimpleHTMLDOMCached($url); + $items = $dom->find('div.view-content > div'); - foreach ($items as $item) { - $title = $item->find('.views-field-title > span', 0); - $author = $item->find('.views-field-pseudo-author-list > span.field-content', 0); - $relativeUrl = $item->find('.views-field-nothing-1 > span > a', 0); - $uri = sprintf('https://www.usenix.org%s', $relativeUrl->href); - // June 2, 2022 - $createdAt = $item->find('div.views-field-field-lv2-publication-date > div > span', 0); + foreach ($items as $item) { + $title = $item->find('.views-field-title > span', 0); + $author = $item->find('.views-field-pseudo-author-list > span.field-content', 0); + $relativeUrl = $item->find('.views-field-nothing-1 > span > a', 0); + $uri = sprintf('https://www.usenix.org%s', $relativeUrl->href); + // June 2, 2022 + $createdAt = $item->find('div.views-field-field-lv2-publication-date > div > span', 0); - $item = [ - 'title' => $title->innertext, - 'author' => strstr($author->plaintext, ',', true) ?: $author->plaintext, - 'uri' => $uri, - 'timestamp' => $createdAt->innertext, - ]; + $item = [ + 'title' => $title->innertext, + 'author' => strstr($author->plaintext, ',', true) ?: $author->plaintext, + 'uri' => $uri, + 'timestamp' => $createdAt->innertext, + ]; - $this->items[] = array_merge($item, $this->getItemContent($uri)); - } - } + $this->items[] = array_merge($item, $this->getItemContent($uri)); + } + } - private function getItemContent(string $uri) : array - { - $html = getSimpleHTMLDOMCached($uri); - $content = $html->find('.paragraphs-items-full', 0)->innertext; - $extra = $html->find('fieldset', 0); - if (!empty($extra)) { - $content .= $extra->innertext; - } + private function getItemContent(string $uri): array + { + $html = getSimpleHTMLDOMCached($uri); + $content = $html->find('.paragraphs-items-full', 0)->innertext; + $extra = $html->find('fieldset', 0); + if (!empty($extra)) { + $content .= $extra->innertext; + } - $tags = []; - foreach($html->find('.field-name-field-lv2-tags div.field-item') as $tag) { - $tags[] = $tag->plaintext; - } + $tags = []; + foreach ($html->find('.field-name-field-lv2-tags div.field-item') as $tag) { + $tags[] = $tag->plaintext; + } - return [ - 'content' => $content, - 'categories' => $tags - ]; - } + return [ + 'content' => $content, + 'categories' => $tags + ]; + } } |