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) image commands
15 * @author Roland Haeder <webmaster@shipsimu.org>
17 <<<<<<< HEAD:framework/main/classes/resolver/command/image/class_ImageCommandResolver.php
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
20 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
21 >>>>>>> Some updates::inc/main/classes/resolver/command/image/class_ImageCommandResolver.php
22 * @license GNU GPL 3.0 or any newer version
23 * @link http://www.shipsimu.org
25 * This program is free software: you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation, either version 3 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program. If not, see <http://www.gnu.org/licenses/>.
38 class ImageCommandResolver extends BaseCommandResolver implements CommandResolver {
40 * Last successfull resolved command
42 private $lastCommandInstance = NULL;
45 * Protected constructor
49 protected function __construct () {
50 // Call parent constructor
51 parent::__construct(__CLASS__);
53 // Set prefix to "Image"
54 $this->setClassPrefix('image');
58 * Creates an instance of a Image command resolver with a given default command
60 * @param $commandName The default command we shall execute
61 * @param $applicationInstance An instance of a manageable application helper class
62 * @return $resolverInstance The prepared command resolver instance
63 * @throws InvalidArgumentException Thrown if default command is not set
64 * @throws InvalidCommandException Thrown if default command is invalid
66 public static final function createImageCommandResolver ($commandName, ManageableApplication $applicationInstance) {
67 // Create the new instance
68 $resolverInstance = new ImageCommandResolver();
70 // Is the variable $commandName set and the command is valid?
71 if (empty($commandName)) {
72 // Then thrown an exception here
73 throw new InvalidArgumentException('Parameter "commandName" is empty');
74 } elseif ($resolverInstance->isCommandValid($commandName) === false) {
75 // Invalid command found
76 throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
79 // Set the application instance
80 $resolverInstance->setApplicationInstance($applicationInstance);
82 // Return the prepared instance
83 return $resolverInstance;