Drupal investigation

Glob.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Finder\Expression;
  11. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  12. use Symfony\Component\Finder\Glob as FinderGlob;
  13. /**
  14. * @author Jean-François Simon <contact@jfsimon.fr>
  15. */
  16. class Glob implements ValueInterface
  17. {
  18. /**
  19. * @var string
  20. */
  21. private $pattern;
  22. /**
  23. * @param string $pattern
  24. */
  25. public function __construct($pattern)
  26. {
  27. $this->pattern = $pattern;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function render()
  33. {
  34. return $this->pattern;
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function renderPattern()
  40. {
  41. return $this->pattern;
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getType()
  47. {
  48. return Expression::TYPE_GLOB;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function isCaseSensitive()
  54. {
  55. return true;
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function prepend($expr)
  61. {
  62. $this->pattern = $expr.$this->pattern;
  63. return $this;
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function append($expr)
  69. {
  70. $this->pattern .= $expr;
  71. return $this;
  72. }
  73. /**
  74. * Tests if glob is expandable ("*.{a,b}" syntax).
  75. *
  76. * @return bool
  77. */
  78. public function isExpandable()
  79. {
  80. return false !== strpos($this->pattern, '{')
  81. && false !== strpos($this->pattern, '}');
  82. }
  83. /**
  84. * @param bool $strictLeadingDot
  85. * @param bool $strictWildcardSlash
  86. *
  87. * @return Regex
  88. */
  89. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  90. {
  91. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  92. return new Regex($regex);
  93. }
  94. }