@@ -57,10 +57,9 @@ public static function getAvailableBackends(): array
5757 * Returns null if no engine found
5858 *
5959 * @param string $itemtype itemtype of assets to analyze
60- * @param ?RestApiClientInterface $client
6160 * @return EmbodiedImpactInterface|null an instance if an embodied impact calculation object or null on error
6261 */
63- public static function getEngineFromItemtype (string $ itemtype, ? RestApiClientInterface $ client = null ): ?EmbodiedImpactInterface
62+ public static function getEngineFromItemtype (string $ itemtype ): ?EmbodiedImpactInterface
6463 {
6564 $ embodied_impact_namespace = Config::getEmbodiedImpactEngine ();
6665 $ embodied_impact_class = $ embodied_impact_namespace . '\\' . $ itemtype ;
@@ -72,7 +71,7 @@ public static function getEngineFromItemtype(string $itemtype, ?RestApiClientInt
7271 /** @var AbstractEmbodiedImpact $embodied_impact */
7372 $ embodied_impact = new $ embodied_impact_class ();
7473 try {
75- return self ::configureEngine ($ embodied_impact, $ client );
74+ return self ::configureEngine ($ embodied_impact );
7675 } catch (\RuntimeException $ e ) {
7776 // If the engine cannot be configured, it is not usable
7877 return null ;
@@ -100,20 +99,15 @@ public static function getInternalEngineFromItemtype(string $itemtype): ?Embodie
10099 * Configure the engine depending on its specificities
101100 *
102101 * @param EmbodiedImpactInterface $engine the engine to configure
103- * @param ?RestApiClientInterface $client
104102 * @return EmbodiedImpactInterface the configured engine
105103 */
106- protected static function configureEngine (EmbodiedImpactInterface $ engine, ? RestApiClientInterface $ client = null ): EmbodiedImpactInterface
104+ protected static function configureEngine (EmbodiedImpactInterface $ engine ): EmbodiedImpactInterface
107105 {
108106 $ embodied_impact_namespace = explode ('\\' , get_class ($ engine ));
109107 switch (array_slice ($ embodied_impact_namespace , -2 , 1 )[0 ]) {
110108 case 'Boavizta ' :
111- if ($ client === null ) {
112- throw new \RuntimeException ('A RestApiClientInterface instance is required to configure Boavizta embodied impact engine ' );
113- }
114109 /** @var AbstractAsset $engine */
115- $ client = $ client ?? new RestApiClient ();
116- $ engine ->setClient (new Boaviztapi ($ client ));
110+ $ engine ->setClient (new Boaviztapi (new RestApiClient ()));
117111 }
118112
119113 return $ engine ;
0 commit comments