]> git.mxchange.org Git - core.git/blob - framework/bootstrap/class_FrameworkBootstrap.php
Rewrote a bit:
[core.git] / framework / bootstrap / class_FrameworkBootstrap.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Bootstrap;
4
5 // Import framework stuff
6 use CoreFramework\Configuration\FrameworkConfiguration;
7 use CoreFramework\Connection\Database\DatabaseConnection;
8 use CoreFramework\Connector\Database\DatabaseConnector;
9 use CoreFramework\Console\Tools\ConsoleTools;
10 use CoreFramework\EntryPoint\ApplicationEntryPoint;
11 use CoreFramework\Factory\ObjectFactory;
12 use CoreFramework\Generic\NullPointerException;
13 use CoreFramework\Helper\Application\ApplicationHelper;
14 use CoreFramework\Loader\ClassLoader;
15 use CoreFramework\Manager\ManageableApplication;
16 use CoreFramework\Middleware\Debug\DebugMiddleware;
17 use CoreFramework\Object\BaseFrameworkSystem;
18 use CoreFramework\Registry\Registry;
19 use CoreFramework\Request\Requestable;
20 use CoreFramework\Response\Responseable;
21
22 // Import SPL stuff
23 use \BadMethodCallException;
24 use \InvalidArgumentException;
25 use \SplFileInfo;
26
27 /**
28  * A framework-bootstrap class which helps the frameworks to bootstrap ... ;-)
29  *
30  * @author              Roland Haeder <webmaster@ship-simu.org>
31  * @version             0.0.0
32  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
33  * @license             GNU GPL 3.0 or any newer version
34  * @link                http://www.ship-simu.org
35  *
36  * This program is free software: you can redistribute it and/or modify
37  * it under the terms of the GNU General Public License as published by
38  * the Free Software Foundation, either version 3 of the License, or
39  * (at your option) any later version.
40  *
41  * This program is distributed in the hope that it will be useful,
42  * but WITHOUT ANY WARRANTY; without even the implied warranty of
43  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
44  * GNU General Public License for more details.
45  *
46  * You should have received a copy of the GNU General Public License
47  * along with this program. If not, see <http://www.gnu.org/licenses/>.
48  */
49 final class FrameworkBootstrap {
50
51         /**
52          * Detected server address
53          */
54         private static $serverAddress = NULL;
55
56         /**
57          * Instance of a Requestable class
58          */
59         private static $requestInstance = NULL;
60
61         /**
62          * Instance of a Responseable class
63          */
64         private static $responseInstance = NULL;
65
66         /*
67          * Includes applications may have. They will be tried in the given order,
68          * some will become soon deprecated.
69          */
70         private static $configAppIncludes = array(
71                 // The ApplicationHelper class (required)
72                 'class_ApplicationHelper' => 'required',
73                 // Some debugging stuff (optional but can be committed)
74                 'debug'                   => 'optional',
75                 // Application's exception handler (optional but can be committed)
76                 'exceptions'              => 'optional',
77                 // Application's configuration file (committed, non-local specific)
78                 'config'                  => 'required',
79                 // Local configuration file (optional, not committed, listed in .gitignore)
80                 'config-local'            => 'optional',
81                 // Application data (deprecated)
82                 'data'                    => 'deprecated',
83                 // Application loader (deprecated)
84                 'loader'                  => 'deprecated',
85                 // Application initializer (deprecated)
86                 'init'                    => 'deprecated',
87                 // Application starter (deprecated)
88                 'starter'                 => 'deprecated',
89         );
90
91         /**
92          * Private constructor, no instance is needed from this class as only
93          * static methods exist.
94          */
95         private function __construct () {
96                 // Prevent making instances from this "utilities" class
97         }
98
99         /**
100          * Getter for request instance
101          *
102          * @return      $requestInstance        An instance of a Requestable class
103          */
104         public static function getRequestInstance () {
105                 return self::$requestInstance;
106         }
107
108         /**
109          * Getter for response instance
110          *
111          * @return      $responseInstance       An instance of a Responseable class
112          */
113         public static function getResponseInstance () {
114                 return self::$responseInstance;
115         }
116
117         /**
118          * "Getter" to get response/request type from analysis of the system.
119          *
120          * @return      $requestType    Analyzed request type
121          */
122         public static function getRequestTypeFromSystem () {
123                 // Default is console
124                 $requestType = 'console';
125
126                 // Is 'HTTP_HOST' set?
127                 if (isset($_SERVER['HTTP_HOST'])) {
128                         // Then it is a HTML response/request.
129                         $requestType = 'html';
130                 } // END - if
131
132                 // Return it
133                 return $requestType;
134         }
135
136         /**
137          * Checks whether the given file/path is in open_basedir(). This does not
138          * gurantee that the file is actually readable and/or writeable. If you need
139          * such gurantee then please use isReadableFile() instead.
140          *
141          * @param       $fileInstance   An instance of a SplFileInfo class
142          * @return      $isReachable    Whether it is within open_basedir()
143          */
144         public static function isReachableFilePath (SplFileInfo $fileInstance) {
145                 // Is not reachable by default
146                 $isReachable = false;
147
148                 // Get open_basedir parameter
149                 $openBaseDir = trim(ini_get('open_basedir'));
150
151                 // Is it set?
152                 if (!empty($openBaseDir)) {
153                         // Check all entries
154                         foreach (explode(PATH_SEPARATOR, $openBaseDir) as $dir) {
155                                 // Check on existence
156                                 if (substr($fileInstance->getPathname(), 0, strlen($dir)) == $dir) {
157                                         // Is reachable
158                                         $isReachable = true;
159
160                                         // Abort lookup as it has been found in open_basedir
161                                         break;
162                                 } // END - if
163                         } // END - foreach
164                 } else {
165                         // If open_basedir is not set, all is allowed
166                         $isReachable = true;
167                 }
168
169                 // Return status
170                 return $isReachable;
171         }
172
173         /**
174          * Checks whether the give file is within open_basedir() (done by
175          * isReachableFilePath()), is actually a file and is readable.
176          *
177          * @param       $fileInstance   An instance of a SplFileInfo class
178          * @return      $isReadable             Whether the file is readable (and therefor exists)
179          */
180         public static function isReadableFile (SplFileInfo $fileInstance) {
181                 // Default is not readable
182                 $isReadable = false;
183
184                 // Check if it is a file and readable
185                 $isReadable = (
186                         (
187                                 self::isReachableFilePath($fileInstance)
188                         ) && (
189                                 $fileInstance->isFile()
190                         ) && (
191                                 $fileInstance->isReadable()
192                         )
193                 );
194
195                 // Return status
196                 return $isReadable;
197         }
198
199         /**
200          * Loads given include file
201          *
202          * @param       $fileInstance   An instance of a SplFileInfo class
203          * @return      void
204          * @throws      InvalidArgumentException        If file was not found or not readable or deprecated
205          */
206         public static function loadInclude (SplFileInfo $fileInstance) {
207                 // Trace message
208                 //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
209
210                 // Should be there ...
211                 if (!self::isReadableFile($fileInstance)) {
212                         // Abort here
213                         throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
214                 } // END - if
215
216                 // Load it
217                 require $fileInstance->getPathname();
218
219                 // Trace message
220                 //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
221         }
222
223         /**
224          * Does the actual bootstrap
225          *
226          * @return      void
227          */
228         public static function doBootstrap () {
229                 // Load basic include files to continue bootstrapping
230                 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
231                 self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
232                 self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
233                 self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
234
235                 // Load global configuration
236                 self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
237         }
238
239         /**
240          * Initializes the framework by scanning for all framework-relevant
241          * classes, interfaces and exception. Then determine the request type and
242          * initialize a Requestable instance which will then contain all request
243          * parameter, also from CLI. Next step is to validate the application
244          * (very basic).
245          *
246          * @return      void
247          */
248         public static function initFramework () {
249                 /**
250                  * 1) Load class loader and scan framework classes, interfaces and
251                  *    exceptions.
252                  */
253                 self::scanFrameworkClasses();
254
255                 /*
256                  * 2) Determine the request type, console or web and store request and
257                  *    response here. This also initializes the request instance will
258                  *    all given parameters (see doc-tag for possible sources of
259                  *    parameters).
260                  */
261                 self::determineRequestType();
262
263                 /*
264                  * 3) Now, that there are all request parameters being available, check
265                  *    if 'app' is supplied. If it is not found, abort execution, if
266                  *    found, continue below with next step.
267                  */
268                 self::validateApplicationParameter();
269         }
270
271         /**
272          * Initializes the detected application. This may fail if required files
273          * are not found in the application's base path (not to be confused with
274          * 'application_base_path' which only points to /some/foo/application/.
275          *
276          * @return      void
277          */
278         public static function prepareApplication () {
279                 // Configuration entry 'detected_app_name' must be set, get it here, including full path
280                 $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
281                 $fullPath    = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_full_app_path');
282
283                 /*
284                  * Now check and load all files, found deprecated files will throw a
285                  * warning at the user.
286                  */
287                 foreach (self::$configAppIncludes as $fileName => $status) {
288                         // Construct file instance
289                         $fileInstance = new SplFileInfo(sprintf('%s%s.php', $fullPath, $fileName));
290
291                         // Determine if this file is wanted/readable/deprecated
292                         if (($status == 'required') && (!self::isReadableFile($fileInstance))) {
293                                 // Nope, required file cannot be found/read from
294                                 ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileInstance->getBasename()));
295                         } elseif (($fileInstance->isFile()) && (!$fileInstance->isReadable())) {
296                                 // Found, not readable file
297                                 ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), $application));
298                         } elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
299                                 // Not found but optional/deprecated file, skip it
300                                 continue;
301                         }
302
303                         // Is the file deprecated?
304                         if ($status == 'deprecated') {
305                                 // Issue warning
306                                 trigger_error(sprintf('Deprecated file "%s.php" found, will not load it to avoid problems. Please remove it from your application "%s" to avoid this warning.', $fileName, $application), E_USER_WARNING);
307
308                                 // Skip loading deprecated file
309                                 continue;
310                         } // END - if
311
312                         // Load it
313                         self::loadInclude($fileInstance);
314                 } // END - foreach
315
316                 // Scan for application's classes, exceptions and interfaces
317                 ClassLoader::scanApplicationClasses();
318         }
319
320         /**
321          * Starts a fully initialized application, the class ApplicationHelper must
322          * be loaded at this point.
323          *
324          * @return      void
325          */
326         public static function startApplication () {
327                 // Configuration entry 'detected_app_name' must be set, get it here
328                 $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
329
330                 // Is there an application helper instance?
331                 $applicationInstance = call_user_func_array(
332                         array(
333                                 'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
334                         ), array()
335                 );
336
337                 // Some sanity checks
338                 if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
339                         // Something went wrong!
340                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
341                                 $application,
342                                 'CoreFramework\Helper\Application\ApplicationHelper'
343                         ));
344                 } elseif (!is_object($applicationInstance)) {
345                         // No object!
346                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is not an object (%s).',
347                                 $application,
348                                 gettype($applicationInstance)
349                         ));
350                 } elseif (!($applicationInstance instanceof ManageableApplication)) {
351                         // Missing interface
352                         ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.',
353                                 $application
354                         ));
355                 }
356
357                 // Set it in registry
358                 Registry::getRegistry()->addInstance('app', $applicationInstance);
359
360                 // Now call all methods in one go
361                 foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) {
362                         // Debug message
363                         //* NOISY-DEBUG: */ printf('[%s:%d]: Calling methodName=%s ...' . PHP_EOL, __METHOD__, __LINE__, $methodName);
364
365                         // Call method
366                         call_user_func(array($applicationInstance, $methodName));
367                 } // END - foreach
368         }
369
370         /**
371          * Initializes database instance, no need to double-call this method
372          *
373          * @return      void
374          */
375         public static function initDatabaseInstance () {
376                 // Get application instance
377                 $applicationInstance = ApplicationHelper::getSelfInstance();
378
379                 // Is the database instance already set?
380                 if ($applicationInstance instanceof DatabaseConnector) {
381                         // Yes, then abort here
382                         throw new BadMethodCallException('Method called twice.');
383                 } // END - if
384
385                 // Initialize database layer
386                 $databaseInstance = ObjectFactory::createObjectByConfiguredName(FrameworkConfiguration::getSelfInstance()->getConfigEntry('database_type') . '_class');
387
388                 // Prepare database instance
389                 $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
390
391                 // Set it in application helper
392                 $applicationInstance->setDatabaseInstance($connectionInstance);
393         }
394
395         /**
396          * Detects the server address (SERVER_ADDR) and set it in configuration
397          *
398          * @return      $serverAddress  The detected server address
399          * @throws      UnknownHostnameException        If SERVER_NAME cannot be resolved to an IP address
400          * @todo        Have to check some more entries from $_SERVER here
401          */
402         public static function detectServerAddress () {
403                 // Is the entry set?
404                 if (!isset(self::$serverAddress)) {
405                         // Is it set in $_SERVER?
406                         if (!empty($_SERVER['SERVER_ADDR'])) {
407                                 // Set it from $_SERVER
408                                 self::$serverAddress = $_SERVER['SERVER_ADDR'];
409                         } elseif (isset($_SERVER['SERVER_NAME'])) {
410                                 // Resolve IP address
411                                 $serverIp = ConsoleTools::resolveIpAddress($_SERVER['SERVER_NAME']);
412
413                                 // Is it valid?
414                                 if ($serverIp === false) {
415                                         /*
416                                          * Why is gethostbyname() returning the host name and not
417                                          * false as many other PHP functions are doing? ;-(
418                                          */
419                                         throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
420                                 } // END - if
421
422                                 // Al fine, set it
423                                 self::$serverAddress = $serverIp;
424                         } else {
425                                 // Run auto-detecting through console tools lib
426                                 self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
427                         }
428                 } // END - if
429
430                 // Return it
431                 return self::$serverAddress;
432         }
433
434         /**
435          * Setter for default time zone (must be correct!)
436          *
437          * @param       $timezone       The timezone string (e.g. Europe/Berlin)
438          * @return      $success        If timezone was accepted
439          * @throws      NullPointerException    If $timezone is NULL
440          * @throws      InvalidArgumentException        If $timezone is empty
441          */
442         public static function setDefaultTimezone ($timezone) {
443                 // Is it null?
444                 if (is_null($timezone)) {
445                         // Throw NPE
446                         throw new NullPointerException(NULL, BaseFrameworkSystem::EXCEPTION_IS_NULL_POINTER);
447                 } elseif (!is_string($timezone)) {
448                         // Is not a string
449                         throw new InvalidArgumentException(sprintf('timezone[]=%s is not a string', gettype($timezone)));
450                 } elseif ((is_string($timezone)) && (empty($timezone))) {
451                         // Entry is empty
452                         throw new InvalidArgumentException('timezone is empty');
453                 }
454
455                 // Default success
456                 $success = FALSE;
457
458                 /*
459                  * Set desired time zone to prevent date() and related functions to
460                  * issue an E_WARNING.
461                  */
462                 $success = date_default_timezone_set($timezone);
463
464                 // Return status
465                 return $success;
466         }
467
468         /**
469          * Checks whether HTTPS is set in $_SERVER
470          *
471          * @return      $isset  Whether HTTPS is set
472          * @todo        Test more fields
473          */
474         public static function isHttpSecured () {
475                 return (isset($_SERVER['HTTPS']));
476         }
477
478         /**
479          * Dectect and return the base URL for all URLs and forms
480          *
481          * @return      $baseUrl        Detected base URL
482          */
483         public static function detectBaseUrl () {
484                 // Initialize the URL
485                 $protocol = 'http';
486
487                 // Do we have HTTPS?
488                 if (self::isHttpSecured()) {
489                         // Add the >s< for HTTPS
490                         $protocol = 's';
491                 } // END - if
492
493                 // Construct the full URL and secure it against CSRF attacks
494                 $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
495
496                 // Return the URL
497                 return $baseUrl;
498         }
499
500         /**
501          * Detect safely and return the full domain where this script is installed
502          *
503          * @return      $fullDomain             The detected full domain
504          */
505         public static function detectDomain () {
506                 // Full domain is localnet.invalid by default
507                 $fullDomain = 'localnet.invalid';
508
509                 // Is the server name there?
510                 if (isset($_SERVER['SERVER_NAME'])) {
511                         // Detect the full domain
512                         $fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
513                 } // END - if
514
515                 // Return it
516                 return $fullDomain;
517         }
518
519         /**
520          * Detect safely the script path without trailing slash which is the glue
521          * between "http://your-domain.invalid/" and "script-name.php"
522          *
523          * @return      $scriptPath             The script path extracted from $_SERVER['SCRIPT_NAME']
524          */
525         public static function detectScriptPath () {
526                 // Default is empty
527                 $scriptPath = '';
528
529                 // Is the scriptname set?
530                 if (isset($_SERVER['SCRIPT_NAME'])) {
531                         // Get dirname from it and replace back-slashes with slashes for lame OSes...
532                         $scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME']));
533                 } // END - if
534
535                 // Return it
536                 return $scriptPath;
537         }
538
539         /**
540          * 1) Loads class scanner and scans all framework's classes and interfaces.
541          * This method also registers the class loader's method autoLoad() for the
542          * SPL auto-load feature. Remember that you can register additional methods
543          * (not functions, please) for other libraries.
544          *
545          * Yes, I know about Composer, but I like to keep my class loader around.
546          * You can always use mine as long as your classes have a namespace
547          * according naming-convention: Vendor\Project\Group[\SubGroup]
548          *
549          * @return      void
550          */
551         private static function scanFrameworkClasses () {
552                 // Include the class loader function
553                 require FrameworkConfiguration::getSelfInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
554
555                 // Register auto-load function with the SPL
556                 spl_autoload_register('CoreFramework\Loader\ClassLoader::autoLoad');
557
558                 // Scan for all framework classes, exceptions and interfaces
559                 ClassLoader::scanFrameworkClasses();
560         }
561
562         /**
563          * 2) Determines request/response type and stores the created
564          * request/response instances in this object for later usage.
565          *
566          * @return      void
567          */
568         private static function determineRequestType () {
569                 // Determine request type
570                 $request = self::getRequestTypeFromSystem();
571                 $requestType = self::getRequestTypeFromSystem();
572
573                 // Create a new request object
574                 $requestInstance = ObjectFactory::createObjectByName(sprintf('CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
575
576                 // Remember request instance here
577                 self::setRequestInstance($requestInstance);
578
579                 // Do we have another response?
580                 if ($requestInstance->isRequestElementSet('request')) {
581                         // Then use it
582                         $request = strtolower($requestInstance->getRequestElement('request'));
583                         $requestType = $request;
584                 } // END - if
585
586                 // ... and a new response object
587                 $responseClass = sprintf('CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
588                 $responseInstance = ObjectFactory::createObjectByName($responseClass);
589
590                 // Remember response instance here
591                 self::setResponseInstance($responseInstance);
592         }
593
594         /**
595          * 3) Validate parameter 'app' if it is set and the application is there.
596          *
597          * @return      void
598          */
599         private static function validateApplicationParameter () {
600                 // Is the parameter set?
601                 if (!self::getRequestInstance()->isRequestElementSet('app')) {
602                         /*
603                          * Don't continue here, the application 'selector' is no longer
604                          * supported and only existed as an idea to select the proper
605                          * application (by user).
606                          */
607                         ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
608                 } // END - if
609
610                 // Get it for local usage
611                 $application = self::getRequestInstance()->getRequestElement('app');
612
613                 // Secure it, by keeping out tags
614                 $application = htmlentities(strip_tags($application), ENT_QUOTES);
615
616                 // Secure it a little more with a reg.exp.
617                 $application = preg_replace('/([^a-z0-9_-])+/i', '', $application);
618
619                 // Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
620                 $applicationPath = sprintf(
621                         '%s%s%s',
622                         FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_base_path'),
623                         $application,
624                         DIRECTORY_SEPARATOR
625                 );
626
627                 // Full path for application
628                 // Is the path there? This secures a bit the parameter (from untrusted source).
629                 if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
630                         // Not found or not readable
631                         ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
632                 } // END - if
633
634                 // Set the detected application's name and full path for later usage
635                 FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
636                 FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_app_name'     , $application);
637         }
638         /**
639          * Setter for request instance
640          *
641          * @param       $requestInstance        An instance of a Requestable class
642          * @return      void
643          */
644         private static function setRequestInstance (Requestable $requestInstance) {
645                 self::$requestInstance = $requestInstance;
646         }
647
648         /**
649          * Setter for response instance
650          *
651          * @param       $responseInstance       An instance of a Responseable class
652          * @return      void
653          */
654         private static function setResponseInstance (Responseable $responseInstance) {
655                 self::$responseInstance = $responseInstance;
656         }
657
658 }