for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Oqq\Minc\Common\Collection;
use Oqq\Minc\Common\Collection\Exception\KeyIsNotDefinedException;
/**
* @author Eric Braun <[email protected]>
*/
abstract class AbstractCollection implements CollectionInterface
{
/** @var array */
protected $values;
* @param array $values
public function __construct(array $values = [])
$this->values = $values;
}
* @inheritdoc
public function __get($key)
return $this->get($key);
public function containsKey($key)
return isset($this->values[$key]) || array_key_exists($key, $this->values);
public function get($key)
$this->assertContainsKey($key);
return $this->values[$key];
public function contains($value)
return false !== array_search($value, $this->values, true);
* @inheritDoc
public function current()
return $this->get($this->key());
public function next()
next($this->values);
public function key()
return key($this->values);
public function valid()
return null !== $this->key();
public function rewind()
reset($this->values);
public function count()
return count($this->values);
* @param mixed $key
*
* @throws KeyIsNotDefinedException
protected function assertContainsKey($key)
if (!$this->containsKey($key)) {
throw new KeyIsNotDefinedException($key);