[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/finder/Expression/ -> Expression.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Finder\Expression;
  13  
  14  @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  15  
  16  /**
  17   * @author Jean-François Simon <contact@jfsimon.fr>
  18   */
  19  class Expression implements ValueInterface
  20  {
  21      const TYPE_REGEX = 1;
  22      const TYPE_GLOB = 2;
  23  
  24      /**
  25       * @var ValueInterface
  26       */
  27      private $value;
  28  
  29      /**
  30       * @param string $expr
  31       *
  32       * @return self
  33       */
  34      public static function create($expr)
  35      {
  36          return new self($expr);
  37      }
  38  
  39      /**
  40       * @param string $expr
  41       */
  42      public function __construct($expr)
  43      {
  44          try {
  45              $this->value = Regex::create($expr);
  46          } catch (\InvalidArgumentException $e) {
  47              $this->value = new Glob($expr);
  48          }
  49      }
  50  
  51      /**
  52       * @return string
  53       */
  54      public function __toString()
  55      {
  56          return $this->render();
  57      }
  58  
  59      /**
  60       * {@inheritdoc}
  61       */
  62      public function render()
  63      {
  64          return $this->value->render();
  65      }
  66  
  67      /**
  68       * {@inheritdoc}
  69       */
  70      public function renderPattern()
  71      {
  72          return $this->value->renderPattern();
  73      }
  74  
  75      /**
  76       * @return bool
  77       */
  78      public function isCaseSensitive()
  79      {
  80          return $this->value->isCaseSensitive();
  81      }
  82  
  83      /**
  84       * @return int
  85       */
  86      public function getType()
  87      {
  88          return $this->value->getType();
  89      }
  90  
  91      /**
  92       * {@inheritdoc}
  93       */
  94      public function prepend($expr)
  95      {
  96          $this->value->prepend($expr);
  97  
  98          return $this;
  99      }
 100  
 101      /**
 102       * {@inheritdoc}
 103       */
 104      public function append($expr)
 105      {
 106          $this->value->append($expr);
 107  
 108          return $this;
 109      }
 110  
 111      /**
 112       * @return bool
 113       */
 114      public function isRegex()
 115      {
 116          return self::TYPE_REGEX === $this->value->getType();
 117      }
 118  
 119      /**
 120       * @return bool
 121       */
 122      public function isGlob()
 123      {
 124          return self::TYPE_GLOB === $this->value->getType();
 125      }
 126  
 127      /**
 128       * @return Glob
 129       *
 130       * @throws \LogicException
 131       */
 132      public function getGlob()
 133      {
 134          if (self::TYPE_GLOB !== $this->value->getType()) {
 135              throw new \LogicException('Regex can\'t be transformed to glob.');
 136          }
 137  
 138          return $this->value;
 139      }
 140  
 141      /**
 142       * @return Regex
 143       */
 144      public function getRegex()
 145      {
 146          return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
 147      }
 148  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1