Just check for if a particular mask is set. It's pretty simple actually if we loop through the $map
and check if its flag is set:
function getPermissions($mask, $permissionMap) {
$permissions = [];
foreach( $permissionMap as $perm => $val )
if( $mask & $val )
array_push( $permissions, $perm );
return $permissions;
}