for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bdf\Form\View;
use ArgumentCountError;
use TypeError;
/**
* Implements @see Renderable
*/
trait RenderableTrait
{
* @var array
private $attributes = [];
* {@inheritdoc}
public function __call(string $name, array $arguments)
if (empty($arguments)) {
throw new ArgumentCountError('Missing the attribute value.');
}
return $this->set($name, $arguments[0]);
public function set(string $name, $value)
if (!is_scalar($value)) {
throw new TypeError('The attribute value must be a scalar value.');
$this->attributes[$name] = $value;
return $this;
public function unset(string $name)
unset($this->attributes[$name]);
public function attributes(): array
return $this->attributes;
abstract public function render(): string;
public function __toString(): string
return $this->render();