for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* MslsRegistry
* @author Dennis Ploetner <[email protected]>
* @since 0.9.8
*/
namespace lloc\Msls;
* Registry instead of singletons
* @package Msls
class MslsRegistry {
* Generic container
*
* @var array
private static $arr = [];
* Instance
* @var MslsRegistry
private static $instance;
* Get an object by key
* @param string $key
* @return mixed
private function get( $key ) {
return isset( self::$arr[ $key ] ) ? self::$arr[ $key ] : null;
}
* Set an object
* @param mixed $instance
private function set( $key, $instance ) {
self::$arr[ $key ] = $instance;
* Registry is a singleton
* @return MslsRegistry
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
return self::$instance;
* Static get_object calls get
public static function get_object( $key ) {
return self::instance()->get( $key );
* Static set_object calls set
public static function set_object( $key, $instance ) {
self::instance()->set( $key, $instance );