Cast floats to string for Bencoding.

This commit is contained in:
Pachira 2024-08-18 20:01:21 +00:00
parent 25063f6b1f
commit 5a1fdccced
2 changed files with 6 additions and 2 deletions

View file

@ -1 +1 @@
0.2408.181655 0.2408.182001

View file

@ -1,7 +1,7 @@
<?php <?php
// Bencode.php // Bencode.php
// Created: 2022-01-13 // Created: 2022-01-13
// Updated: 2024-08-01 // Updated: 2024-08-18
namespace Index\Bencode; namespace Index\Bencode;
@ -36,6 +36,10 @@ final class Bencode {
case 'string': case 'string':
return sprintf('%d:%s', strlen($value), $value); return sprintf('%d:%s', strlen($value), $value);
case 'double':
$value = (string)$value;
return sprintf('%d:%s', strlen($value), $value);
case 'integer': case 'integer':
return sprintf('i%de', $value); return sprintf('i%de', $value);