1
0
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:
yohang 2011-10-25 16:12:42 +02:00
parent add655eca7
commit 75e8ad03d5
2 changed files with 24 additions and 0 deletions

9
phpunit.xml.dist Normal file
View 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
View 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;
});