Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F14039942
Autoloader.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
961 B
Referenced Files
None
Subscribers
None
Autoloader.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Registration
;
class
Autoloader
{
///
/// PSR-4
///
public
static
function
registerPSR4
(
string
$namespace
,
string
$path
)
:
void
{
spl_autoload_register
(
function
(
$class
)
use
(
$namespace
,
$path
)
{
$len
=
strlen
(
$namespace
);
if
(
substr
(
$class
,
0
,
$len
)
===
$namespace
)
{
$classPath
=
Autoloader
::
getPathFor
(
substr
(
$class
,
$len
));
include
$path
.
'/'
.
$classPath
;
}
});
}
public
static
function
getPathFor
(
string
$name
)
:
string
{
return
str_replace
(
"
\\
"
,
"/"
,
$name
)
.
'.php'
;
}
///
/// Methods to register OmniTools library
///
public
static
function
selfRegister
()
:
void
{
self
::
registerPSR4
(
"Keruald
\\
OmniTools
\\
"
,
self
::
getLibraryPath
());
}
public
static
function
getLibraryPath
()
:
string
{
return
dirname
(
__DIR__
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 28, 17:38 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3163914
Default Alt Text
Autoloader.php (961 B)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment