PHPackages                             bbprojectnet/unit-helpers - 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. bbprojectnet/unit-helpers

ActiveLibrary

bbprojectnet/unit-helpers
=========================

Simple unit helpers for configuration purposes.

1.0.0(3y ago)14.4k↓100%MITPHPPHP &gt;=8.0.0

Since Oct 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bbprojectnet/unit-helpers)[ Packagist](https://packagist.org/packages/bbprojectnet/unit-helpers)[ RSS](/packages/bbprojectnet-unit-helpers/feed)WikiDiscussions main Synced today

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

Unit helpers
============

[](#unit-helpers)

This package is intended to make it easier to specify time and size in configuration files more clearly.

### Example 1:

[](#example-1)

```
// Before
$query->where('size', '>=', 209715200)->get();

// After
$query->where('size', '>=', Size::mb(200))->get();
```

### Example 2:

[](#example-2)

```
// Before
$config = [
	'expiration' => 4680, // 3 days and 6 hours in minutes
];

// After
$config = [
	'expiration' => Time::of(days: 3, hours: 6, 'minutes'),
	// or
	'expiration' => Time::of(days: 3.25, 'minutes'),
	// or
	'expiration' => Time::days(3.25, 'minutes'),
];
```

### Example 3:

[](#example-3)

```
// Before
class Job
{
	protected int $timeout = 10800;
}

// After
class Job
{
	protected int $timeout = Time::HOUR * 3;
}
```

Requirements
------------

[](#requirements)

- PHP 8.0 and above

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

[](#installation)

Require this package with composer using the following command:

```
composer require bbprojectnet/unit-helpers
```

Usage
-----

[](#usage)

As simple static call:

```
$timeout = Time::hours(4);
```

Static call with output unit specified:

```
$timeout = Time::hours(4, 'minutes');
```

As method parameter:

```
$timeout = Time::of(days: 2);
```

With mixed unit types:

```
$timeout = Time::of(days: 2, hours: 10);
```

With mixed unit types and output unit specified:

```
$timeout = Time::of(days: 2, hours: 10, as: 'minutes');
```

With mixed unit types, fractions, negative values and output unit specified:

```
$timeout = Time::of(days: 2.4, hours: -2, minutes: 0.5, as: 'minutes');
```

As constant in places where method invocation is not possible:

```
protected int $timeout = Time::HOUR * 3;
```

License
-------

[](#license)

The Unit helpers package is open-sourced software licensed under the MIT license.

###  Health Score

28

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

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

1250d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/675fcdb8ca5581ded26155cdd2821dbfd7300fa790d1a7acc66f2d02a3b0fb24?d=identicon)[bbprojectnet](/maintainers/bbprojectnet)

---

Top Contributors

[![bbprojectnet](https://avatars.githubusercontent.com/u/1136309?v=4)](https://github.com/bbprojectnet "bbprojectnet (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bbprojectnet-unit-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/bbprojectnet-unit-helpers/health.svg)](https://phpackages.com/packages/bbprojectnet-unit-helpers)
```

PHPackages © 2026

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