thesis/endian

Library for encoding and decoding numbers in either big-endian or little-endian order.

Fund package maintenance!
www.tinkoff.ru/cf/5MqZQas2dk7

Installs: 19 482

Dependents: 4

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

pkg:composer/thesis/endian

0.3.0 2025-11-25 10:54 UTC

This package is auto-updated.

Last update: 2025-11-25 10:55:11 UTC


README

PHP Version Requirement GitHub Release Code Coverage

Installation

composer require thesis/endian

Read/write in any byte order:

  1. In network (big endian) byte order.
use Thesis\Endian;

echo Endian\Order::network->unpackInt32(
    Endian\Order::network->packInt32(-200),
); // -200
  1. In big endian byte order.
use Thesis\Endian;

echo Endian\Order::big->unpackInt8(
    Endian\Order::big->packInt8(17),
); // 17
  1. In little endian byte order.
use Thesis\Endian;

echo Endian\Order::little->unpackFloat(
    Endian\Order::little->packFloat(2.2),
); // 2.2
  1. In native endian byte order.
use Thesis\Endian;
use BcMath\Number;

echo Endian\Order::native()
    ->unpackInt64(
        Endian\Order::native()->packInt64(new Number('9223372036854775807')),
    )
    ->value; // 9223372036854775807

Supported types:

  • int8
  • uint8
  • int16
  • uint16
  • int32
  • uint32
  • int64
  • uint64
  • float
  • double