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
use Hamcrest\Description;
8
use Hamcrest\TypeSafeMatcher;
9
 
10
/**
11
 * Tests if a string is equal to another string, regardless of the case.
12
 */
13
class IsEqualIgnoringCase extends TypeSafeMatcher
14
{
15
 
16
    private $_string;
17
 
18
    public function __construct($string)
19
    {
20
        parent::__construct(self::TYPE_STRING);
21
 
22
        $this->_string = $string;
23
    }
24
 
25
    protected function matchesSafely($item)
26
    {
27
        return strtolower($this->_string) === strtolower($item);
28
    }
29
 
30
    protected function describeMismatchSafely($item, Description $mismatchDescription)
31
    {
32
        $mismatchDescription->appendText('was ')->appendText($item);
33
    }
34
 
35
    public function describeTo(Description $description)
36
    {
37
        $description->appendText('equalToIgnoringCase(')
38
                                ->appendValue($this->_string)
39
                                ->appendText(')')
40
                                ;
41
    }
42
 
43
    /**
44
     * Matches if value is a string equal to $string, regardless of the case.
45
     *
46
     * @factory
47
     */
48
    public static function equalToIgnoringCase($string)
49
    {
50
        return new self($string);
51
    }
52
}