src/login_token.php
public static function create($user_id) {
	$text  = bootstrap::get_library('text');
	$mysql = bootstrap::get_library('mysql');
	
	$new_token  = $text::generate_token(self::TOKEN_LENGTH);
	$expiration = (time() + self::EXPIRATION);
	
	$sql   = "INSERT INTO `login_tokens` SET `code` = '%s', `user_id` = %d, `expire_at` = %d;";
	$binds = [$new_token, $user_id, $expiration];
	$mysql::query($sql, $binds);
	
	return new static($mysql::$insert_id);
}
public static function create($user_id) {
	$text  = bootstrap::get_library('text');
	$mysql = bootstrap::get_library('mysql');
	
	$new_token  = $text::generate_token(self::TOKEN_LENGTH);
	$expiration = (time() + self::EXPIRATION);
	
	$sql   = "INSERT INTO `login_tokens` SET `code` = '%s', `user_id` = %d, `expire_at` = %d;";
	$binds = [$new_token, $user_id, $expiration];
	$mysql::query($sql, $binds);
	
	return new static($mysql::$insert_id);
}
public static function create ( $ user_id ) { $ text = bootstrap :: get_library ( 'text' ) ; $ mysql = bootstrap :: get_library ( 'mysql' ) ; $ new_token = $ text :: generate_token ( self :: TOKEN_LENGTH ) ; $ expiration = ( time ( ) + self :: EXPIRATION ) ; $ sql = "INSERT INTO `login_tokens` SET `code` = '%s', `user_id` = %d, `expire_at` = %d;" ; $ binds = [ $ new_token , $ user_id , $ expiration ] ; $ mysql :: query ( $ sql , $ binds ) ; return new static ( $ mysql :: $ insert_id ) ; }
create a new temporary login token

@param  int   $user_id
@return $this
create a new temporary login token