Page MenuHomeWickedGov Phorge

IsTraversableWithSize.php
No OneTemporary

Size
923 B
Referenced Files
None
Subscribers
None

IsTraversableWithSize.php

<?php
namespace Hamcrest\Collection;
/*
Copyright (c) 2009 hamcrest.org
*/
use Hamcrest\FeatureMatcher;
use Hamcrest\Matcher;
use Hamcrest\Util;
/**
* Matches if traversable size satisfies a nested matcher.
*/
class IsTraversableWithSize extends FeatureMatcher
{
public function __construct(Matcher $sizeMatcher)
{
parent::__construct(
self::TYPE_OBJECT,
'Traversable',
$sizeMatcher,
'a traversable with size',
'traversable size'
);
}
protected function featureValueOf($actual)
{
$size = 0;
foreach ($actual as $value) {
$size++;
}
return $size;
}
/**
* Does traversable size satisfy a given matcher?
*
* @factory
*/
public static function traversableWithSize($size)
{
return new self(Util::wrapValueWithIsEqual($size));
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, May 16, 22:39 (2 h, 49 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
26/52/3756e6644c3c409b70fe27025021
Default Alt Text
IsTraversableWithSize.php (923 B)

Event Timeline