for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tleckie\Acl;
use Tleckie\Acl\Role\RoleInterface;
/**
* Class Role
*
* @package Tleckie\Acl
* @author Teodoro Leckie Westberg <[email protected]>
*/
class Role implements RoleInterface
{
/** @var string */
private string $id;
/** @var RoleInterface[] */
private array $parents;
private array $children;
* Role constructor.
* @param string $id
public function __construct(string $id)
$this->id = $id;
$this->parents = [];
$this->children = [];
}
* @inheritdoc
public function __toString(): string
return $this->id;
public function addParent(RoleInterface $role): RoleInterface
$this->parents[(string)$role] = $role;
return $this;
public function removeParent(RoleInterface $role): RoleInterface
unset($this->parents[(string)$role]);
public function parents(): array
return $this->parents;
public function hasParents(): bool
return !empty($this->parents);
public function addChildren(RoleInterface $role): RoleInterface
$this->children[(string)$role] = $role;
public function removeChildren(RoleInterface $role): RoleInterface
unset($this->children[(string)$role]);
public function children(): array
return $this->children;