signpostmarv/steam-id

SteamID Parsing

v0.2.0 2022-06-21 23:38 UTC

This package is auto-updated.

Last update: 2024-03-22 03:36:32 UTC


README

Test Status Code Coverage Type Coverage

A library for parsing Steam IDs

Requirements

  • php-7.4
  • ext-ctype

Install

composer require signpostmarv/steam-id

Suggested Steps

Use vimeo/psalm

Psalm saves on implementing runtime checks that can be detected with static analysis.

For example, at the time of writing an ID's Universe component does not go higher than 5 but uses an 8-bit field, but the following code will fail to pass a check on psalm:

new \SignpostMarv\SteamId\SteamId(0, 0, 0, 0, 6);

ERROR: InvalidArgument - Argument 5 of SignpostMarv\SteamId\SteamId::__construct expects int(0)|int(1)|int(2)|int(3)|int(4)|int(5), int(6) provided

Optional Steps

Use either the BCMath or GMP calculators if the relevant php extension is available.

Examples

Obtain Steam Community URL

use SignpostMarv\SteamId\Parser;

$parser = new Parser();

$id = $parser->FromString('76561197960287930');

$url = $parser->ToSteamCommunityUrl($id);

License

Apache-2.0