aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2022-06-24 18:29:35 +0200
committerGravatar GitHub <noreply@github.com> 2022-06-24 18:29:35 +0200
commit5076d09de61c5b08fef8293b5452f158df1fa0ba (patch)
treea6b34c936c9583cdc56e0e6191dd573ef325fbf0
parentd2313bddccfbde49d8b97b78c3626d039493908c (diff)
downloadrss-bridge-5076d09de61c5b08fef8293b5452f158df1fa0ba.tar.gz
rss-bridge-5076d09de61c5b08fef8293b5452f158df1fa0ba.tar.zst
rss-bridge-5076d09de61c5b08fef8293b5452f158df1fa0ba.zip
refactor: prepare for PSR2 (#2859)
-rw-r--r--actions/DisplayAction.php4
-rw-r--r--bridges/BAEBridge.php8
-rw-r--r--bridges/CVEDetailsBridge.php10
-rw-r--r--bridges/FacebookBridge.php12
-rw-r--r--bridges/FeedExpanderExampleBridge.php6
-rw-r--r--bridges/FicbookBridge.php24
-rw-r--r--bridges/GiteaBridge.php56
-rw-r--r--bridges/GithubIssueBridge.php15
-rw-r--r--bridges/GogsBridge.php32
-rw-r--r--bridges/IPBBridge.php2
-rw-r--r--bridges/KernelBugTrackerBridge.php2
-rw-r--r--bridges/LWNprevBridge.php4
-rw-r--r--bridges/MoinMoinBridge.php1
-rw-r--r--bridges/NationalGeographicBridge.php23
-rw-r--r--bridges/PillowfortBridge.php12
-rw-r--r--bridges/RaceDepartmentBridge.php2
-rw-r--r--bridges/TwitterBridge.php4
-rw-r--r--bridges/TwitterV2Bridge.php3
-rw-r--r--index.php8
-rw-r--r--lib/ActionInterface.php2
-rw-r--r--lib/BridgeCard.php2
-rw-r--r--lib/BridgeList.php2
-rw-r--r--lib/FeedExpander.php48
-rw-r--r--lib/FeedItem.php4
24 files changed, 140 insertions, 146 deletions
diff --git a/actions/DisplayAction.php b/actions/DisplayAction.php
index cb0963a0..e7031dab 100644
--- a/actions/DisplayAction.php
+++ b/actions/DisplayAction.php
@@ -15,7 +15,7 @@ class DisplayAction implements ActionInterface
{
public $userData = [];
- private function get_return_code($error) {
+ private function getReturnCode($error) {
$returnCode = $error->getCode();
if ($returnCode === 301 || $returnCode === 302) {
# Don't pass redirect codes to the exterior
@@ -184,7 +184,7 @@ class DisplayAction implements ActionInterface
$items[] = $item;
} elseif(Configuration::getConfig('error', 'output') === 'http') {
- header('Content-Type: text/html', true, $this->get_return_code($e));
+ header('Content-Type: text/html', true, $this->getReturnCode($e));
die(buildTransformException($e, $bridge));
}
}
diff --git a/bridges/BAEBridge.php b/bridges/BAEBridge.php
index 6c5d8ba2..80c08362 100644
--- a/bridges/BAEBridge.php
+++ b/bridges/BAEBridge.php
@@ -43,10 +43,10 @@ class BAEBridge extends BridgeAbstract {
$content = $htmlDetail->find('article p', 0)->innertext;
if (!empty($this->getInput('keyword'))) {
- $keyword = $this->remove_accents(strtolower($this->getInput('keyword')));
- $cleanTitle = $this->remove_accents(strtolower($item['title']));
+ $keyword = $this->removeAccents(strtolower($this->getInput('keyword')));
+ $cleanTitle = $this->removeAccents(strtolower($item['title']));
if (strpos($cleanTitle, $keyword) === false) {
- $cleanContent = $this->remove_accents(strtolower($content));
+ $cleanContent = $this->removeAccents(strtolower($content));
if (strpos($cleanContent, $keyword) === false) {
continue;
}
@@ -79,7 +79,7 @@ class BAEBridge extends BridgeAbstract {
return $uri;
}
- private function remove_accents($string) {
+ private function removeAccents($string) {
$chars = array(
// Decompositions for Latin-1 Supplement
'ª' => 'a', 'º' => 'o',
diff --git a/bridges/CVEDetailsBridge.php b/bridges/CVEDetailsBridge.php
index 1d20abfb..18da49bd 100644
--- a/bridges/CVEDetailsBridge.php
+++ b/bridges/CVEDetailsBridge.php
@@ -39,7 +39,7 @@ class CVEDetailsBridge extends BridgeAbstract {
// Because of the optional product ID, we need to attach it if it is
// set. The search result page has the exact same structure (with and
// without the product ID).
- private function _buildURL() {
+ private function buildUrl() {
$url = self::URI . '/vulnerability-list/vendor_id-' . $this->getInput('vendor_id');
if ($this->getInput('product_id') !== '') {
$url .= '/product_id-' . $this->getInput('product_id');
@@ -54,8 +54,8 @@ class CVEDetailsBridge extends BridgeAbstract {
// Make the actual request to cvedetails.com and stores the response
// (HTML) for later use and extract vendor and product from it.
- private function _fetchContent() {
- $html = getSimpleHTMLDOM($this->_buildURL());
+ private function fetchContent() {
+ $html = getSimpleHTMLDOM($this->buildUrl());
$this->html = defaultLinkTo($html, self::URI);
$vendor = $html->find('#contentdiv > h1 > a', 0);
@@ -80,7 +80,7 @@ class CVEDetailsBridge extends BridgeAbstract {
}
if ($this->html == null) {
- $this->_fetchContent();
+ $this->fetchContent();
}
$name = 'CVE Vulnerabilities for ' . $this->vendor;
@@ -94,7 +94,7 @@ class CVEDetailsBridge extends BridgeAbstract {
// Pull the data from the HTML response and fill the items..
public function collectData() {
if ($this->html == null) {
- $this->_fetchContent();
+ $this->fetchContent();
}
foreach ($this->html->find('#vulnslisttable .srrowns') as $i => $tr) {
diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php
index 6d56fbae..e5cc6c34 100644
--- a/bridges/FacebookBridge.php
+++ b/bridges/FacebookBridge.php
@@ -395,7 +395,7 @@ class FacebookBridge extends BridgeAbstract {
/**
* Bypass external link redirection
*/
- private function unescape_fb_link($content){
+ private function unescapeFacebookLink($content){
return preg_replace_callback('/ href=\"([^"]+)\"/i', function($matches){
if(is_array($matches) && count($matches) > 1) {
@@ -413,7 +413,7 @@ class FacebookBridge extends BridgeAbstract {
/**
* Remove Facebook's tracking code
*/
- private function remove_tracking_codes($content){
+ private function removeTrackingCodes($content){
return preg_replace_callback('/ href=\"([^"]+)\"/i', function($matches){
if(is_array($matches) && count($matches) > 1) {
@@ -434,7 +434,7 @@ class FacebookBridge extends BridgeAbstract {
* Convert textual representation of emoticons back to ASCII emoticons.
* i.e. "<i><u>smile emoticon</u></i>" => ":)"
*/
- private function unescape_fb_emote($content){
+ private function unescapeFacebookEmote($content){
return preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', function($matches){
static $facebook_emoticons = array(
'smile' => ':)',
@@ -669,7 +669,7 @@ EOD;
// Remove html nodes, keep only img, links, basic formatting
$content = strip_tags($content, '<a><img><i><u><br><p>');
- $content = $this->unescape_fb_link($content);
+ $content = $this->unescapeFacebookLink($content);
// Clean useless html tag properties and fix link closing tags
foreach (array(
@@ -690,7 +690,7 @@ EOD;
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
- $this->unescape_fb_emote($content);
+ $this->unescapeFacebookEmote($content);
// Restore links in the post before further parsing
$post = defaultLinkTo($post, self::URI);
@@ -698,7 +698,7 @@ EOD;
// Restore links in the content before adding to the item
$content = defaultLinkTo($content, self::URI);
- $content = $this->remove_tracking_codes($content);
+ $content = $this->removeTrackingCodes($content);
// Retrieve date of the post
$date = $post->find('abbr')[0];
diff --git a/bridges/FeedExpanderExampleBridge.php b/bridges/FeedExpanderExampleBridge.php
index f5b83071..708d4c13 100644
--- a/bridges/FeedExpanderExampleBridge.php
+++ b/bridges/FeedExpanderExampleBridge.php
@@ -44,13 +44,13 @@ class FeedExpanderExampleBridge extends FeedExpander {
protected function parseItem($newsItem) {
switch($this->getInput('version')) {
case 'rss_0_9_1':
- return $this->parseRSS_0_9_1_Item($newsItem);
+ return $this->parseRss091Item($newsItem);
break;
case 'rss_1_0':
- return $this->parseRSS_1_0_Item($newsItem);
+ return $this->parseRss1Item($newsItem);
break;
case 'rss_2_0':
- return $this->parseRSS_2_0_Item($newsItem);
+ return $this->parseRss2Item($newsItem);
break;
case 'atom_1_0':
return $this->parseATOMItem($newsItem);
diff --git a/bridges/FicbookBridge.php b/bridges/FicbookBridge.php
index 6aef93b1..64cdb32d 100644
--- a/bridges/FicbookBridge.php
+++ b/bridges/FicbookBridge.php
@@ -39,36 +39,36 @@ class FicbookBridge extends BridgeAbstract {
public function getURI() {
switch($this->queriedContext) {
- case 'Site News': {
+ case 'Site News':
// For some reason this is not HTTPS
return 'http://ficbook.net/sitenews';
- }
- case 'Fiction Updates': {
+
+ case 'Fiction Updates':
return self::URI
. 'readfic/'
. urlencode($this->getInput('fiction_id'));
- }
- case 'Fiction Comments': {
+
+ case 'Fiction Comments':
return self::URI
. 'readfic/'
. urlencode($this->getInput('fiction_id'))
. '/comments#content';
- }
+
default: return parent::getURI();
}
}
public function getName() {
switch($this->queriedContext) {
- case 'Site News': {
+ case 'Site News':
return $this->queriedContext . ' | ' . self::NAME;
- }
- case 'Fiction Updates': {
+
+ case 'Fiction Updates':
return $this->titleName . ' | ' . self::NAME;
- }
- case 'Fiction Comments': {
+
+ case 'Fiction Comments':
return $this->titleName . ' | Comments | ' . self::NAME;
- }
+
default: return self::NAME;
}
}
diff --git a/bridges/GiteaBridge.php b/bridges/GiteaBridge.php
index 5b393d54..f7b7b782 100644
--- a/bridges/GiteaBridge.php
+++ b/bridges/GiteaBridge.php
@@ -98,48 +98,48 @@ class GiteaBridge extends BridgeAbstract {
public function getURI() {
switch($this->queriedContext) {
- case 'Commits': {
+ case 'Commits':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/commits/' . $this->getInput('branch');
- } break;
- case 'Issues': {
+
+ case 'Issues':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/issues/';
- } break;
- case 'Single issue': {
+
+ case 'Single issue':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/issues/' . $this->getInput('issue');
- } break;
- case 'Releases': {
+
+ case 'Releases':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/releases/';
- } break;
- case 'Tags': {
+
+ case 'Tags':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/tags/';
- } break;
- case 'Pull requests': {
+
+ case 'Pull requests':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/pulls/';
- } break;
- case 'Single pull request': {
+
+ case 'Single pull request':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/pulls/' . $this->getInput('pull_request');
- } break;
+
default: return parent::getURI();
}
}
@@ -152,27 +152,27 @@ class GiteaBridge extends BridgeAbstract {
$this->title = $html->find('[property="og:title"]', 0)->content;
switch($this->queriedContext) {
- case 'Commits': {
+ case 'Commits':
$this->collectCommitsData($html);
- } break;
- case 'Issues': {
+ break;
+ case 'Issues':
$this->collectIssuesData($html);
- } break;
- case 'Pull requests': {
+ break;
+ case 'Pull requests':
$this->collectPullRequestsData($html);
- } break;
- case 'Single issue': {
+ break;
+ case 'Single issue':
$this->collectSingleIssueOrPrData($html);
- } break;
- case 'Single pull request': {
+ break;
+ case 'Single pull request':
$this->collectSingleIssueOrPrData($html);
- } break;
- case 'Releases': {
+ break;
+ case 'Releases':
$this->collectReleasesData($html);
- } break;
- case 'Tags': {
+ break;
+ case 'Tags':
$this->collectTagsData($html);
- } break;
+ break;
}
}
diff --git a/bridges/GithubIssueBridge.php b/bridges/GithubIssueBridge.php
index 9c82e4e6..e3a0c73a 100644
--- a/bridges/GithubIssueBridge.php
+++ b/bridges/GithubIssueBridge.php
@@ -263,23 +263,22 @@ class GithubIssueBridge extends BridgeAbstract {
$path_segments = array_values(array_filter(explode('/', $url_components['path'])));
switch(count($path_segments)) {
- case 2: { // Project issues
+ case 2: // Project issues
list($user, $project) = $path_segments;
$show_comments = 'off';
- } break;
- case 3: { // Project issues with issue comments
+ break;
+ case 3: // Project issues with issue comments
if($path_segments[2] !== static::URL_PATH) {
return null;
}
list($user, $project) = $path_segments;
$show_comments = 'on';
- } break;
- case 4: { // Issue comments
+ break;
+ case 4: // Issue comments
list($user, $project, /* issues */, $issue) = $path_segments;
- } break;
- default: {
+ break;
+ default:
return null;
- }
}
return array(
diff --git a/bridges/GogsBridge.php b/bridges/GogsBridge.php
index a2adc1f9..c90c8c57 100644
--- a/bridges/GogsBridge.php
+++ b/bridges/GogsBridge.php
@@ -64,30 +64,30 @@ class GogsBridge extends BridgeAbstract {
public function getURI() {
switch($this->queriedContext) {
- case 'Commits': {
+ case 'Commits':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/commits/' . $this->getInput('branch');
- } break;
- case 'Issues': {
+
+ case 'Issues':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/issues/';
- } break;
- case 'Single issue': {
+
+ case 'Single issue':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/issues/' . $this->getInput('issue');
- } break;
- case 'Releases': {
+
+ case 'Releases':
return $this->getInput('host')
. '/' . $this->getInput('user')
. '/' . $this->getInput('project')
. '/releases/';
- } break;
+
default: return parent::getURI();
}
}
@@ -115,18 +115,18 @@ class GogsBridge extends BridgeAbstract {
$this->title = $html->find('[property="og:title"]', 0)->content;
switch($this->queriedContext) {
- case 'Commits': {
+ case 'Commits':
$this->collectCommitsData($html);
- } break;
- case 'Issues': {
+ break;
+ case 'Issues':
$this->collectIssuesData($html);
- } break;
- case 'Single issue': {
+ break;
+ case 'Single issue':
$this->collectSingleIssueData($html);
- } break;
- case 'Releases': {
+ break;
+ case 'Releases':
$this->collectReleasesData($html);
- } break;
+ break;
}
}
diff --git a/bridges/IPBBridge.php b/bridges/IPBBridge.php
index 3895e383..af2ed390 100644
--- a/bridges/IPBBridge.php
+++ b/bridges/IPBBridge.php
@@ -68,7 +68,7 @@ class IPBBridge extends FeedExpander {
case $this->isTopic($html):
$this->collectTopic($html, $limit);
break;
- case $this->isForum($html);
+ case $this->isForum($html):
$this->collectForum($html);
break;
default:
diff --git a/bridges/KernelBugTrackerBridge.php b/bridges/KernelBugTrackerBridge.php
index 0c56dedf..2677d717 100644
--- a/bridges/KernelBugTrackerBridge.php
+++ b/bridges/KernelBugTrackerBridge.php
@@ -78,7 +78,9 @@ Returns feeds for bug comments';
// Order comments
switch($sorting) {
case 'lf': $comments = array_reverse($comments, true);
+ // fall-through
case 'of':
+ // fall-through
default: // Nothing to do, keep original order
}
diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php
index 8033594b..40b1b129 100644
--- a/bridges/LWNprevBridge.php
+++ b/bridges/LWNprevBridge.php
@@ -8,7 +8,7 @@ class LWNprevBridge extends BridgeAbstract{
private $editionTimeStamp;
- function getURI(){
+ public function getURI(){
return self::URI . 'free/bigpage';
}
@@ -144,6 +144,7 @@ EOD;
if($cat->getAttribute('class') !== 'Cat2HL') {
break;
}
+ // fall-through? Looks like a bug
case 'Cat2HL':
$cat2 = $cat->textContent;
$cat = $cat->previousSibling;
@@ -155,6 +156,7 @@ EOD;
if($cat->getAttribute('class') !== 'Cat1HL') {
break;
}
+ // fall-through? Looks like a bug
case 'Cat1HL':
$cat1 = $cat->textContent;
$cats[0] = $cat1;
diff --git a/bridges/MoinMoinBridge.php b/bridges/MoinMoinBridge.php
index ca6e4581..1920c5a1 100644
--- a/bridges/MoinMoinBridge.php
+++ b/bridges/MoinMoinBridge.php
@@ -113,6 +113,7 @@ class MoinMoinBridge extends BridgeAbstract {
break;
}
+ // fall-through
case 'separator':
default: // Use contents from the current page
$item['content'] = $this->cleanArticle($section[2]);
diff --git a/bridges/NationalGeographicBridge.php b/bridges/NationalGeographicBridge.php
index be8dfbd7..e5273a8e 100644
--- a/bridges/NationalGeographicBridge.php
+++ b/bridges/NationalGeographicBridge.php
@@ -48,12 +48,10 @@ class NationalGeographicBridge extends BridgeAbstract {
public function getURI() {
switch ($this->queriedContext) {
- case self::CONTEXT_BY_TOPIC: {
+ case self::CONTEXT_BY_TOPIC:
return self::URI . $this->getInput(self::PARAMETER_TOPIC);
- } break;
- default: {
+ default:
return parent::getURI();
- }
}
}
@@ -68,26 +66,21 @@ class NationalGeographicBridge extends BridgeAbstract {
public function collectData() {
$this->topicName = $this->getTopicName($this->getInput(self::PARAMETER_TOPIC));
switch($this->topicName) {
- case self::TOPIC_MAGAZINE: {
+ case self::TOPIC_MAGAZINE:
return $this->collectMagazine();
- } break;
- case self::TOPIC_LATEST_STORIES: {
+ case self::TOPIC_LATEST_STORIES:
return $this->collectLatestStories();
- } break;
- default: {
+ default:
returnServerError('Unknown topic: "' . $this->topicName . '"');
- }
}
}
public function getName() {
switch ($this->queriedContext) {
- case self::CONTEXT_BY_TOPIC: {
+ case self::CONTEXT_BY_TOPIC:
return static::NAME . ': ' . $this->topicName;
- } break;
- default: {
+ default:
return parent::getName();
- }
}
}
@@ -327,7 +320,7 @@ EOD;
case 'video':
$content .= $this->handleImages($module, $module['cmsType']);
break;
- case 'pullquote';
+ case 'pullquote':
$quote = $module['quote'];
$author_name = '';
$authors = (isset($module['byLineProps']['authors']) ? $module['byLineProps']['authors'] : array());
diff --git a/bridges/PillowfortBridge.php b/bridges/PillowfortBridge.php
index b78d83e3..527cc1c7 100644
--- a/bridges/PillowfortBridge.php
+++ b/bridges/PillowfortBridge.php
@@ -110,7 +110,7 @@ EOD;
//preg_replace used for images with spaces in the url
switch($dimensions) {
- case 'None': {
+ case 'None':
foreach($media as $image) {
$imageURL = preg_replace('[ ]', '%20', $image['url']);
$text .= <<<EOD
@@ -120,8 +120,8 @@ EOD;
EOD;
}
break;
- }
- case 'Small': {
+
+ case 'Small':
foreach($media as $image) {
$imageURL = preg_replace('[ ]', '%20', $image['small_image_url']);
$text .= <<<EOD
@@ -134,8 +134,8 @@ EOD;
EOD;
}
break;
- }
- case 'Full': {
+
+ case 'Full':
foreach($media as $image) {
$imageURL = preg_replace('[ ]', '%20', $image['url']);
$text .= <<<EOD
@@ -148,7 +148,7 @@ EOD;
EOD;
}
break;
- }
+
default:
break;
}
diff --git a/bridges/RaceDepartmentBridge.php b/bridges/RaceDepartmentBridge.php
index 5d2ea9ce..b8b6e6fb 100644
--- a/bridges/RaceDepartmentBridge.php
+++ b/bridges/RaceDepartmentBridge.php
@@ -10,7 +10,7 @@ class RaceDepartmentBridge extends FeedExpander {
}
protected function parseItem($feedItem) {
- $item = parent::parseRSS_2_0_Item($feedItem);
+ $item = parent::parseRss2Item($feedItem);
//fetch page
$articlePage = getSimpleHTMLDOMCached($feedItem->link);
diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php
index a26af31f..71ac52ba 100644
--- a/bridges/TwitterBridge.php
+++ b/bridges/TwitterBridge.php
@@ -266,8 +266,10 @@ EOD
switch($this->queriedContext) {
case 'By keyword or hashtag':
returnServerError('No results for this query.');
+ // fall-through
case 'By username':
returnServerError('Requested username can\'t be found.');
+ // fall-through
case 'By list':
returnServerError('Requested username or list can\'t be found');
}
@@ -613,6 +615,7 @@ EOD;
} catch (HttpException $e) {
switch ($e->getCode()) {
case 401:
+ // fall-through
case 403:
if ($retries) {
$retries--;
@@ -620,6 +623,7 @@ EOD;
$this->getApiKey(1);
continue 2;
}
+ // fall-through
default:
$code = $e->getCode();
$data = $e->getMessage();
diff --git a/bridges/TwitterV2Bridge.php b/bridges/TwitterV2Bridge.php
index 8ca94377..1636139d 100644
--- a/bridges/TwitterV2Bridge.php
+++ b/bridges/TwitterV2Bridge.php
@@ -259,10 +259,13 @@ EOD
switch($this->queriedContext) {
case 'By keyword or hashtag':
returnServerError('No results for this query.');
+ // fall-through
case 'By username':
returnServerError('Requested username cannnot be found.');
+ // fall-through
case 'By list ID':
returnServerError('Requested list cannnot be found');
+ // fall-through
}
}
diff --git a/index.php b/index.php
index 6b9f6fd3..f118d500 100644
--- a/index.php
+++ b/index.php
@@ -14,10 +14,9 @@ if (isset($argv)) {
}
try {
+ $actionFac = new ActionFactory();
- $actionFac = new \ActionFactory();
-
- if(array_key_exists('action', $params)) {
+ if (array_key_exists('action', $params)) {
$action = $actionFac->create($params['action']);
$action->userData = $params;
$action->execute();
@@ -25,8 +24,9 @@ try {
$showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN);
echo BridgeList::create($showInactive);
}
-} catch(\Throwable $e) {
+} catch (\Throwable $e) {
error_log($e);
+
$code = $e->getCode();
if ($code !== -1) {
header('Content-Type: text/plain', true, $code);
diff --git a/lib/ActionInterface.php b/lib/ActionInterface.php
index 63088573..c8684d52 100644
--- a/lib/ActionInterface.php
+++ b/lib/ActionInterface.php
@@ -22,5 +22,5 @@ interface ActionInterface {
*
* @return void
*/
- function execute();
+ public function execute();
}
diff --git a/lib/BridgeCard.php b/lib/BridgeCard.php
index befde86a..22520170 100644
--- a/lib/BridgeCard.php
+++ b/lib/BridgeCard.php
@@ -286,7 +286,7 @@ This bridge is not fetching its content through a secure connection</div>';
* @param bool $isActive Indicates if the bridge is active or not
* @return string The bridge card
*/
- static function displayBridgeCard($bridgeName, $formats, $isActive = true){
+ public static function displayBridgeCard($bridgeName, $formats, $isActive = true){
$bridgeFac = new \BridgeFactory();
diff --git a/lib/BridgeList.php b/lib/BridgeList.php
index 3b6d832e..c5082e57 100644
--- a/lib/BridgeList.php
+++ b/lib/BridgeList.php
@@ -194,7 +194,7 @@ EOD;
* if enabled.
* @return string The home page
*/
- static function create($showInactive = true) {
+ public static function create($showInactive = true) {
$totalBridges = 0;
$totalActiveBridges = 0;
diff --git a/lib/FeedExpander.php b/lib/FeedExpander.php
index 58d830b7..b84c608a 100644
--- a/lib/FeedExpander.php
+++ b/lib/FeedExpander.php
@@ -111,14 +111,17 @@ abstract class FeedExpander extends BridgeAbstract {
case isset($rssContent->item[0]):
Debug::log('Detected RSS 1.0 format');
$this->feedType = self::FEED_TYPE_RSS_1_0;
+ $this->collectRss1($rssContent, $maxItems);
break;
case isset($rssContent->channel[0]):
Debug::log('Detected RSS 0.9x or 2.0 format');
$this->feedType = self::FEED_TYPE_RSS_2_0;
+ $this->collectRss2($rssContent, $maxItems);
break;
case isset($rssContent->entry[0]):
Debug::log('Detected ATOM format');
$this->feedType = self::FEED_TYPE_ATOM_1_0;
+ $this->collectAtom1($rssContent, $maxItems);
break;
default:
Debug::log('Unknown feed format/version');
@@ -126,9 +129,6 @@ abstract class FeedExpander extends BridgeAbstract {
break;
}
- Debug::log('Calling function "collect_' . $this->feedType . '_data"');
- $this->{'collect_' . $this->feedType . '_data'}($rssContent, $maxItems);
-
return $this;
}
@@ -145,8 +145,8 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo Instead of passing $maxItems to all functions, just add all items
* and remove excessive items later.
*/
- protected function collect_RSS_1_0_data($rssContent, $maxItems){
- $this->load_RSS_2_0_feed_data($rssContent->channel[0]);
+ protected function collectRss1($rssContent, $maxItems){
+ $this->loadRss2Data($rssContent->channel[0]);
foreach($rssContent->item as $item) {
Debug::log('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
@@ -170,13 +170,13 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo Instead of passing $maxItems to all functions, just add all items
* and remove excessive items later.
*/
- protected function collect_RSS_2_0_data($rssContent, $maxItems){
+ protected function collectRss2($rssContent, $maxItems){
$rssContent = $rssContent->channel[0];
Debug::log('RSS content is ===========\n'
. var_export($rssContent, true)
. '===========');
- $this->load_RSS_2_0_feed_data($rssContent);
+ $this->loadRss2Data($rssContent);
foreach($rssContent->item as $item) {
Debug::log('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
@@ -200,8 +200,8 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo Instead of passing $maxItems to all functions, just add all items
* and remove excessive items later.
*/
- protected function collect_ATOM_1_0_data($content, $maxItems){
- $this->load_ATOM_feed_data($content);
+ protected function collectAtom1($content, $maxItems){
+ $this->loadAtomData($content);
foreach($content->entry as $item) {
Debug::log('parsing item ' . var_export($item, true));
$tmp_item = $this->parseItem($item);
@@ -213,16 +213,6 @@ abstract class FeedExpander extends BridgeAbstract {
}
/**
- * Convert RSS 2.0 time to timestamp
- *
- * @param object $item A feed item
- * @return int The timestamp
- */
- protected function RSS_2_0_time_to_timestamp($item){
- return DateTime::createFromFormat('D, d M Y H:i:s e', $item->pubDate)->getTimestamp();
- }
-
- /**
* Load RSS 2.0 feed data into RSS-Bridge
*
* @param object $rssContent The RSS content
@@ -230,7 +220,7 @@ abstract class FeedExpander extends BridgeAbstract {
*
* @todo set title, link, description, language, and so on
*/
- protected function load_RSS_2_0_feed_data($rssContent){
+ protected function loadRss2Data($rssContent){
$this->title = trim((string)$rssContent->title);
$this->uri = trim((string)$rssContent->link);
@@ -245,7 +235,7 @@ abstract class FeedExpander extends BridgeAbstract {
* @param object $content The Atom content
* @return void
*/
- protected function load_ATOM_feed_data($content){
+ protected function loadAtomData($content){
$this->title = (string)$content->title;
// Find best link (only one, or first of 'alternate')
@@ -282,7 +272,7 @@ abstract class FeedExpander extends BridgeAbstract {
*/
protected function parseATOMItem($feedItem){
// Some ATOM entries also contain RSS 2.0 fields
- $item = $this->parseRSS_2_0_Item($feedItem);
+ $item = $this->parseRss2Item($feedItem);
if(isset($feedItem->id)) $item['uri'] = (string)$feedItem->id;
if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title;
@@ -317,7 +307,7 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
* of its own?
*/
- protected function parseRSS_0_9_1_Item($feedItem){
+ protected function parseRss091Item($feedItem){
$item = array();
if(isset($feedItem->link)) $item['uri'] = (string)$feedItem->link;
if(isset($feedItem->title)) $item['title'] = (string)$feedItem->title;
@@ -338,9 +328,9 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
* of its own?
*/
- protected function parseRSS_1_0_Item($feedItem){
+ protected function parseRss1Item($feedItem){
// 1.0 adds optional elements around the 0.91 standard
- $item = $this->parseRSS_0_9_1_Item($feedItem);
+ $item = $this->parseRss091Item($feedItem);
$namespaces = $feedItem->getNamespaces(true);
if(isset($namespaces['dc'])) {
@@ -362,9 +352,9 @@ abstract class FeedExpander extends BridgeAbstract {
* @todo To reduce confusion, the RSS-Bridge item should maybe have a class
* of its own?
*/
- protected function parseRSS_2_0_Item($feedItem){
+ protected function parseRss2Item($feedItem){
// Primary data is compatible to 0.91 with some additional data
- $item = $this->parseRSS_0_9_1_Item($feedItem);
+ $item = $this->parseRss091Item($feedItem);
$namespaces = $feedItem->getNamespaces(true);
if(isset($namespaces['dc'])) $dc = $feedItem->children($namespaces['dc']);
@@ -418,10 +408,10 @@ abstract class FeedExpander extends BridgeAbstract {
protected function parseItem($item){
switch($this->feedType) {
case self::FEED_TYPE_RSS_1_0:
- return $this->parseRSS_1_0_Item($item);
+ return $this->parseRss1Item($item);
break;
case self::FEED_TYPE_RSS_2_0:
- return $this->parseRSS_2_0_Item($item);
+ return $this->parseRss2Item($item);
break;
case self::FEED_TYPE_ATOM_1_0:
return $this->parseATOMItem($item);
diff --git a/lib/FeedItem.php b/lib/FeedItem.php
index 9a435730..8690eb95 100644
--- a/lib/FeedItem.php
+++ b/lib/FeedItem.php
@@ -483,7 +483,7 @@ class FeedItem {
* @param string $name Property name
* @param mixed $value Property value
*/
- function __set($name, $value) {
+ public function __set($name, $value) {
switch($name) {
case 'uri': $this->setURI($value); break;
case 'title': $this->setTitle($value); break;
@@ -506,7 +506,7 @@ class FeedItem {
* @param string $name Property name
* @return mixed Property value
*/
- function __get($name) {
+ public function __get($name) {
switch($name) {
case 'uri': return $this->getURI();
case 'title': return $this->getTitle();