. // }}} namespace App\Core; /** * User role enum * * @category User * @package GNUsocial * * @author Hugo Sales * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ abstract class UserRoles { const ADMIN = 1; const MODERATOR = 2; const USER = 4; public static function bitmapToStrings(int $r): array { $roles = []; $consts = (new ReflectionClass(__CLASS__))->getConstants(); while ($r != 0) { foreach ($consts as $c => $v) { if ($r & $v !== 0) { $r &= ~$v; $roles[] = "ROLE_{$c}"; } } } return $roles; } }