-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoload.php
41 lines (41 loc) · 1.08 KB
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php declare(strict_types=1);
namespace SM;
use function define,defined,spl_autoload_register;
use const DIRECTORY_SEPARATOR;
###
defined('SM\\AUTO') ||
define('SM\\AUTO', new class()
{
const DIR=__DIR__.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR;
const MAP=[
'SM\\Conio' => 'conio.php',
'SM\\ErrorEx' => 'error.php',
'SM\\ErrorLog' => 'error.php',
'SM\\Hurl' => 'hurl.php',
'SM\\Process' => 'process.php',
'SM\\Promise' => 'promise.php',
'SM\\Loop' => 'promise.php',
'SM\\SyncExchange' => 'sync.php',
'SM\\SyncAggregate' => 'sync.php',
'SM\\Sys' => 'sysapi.php'
];
public bool $ready=false;
function autoload(string $class): void
{
isset(self::MAP[$class]) &&
include(self::DIR.self::MAP[$class]);
}
function register(): bool
{
if ($this->ready) {
return true;
}
if (!spl_autoload_register($this->autoload(...))) {
return false;
}
require(self::DIR.'functions.php');
return $this->ready = true;
}
});
return (AUTO)->register();
###