PHPackages                             componenta/byte - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. componenta/byte

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

componenta/byte
===============

Byte, information unit, and bit-rate value objects

v1.0.0(1mo ago)00MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/byte)[ Packagist](https://packagist.org/packages/componenta/byte)[ RSS](/packages/componenta-byte/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Componenta Byte
===============

[](#componenta-byte)

Information-size and transfer-rate value objects.

The package contains:

- `Byte` for data sizes stored internally as bytes
- `ByteUnit` and `InformationUnit` enums for unit metadata
- `BitRate` for transfer rates stored internally as bits per second
- `BitRateUnit` for bit/byte-per-second labels and conversion factors

Installation
------------

[](#installation)

```
composer require componenta/byte
```

Related Packages
----------------

[](#related-packages)

This package is standalone.

PackageWhy it may be used nearby`componenta/duration`Transfer-time calculations pair naturally with typed durations.`componenta/validation`Can validate user input before creating `Byte` or `BitRate`.`componenta/config`Can store upload or bandwidth limits that are later converted to value objects.Byte Usage
----------

[](#byte-usage)

```
use Componenta\Stdlib\Byte;

$size = Byte::mb(1.5);

(string) $size;        // "1.5 MB"
$size->toBits();       // 12582912.0
$size->to('kB', 2);    // formatted string
$size->getValue('MB'); // numeric value in megabytes
```

`Byte` accepts numeric values and human-readable strings:

```
$a = Byte::fromHumanReadable('10 MB');
$b = Byte::fromBits(8_000);
$c = Byte::from(2, 'GB');
```

Byte Operations
---------------

[](#byte-operations)

`Byte` supports:

- comparison: `compare`, `equalTo`, `lessThan`, `greaterThan`, range checks
- arithmetic: `increment`, `decrement`, `multiply`, `divide`, `modulo`, `abs`
- aggregation: `sum`, `average`, `maximum`, `minimum`
- transfer estimates: `getTransferTime`, `getFormattedTransferTime`

Range generation is capped internally to avoid accidental huge allocations.

Bit Rate Usage
--------------

[](#bit-rate-usage)

```
use Componenta\Stdlib\BitRate;
use Componenta\Stdlib\Byte;

$rate = BitRate::mbps(80);

$seconds = Byte::mb(10)->getTransferTime($rate);
$amount = $rate->calculateTransferAmount(1);
```

`BitRate` supports both bit and byte transfer units:

```
BitRate::fromHumanReadable('80 Mbps');
BitRate::fromHumanReadable('10 MBps');
BitRate::kilobytesPerSecond(512);
```

Unit Rules
----------

[](#unit-rules)

- `Byte` uses binary storage units based on 1024.
- `BitRate` uses decimal transfer units based on 1000.
- `BitRate` stores its internal value as bits per second.
- `Mbps` and `MBps` are different labels: megabits per second vs megabytes per second.

Serialization
-------------

[](#serialization)

`BitRate` implements `JsonSerializable`. `Byte` implements `Stringable` and exposes explicit conversion methods for numeric values and formatted strings.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/componenta-byte/health.svg)

```
[![Health](https://phpackages.com/badges/componenta-byte/health.svg)](https://phpackages.com/packages/componenta-byte)
```

###  Alternatives

[utopia-php/messaging

A simple, light and advanced PHP messaging library

23236.1k6](/packages/utopia-php-messaging)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
