public static function create() {
        $args = func_get_args();
        $className = empty(self::$className) ? get_class() : self::$className;
        $class = new \ReflectionClass($className);
        $constructor = $class->getConstructor();
        $arity = $constructor->getNumberOfParameters();

        if (sizeof($args) < $arity) {
            array_fill(0, $arity, null);
        }
        $bypassCache = (sizeof($args) > $arity + 1) ? array_pop($args) : false;
        $fetch = (sizeof($args) > $arity) ? array_pop($args) : true;

        $object = $class->newInstanceWithoutConstructor();
        $constructor->setAccessible(true);
        $constructor->invokeArgs($object, $args);
        $cachedObject = $object->cachedInstance();
        if ($cachedObject != null && !$bypassCache) {
            $object = $cachedObject;
        }

        if ($fetch && ($bypassCache || !$object->isFetched())) {
            $object->fetch();
            $object->cache();
        }

        return $object;
    }
public static function create() {
        $args = func_get_args();
        $className = empty(self::$className) ? get_class() : self::$className;
        $class = new \ReflectionClass($className);
        $constructor = $class->getConstructor();
        $arity = $constructor->getNumberOfParameters();

        if (sizeof($args) < $arity) {
            array_fill(0, $arity, null);
        }
        $bypassCache = (sizeof($args) > $arity + 1) ? array_pop($args) : false;
        $fetch = (sizeof($args) > $arity) ? array_pop($args) : true;

        $object = $class->newInstanceWithoutConstructor();
        $constructor->setAccessible(true);
        $constructor->invokeArgs($object, $args);
        $cachedObject = $object->cachedInstance();
        if ($cachedObject != null && !$bypassCache) {
            $object = $cachedObject;
        }

        if ($fetch && ($bypassCache || !$object->isFetched())) {
            $object->fetch();
            $object->cache();
        }

        return $object;
    }
public static function create ( ) { $ args = func_get_args ( ) ; $ className = empty ( self :: $ className ) ? get_class ( ) : self :: $ className ; $ class = new \ ReflectionClass ( $ className ) ; $ constructor = $ class -> getConstructor ( ) ; $ arity = $ constructor -> getNumberOfParameters ( ) ; if ( sizeof ( $ args ) < $ arity ) { array_fill ( 0 , $ arity , null ) ; } $ bypassCache = ( sizeof ( $ args ) > $ arity + 1 ) ? array_pop ( $ args ) : false ; $ fetch = ( sizeof ( $ args ) > $ arity ) ? array_pop ( $ args ) : true ; $ object = $ class -> newInstanceWithoutConstructor ( ) ; $ constructor -> setAccessible ( true ) ; $ constructor -> invokeArgs ( $ object , $ args ) ; $ cachedObject = $ object -> cachedInstance ( ) ; if ( $ cachedObject != null && ! $ bypassCache ) { $ object = $ cachedObject ; } if ( $ fetch && ( $ bypassCache || ! $ object -> isFetched ( ) ) ) { $ object -> fetch ( ) ; $ object -> cache ( ) ; } return $ object ; }
Creates a new instance of the cacheable object or returns an already
cached one

The parameters of this method are derived from the constructor of the
cacheable class. Additionally, the following parameters are dynamically
added:

@param bool $fetch If <var>true</var> the object’s <var>fetch()</var>
method will be called
@param bool $bypassCache If <var>true</var> the cache will not be hit
@return mixed A new object or a matching cached one
Creates a new instance of the cacheable object or returns an already cached one