for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Redaxscript;
use function array_key_exists;
/**
* abstract class to create a singleton class
*
* @since 2.2.0
* @package Redaxscript
* @category Singleton
* @author Henry Ruhs
* @codeCoverageIgnore
*/
abstract class Singleton
{
* array of static instances
protected static array $_instanceArray = [];
* constructor of the class
private function __construct()
}
* clone of the class
* @since 5.0.0
private function __clone()
* get the instance
* @return static
public static function getInstance()
$className = static::class;
/* create instance */
if (!array_key_exists($className, static::$_instanceArray))
static::$_instanceArray[$className] = new static();
return static::$_instanceArray[$className];
* clear the instance
* @since 3.0.0
public static function clearInstance() : void
self::$_instanceArray[$className] = null;