HttpServiceApiWrapperFactory.php in HTTP Client Manager 8.2
File
src/HttpServiceApiWrapperFactory.php
View source
<?php
namespace Drupal\http_client_manager;
use Drupal\http_client_manager\Plugin\HttpServiceApiWrapper\HttpServiceApiWrapperInterface;
class HttpServiceApiWrapperFactory implements HttpServiceApiWrapperFactoryInterface {
protected $apiWrappers;
public function __construct() {
$this->apiWrappers = [];
}
public function addApiWrapper(HttpServiceApiWrapperInterface $wrapper, $api) {
$this->apiWrappers[$api] = $wrapper;
}
public function get($name) {
if (!isset($this->apiWrappers[$name])) {
$message = sprintf('Cannot find an api wrapper with the name "%s', $name);
throw new \InvalidArgumentException($message);
}
return $this->apiWrappers[$name];
}
}