[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/src/ProxyManager/Inflector/ -> ClassNameInflector.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace ProxyManager\Inflector;
   6  
   7  use ProxyManager\Inflector\Util\ParameterHasher;
   8  
   9  /**
  10   * {@inheritDoc}
  11   *
  12   * @author Marco Pivetta <ocramius@gmail.com>
  13   * @license MIT
  14   */
  15  final class ClassNameInflector implements ClassNameInflectorInterface
  16  {
  17      /**
  18       * @var string
  19       */
  20      protected $proxyNamespace;
  21  
  22      /**
  23       * @var int
  24       */
  25      private $proxyMarkerLength;
  26  
  27      /**
  28       * @var string
  29       */
  30      private $proxyMarker;
  31  
  32      /**
  33       * @var \ProxyManager\Inflector\Util\ParameterHasher
  34       */
  35      private $parameterHasher;
  36  
  37      /**
  38       * @param string $proxyNamespace
  39       */
  40      public function __construct(string $proxyNamespace)
  41      {
  42          $this->proxyNamespace    = $proxyNamespace;
  43          $this->proxyMarker       = '\\' . static::PROXY_MARKER . '\\';
  44          $this->proxyMarkerLength = strlen($this->proxyMarker);
  45          $this->parameterHasher   = new ParameterHasher();
  46      }
  47  
  48      /**
  49       * {@inheritDoc}
  50       */
  51      public function getUserClassName(string $className) : string
  52      {
  53          $className = ltrim($className, '\\');
  54  
  55          if (false === $position = strrpos($className, $this->proxyMarker)) {
  56              return $className;
  57          }
  58  
  59          return substr(
  60              $className,
  61              $this->proxyMarkerLength + $position,
  62              strrpos($className, '\\') - ($position + $this->proxyMarkerLength)
  63          );
  64      }
  65  
  66      /**
  67       * {@inheritDoc}
  68       */
  69      public function getProxyClassName(string $className, array $options = []) : string
  70      {
  71          return $this->proxyNamespace
  72              . $this->proxyMarker
  73              . $this->getUserClassName($className)
  74              . '\\Generated' . $this->parameterHasher->hashParameters($options);
  75      }
  76  
  77      /**
  78       * {@inheritDoc}
  79       */
  80      public function isProxyClassName(string $className) : bool
  81      {
  82          return false !== strrpos($className, $this->proxyMarker);
  83      }
  84  }


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