packages/sql-semantics-postgres/src/Statement/Catalog/Access/Role/RoleMembersKind.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Role;
6
7/**
8 * The role options that list other roles: the value of a case is its keywords.
9 *
10 * ROLE and USER list the members of the new role, ADMIN lists members that
11 * may grant the membership, IN ROLE and IN GROUP list the roles the new role
12 * becomes a member of. USER and IN GROUP are obsolete spellings of ROLE and
13 * IN ROLE; each spelling is kept as written.
14 * Source: https://www.postgresql.org/docs/17/sql-createrole.html.
15 *
16 * @visibility public
17 * @example Reading the option an obsolete spelling fills
18 * \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Role\RoleMembersKind::InGroup->option() // => 'addroleto'
19 */
20enum RoleMembersKind: string
21{
22 case User = 'USER';
23 case Role = 'ROLE';
24 case Admin = 'ADMIN';
25 case InRole = 'IN ROLE';
26 case InGroup = 'IN GROUP';
27
28 /**
29 * Answers the option of the server the spelling fills.
30 */
31 public function option(): string
32 {
33 return match ($this) {
34 self::User, self::Role => 'rolemembers',
35 self::Admin => 'adminmembers',
36 self::InRole, self::InGroup => 'addroleto',
37 };
38 }
39}
40