Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Expression / Glob.php
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__.'\Glob class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
15
16 use Symfony\Component\Finder\Glob as FinderGlob;
17
18 /**
19  * @author Jean-François Simon <contact@jfsimon.fr>
20  */
21 class Glob implements ValueInterface
22 {
23     /**
24      * @var string
25      */
26     private $pattern;
27
28     /**
29      * @param string $pattern
30      */
31     public function __construct($pattern)
32     {
33         $this->pattern = $pattern;
34     }
35
36     /**
37      * {@inheritdoc}
38      */
39     public function render()
40     {
41         return $this->pattern;
42     }
43
44     /**
45      * {@inheritdoc}
46      */
47     public function renderPattern()
48     {
49         return $this->pattern;
50     }
51
52     /**
53      * {@inheritdoc}
54      */
55     public function getType()
56     {
57         return Expression::TYPE_GLOB;
58     }
59
60     /**
61      * {@inheritdoc}
62      */
63     public function isCaseSensitive()
64     {
65         return true;
66     }
67
68     /**
69      * {@inheritdoc}
70      */
71     public function prepend($expr)
72     {
73         $this->pattern = $expr.$this->pattern;
74
75         return $this;
76     }
77
78     /**
79      * {@inheritdoc}
80      */
81     public function append($expr)
82     {
83         $this->pattern .= $expr;
84
85         return $this;
86     }
87
88     /**
89      * Tests if glob is expandable ("*.{a,b}" syntax).
90      *
91      * @return bool
92      */
93     public function isExpandable()
94     {
95         return false !== strpos($this->pattern, '{')
96             && false !== strpos($this->pattern, '}');
97     }
98
99     /**
100      * @param bool $strictLeadingDot
101      * @param bool $strictWildcardSlash
102      *
103      * @return Regex
104      */
105     public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
106     {
107         $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
108
109         return new Regex($regex);
110     }
111 }