public function createInstance(
        $class, $useParameter = false, $jvalue = null
    ) {
        if (isset($this->classMap[$class])) {
            if (is_callable($mapper = $this->classMap[$class])) {
                $class = $mapper($class, $jvalue);
            } else {
                $class = $this->classMap[$class];
            }
        }
        if ($useParameter) {
            return new $class($jvalue);
        } else {
            return (new ReflectionClass($class))->newInstanceWithoutConstructor();
        }
    }
public function createInstance(
        $class, $useParameter = false, $jvalue = null
    ) {
        if (isset($this->classMap[$class])) {
            if (is_callable($mapper = $this->classMap[$class])) {
                $class = $mapper($class, $jvalue);
            } else {
                $class = $this->classMap[$class];
            }
        }
        if ($useParameter) {
            return new $class($jvalue);
        } else {
            return (new ReflectionClass($class))->newInstanceWithoutConstructor();
        }
    }
public function createInstance ( $ class , $ useParameter = false , $ jvalue = null ) { if ( isset ( $ this -> classMap [ $ class ] ) ) { if ( is_callable ( $ mapper = $ this -> classMap [ $ class ] ) ) { $ class = $ mapper ( $ class , $ jvalue ) ; } else { $ class = $ this -> classMap [ $ class ] ; } } if ( $ useParameter ) { return new $ class ( $ jvalue ) ; } else { return ( new ReflectionClass ( $ class ) ) -> newInstanceWithoutConstructor ( ) ; } }
Create a new object of the given type.

This method exists to be overwritten in child classes,
so you can do dependency injection or so.

@param string  $class        Class name to instantiate
@param boolean $useParameter Pass $parameter to the constructor or not
@param mixed   $jvalue       Constructor parameter (the json value)

@return object Freshly created object
Create a new object of the given type .