Kotchasan

Singleton
in package

This class provides the base functionality for creating singleton classes.

Tags
see
https://www.kotchasan.com/

Table of Contents

$instance  : Singleton|null
getInstance()  : static
Get the instance of the class.
init()  : void
Initialize the class.
__clone()  : void
Clone method.
__construct()  : void
Constructor.
__wakeup()  : void
Wakeup method.

Properties

$instance

private static Singleton|null $instance = null

The instance of the class. This variable holds the single instance of the class.

Methods

getInstance()

Get the instance of the class.

public static getInstance() : static

This method returns the instance of the class. If the instance doesn't exist, it creates a new one.

Return values
static

The instance of the class.

init()

Initialize the class.

protected abstract init() : void

This method is called when the class is loaded.

Return values
void

__clone()

Clone method.

private __clone() : void

This method is private to prevent cloning of the instance.

Return values
void

__construct()

Constructor.

private __construct() : void

This method is private to prevent direct instantiation of the class. It initializes the class by calling the init method.

Return values
void

__wakeup()

Wakeup method.

private __wakeup() : void

This method is private to prevent deserialization of the instance.

Return values
void

Search results