Skip to content

Commit

Permalink
feat(flextype): simplefy Flextype core singleton class #199
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Aug 1, 2021
1 parent 39fd62d commit c8cdad5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/flextype/Foundation/Flextype.php
Expand Up @@ -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.
Expand Down Expand Up @@ -93,19 +93,20 @@ public function container(): Container

/**
* Returns Flextype Instance.
*
* Gets the instance via lazy initialization (created on first usage)
*
* @return Flextype Returns the current Flextype Instance.
*
* @access public
*/
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;
}

/**
Expand Down

0 comments on commit c8cdad5

Please sign in to comment.