[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/doctrine/inflector/lib/Doctrine/Inflector/Rules/ -> Pattern.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace Doctrine\Inflector\Rules;
   6  
   7  use function preg_match;
   8  
   9  final class Pattern
  10  {
  11      /** @var string */
  12      private $pattern;
  13  
  14      /** @var string */
  15      private $regex;
  16  
  17      public function __construct(string $pattern)
  18      {
  19          $this->pattern = $pattern;
  20  
  21          if (isset($this->pattern[0]) && $this->pattern[0] === '/') {
  22              $this->regex = $this->pattern;
  23          } else {
  24              $this->regex = '/' . $this->pattern . '/i';
  25          }
  26      }
  27  
  28      public function getPattern(): string
  29      {
  30          return $this->pattern;
  31      }
  32  
  33      public function getRegex(): string
  34      {
  35          return $this->regex;
  36      }
  37  
  38      public function matches(string $word): bool
  39      {
  40          return preg_match($this->getRegex(), $word) === 1;
  41      }
  42  }


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