Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
namespace Hamcrest\Text;
3
 
4
/*
5
 Copyright (c) 2010 hamcrest.org
6
 */
7
 
8
/**
9
 * Tests if the argument is a string that matches a regular expression.
10
 */
11
class MatchesPattern extends SubstringMatcher
12
{
13
 
14
    public function __construct($pattern)
15
    {
16
        parent::__construct($pattern);
17
    }
18
 
19
    /**
20
     * Matches if value is a string that matches regular expression $pattern.
21
     *
22
     * @factory
23
     */
24
    public static function matchesPattern($pattern)
25
    {
26
        return new self($pattern);
27
    }
28
 
29
    // -- Protected Methods
30
 
31
    protected function evalSubstringOf($item)
32
    {
33
        return preg_match($this->_substring, (string) $item) >= 1;
34
    }
35
 
36
    protected function relationship()
37
    {
38
        return 'matching';
39
    }
40
}