Get an instance of a given check class

@throws \RuntimeException when class does not exist or is invalid
@param string $checkClass Name of the check class
@return \CsvMigrations\Utility\Validate\Check\CheckInterface
778392
public static function getInstance(string $checkClass) : CheckInterface
    {
        $checkClass = $checkClass;

        if (!class_exists($checkClass)) {
            throw new RuntimeException("Check class [$checkClass] does not exist");
        }

        if (!in_array(static::$interface, array_keys(class_implements($checkClass)))) {
            throw new RuntimeException("Check class [$checkClass] does not implement [" . static::$interface . "]");
        }

        return new $checkClass();
    }
356780
public function registerChecker(CheckerInterface $checker)
    {
        if (!$this->hasChecker($checker)) {
            $this->checkers[] = $checker;
        }

        return $this;
    }
35597
private function createType($typeClass)
    {
        if ($typeClass !== DataTableType::class && !is_subclass_of($typeClass, DataTableType::class)) {
            throw new \InvalidArgumentException("Class '$typeClass' must extends DataTableType class.");
        }

        if ($this->container->has($typeClass)) {
            return $this->container->get($typeClass);
        } else {
            return new $typeClass();
        }
    }
561692
protected static function getObject($objectOrClass): object
    {
        self::assertParam($objectOrClass);

        if (\is_string($objectOrClass)) {
            try {
                $objectOrClass = new $objectOrClass();
            } catch (\Error $e) {
                try {
                    $class = new \ReflectionClass($objectOrClass);
                    $objectOrClass = $class->newInstanceWithoutConstructor();
                    // @codeCoverageIgnoreStart
                } catch (\ReflectionException $exception) {
                    throw new \RuntimeException(
                        '[' . typeOf($exception) . '] ' . $exception->getMessage(),
                        (int)$exception->getCode(),
                        $exception
                    );
                }
                // @codeCoverageIgnoreEnd
            }
        }
        return $objectOrClass;
    }
1206292
public function getClass($class)
    {
        $this->checkClass($class);

        if (null === $this->infoClass) {
            $infoClass = get_class($this).'Info';
            $this->infoClass = new $infoClass();
        }

        return $this->infoClass->{'get'.str_replace('\\', '', $class).'Class'}();
    }
1041415
public function instance()
    {
        $cache = new CacheItemPool();

        $cache->changeConfig([
            'cacheDirectory' => $this->getCacheDirectory(),
        ]);

        return new PasswordExposedChecker(null, $cache);
    }
197585
public function getClass($class)
    {
        $cacheKey = self::CACHE_KEY_CLASSES . strtolower($class);

        if (! $reflectionClass = $this->cache->fetch($cacheKey)) {
            $reflectionClass = new ReflectionClass($class);
            $this->cache->store($cacheKey, $reflectionClass);
        }

        return $reflectionClass;
    }
23287
function classGetReflection($class) {
    if (array_key_exists($class, $this->classLikesByQcn)) {
      return $this->classLikesByQcn[$class];
    }
    if (class_exists($class, FALSE) || interface_exists($class, FALSE) || trait_exists($class, FALSE)) {
      $reflectionClass = new \ReflectionClass($class);
      $this->initKnownClass($class, $reflectionClass);
    }
    else {
      $this->triggerAutoload($class);
    }
    if (isset($this->classLikesByQcn[$class])) {
      return $this->classLikesByQcn[$class];
    }
    if (array_key_exists($class, $this->classLikesByQcn)) {
      return $this->classLikesByQcn[$class];
    }
    return NULL;
  }
69753
public function get(string $class)
    {
        if (isset($this->instantiated[$class]) && $this->shared[$class]) {
            return $this->instantiated[$class];
        }

        $args = $this->services[$class];

        switch (count($args)) {
            case 0:
                $object = new $class();
                break;
            case 1:
                $object = new $class($args[0]);
                break;
            case 2:
                $object = new $class($args[0], $args[1]);
                break;
            case 3:
                $object = new $class($args[0], $args[1], $args[2]);
                break;
            default:
                throw new \OutOfRangeException('Too many arguments given');
        }

        if ($this->shared[$class]) {
            $this->instantiated[$class] = $object;
        }

        return $object;
    }
123041
protected function getClassFootprint(ClassScanner $class)
    {
        $footprint = new ClassFootprint();

        if ($class->isInterface()) {
            $footprint->setType(ClassFootprint::TYPE_INTERFACE);
        } elseif ($class->isTrait()) {
            $footprint->setType(ClassFootprint::TYPE_TRAIT);
        }

        $footprint->setParent($class->getParentClass());

        foreach ($class->getConstants(false) as $constant) {
            $footprint->addConstant($constant->getName(), $constant->getValue());
        }

        foreach ($class->getInterfaces() as $interface) {
            $footprint->addInterface($interface);
        }

        return $footprint;
    }
