[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/ -> BaseAdapter.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace ProxyManager\Factory\RemoteObject\Adapter;
   6  
   7  use ProxyManager\Factory\RemoteObject\AdapterInterface;
   8  use Zend\Server\Client;
   9  
  10  /**
  11   * Remote Object base adapter
  12   *
  13   * @author Vincent Blanchon <blanchon.vincent@gmail.com>
  14   * @license MIT
  15   */
  16  abstract class BaseAdapter implements AdapterInterface
  17  {
  18      /**
  19       * Adapter client
  20       *
  21       * @var \Zend\Server\Client
  22       */
  23      protected $client;
  24  
  25      /**
  26       * Service name mapping
  27       *
  28       * @var string[]
  29       */
  30      protected $map = [];
  31  
  32      /**
  33       * Constructor
  34       *
  35       * @param Client $client
  36       * @param array  $map    map of service names to their aliases
  37       */
  38      public function __construct(Client $client, array $map = [])
  39      {
  40          $this->client = $client;
  41          $this->map    = $map;
  42      }
  43  
  44      /**
  45       * {@inheritDoc}
  46       */
  47      public function call(string $wrappedClass, string $method, array $params = [])
  48      {
  49          $serviceName = $this->getServiceName($wrappedClass, $method);
  50  
  51          if (\array_key_exists($serviceName, $this->map)) {
  52              $serviceName = $this->map[$serviceName];
  53          }
  54  
  55          return $this->client->call($serviceName, $params);
  56      }
  57  
  58      /**
  59       * Get the service name will be used by the adapter
  60       */
  61      abstract protected function getServiceName(string $wrappedClass, string $method) : string;
  62  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1