for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Polidog\Chatwork\Entity\Collection;
use Polidog\Chatwork\Entity\EntityInterface;
use Polidog\Chatwork\Exception\OutOfBoundsException;
abstract class AbstractCollection implements \IteratorAggregate, \Countable, CollectionInterface
{
protected $entities = [];
/**
* @param array $entities
*/
public function __construct(array $entities = [])
$this->entities = $entities;
}
* {@inheritdoc}
public function add(EntityInterface $entity)
$this->entities[] = $entity;
return $this;
public function get($idx)
if (!array_key_exists($idx, $this->entities)) {
throw new OutOfBoundsException('index not found, index:'.$idx);
return $this->entities[$idx];
* @return \ArrayIterator
public function getIterator()
foreach ($this->entities as $key => $entity) {
yield $key => $entity;
yield $key => $entity
Generator
ArrayIterator
public function count()
return count($this->entities);