for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Arrays\Collection\Modifier;
use Yiisoft\Arrays\Collection\Modifier\ModifierInterface\DataModifierInterface;
/**
* "Unset Value" modifiers removes an array element with a given key.
*/
final class UnsetValue implements DataModifierInterface
{
* @var int|string
private $key;
* @param int|string $key
public function __construct($key)
$this->key = $key;
}
* @return self
public function withKey($key): self
$new = clone $this;
$new->key = $key;
return $new;
public function apply(array $data): array
unset($data[$this->key]);
return $data;