for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace CCT\Component\Collections\Traits;
trait ParameterCollectionTrait
{
/**
* @var array
*/
protected $elements;
* {@inheritdoc}
public function set($key, $value): void
$this->elements[$key] = $value;
}
public function get($key, $default = null)
return $this->has($key)
? $this->elements[$key]
: $default
;
public function keys(): array
return array_keys($this->elements);
public function values(): array
return array_values($this->elements);
public function remove($key)
if (false === $this->has($key)) {
return null;
$element = $this->elements[$key];
unset($this->elements[$key]);
return $element;
public function addElements(array $elements): void
$this->elements = array_replace($this->elements, $elements);
public function clear(): void
$this->elements = [];
public function replace(array $elements = []): void
$this->elements = $elements;
public function has($key) : bool
return isset($this->elements[$key]) || array_key_exists($key, $this->elements);