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\Collection;
3
 
4
/*
5
 Copyright (c) 2009 hamcrest.org
6
 */
7
use Hamcrest\FeatureMatcher;
8
use Hamcrest\Matcher;
9
use Hamcrest\Util;
10
 
11
/**
12
 * Matches if traversable size satisfies a nested matcher.
13
 */
14
class IsTraversableWithSize extends FeatureMatcher
15
{
16
 
17
    public function __construct(Matcher $sizeMatcher)
18
    {
19
        parent::__construct(
20
            self::TYPE_OBJECT,
21
            'Traversable',
22
            $sizeMatcher,
23
            'a traversable with size',
24
            'traversable size'
25
        );
26
    }
27
 
28
    protected function featureValueOf($actual)
29
    {
30
        $size = 0;
31
        foreach ($actual as $value) {
32
            $size++;
33
        }
34
 
35
        return $size;
36
    }
37
 
38
    /**
39
     * Does traversable size satisfy a given matcher?
40
     *
41
     * @factory
42
     */
43
    public static function traversableWithSize($size)
44
    {
45
        return new self(Util::wrapValueWithIsEqual($size));
46
    }
47
}