for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the bisarca/graph package.
*
* (c) Emanuele Minotto <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Bisarca\Graph\Attribute;
/**
* Trait to facilitate attributes implementation.
trait AttributeAwareTrait
{
* Contained attributes.
* @var array
private $attributes = [];
* {@inheritdoc}
public function setAttribute(string $name, $value)
$this->attributes[$name] = $value;
}
public function getAttribute(string $name, $default = null)
return $this->attributes[$name] ?? $default;
public function removeAttribute(string $name)
unset($this->attributes[$name]);
public function hasAttribute(string $name): bool
return isset($this->attributes[$name]);
public function getAttributes(): array
return $this->attributes;
public function clearAttributes()
$this->attributes = [];
public function hasAttributes(): bool
return !empty($this->attributes);