Pop\Loader\Autoloader::__invoke PHP Method

__invoke() public method

Credit to Andreas Schipplock for helping to improve this method: https://github.com/schipplock
public __invoke ( string $class ) : void
$class string
return void
    public function __invoke($class)
    {
        if (array_key_exists($class, $this->classmap)) {
            require_once $this->classmap[$class];
        } else {
            $sep = strpos($class, '\\') !== false ? '\\' : '_';
            $classFile = str_replace($sep, DIRECTORY_SEPARATOR, $class) . '.php';
            // Check to see if the prefix is registered with the autoloader
            $prefix = null;
            foreach ($this->prefixes as $key => $value) {
                if (substr($class, 0, strlen($key)) == $key) {
                    $prefix = $key;
                }
            }
            // If the prefix was found, append the correct directory
            if (null !== $prefix) {
                $classFile = $this->prefixes[$prefix] . DIRECTORY_SEPARATOR . $classFile;
            }
            // Try to include the file, else return
            // Without error suppression
            if (!$this->suppress) {
                if (!(include_once $classFile)) {
                    return;
                }
                // With error suppression
            } else {
                if (!@(include_once $classFile)) {
                    return;
                }
            }
        }
    }