]> git.mxchange.org Git - friendica-addons.git/blob - twitter/vendor/abraham/twitteroauth/autoload.php
Merge branch '3.6-release'
[friendica-addons.git] / twitter / vendor / abraham / twitteroauth / autoload.php
1 <?php
2
3 /**
4  * Use to autoload needed classes without Composer.
5  *
6  * @param string $class The fully-qualified class name.
7  * @return void
8  */
9 spl_autoload_register(function ($class) {
10
11     // project-specific namespace prefix
12     $prefix = 'Abraham\\TwitterOAuth\\';
13
14     // base directory for the namespace prefix
15     $base_dir = __DIR__ . '/src/';
16
17     // does the class use the namespace prefix?
18     $len = strlen($prefix);
19     if (strncmp($prefix, $class, $len) !== 0) {
20         // no, move to the next registered autoloader
21         return;
22     }
23
24     // get the relative class name
25     $relative_class = substr($class, $len);
26
27     // replace the namespace prefix with the base directory, replace namespace
28     // separators with directory separators in the relative class name, append
29     // with .php
30     $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
31
32     // if the file exists, require it
33     if (file_exists($file)) {
34         require $file;
35     }
36 });