4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Expression;
14 @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
17 * @author Jean-François Simon <contact@jfsimon.fr>
19 class Expression implements ValueInterface
34 public static function create($expr)
36 return new self($expr);
42 public function __construct($expr)
45 $this->value = Regex::create($expr);
46 } catch (\InvalidArgumentException $e) {
47 $this->value = new Glob($expr);
54 public function __toString()
56 return $this->render();
62 public function render()
64 return $this->value->render();
70 public function renderPattern()
72 return $this->value->renderPattern();
78 public function isCaseSensitive()
80 return $this->value->isCaseSensitive();
86 public function getType()
88 return $this->value->getType();
94 public function prepend($expr)
96 $this->value->prepend($expr);
104 public function append($expr)
106 $this->value->append($expr);
114 public function isRegex()
116 return self::TYPE_REGEX === $this->value->getType();
122 public function isGlob()
124 return self::TYPE_GLOB === $this->value->getType();
130 * @throws \LogicException
132 public function getGlob()
134 if (self::TYPE_GLOB !== $this->value->getType()) {
135 throw new \LogicException('Regex can\'t be transformed to glob.');
144 public function getRegex()
146 return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();