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