Skip to content

Instantly share code, notes, and snippets.

@richardsweeney
Last active September 27, 2017 08:20
Show Gist options
  • Save richardsweeney/c12ce6675006df114852978790fdd0a0 to your computer and use it in GitHub Desktop.
Save richardsweeney/c12ce6675006df114852978790fdd0a0 to your computer and use it in GitHub Desktop.
<?php
final class Singelton {
/**
* @var null|Singleton
*/
protected static $instance = null;
/**
* Singleton constructor
*/
private function __construct() {
// Yepp.
}
/**
* Get singleton instance
*
* @return Singleton
*/
public static function get_instance() : Singleton {
if ( null === self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment