1 | <?php |
||
5 | final class AliasLoader |
||
6 | { |
||
7 | /** |
||
8 | * The singleton instance of the loader. |
||
9 | * |
||
10 | * @var AliasLoader |
||
11 | */ |
||
12 | protected static $instance; |
||
13 | |||
14 | /** |
||
15 | * The array of class aliases. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $aliases; |
||
20 | |||
21 | /** |
||
22 | * Indicates if a loader has been registered. |
||
23 | * |
||
24 | * @var bool |
||
25 | */ |
||
26 | protected $registered = false; |
||
27 | |||
28 | private function __construct( array $aliases ) |
||
29 | { |
||
30 | $this->aliases = $aliases; |
||
31 | } |
||
32 | |||
33 | private function __clone() |
||
35 | |||
36 | /** |
||
37 | * Get or create the singleton alias loader instance. |
||
38 | * |
||
39 | * @return AliasLoader |
||
40 | */ |
||
41 | public static function getInstance( array $aliases = [] ) |
||
53 | |||
54 | /** |
||
55 | * Load a class alias if it is registered. |
||
56 | * |
||
57 | * @param string $alias |
||
58 | * |
||
59 | * @return bool|null |
||
60 | */ |
||
61 | 1 | public function load( $alias ) |
|
67 | |||
68 | /** |
||
69 | * Register the loader on the auto-loader stack. |
||
70 | * |
||
71 | * @return void |
||
72 | */ |
||
73 | public function register() |
||
80 | } |
||
81 |