| 1 |
<?php |
| 2 |
|
| 3 |
namespace Cmb2Grid\DesignPatterns; |
| 4 |
|
| 5 |
/** |
| 6 |
* Description of Singleton. |
| 7 |
* |
| 8 |
* Pablo Pacheco <pablo.pacheco@origgami.com.br> |
| 9 |
*/ |
| 10 |
if ( ! class_exists('\Cmb2Grid\DesignPatterns\Singleton')) { |
| 11 |
abstract class Singleton |
| 12 |
{ |
| 13 |
abstract protected function __construct(); |
| 14 |
|
| 15 |
/** |
| 16 |
* Returns the *Singleton* instance of this class. |
| 17 |
* |
| 18 |
* @staticvar Singleton $instance The *Singleton* instances of this class. |
| 19 |
* |
| 20 |
* @return Current_Class_Name |
| 21 |
*/ |
| 22 |
public static function getInstance() |
| 23 |
{ |
| 24 |
static $instance = null; |
| 25 |
if (null === $instance) { |
| 26 |
$instance = new static(); |
| 27 |
} |
| 28 |
|
| 29 |
return $instance; |
| 30 |
} |
| 31 |
|
| 32 |
final private function __clone() |
| 33 |
{ |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|