mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-05-03 15:38:09 +02:00
Added small autoloader
This commit is contained in:
parent
add655eca7
commit
75e8ad03d5
9
phpunit.xml.dist
Normal file
9
phpunit.xml.dist
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit bootstrap="src/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="Faker Test Suite">
|
||||
<directory>./test/Faker/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
</phpunit>
|
15
src/autoload.php
Normal file
15
src/autoload.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function($className) {
|
||||
$className = ltrim($className, '\\');
|
||||
$fileName = '';
|
||||
$namespace = '';
|
||||
if ($lastNsPos = strripos($className, '\\')) {
|
||||
$namespace = substr($className, 0, $lastNsPos);
|
||||
$className = substr($className, $lastNsPos + 1);
|
||||
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
|
||||
|
||||
require __DIR__.'/'.$fileName;
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user