<?php

/**
 * An example of a project-specific implementation.
 *
 * After registering this autoload function with SPL, the following line
 * would cause the function to attempt to load the \Foo\Bar\Baz\Qux class
 * from /path/to/project/src/Baz/Qux.php:
 *
 *      new \Foo\Bar\Baz\Qux;
 *
 * @param string $class The fully-qualified class name.
 * @return void
 * @link https://www.php-fig.org/psr/psr-4/examples/
 */
spl_autoload_register(function ($class) {
    $prefix = 'Negundo\\Client\\';
    
    $base_dir = __DIR__ . '/src/';

    $len = strlen($prefix);
    
    if (strncmp($prefix, $class, $len) !== 0) {
        return;
    }

    $file = $base_dir . str_replace('\\', '/', substr($class, $len)) . '.php';

    if ( file_exists($file) ) {
        require $file;
    }
});