for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tleckie\Acl;
use Tleckie\Acl\Resource\ResourceInterface;
/**
* Class Resource
*
* @package Tleckie\Acl
* @author Teodoro Leckie Westberg <[email protected]>
*/
class Resource implements ResourceInterface
{
/** @var string */
private string $id;
/** @var ResourceInterface[] */
private array $parents;
private array $children;
* Resource 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(ResourceInterface $resource): ResourceInterface
$this->parents[(string)$resource] = $resource;
return $this;
public function removeParent(ResourceInterface $resource): ResourceInterface
unset($this->parents[(string)$resource]);
public function parents(): array
return $this->parents;
public function hasParents(): bool
return !empty($this->parents);
public function addChildren(ResourceInterface $resource): ResourceInterface
$this->children[(string)$resource] = $resource;
public function removeChildren(ResourceInterface $resource): ResourceInterface
unset($this->children[(string)$resource]);
public function children(): array
return $this->children;