[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/laminas/laminas-zendframework-bridge/src/ -> Replacements.php (source)

   1  <?php
   2  
   3  /**
   4   * @see       https://github.com/laminas/laminas-zendframework-bridge for the canonical source repository
   5   * @copyright https://github.com/laminas/laminas-zendframework-bridge/blob/master/COPYRIGHT.md
   6   * @license   https://github.com/laminas/laminas-zendframework-bridge/blob/master/LICENSE.md New BSD License
   7   */
   8  
   9  namespace Laminas\ZendFrameworkBridge;
  10  
  11  use function array_merge;
  12  use function str_replace;
  13  use function strpos;
  14  use function strtr;
  15  
  16  class Replacements
  17  {
  18      /** @var string[] */
  19      private $replacements;
  20  
  21      public function __construct(array $additionalReplacements = [])
  22      {
  23          $this->replacements = array_merge(
  24              require __DIR__ . '/../config/replacements.php',
  25              $additionalReplacements
  26          );
  27  
  28          // Provide multiple variants of strings containing namespace separators
  29          foreach ($this->replacements as $original => $replacement) {
  30              if (false === strpos($original, '\\')) {
  31                  continue;
  32              }
  33              $this->replacements[str_replace('\\', '\\\\', $original)] = str_replace('\\', '\\\\', $replacement);
  34              $this->replacements[str_replace('\\', '\\\\\\\\', $original)] = str_replace('\\', '\\\\\\\\', $replacement);
  35          }
  36      }
  37  
  38      /**
  39       * @param string $value
  40       * @return string
  41       */
  42      public function replace($value)
  43      {
  44          return strtr($value, $this->replacements);
  45      }
  46  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer