@@ -70,71 +70,71 @@ |
||
70 | 70 | */ |
71 | 71 | class LoaderFactory |
72 | 72 | { |
73 | - /** |
|
74 | - * @var LoaderInterface $loader ; |
|
75 | - */ |
|
76 | - private static $loader; |
|
73 | + /** |
|
74 | + * @var LoaderInterface $loader ; |
|
75 | + */ |
|
76 | + private static $loader; |
|
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @param EE_Registry|CoffeeShop $generator provided during very first instantiation in |
|
81 | - * BootstrapDependencyInjectionContainer::buildLoader() |
|
82 | - * otherwise can be left null |
|
83 | - * @param ClassInterfaceCache|null $class_cache also provided during first instantiation |
|
84 | - * @param ObjectIdentifier|null $object_identifier |
|
85 | - * @return LoaderInterface |
|
86 | - * @throws InvalidArgumentException |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - * @throws InvalidInterfaceException |
|
89 | - */ |
|
90 | - public static function getLoader( |
|
91 | - $generator = null, |
|
92 | - ClassInterfaceCache $class_cache = null, |
|
93 | - ObjectIdentifier $object_identifier = null |
|
94 | - ): LoaderInterface { |
|
95 | - if ( |
|
96 | - ! LoaderFactory::$loader instanceof LoaderInterface |
|
97 | - && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop) |
|
98 | - && $class_cache instanceof ClassInterfaceCache |
|
99 | - && $object_identifier instanceof ObjectIdentifier |
|
100 | - ) { |
|
101 | - $core_loader = new CoreLoader($generator); |
|
102 | - LoaderFactory::$loader = new Loader( |
|
103 | - $core_loader, |
|
104 | - new CachingLoader( |
|
105 | - $core_loader, |
|
106 | - new LooseCollection(''), |
|
107 | - $object_identifier |
|
108 | - ), |
|
109 | - $class_cache |
|
110 | - ); |
|
111 | - } |
|
112 | - return LoaderFactory::$loader; |
|
113 | - } |
|
79 | + /** |
|
80 | + * @param EE_Registry|CoffeeShop $generator provided during very first instantiation in |
|
81 | + * BootstrapDependencyInjectionContainer::buildLoader() |
|
82 | + * otherwise can be left null |
|
83 | + * @param ClassInterfaceCache|null $class_cache also provided during first instantiation |
|
84 | + * @param ObjectIdentifier|null $object_identifier |
|
85 | + * @return LoaderInterface |
|
86 | + * @throws InvalidArgumentException |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + * @throws InvalidInterfaceException |
|
89 | + */ |
|
90 | + public static function getLoader( |
|
91 | + $generator = null, |
|
92 | + ClassInterfaceCache $class_cache = null, |
|
93 | + ObjectIdentifier $object_identifier = null |
|
94 | + ): LoaderInterface { |
|
95 | + if ( |
|
96 | + ! LoaderFactory::$loader instanceof LoaderInterface |
|
97 | + && ($generator instanceof EE_Registry || $generator instanceof CoffeeShop) |
|
98 | + && $class_cache instanceof ClassInterfaceCache |
|
99 | + && $object_identifier instanceof ObjectIdentifier |
|
100 | + ) { |
|
101 | + $core_loader = new CoreLoader($generator); |
|
102 | + LoaderFactory::$loader = new Loader( |
|
103 | + $core_loader, |
|
104 | + new CachingLoader( |
|
105 | + $core_loader, |
|
106 | + new LooseCollection(''), |
|
107 | + $object_identifier |
|
108 | + ), |
|
109 | + $class_cache |
|
110 | + ); |
|
111 | + } |
|
112 | + return LoaderFactory::$loader; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Used for instantiating a new instance of a class |
|
118 | - * |
|
119 | - * @param FullyQualifiedName|string $fqcn |
|
120 | - * @param array $arguments |
|
121 | - * @return mixed |
|
122 | - */ |
|
123 | - public static function getNew($fqcn, array $arguments = []) |
|
124 | - { |
|
125 | - return LoaderFactory::getLoader()->getNew($fqcn, $arguments); |
|
126 | - } |
|
116 | + /** |
|
117 | + * Used for instantiating a new instance of a class |
|
118 | + * |
|
119 | + * @param FullyQualifiedName|string $fqcn |
|
120 | + * @param array $arguments |
|
121 | + * @return mixed |
|
122 | + */ |
|
123 | + public static function getNew($fqcn, array $arguments = []) |
|
124 | + { |
|
125 | + return LoaderFactory::getLoader()->getNew($fqcn, $arguments); |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | - /** |
|
130 | - * Used for getting a shared instance of a class |
|
131 | - * |
|
132 | - * @param FullyQualifiedName|string $fqcn |
|
133 | - * @param array $arguments |
|
134 | - * @return mixed |
|
135 | - */ |
|
136 | - public static function getShared($fqcn, array $arguments = []) |
|
137 | - { |
|
138 | - return LoaderFactory::getLoader()->getShared($fqcn, $arguments); |
|
139 | - } |
|
129 | + /** |
|
130 | + * Used for getting a shared instance of a class |
|
131 | + * |
|
132 | + * @param FullyQualifiedName|string $fqcn |
|
133 | + * @param array $arguments |
|
134 | + * @return mixed |
|
135 | + */ |
|
136 | + public static function getShared($fqcn, array $arguments = []) |
|
137 | + { |
|
138 | + return LoaderFactory::getLoader()->getShared($fqcn, $arguments); |
|
139 | + } |
|
140 | 140 | } |