protected function matches($actual)
{
if ($this->analyzer->isInteger($this->expected) === false) {
throw new \PHPUnit_Framework_Exception('Expected value of ' . __CLASS__ . ' must be an integer');
}
switch (true) {
case $this->analyzer->isArray($actual):
$asserter = new asserters\phpArray(null, $this->analyzer);
$asserter->setWith($actual)->hasSize($this->expected);
break;
case $actual instanceof \countable:
$asserter = new asserters\sizeOf(null, $this->analyzer);
$asserter->setWith($actual)->isEqualTo($this->expected);
break;
case $actual instanceof \iteratorAggregate:
$asserter = new asserters\integer(null, $this->analyzer);
$asserter->setWith(iterator_count($actual->getIterator()))->isEqualTo($this->expected);
break;
case $actual instanceof \traversable:
case $actual instanceof \iterator:
$asserter = new asserters\integer(null, $this->analyzer);
$asserter->setWith(iterator_count($actual))->isEqualTo($this->expected);
break;
default:
throw new \PHPUnit_Framework_Exception('Actual value of ' . __CLASS__ . ' must be an array, a countable object or a traversable object');
}
}