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