rss-bridge/bridges/NFLRUSBridge.php
Jan Tojnar 19ad2584da
[NFLRUSBridge] Remove byte-order-mark (#2777)
With UTF-8 byte-order mark in the file, the `ListActionTest::testOutput`
would fail after converting tests to PSR-4 namespaces:

    invalid JSON output: Syntax error
    Failed asserting that null is not null.

This is because ListAction::execute tries to create the bridge objects
and, when the files containing the bridge classes are not loaded yet,
the autoloader starts including them. Since this happens after output
buffering has begun, any text in the PHP file before the `<?php` tag
such as the BOM will end up in the buffer to be parsed by `json_decode`.

Previously, it worked by chance thanks to some other test including the file
before `ListActionTest`. With the restructuring, `Actions\ListActionTest`
will run sooner and become responsible for triggering the autoloader.

To prevent this in the future, I also disallowed BOM in the coding style.
2022-06-07 04:59:22 +02:00

27 lines
670 B
PHP

<?php
class NFLRUSBridge extends BridgeAbstract {
const NAME = 'NFLRUS';
const URI = 'http://nflrus.ru/';
const DESCRIPTION = 'Returns the recent articles published on nflrus.ru';
const MAINTAINER = 'Maxim Shpak';
public function collectData() {
$html = getSimpleHTMLDOM(self::URI);
$html = defaultLinkTo($html, self::URI);
$articles = $html->find('.big-post_content-col');
foreach($articles as $article) {
$item = array();
$url = $article->find('.big-post_title.card-title a', 0);
$item['uri'] = $url->href;
$item['title'] = $url->plaintext;
$item['content'] = $article->find('div', 0)->innertext;
$this->items[] = $item;
}
}
}