You are here

trait MatchableRegex in AmazonS3 7.2

Base class for objects that can be matched against a regular expression.

This class also handles '*' to mean 'any string'.

@class MatchableRegex @package Drupal\amazons3\Matchable

Hierarchy

File

src/Matchable/MatchableRegex.php, line 13

Namespace

Drupal\amazons3\Matchable
View source
trait MatchableRegex {

  /**
   * {@inheritdoc}
   */
  public function match($subject) {
    $pattern = $this
      ->__toString();
    if ($pattern === '*' || preg_match('#' . strtr($pattern, '#', '\\#') . '#', $subject)) {
      return $this;
    }
    return FALSE;
  }

  /**
   * Return the pattern this object matches against.
   *
   * @return string
   */
  public abstract function __toString();

}

Members

Namesort descending Modifiers Type Description Overrides
MatchableRegex::match public function
MatchableRegex::__toString abstract public function Return the pattern this object matches against. 1