PHP BattlEye GUID

v1.0.0 2025-05-01 16:40 UTC

This package is auto-updated.

Last update: 2025-05-01 18:53:16 UTC


README

Latest Version on Packagist Tests Total Downloads

It provides BattlEye GUID value object.
It also can be converted from SteamID64.

Installation

Requires PHP 8.2+

You can install the package via composer:

composer require battleyephp/guid

Usage

To create a GUID from a SteamID64:

use BattlEye\Guid\Guid;

$guid = Guid::fromSteamId64(76561198066209976);

echo $guid->toString(); // 'a0d1158281d8639495a1908b5a802470'

// It is stringable, so you can
// cast it to the string.
echo (string) $guid;

You can pass an already calculated GUID string to create an object:

use BattlEye\Guid\Guid;

$guid = Guid::fromString('a0d1158281d8639495a1908b5a802470');
// same as
$guid = new Guid('a0d1158281d8639495a1908b5a802470');

Note: It can contain only valid MD5 hash, otherwise it throws an exception.

use BattlEye\Guid\Guid;
use InvalidArgumentException;

try {
    Guid::fromString('invalid');
} catch (InvalidArgumentException) {
    // Invalid GUID
}

Testing

composer test