You are here

class BasicPath in AmazonS3 7.2

A path pattern to use when testing URL paths.

@class BasicPath @package Drupal\amazons3\Matchable

Hierarchy

Expanded class hierarchy of BasicPath

5 files declare their use of BasicPath
BasicPathTest.php in tests/Matchable/BasicPathTest.php
MatchablePathsTest.php in tests/Matchable/MatchablePathsTest.php
StreamWrapper.php in src/StreamWrapper.php
Drupal stream wrapper implementation for Amazon S3
StreamWrapperConfiguration.php in src/StreamWrapperConfiguration.php
StreamWrapperTest.php in tests/StreamWrapperTest.php

File

src/Matchable/BasicPath.php, line 11

Namespace

Drupal\amazons3\Matchable
View source
class BasicPath implements Matchable {
  use MatchableRegex;

  /**
   * The path pattern for this presigned path configuration.
   *
   * @var string
   */
  protected $pattern;

  /**
   * Create an array of BasicPaths.
   *
   * @param array $patterns
   *   An array of regular expression patterns to use when creating the basic
   *   path.
   *
   * @return BasicPath[]
   *   An array of BasicPaths.
   */
  public static function factory(array $patterns) {
    $basicPaths = array();
    foreach ($patterns as $pattern) {
      $basicPaths[] = new static($pattern);
    }
    return $basicPaths;
  }

  /**
   * Construct a new BasicPath.
   *
   * @param $pattern
   *   An regular expression pattern, without start and end markers.
   */
  public function __construct($pattern) {
    $result = @preg_match('#' . strtr($pattern, '#', '\\#') . '#', 'foo');
    if ($pattern != '*' && ($result === FALSE || preg_last_error() != PREG_NO_ERROR)) {
      throw new \InvalidArgumentException('BasicPath pattern is not a valid regular expression.');
    }
    $this->pattern = $pattern;
  }

  /**
   * @return string
   */
  public function getPath() {
    return $this->pattern;
  }

  /**
   * @return string
   */
  function __toString() {
    return $this->pattern;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BasicPath::$pattern protected property The path pattern for this presigned path configuration.
BasicPath::factory public static function Create an array of BasicPaths. 1
BasicPath::getPath public function 1
BasicPath::__construct public function Construct a new BasicPath. 1
BasicPath::__toString function Overrides MatchableRegex::__toString
MatchableRegex::match public function