for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Boudewijn Schoon <[email protected]>
* @copyright Zicht Online <http://zicht.nl>
*/
namespace Zicht\Itertools\lib\Containers;
* Class Pair
*
* @package Zicht\Itertools\lib\Containers
class KeyValuePair implements \ArrayAccess
{
/** @var mixed */
public $key;
public $value;
* Pair constructor.
* @param mixed $key
* @param mixed $value
public function __construct($key = null, $value = null)
$this->key = $key;
$this->value = $value;
}
* @{inheritDoc}
public function offsetExists($offset)
return in_array($offset, [0, 1, 'key', 'value']);
public function offsetGet($offset)
if ($offset === 0 || $offset === 'key') {
return $this->key;
if ($offset === 1 || $offset === 'value') {
return $this->value;
throw new \InvalidArgumentException('$OFFSET must be either 0, 1, "key", or "value"');
public function offsetSet($offset, $value)
$this->key = $value;
public function offsetUnset($offset)
return $this->offsetSet($offset, null);