original_string: protected function getSaveValueSecure($value)
      {
          $newPermissions = is_array($value) ? array_map('intval', $value) : [];
  
          if (!empty($newPermissions)) {
              $existingPermissions = $this->model->permissions ?: [];
  
              $allowedPermissions = array_map(function ($permissionObject) {
                  return $permissionObject->code;
              }, array_flatten($this->getFilteredPermissions()));
  
              foreach ($newPermissions as $permission => $code) {
                  if (in_array($permission, $allowedPermissions)) {
                      $existingPermissions[$permission] = $code;
                  }
              }
  
              $newPermissions = $existingPermissions;
          }
  
          return $newPermissions;
      }
code: protected function getSaveValueSecure($value)
      {
          $newPermissions = is_array($value) ? array_map('intval', $value) : [];
  
          if (!empty($newPermissions)) {
              $existingPermissions = $this->model->permissions ?: [];
  
              $allowedPermissions = array_map(function ($permissionObject) {
                  return $permissionObject->code;
              }, array_flatten($this->getFilteredPermissions()));
  
              foreach ($newPermissions as $permission => $code) {
                  if (in_array($permission, $allowedPermissions)) {
                      $existingPermissions[$permission] = $code;
                  }
              }
  
              $newPermissions = $existingPermissions;
          }
  
          return $newPermissions;
      }
code_tokens: protected function getSaveValueSecure ( $ value ) { $ newPermissions = is_array ( $ value ) ? array_map ( 'intval' , $ value ) : [ ] ; if ( ! empty ( $ newPermissions ) ) { $ existingPermissions = $ this -> model -> permissions ? : [ ] ; $ allowedPermissions = array_map ( function ( $ permissionObject ) { return $ permissionObject -> code ; } , array_flatten ( $ this -> getFilteredPermissions ( ) ) ) ; foreach ( $ newPermissions as $ permission => $ code ) { if ( in_array ( $ permission , $ allowedPermissions ) ) { $ existingPermissions [ $ permission ] = $ code ; } } $ newPermissions = $ existingPermissions ; } return $ newPermissions ; }
docstring: Returns a safely parsed set of permissions, ensuring the user cannot elevate
  their own permissions or permissions of another user above their own.
  
  @param string $value
  @return array
docstring_tokens: Returns a safely parsed set of permissions ensuring the user cannot elevate their own permissions or permissions of another user above their own .