PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.2
Defender Security – Malware Scanner, Login Security & Firewall v5.7.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / extra / maxmind-db / reader / autoload.php

autoload.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.2, at src/extra/maxmind-db/reader/autoload.php

47 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare( strict_types=1 );
4
5 /**
6 * PSR-4 autoloader implementation for the MaxMind\DB namespace.
7 * First we define the 'mmdb_autoload' function, and then we register
8 * it with 'spl_autoload_register' so that PHP knows to use it.
9 *
10 * @param mixed $class
11 */
12
13 /**
14 * Automatically include the file that defines <code>class</code>.
15 *
16 * @param string $class
17 * the name of the class to load
18 */
19 function mmdb_autoload( $class ): void {
20 /*
21 * A project-specific mapping between the namespaces and where
22 * they're located. By convention, we include the trailing
23 * slashes. The one-element array here simply makes things easy
24 * to extend in the future if (for example) the test classes
25 * begin to use one another.
26 */
27 $namespace_map = [ 'MaxMind\\Db\\' => __DIR__ . '/src/MaxMind/Db/' ];
28
29 foreach ( $namespace_map as $prefix => $dir ) {
30 // First swap out the namespace prefix with a directory...
31 $path = str_replace( $prefix, $dir, $class );
32
33 // replace the namespace separator with a directory separator...
34 $path = str_replace( '\\', '/', $path );
35
36 // and finally, add the PHP file extension to the result.
37 $path = $path . '.php';
38
39 // $path should now contain the path to a PHP file defining $class
40 if ( file_exists( $path ) ) {
41 include $path;
42 }
43 }
44 }
45
46 spl_autoload_register( 'mmdb_autoload' );
47