@@ -90,7 +90,7 @@ public static function parse(string $permission): self
9090
9191 $ permission = $ permissionParts [0 ];
9292
93- if (!\in_array ($ permission , array_merge ( Database::PERMISSIONS , [Database:: PERMISSION_WRITE ]) )) {
93+ if (!\in_array ($ permission , Database::PERMISSIONS )) {
9494 throw new DatabaseException ('Invalid permission type: " ' . $ permission . '". ' );
9595 }
9696 $ fullRole = \str_replace ('") ' , '' , $ permissionParts [1 ]);
@@ -140,43 +140,6 @@ public static function parse(string $permission): self
140140 return new self ($ permission , $ role , $ identifier , $ dimension );
141141 }
142142
143- /**
144- * Map aggregate permissions into the set of individual permissions they represent.
145- *
146- * @param array<string>|null $permissions
147- * @param array<string> $allowed
148- * @return array<string>|null
149- * @throws Exception
150- */
151- public static function aggregate (?array $ permissions , array $ allowed = Database::PERMISSIONS ): ?array
152- {
153- if (\is_null ($ permissions )) {
154- return null ;
155- }
156- $ mutated = [];
157- foreach ($ permissions as $ i => $ permission ) {
158- $ permission = self ::parse ($ permission );
159- foreach (self ::$ aggregates as $ type => $ subTypes ) {
160- if ($ permission ->getPermission () != $ type ) {
161- $ mutated [] = $ permission ->toString ();
162- continue ;
163- }
164- foreach ($ subTypes as $ subType ) {
165- if (!\in_array ($ subType , $ allowed )) {
166- continue ;
167- }
168- $ mutated [] = (new self (
169- $ subType ,
170- $ permission ->getRole (),
171- $ permission ->getIdentifier (),
172- $ permission ->getDimension ()
173- ))->toString ();
174- }
175- }
176- }
177- return \array_values (\array_unique ($ mutated ));
178- }
179-
180143 /**
181144 * Create a read permission string from the given Role
182145 *
@@ -244,21 +207,4 @@ public static function delete(Role $role): string
244207 );
245208 return $ permission ->toString ();
246209 }
247-
248- /**
249- * Create a write permission string from the given Role
250- *
251- * @param Role $role
252- * @return string
253- */
254- public static function write (Role $ role ): string
255- {
256- $ permission = new self (
257- 'write ' ,
258- $ role ->getRole (),
259- $ role ->getIdentifier (),
260- $ role ->getDimension ()
261- );
262- return $ permission ->toString ();
263- }
264210}
0 commit comments