public static function getInstance()
    {
        // get arguments (all arguments optional)
        $arguments = func_get_args();
        $arguments = array_shift($arguments);

        // get name of calling class (child)
        $callerSignature = get_called_class();

        // check for strict runtimeEnvironment
        if (self::$strict === true) {
            // build identifier including parameter
            if (is_array($arguments)) {
                // array to hold all elements for crc but object(s)
                $crc = [];

                // iterate over arguments to filter objects out => too complex!
                // TODO: maybe serialize objects is a way to process them?!
                foreach ($arguments as $argument) {
                    // add if not object
                    if (!is_object($argument)) {
                        $crc[] = $argument;
                    }
                }
            } else {
                // if no arguments use direct as crc
                $crc = $arguments;
            }

            // build identifier including (strict) parameter
            $identifier = md5($callerSignature.serialize($crc));
        } else {
            // build identifier excluding (loose) parameter
            $identifier = md5($callerSignature);
        }

        // check for already assigned instance
        if (!isset(self::$instances[$identifier])) {
            // get instance
            $instance = self::genericInstantiate($callerSignature, $arguments);

            // store instance
            self::$instances[$identifier] = $instance;
        } else {
            // we have a match
            $instance = self::$instances[$identifier];
        }

        // return instance
        return $instance;
    }
public static function getInstance()
    {
        // get arguments (all arguments optional)
        $arguments = func_get_args();
        $arguments = array_shift($arguments);

        // get name of calling class (child)
        $callerSignature = get_called_class();

        // check for strict runtimeEnvironment
        if (self::$strict === true) {
            // build identifier including parameter
            if (is_array($arguments)) {
                // array to hold all elements for crc but object(s)
                $crc = [];

                // iterate over arguments to filter objects out => too complex!
                // TODO: maybe serialize objects is a way to process them?!
                foreach ($arguments as $argument) {
                    // add if not object
                    if (!is_object($argument)) {
                        $crc[] = $argument;
                    }
                }
            } else {
                // if no arguments use direct as crc
                $crc = $arguments;
            }

            // build identifier including (strict) parameter
            $identifier = md5($callerSignature.serialize($crc));
        } else {
            // build identifier excluding (loose) parameter
            $identifier = md5($callerSignature);
        }

        // check for already assigned instance
        if (!isset(self::$instances[$identifier])) {
            // get instance
            $instance = self::genericInstantiate($callerSignature, $arguments);

            // store instance
            self::$instances[$identifier] = $instance;
        } else {
            // we have a match
            $instance = self::$instances[$identifier];
        }

        // return instance
        return $instance;
    }
public static function getInstance ( ) { // get arguments (all arguments optional) $ arguments = func_get_args ( ) ; $ arguments = array_shift ( $ arguments ) ; // get name of calling class (child) $ callerSignature = get_called_class ( ) ; // check for strict runtimeEnvironment if ( self :: $ strict === true ) { // build identifier including parameter if ( is_array ( $ arguments ) ) { // array to hold all elements for crc but object(s) $ crc = [ ] ; // iterate over arguments to filter objects out => too complex! // TODO: maybe serialize objects is a way to process them?! foreach ( $ arguments as $ argument ) { // add if not object if ( ! is_object ( $ argument ) ) { $ crc [ ] = $ argument ; } } } else { // if no arguments use direct as crc $ crc = $ arguments ; } // build identifier including (strict) parameter $ identifier = md5 ( $ callerSignature . serialize ( $ crc ) ) ; } else { // build identifier excluding (loose) parameter $ identifier = md5 ( $ callerSignature ) ; } // check for already assigned instance if ( ! isset ( self :: $ instances [ $ identifier ] ) ) { // get instance $ instance = self :: genericInstantiate ( $ callerSignature , $ arguments ) ; // store instance self :: $ instances [ $ identifier ] = $ instance ; } else { // we have a match $ instance = self :: $ instances [ $ identifier ] ; } // return instance return $ instance ; }
Instance getter for singleton instances

@author Benjamin Carl <opensource@clickalicious.de>
@return object instance/object of this class
@access public
Instance getter for singleton instances