Server IP : 192.158.238.246 / Your IP : 18.119.131.131 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/jenniferflocom/www/wp-content/plugins/gutenkit-blocks-addon/includes/Traits/ |
Upload File : |
<?php namespace Gutenkit\Traits; /** * Trait for making singleton instance * This is a factory singleton * * @package Gutenkit\Traits */ trait Singleton { /** * The Singleton's instance is stored in a static field. This field is an * array, because we'll allow our Singleton to have subclasses. Each item in * this array will be an instance of a specific Singleton's subclass. You'll * see how this works in a moment. */ private static $instances = array(); /** * This is the static method that controls the access to the singleton * instance. On the first run, it creates a singleton object and places it * into the static field. On subsequent runs, it returns the client existing * object stored in the static field. * * This implementation lets you subclass the Singleton class while keeping * just one instance of each subclass around. * * @return object * @since 1.0.0 */ public static function instance() { $class = get_called_class(); if ( ! isset( self::$instances[$class] ) ) { self::$instances[$class] = new $class(); } return self::$instances[$class]; } }