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) 2009 hamcrest.org
6
 */
7
 
8
use Hamcrest\Description;
9
use Hamcrest\TypeSafeMatcher;
10
 
11
abstract class SubstringMatcher extends TypeSafeMatcher
12
{
13
 
14
    protected $_substring;
15
 
16
    public function __construct($substring)
17
    {
18
        parent::__construct(self::TYPE_STRING);
19
 
20
        $this->_substring = $substring;
21
    }
22
 
23
    protected function matchesSafely($item)
24
    {
25
        return $this->evalSubstringOf($item);
26
    }
27
 
28
    protected function describeMismatchSafely($item, Description $mismatchDescription)
29
    {
30
        $mismatchDescription->appendText('was "')->appendText($item)->appendText('"');
31
    }
32
 
33
    public function describeTo(Description $description)
34
    {
35
        $description->appendText('a string ')
36
                                ->appendText($this->relationship())
37
                                ->appendText(' ')
38
                                ->appendValue($this->_substring)
39
                                ;
40
    }
41
 
42
    abstract protected function evalSubstringOf($string);
43
 
44
    abstract protected function relationship();
45
}