1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(flextype): simplefy Flextype core singleton class #199

This commit is contained in:
Awilum
2021-08-01 11:13:36 +03:00
parent 39fd62dd8c
commit c8cdad545f

View File

@@ -23,11 +23,11 @@ final class Flextype
public const VERSION = '0.9.16';
/**
* The Flextype Application instances.
* The Flextype instance.
*
* @var array
*/
private static array $instances = [];
private static ?Flextype $instance = null;
/**
* The Flextype Application.
@@ -93,6 +93,8 @@ final class Flextype
/**
* Returns Flextype Instance.
*
* Gets the instance via lazy initialization (created on first usage)
*
* @return Flextype Returns the current Flextype Instance.
*
@@ -100,12 +102,11 @@ final class Flextype
*/
public static function getInstance(?ContainerInterface $container = null): Flextype
{
$cls = static::class;
if (! isset(self::$instances[$cls])) {
self::$instances[$cls] = new static($container);
if (static::$instance === null) {
static::$instance = new self();
}
return self::$instances[$cls];
return static::$instance;
}
/**