rss-bridge/bridges/NotAlwaysBridge.php
Jan Tojnar 951092eef3
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer

$ echo >.php-cs-fixer.dist.php "<?php

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__);

$rules = [
    '@PSR12' => true,
    // '@PSR12:risky' => true,
    '@PHP74Migration' => true,
    // '@PHP74Migration:risky' => true,
    // buggy, duplicates existing comment sometimes
    'no_break_comment' => false,
    'array_syntax' => true,
    'lowercase_static_reference' => true,
    'visibility_required' => false,
    // Too much noise
    'binary_operator_spaces' => false,
    'heredoc_indentation' => false,
    'trailing_comma_in_multiline' => false,
];

$config = new PhpCsFixer\Config();

return $config
    ->setRules($rules)
    // ->setRiskyAllowed(true)
    ->setFinder($finder);

"

$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.1.7

$ vendor/bin/php-cs-fixer fix
$ rm .php-cs-fixer.cache
$ vendor/bin/php-cs-fixer fix
2022-07-08 13:00:52 +02:00

64 lines
1.9 KiB
PHP

<?php
class NotAlwaysBridge extends BridgeAbstract
{
const MAINTAINER = 'mozes';
const NAME = 'Not Always family Bridge';
const URI = 'https://notalwaysright.com/';
const DESCRIPTION = 'Returns the latest stories';
const CACHE_TIMEOUT = 1800; // 30 minutes
const PARAMETERS = [ [
'filter' => [
'type' => 'list',
'name' => 'Filter',
'values' => [
'All' => '',
'Right' => 'right',
'Working' => 'working',
'Romantic' => 'romantic',
'Related' => 'related',
'Learning' => 'learning',
'Friendly' => 'friendly',
'Hopeless' => 'hopeless',
'Unfiltered' => 'unfiltered'
]
]
]];
public function getIcon()
{
return self::URI . 'favicon_nar.png';
}
public function collectData()
{
$html = getSimpleHTMLDOM($this->getURI());
foreach ($html->find('.post') as $post) {
#print_r($post);
$item = [];
$item['uri'] = $post->find('h1', 0)->find('a', 0)->href;
$item['content'] = $post;
$item['title'] = $post->find('h1', 0)->find('a', 0)->innertext;
$this->items[] = $item;
}
}
public function getName()
{
if (!is_null($this->getInput('filter'))) {
return $this->getInput('filter') . ' - NotAlways Bridge';
}
return parent::getName();
}
public function getURI()
{
if (!is_null($this->getInput('filter'))) {
return self::URI . $this->getInput('filter') . '/';
}
return parent::getURI();
}
}