* @license MIT */ abstract class BaseAdapter implements AdapterInterface { /** * Adapter client * * @var \Zend\Server\Client */ protected $client; /** * Service name mapping * * @var string[] */ protected $map = array(); /** * Constructor * * @param Client $client * @param array $map map of service names to their aliases */ public function __construct(Client $client, array $map = array()) { $this->client = $client; $this->map = $map; } /** * {@inheritDoc} */ public function call($wrappedClass, $method, array $params = array()) { $serviceName = $this->getServiceName($wrappedClass, $method); if (isset($this->map[$serviceName])) { $serviceName = $this->map[$serviceName]; } return $this->client->call($serviceName, $params); } /** * Get the service name will be used by the adapter * * @param string $wrappedClass * @param string $method * * @return string Service name */ abstract protected function getServiceName($wrappedClass, $method); }