3 namespace Org\Mxchange\CoreFramework\Resolver\Command;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
7 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
10 use \InvalidArgumentException;
13 * A command resolver for local (non-hubbed) HTML commands
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
18 * @license GNU GPL 3.0 or any newer version
19 * @link http://www.shipsimu.org
21 * This program is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver {
36 * Last successfull resolved command
38 private $lastCommandInstance = NULL;
41 * Protected constructor
45 private function __construct () {
46 // Call parent constructor
47 parent::__construct(__CLASS__);
49 // Set prefix to "html"
50 $this->setClassPrefix('html');
54 * Creates an instance of a Html command resolver with a given default command
56 * @param $commandName The default command we shall execute
57 * @return $resolverInstance The prepared command resolver instance
58 * @throws InvalidArgumentException Thrown if default command is not set
59 * @throws InvalidCommandException Thrown if default command is invalid
61 public static final function createHtmlCommandResolver (string $commandName) {
62 // Create the new instance
63 $resolverInstance = new HtmlCommandResolver();
65 // Is the variable $commandName set and the command is valid?
66 if (empty($commandName)) {
67 // Then thrown an exception here
68 throw new InvalidArgumentException('Parameter "commandName" is empty');
69 } elseif ($resolverInstance->isCommandValid($commandName) === false) {
70 // Invalid command found
71 // @TODO Missing namespace!
72 throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
75 // Return the prepared instance
76 return $resolverInstance;