177525e430a16b15f6af2ed57d0f5eb10e3e7933
[core.git] / framework / main / classes / resolver / class_BaseResolver.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Resolver;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
7 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
8
9 /**
10  * A generic resolver class
11  *
12  * @author              Roland Haeder <webmaster@shipsimu.org>
13  * @version             0.0.0
14 <<<<<<< HEAD:framework/main/classes/resolver/class_BaseResolver.php
15  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
16 =======
17  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
18 >>>>>>> Some updates::inc/main/classes/resolver/class_BaseResolver.php
19  * @license             GNU GPL 3.0 or any newer version
20  * @link                http://www.shipsimu.org
21  *
22  * This program is free software: you can redistribute it and/or modify
23  * it under the terms of the GNU General Public License as published by
24  * the Free Software Foundation, either version 3 of the License, or
25  * (at your option) any later version.
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30  * GNU General Public License for more details.
31  *
32  * You should have received a copy of the GNU General Public License
33  * along with this program. If not, see <http://www.gnu.org/licenses/>.
34  */
35 abstract class BaseResolver extends BaseFrameworkSystem {
36         /**
37          * Namespace
38          */
39         private $namespace = '';
40
41         /**
42          * Class name
43          */
44         private $className = '';
45
46         /**
47          * Prefix for class
48          */
49         private $classPrefix = '';
50
51         /**
52          * (Last) resolved instance
53          */
54         private $resolvedInstance = NULL;
55
56         // Exception constants
57         const EXCEPTION_INVALID_COMMAND    = 0x1d0;
58         const EXCEPTION_INVALID_CONTROLLER = 0x1d1;
59         const EXCEPTION_INVALID_ACTION     = 0x1d2;
60         const EXCEPTION_INVALID_STATE      = 0x1d3;
61
62         /**
63          * Protected constructor
64          *
65          * @param       $className      Real name of the class
66          * @return      void
67          */
68         protected function __construct ($className) {
69                 // Call parent constructor
70                 parent::__construct($className);
71         }
72
73         /**
74          * Getter for namespace
75          *
76          * @return      $namespace      Namespace to look in
77          */
78         public final function getNamespace () {
79                 return $this->namespace;
80         }
81
82         /**
83          * Setter for namespace
84          *
85          * @param       $namespace      Namespace to look in
86          * @return      void
87          */
88         protected final function setNamespace ($namespace) {
89                 $this->namespace = (string) $namespace;
90         }
91
92         /**
93          * Getter for class name
94          *
95          * @return      $className      Name of the class
96          */
97         public final function getClassName () {
98                 return $this->className;
99         }
100
101         /**
102          * Setter for class name
103          *
104          * @param       $className      Name of the class
105          * @return      void
106          */
107         protected final function setClassName ($className) {
108                 $this->className = (string) $className;
109         }
110
111         /**
112          * "Getter" for class name (useable for an object factory)
113          *
114          * @return      $className      Capitalized class name
115          */
116         protected function getCapitalizedClassPrefix () {
117                 // Get class name
118                 $className = $this->getClassPrefix();
119
120                 // And capitalize it
121                 $className = self::convertToClassName($className);
122
123                 // Return it
124                 return $className;
125         }
126
127         /**
128          * Getter for class prefix
129          *
130          * @return      $classPrefix    Last validated classPrefix
131          */
132         protected final function getClassPrefix () {
133                 return $this->classPrefix;
134         }
135
136         /**
137          * Setter for class prefix
138          *
139          * @param       $classPrefix    Last validated classPrefix
140          * @return      void
141          */
142         protected final function setClassPrefix ($classPrefix) {
143                 $this->classPrefix = (string) $classPrefix;
144         }
145
146         /**
147          * Getter for (last) resolved instance
148          *
149          * @return      $resolvedInstance       Last validated resolvedInstance
150          */
151         protected final function getResolvedInstance () {
152                 return $this->resolvedInstance;
153         }
154
155         /**
156          * Setter for (last) resolved instance
157          *
158          * @param       $resolvedInstance       (Last) validated resolved instance
159          * @return      void
160          */
161         protected final function setResolvedInstance (FrameworkInterface $resolvedInstance) {
162                 $this->resolvedInstance = $resolvedInstance;
163         }
164
165 }