for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Everlution\Navigation\Voter\Regex;
use Everlution\Navigation\Property\BaseProperty;
use Everlution\Navigation\Voter\Match;
use Everlution\Navigation\Voter\Voter;
/**
* Class RegexMatch.
* @author Ivan Barlog <[email protected]>
*/
class RegexMatch extends BaseProperty implements Match
{
/** @var string */
private $regex;
private $pattern;
private $modifiers;
public function __construct(string $pattern, string $modifiers = '')
$regex = sprintf('/%s/%s', str_replace('/', '\/', $pattern), $modifiers);
if (false === preg_match($regex, '')) {
throw new InvalidRegexPatternException($pattern);
}
$this->regex = $regex;
$this->pattern = $pattern;
$this->modifiers = $modifiers;
* @param Voter $voter
* @return null|string
public function accept(Voter &$voter)
if (!$voter instanceof RegexVoter) {
return null;
return $this->regex;
* @return string
public function getPattern(): string
return $this->pattern;
public function getModifiers(): string
return $this->modifiers;