update patch 1

This commit is contained in:
fiqhpratama
2024-12-02 01:18:34 +07:00
parent 453d9bb470
commit 25026b0a85
3380 changed files with 103529 additions and 363623 deletions
+8 -3
View File
@@ -14,7 +14,7 @@ namespace Symfony\Component\Uid;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
abstract class AbstractUid implements \JsonSerializable, \Stringable
abstract class AbstractUid implements \JsonSerializable, \Stringable, HashableInterface
{
/**
* The identifier in its canonic representation.
@@ -95,7 +95,7 @@ abstract class AbstractUid implements \JsonSerializable, \Stringable
*/
public function toBase58(): string
{
return strtr(sprintf('%022s', BinaryUtil::toBase($this->toBinary(), BinaryUtil::BASE58)), '0', '1');
return strtr(\sprintf('%022s', BinaryUtil::toBase($this->toBinary(), BinaryUtil::BASE58)), '0', '1');
}
/**
@@ -108,7 +108,7 @@ abstract class AbstractUid implements \JsonSerializable, \Stringable
public function toBase32(): string
{
$uid = bin2hex($this->toBinary());
$uid = sprintf('%02s%04s%04s%04s%04s%04s%04s',
$uid = \sprintf('%02s%04s%04s%04s%04s%04s%04s',
base_convert(substr($uid, 0, 2), 16, 32),
base_convert(substr($uid, 2, 5), 16, 32),
base_convert(substr($uid, 7, 5), 16, 32),
@@ -161,6 +161,11 @@ abstract class AbstractUid implements \JsonSerializable, \Stringable
return $this->uid === $other->uid;
}
public function hash(): string
{
return $this->uid;
}
public function compare(self $other): int
{
return (\strlen($this->uid) - \strlen($other->uid)) ?: ($this->uid <=> $other->uid);