for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Greppy package.
*
* (c) Daniel Ribeiro <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Relax\Greppy;
/**
* A basic regex matcher.
* @author Daniel Ribeiro <[email protected]>
* @package Greppy
final class SimpleMatcher implements Matcher
{
* @var string
private $subject;
* @param string $subject The subject to match against
* @throws \InvalidArgumentException
public function __construct($subject)
if (!is_string($subject)) {
throw new \InvalidArgumentException(sprintf("Expected string subject, got %s.", $subject));
}
$this->subject = $subject;
* {@inheritdoc}
public function getSubject()
return $this->subject;
public function matches(Pattern $pattern)
return (bool) preg_match((string) $pattern, $this->getSubject());