<?php
/**
 * Cecha singleton
 *
 * @link https://krzysztof-turek.com
 *
 * @package tylkofotografia.pl
 * @version 0.2
 */

trait Singleton {
    private static $instances = [];

    protected function __construct() { }

    final protected function __clone() { }

    public static function getInstance() {
        
        $class = get_called_class();

        if ( !isset( $instances[$class])) {
            $instances[$class] = new $class;
        }
        return $instances[$class];
    }
}