/** * @param string $string * @return bool */ public function allows($string) { Assertion::string($string, 'Scope to check should be a string, "%s" given'); if (!$this->isRegexp) { return $this->scope === $string; } $regexp = new RegularExpression($this->scope); return $regexp->matches($string); }
/** * @param string $string * @return bool */ public function inScope($string) { Assertion::string($string, 'Scope to check must be a string, "%s" given', 'string'); foreach ($this->scopes as $scope) { if ($scope->allows($string)) { return true; } } return false; }
/** * @param string * @return bool */ public function matches($string) { Assertion::string($string, 'String to match pattern against is not a string, "%s" given'); return preg_match($this->pattern, $string) === 1; }