original_string: public static function set_user_device_type($newdevice) {
          $devicetype = self::get_device_type();
          if ($newdevice == $devicetype) {
              unset_user_preference('switchdevice'.$devicetype);
              return true;
          } else {
              $devicetypes = self::get_device_type_list();
              if (in_array($newdevice, $devicetypes)) {
                  set_user_preference('switchdevice'.$devicetype, $newdevice);
                  return true;
              }
          }
          throw new coding_exception('Invalid device type provided to set_user_device_type');
      }
code: public static function set_user_device_type($newdevice) {
          $devicetype = self::get_device_type();
          if ($newdevice == $devicetype) {
              unset_user_preference('switchdevice'.$devicetype);
              return true;
          } else {
              $devicetypes = self::get_device_type_list();
              if (in_array($newdevice, $devicetypes)) {
                  set_user_preference('switchdevice'.$devicetype, $newdevice);
                  return true;
              }
          }
          throw new coding_exception('Invalid device type provided to set_user_device_type');
      }
code_tokens: public static function set_user_device_type ( $ newdevice ) { $ devicetype = self :: get_device_type ( ) ; if ( $ newdevice == $ devicetype ) { unset_user_preference ( 'switchdevice' . $ devicetype ) ; return true ; } else { $ devicetypes = self :: get_device_type_list ( ) ; if ( in_array ( $ newdevice , $ devicetypes ) ) { set_user_preference ( 'switchdevice' . $ devicetype , $ newdevice ) ; return true ; } } throw new coding_exception ( 'Invalid device type provided to set_user_device_type' ) ; }
docstring: Switches the device type we think the user is using to what ever was given.
  @param string $newdevice
  @return bool
  @throws coding_exception
docstring_tokens: Switches the device type we think the user is using to what ever was given .