Menu

## Singleton
in package

Singleton.php : 18

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

Singleton.php : 24
`private static Singleton|null $instance = null`

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

### Methods

#### getInstance()

Singleton.php : 34

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()

Singleton.php : 49

Initialize the class.

`protected abstract init() : void`

This method is called when the class is loaded.

##### Return values

void —

#### __clone()

Singleton.php : 58

Clone method.

`private __clone() : void`

This method is private to prevent cloning of the instance.

##### Return values

void —

#### __construct()

Singleton.php : 71

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()

Singleton.php : 84

Wakeup method.

`private __wakeup() : void`

This method is private to prevent deserialization of the instance.

##### Return values

void —

## Search results