diff options
author | 2022-06-22 18:30:37 +0200 | |
---|---|---|
committer | 2022-06-22 18:30:37 +0200 | |
commit | ee80f4918e85cdc3c2c41e8e2c8b667c02b3f0bf (patch) | |
tree | 59273deedb25b7477aab2852bd39922721f1457c | |
parent | fad0dbb6efcd772670a4cfb27bac57473deec37b (diff) | |
download | rss-bridge-ee80f4918e85cdc3c2c41e8e2c8b667c02b3f0bf.tar.gz rss-bridge-ee80f4918e85cdc3c2c41e8e2c8b667c02b3f0bf.tar.zst rss-bridge-ee80f4918e85cdc3c2c41e8e2c8b667c02b3f0bf.zip |
refactor: action (#2836)
-rw-r--r-- | actions/ConnectivityAction.php | 5 | ||||
-rw-r--r-- | actions/DetectAction.php | 5 | ||||
-rw-r--r-- | actions/DisplayAction.php | 5 | ||||
-rw-r--r-- | actions/ListAction.php | 3 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | lib/ActionAbstract.php | 33 | ||||
-rw-r--r-- | lib/ActionInterface.php | 8 | ||||
-rw-r--r-- | tests/Actions/ActionImplementationTest.php | 7 | ||||
-rw-r--r-- | tests/Actions/ListActionTest.php | 1 |
9 files changed, 18 insertions, 51 deletions
diff --git a/actions/ConnectivityAction.php b/actions/ConnectivityAction.php index 43abdd34..1018c4a2 100644 --- a/actions/ConnectivityAction.php +++ b/actions/ConnectivityAction.php @@ -21,7 +21,10 @@ * - Returns a responsive web page that automatically checks all whitelisted * bridges (using JavaScript) if no bridge is specified. */ -class ConnectivityAction extends ActionAbstract { +class ConnectivityAction implements ActionInterface +{ + public $userData = []; + public function execute() { if(!Debug::isEnabled()) { diff --git a/actions/DetectAction.php b/actions/DetectAction.php index e58aee93..d662d7aa 100644 --- a/actions/DetectAction.php +++ b/actions/DetectAction.php @@ -11,7 +11,10 @@ * @link https://github.com/rss-bridge/rss-bridge */ -class DetectAction extends ActionAbstract { +class DetectAction implements ActionInterface +{ + public $userData = []; + public function execute() { $targetURL = $this->userData['url'] or returnClientError('You must specify a url!'); diff --git a/actions/DisplayAction.php b/actions/DisplayAction.php index df850b9d..cb0963a0 100644 --- a/actions/DisplayAction.php +++ b/actions/DisplayAction.php @@ -11,7 +11,10 @@ * @link https://github.com/rss-bridge/rss-bridge */ -class DisplayAction extends ActionAbstract { +class DisplayAction implements ActionInterface +{ + public $userData = []; + private function get_return_code($error) { $returnCode = $error->getCode(); if ($returnCode === 301 || $returnCode === 302) { diff --git a/actions/ListAction.php b/actions/ListAction.php index f7b92063..a778d846 100644 --- a/actions/ListAction.php +++ b/actions/ListAction.php @@ -11,7 +11,8 @@ * @link https://github.com/rss-bridge/rss-bridge */ -class ListAction extends ActionAbstract { +class ListAction implements ActionInterface +{ public function execute() { $list = new StdClass(); $list->bridges = array(); @@ -19,7 +19,7 @@ try { if(array_key_exists('action', $params)) { $action = $actionFac->create($params['action']); - $action->setUserData($params); + $action->userData = $params; $action->execute(); } else { $showInactive = filter_input(INPUT_GET, 'show_inactive', FILTER_VALIDATE_BOOLEAN); diff --git a/lib/ActionAbstract.php b/lib/ActionAbstract.php deleted file mode 100644 index b925d609..00000000 --- a/lib/ActionAbstract.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * This file is part of RSS-Bridge, a PHP project capable of generating RSS and - * Atom feeds for websites that don't have one. - * - * For the full license information, please view the UNLICENSE file distributed - * with this source code. - * - * @package Core - * @license http://unlicense.org/ UNLICENSE - * @link https://github.com/rss-bridge/rss-bridge - */ - -/** - * An abstract class for action objects - */ -abstract class ActionAbstract implements ActionInterface { - /** - * Holds the user data. - * - * @var array - */ - protected $userData = null; - - /** - * {@inheritdoc} - * - * @param array $userData {@inheritdoc} - */ - public function setUserData($userData) { - $this->userData = $userData; - } -} diff --git a/lib/ActionInterface.php b/lib/ActionInterface.php index c38d057a..63088573 100644 --- a/lib/ActionInterface.php +++ b/lib/ActionInterface.php @@ -16,14 +16,6 @@ */ interface ActionInterface { /** - * Set user data for the action to consume. - * - * @param array $userData An associative array of user data. - * @return void - */ - function setUserData($userData); - - /** * Execute the action. * * Note: This function directly outputs data to the user. diff --git a/tests/Actions/ActionImplementationTest.php b/tests/Actions/ActionImplementationTest.php index b10d44e5..0caf6d80 100644 --- a/tests/Actions/ActionImplementationTest.php +++ b/tests/Actions/ActionImplementationTest.php @@ -2,7 +2,6 @@ namespace RssBridge\Tests\Actions; -use ActionAbstract; use ActionInterface; use PHPUnit\Framework\TestCase; @@ -32,15 +31,15 @@ class ActionImplementationTest extends TestCase { * @dataProvider dataActionsProvider */ public function testVisibleMethods($path) { - $allowedActionAbstract = get_class_methods(ActionAbstract::class); - sort($allowedActionAbstract); + $allowedMethods = get_class_methods(ActionInterface::class); + sort($allowedMethods); $this->setAction($path); $methods = get_class_methods($this->obj); sort($methods); - $this->assertEquals($allowedActionAbstract, $methods); + $this->assertEquals($allowedMethods, $methods); } public function dataActionsProvider() { diff --git a/tests/Actions/ListActionTest.php b/tests/Actions/ListActionTest.php index bbd6ec78..1ecf50ed 100644 --- a/tests/Actions/ListActionTest.php +++ b/tests/Actions/ListActionTest.php @@ -80,7 +80,6 @@ class ListActionTest extends TestCase { $actionFac = new ActionFactory(); $action = $actionFac->create('list'); - $action->setUserData(array()); /* no user data required */ ob_start(); $action->execute(); |