You are here

public static function Singleton::instance in Convert Media Tags to Markup 2.x

Same name and namespace in other branches
  1. 8 src/traits/Singleton.php \Drupal\convert_media_tags_to_markup\traits\Singleton::instance()

Implements the Singleton design pattern.

Only one instance of the Concord class should exist per execution.

Return value

Concord The single instance of the concord class.

File

src/traits/Singleton.php, line 25

Class

Singleton
Implements the Singleton design pattern.

Namespace

Drupal\convert_media_tags_to_markup\traits

Code

public static function instance() {

  // See http://stackoverflow.com/questions/15443458
  $class = get_called_class();

  // Not sure why the linter tells me $instance is not used.
  // @codingStandardsIgnoreStart
  if (!$class::$instance) {

    // @codingStandardsIgnoreEnd
    $class::$instance = new $class();
  }
  return $class::$instance;
}