]> git.mxchange.org Git - core.git/blob - framework/main/classes/resolver/command/image/class_ImageCommandResolver.php
Some updates:
[core.git] / framework / main / classes / resolver / command / image / class_ImageCommandResolver.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Resolver\Command;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Command\InvalidCommandException;
7 use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
8
9 // Import SPL stuff
10 use \InvalidArgumentException;
11
12 /**
13  * A command resolver for local (non-hubbed) image commands
14  *
15  * @author              Roland Haeder <webmaster@shipsimu.org>
16  * @version             0.0.0
17 <<<<<<< HEAD:framework/main/classes/resolver/command/image/class_ImageCommandResolver.php
18  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
19 =======
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
24  *
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.
29  *
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.
34  *
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/>.
37  */
38 class ImageCommandResolver extends BaseCommandResolver implements CommandResolver {
39         /**
40          * Last successfull resolved command
41          */
42         private $lastCommandInstance = NULL;
43
44         /**
45          * Protected constructor
46          *
47          * @return      void
48          */
49         protected function __construct () {
50                 // Call parent constructor
51                 parent::__construct(__CLASS__);
52
53                 // Set prefix to "Image"
54                 $this->setClassPrefix('image');
55         }
56
57         /**
58          * Creates an instance of a Image command resolver with a given default command
59          *
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
65          */
66         public static final function createImageCommandResolver ($commandName, ManageableApplication $applicationInstance) {
67                 // Create the new instance
68                 $resolverInstance = new ImageCommandResolver();
69
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);
77                 }
78
79                 // Set the application instance
80                 $resolverInstance->setApplicationInstance($applicationInstance);
81
82                 // Return the prepared instance
83                 return $resolverInstance;
84         }
85
86 }