$stack */ private array $stack = []; /** * Chek if a group exists. * * @param string $id The group ID * * @return bool True if it exists */ public function has(string $id): bool { return isset($this->stack[$id]); } /** * Add a group. * * Existing group will be overwritten. * * @param Group $group The group object * * @return Groups The groups instance */ public function add(Group $group): Groups { $this->stack[$group->id] = $group; return $this; } /** * Get a group. * * @param string $id The group ID * * @return Group The group descriptor */ public function get(string $id): Group { return $this->stack[$id] ?? new Group($id, 'undefined'); } /** * Get all groups. * * @return array The groups stack */ public function dump(): array { return $this->stack; } }