Mockery\Container::_getInstance PHP Method

_getInstance() protected method

protected _getInstance ( $mockName, $constructorArgs = null )
    protected function _getInstance($mockName, $constructorArgs = null)
    {
        if ($constructorArgs !== null) {
            $r = new \ReflectionClass($mockName);
            return $r->newInstanceArgs($constructorArgs);
        }
        try {
            $instantiator = new Instantiator();
            $instance = $instantiator->instantiate($mockName);
        } catch (\Exception $ex) {
            $internalMockName = $mockName . '_Internal';
            if (!class_exists($internalMockName)) {
                eval("class {$internalMockName} extends {$mockName} {" . 'public function __construct() {}' . '}');
            }
            $instance = new $internalMockName();
        }
        return $instance;
    }