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
/**
9
 * Tests if the argument is a string that contains a substring.
10
 */
11
class StringStartsWith extends SubstringMatcher
12
{
13
 
14
    public function __construct($substring)
15
    {
16
        parent::__construct($substring);
17
    }
18
 
19
    /**
20
     * Matches if value is a string that starts with $substring.
21
     *
22
     * @factory
23
     */
24
    public static function startsWith($substring)
25
    {
26
        return new self($substring);
27
    }
28
 
29
    // -- Protected Methods
30
 
31
    protected function evalSubstringOf($string)
32
    {
33
        return (substr($string, 0, strlen($this->_substring)) === $this->_substring);
34
    }
35
 
36
    protected function relationship()
37
    {
38
        return 'starting with';
39
    }
40
}