for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace PTS\Psr7;
use function array_key_exists;
trait ServerMessage
{
protected array $attributes = [];
/**
* @return array
*/
public function getAttributes(): array
return $this->attributes;
}
* @param string $attribute
* @param mixed $default
*
* @return mixed
public function getAttribute($attribute, $default = null)
if (false === array_key_exists($attribute, $this->attributes)) {
return $default;
return $this->attributes[$attribute];
* @param mixed $value
* @return $this
public function withAttribute($attribute, $value)
$this->attributes[$attribute] = $value;
return $this;
public function withoutAttribute($attribute)
unset($this->attributes[$attribute]);