diff --git a/src/flextype/Foundation/Flextype.php b/src/flextype/Foundation/Flextype.php index 8ffe7b4d7..8861db11a 100644 --- a/src/flextype/Foundation/Flextype.php +++ b/src/flextype/Foundation/Flextype.php @@ -9,25 +9,11 @@ namespace Flextype\Foundation; -use Exception; use DI\Bridge\Slim\Bridge; use DI\Container; -use Slim\App; -use Slim\Middleware\ContentLengthMiddleware; -use Slim\Middleware\OutputBufferingMiddleware; -use Slim\Middleware\RoutingMiddleware; -use Slim\Psr7\Factory\StreamFactory; -use Atomastic\Csrf\Csrf; -use Atomastic\Registry\Registry; -use Atomastic\Session\Session; -use Cocur\Slugify\Slugify; -use DateTimeZone; -use Flextype\Foundation\Actions; -use Psr\Http\Message\ResponseInterface as Response; -use Psr\Http\Message\ServerRequestInterface as Request; +use Exception; use Psr\Container\ContainerInterface; - -use function is_null; +use Slim\App; final class Flextype { @@ -37,16 +23,21 @@ final class Flextype public const VERSION = '0.9.16'; /** - * The Flextype's instance is stored in a static field. This field is an - * array, because we'll allow our Flextype to have subclasses. Each item in - * this array will be an instance of a specific Flextype's subclass. + * The Flextype Application instances. * * @var array */ private static array $instances = []; - private App $app; - private Container $container; + /** + * The Flextype Application. + */ + private static App $app; + + /** + * The Flextype Application Container. + */ + private static Container $container; /** * Flextype should not be cloneable. @@ -65,29 +56,49 @@ public function __wakeup(): void } /** - * Flextype construct + * Flextype construct. */ - protected function __construct(ContainerInterface $container = null) + protected function __construct(?ContainerInterface $container = null) { - $this->app = Bridge::create($container); - $this->container = $this->app->getContainer(); + // Set Application with PHP-DI Bridge + self::$app = Bridge::create($container); + + // Set Application Container + self::$container = self::$app->getContainer(); } - public function app() + /** + * Get Flextype Application. + * + * @return App Returns Flextype Application. + * + * @access public + */ + public function app(): App { - return $this->app; + return self::$app; } - public function container() + /** + * Get Flextype Application Container. + * + * @return Flextype Returns Flextype Application Container. + * + * @access public + */ + public function container(): Container { - return $this->container; + return self::$container; } - /** - * Returns Flextype Instance + * Returns Flextype Instance. + * + * @return Flextype Returns the current Flextype Instance. + * + * @access public */ - public static function getInstance(ContainerInterface $container = null): Flextype + public static function getInstance(?ContainerInterface $container = null): Flextype { $cls = static::class; if (! isset(self::$instances[$cls])) { @@ -98,7 +109,11 @@ public static function getInstance(ContainerInterface $container = null): Flexty } /** - * Returns the current Flextype version + * Get the current Flextype version. + * + * @return string Returns the current Flextype version. + * + * @access public */ public function getVersion(): string {