147595
protected function instance($class)
    {
        $reflection = new \ReflectionClass($class);

        $arguments = array();

        $constructor = $reflection->getConstructor();

        if ($this->container->has($class))
        {
            return $this->container->get($class);
        }

        if ($constructor !== null)
        {
            $arguments = $this->arguments($constructor);
        }

        return $reflection->newInstanceArgs($arguments);
    }
1368234
public static function load($class)
    {
        /* Protects us from possible remote code inclusion due to:
           https://bugs.php.net/bug.php?id=55475
           We should already be safe without this check due to the
           way this autoloader works, but this helps other autoloaders
           that use other mechanisms and may be vulnerable. */
        if (strpos($class, ":") !== false) {
            // Safer than returning false as it prevents
            // other autoloaders from ever executing...
            throw new \Exception('Possible remote code injection detected');
        }

        // need to check if there's a current map file specified ALSO.
        // this could be the first time writing it.
        $mapped = self::isMapped($class);
        if ($mapped) {
            require_once self::$map[$class];
            if (!self::loadSuccessful($class)) {
                // record this failure & keep going, we may still find it
                self::$unmapped[] = $class;
            } else {
                return true;
            }
        }

        $file = str_replace(
            array('_', '\\'),
            DIRECTORY_SEPARATOR,
            $class
        ) . '.php';
        foreach (self::$paths as $path) {
            if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
                require_once $path . DIRECTORY_SEPARATOR . $file;
                if (!self::loadSuccessful($class)) {
                    throw new \Exception(
                        'Class ' . $class . ' was not present in ' .
                        $path . DIRECTORY_SEPARATOR . $file .
                        '") [Autoload]'
                    );
                }

                if (in_array($class, self::$unmapped)) {
                    self::updateMap(
                        $class,
                        $path . DIRECTORY_SEPARATOR . $file
                    );
                }
                return true;
            }
        }

        $e = new \Exception(
            'Class ' . $class . ' could not be loaded from ' .
            $file . ', file does not exist (registered paths="' .
            implode(PATH_SEPARATOR, self::$paths) .
            '") [Autoload]'
        );
        $trace = $e->getTrace();
        if (isset($trace[2]) && isset($trace[2]['function']) &&
            in_array(
                $trace[2]['function'],
                array('class_exists', 'interface_exists')
            )) {
            return false;
        }
        if (isset($trace[1]) && isset($trace[1]['function']) &&
            in_array(
                $trace[1]['function'],
                array('class_exists', 'interface_exists')
            )) {
            return false;
        }

        // If there are other autoload functions registered,
        // let's try to play nicely with them...
        // ...otherwise, we just throw an exception.
        if (count(spl_autoload_functions()) == 1) {
            throw $e;
        }
        return false;
    }
106398
public static function fromClass(string $class): self
    {
        /** @var \Colibri\Migration\Migration|string $class */
        $migration             = new self($class);
        $migration->hash       = $class::hash();
        $migration->name       = $class::name();
        $migration->createdAt  = $class::createdAt();
        $migration->migratedAt = $class::migratedAt();

        return $migration;
    }
929600
public function getAdminByClass($class)
    {
        if (!$this->hasAdminByClass($class)) {
            return null;
        }

        if (!\is_array($this->adminClasses[$class])) {
            throw new \RuntimeException('Invalid format for the Pool::adminClass property');
        }

        if (\count($this->adminClasses[$class]) > 1) {
            throw new \RuntimeException(sprintf(
                'Unable to find a valid admin for the class: %s, there are too many registered: %s',
                $class,
                implode(', ', $this->adminClasses[$class])
            ));
        }

        return $this->getInstance($this->adminClasses[$class][0]);
    }
1349128
static function instance($class = null) {
        if (!$class) {
            $class = get_called_class();
        }
        if (!is_a($class, ValidateBuilder::class, true)) {
            throw new \Exception($class . ' is not a subclass of ' . ValidateBuilder::class);
        }
        if (!isset(self::$instances[$class])) {
            self::$instances[$class] = new $class;
        }

        return self::$instances[$class];
    }
505809
public function getPayPalCheckoutService()
    {
        if (is_null($this->checkoutService)) {
            $this->setPayPalCheckoutService(oxNew(\OxidEsales\PayPalModule\Core\PayPalService::class));
        }

        return $this->checkoutService;
    }
310856
public function find($class)
    {
        $reflectionClass = new \ReflectionClass($class);

        do {
            $classNamespace = $reflectionClass->getNamespaceName();
            foreach ($this->bundles as $bundleName => $bundleClass) {
                $bundleNamespace = \substr($bundleClass, 0, \strrpos($bundleClass, '\\'));
                if (0 === \strpos($classNamespace, $bundleNamespace)) {
                    return $bundleName;
                }
            }
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);

        return null;
    }