public static function get($className, $parentClassName = '')
    {
        $className = self::cleanName($className);

        // We store the relationship between class & parent to prevent cyclical references
        if ($parentClassName) {
            self::$relations[$className][$parentClassName] = true;
        }

        // And we check for cyclical references to prevent infinite loops
        if ($parentClassName
            && isset(self::$relations[$parentClassName])
            && isset(self::$relations[$parentClassName][$className])
        ) {
            $message  = "Cyclical dependency found: {$className} depends on {$parentClassName}";
            $message .= " but is itself a dependency of {$parentClassName}.";
            throw new \Parable\DI\Exception($message);
        }

        if (!self::isStored($className)) {
            self::store(self::create($className, $parentClassName));
        }

        return self::$instances[$className];
    }
public static function get($className, $parentClassName = '')
    {
        $className = self::cleanName($className);

        // We store the relationship between class & parent to prevent cyclical references
        if ($parentClassName) {
            self::$relations[$className][$parentClassName] = true;
        }

        // And we check for cyclical references to prevent infinite loops
        if ($parentClassName
            && isset(self::$relations[$parentClassName])
            && isset(self::$relations[$parentClassName][$className])
        ) {
            $message  = "Cyclical dependency found: {$className} depends on {$parentClassName}";
            $message .= " but is itself a dependency of {$parentClassName}.";
            throw new \Parable\DI\Exception($message);
        }

        if (!self::isStored($className)) {
            self::store(self::create($className, $parentClassName));
        }

        return self::$instances[$className];
    }
public static function get ( $ className , $ parentClassName = '' ) { $ className = self :: cleanName ( $ className ) ; // We store the relationship between class & parent to prevent cyclical references if ( $ parentClassName ) { self :: $ relations [ $ className ] [ $ parentClassName ] = true ; } // And we check for cyclical references to prevent infinite loops if ( $ parentClassName && isset ( self :: $ relations [ $ parentClassName ] ) && isset ( self :: $ relations [ $ parentClassName ] [ $ className ] ) ) { $ message = "Cyclical dependency found: {$className} depends on {$parentClassName}" ; $ message .= " but is itself a dependency of {$parentClassName}." ; throw new \ Parable \ DI \ Exception ( $ message ) ; } if ( ! self :: isStored ( $ className ) ) { self :: store ( self :: create ( $ className , $ parentClassName ) ) ; } return self :: $ instances [ $ className ] ; }
Return an already instantiated instance or create a new one.

@param string $className
@param string $parentClassName

@return mixed
@throws \Parable\DI\Exception
Return an already instantiated instance or create a new one .