src/Titon/Common/Traits/Instanceable.php
public static function getInstance($key = 'default', array $params = []) {
        $class = get_called_class();

        if (isset(static::$_instances[$class][$key])) {
            return static::$_instances[$class][$key];
        }

        $reflection = new ReflectionClass($class);
        $object = $reflection->newInstanceArgs($params);

        static::$_instances[$class][$key] = $object;

        return $object;
    }
public static function getInstance($key = 'default', array $params = []) {
        $class = get_called_class();

        if (isset(static::$_instances[$class][$key])) {
            return static::$_instances[$class][$key];
        }

        $reflection = new ReflectionClass($class);
        $object = $reflection->newInstanceArgs($params);

        static::$_instances[$class][$key] = $object;

        return $object;
    }
public static function getInstance ( $ key = 'default' , array $ params = [ ] ) { $ class = get_called_class ( ) ; if ( isset ( static :: $ _instances [ $ class ] [ $ key ] ) ) { return static :: $ _instances [ $ class ] [ $ key ] ; } $ reflection = new ReflectionClass ( $ class ) ; $ object = $ reflection -> newInstanceArgs ( $ params ) ; static :: $ _instances [ $ class ] [ $ key ] = $ object ; return $ object ; }
Return an object instance else instantiate a new one.

@param string $key
@param array $params
@return $this
Return an object instance else instantiate a new one .