PHPackages                             texdc/range - 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. texdc/range

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

texdc/range
===========

A library of range objects

v2.0.1(8y ago)4271MITPHPPHP ~7.0

Since Sep 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/texdc/range)[ Packagist](https://packagist.org/packages/texdc/range)[ RSS](/packages/texdc-range/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (9)Used By (0)

range
=====

[](#range)

```
Oh, give me a home where the buffalo roam
Where the deer and the antelope play
Where seldom is heard a discouraging word
And the skies are not cloudy all day

```

\-- [Home on the Range](http://en.wikipedia.org/wiki/Home_on_the_Range)

The inspiration for this library came from a discussion by [Martin Fowler](https://web.archive.org/web/20101220225210/http://martinfowler.com/ap2/range.html).

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/48708669ef51c1bc67ad5ae58ba26e7fa5122b6a2d7528929ff174b34f2a40b8/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f74657864632f72616e67652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/texdc/range)[![Coverage Status](https://camo.githubusercontent.com/8c3f468a05d664866c9802052b483dc24428f09356286f2db82d46449471b214/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f74657864632f72616e67652e7376673f7374796c653d666c61742d737175617265)](http://img.shields.io/coveralls/texdc/range.svg)

install
-------

[](#install)

[Composer](https://getcomposer.org):

```
composer require texdc/range @stable
```

examples
--------

[](#examples)

##### Range

[](#range-1)

Ranges provide simple validation and iteration.

```
use texdc\range\DateRange;

$dateRange = new DateRange(new DateTime, new DateTime('+1 month'));

assert($dateRange->includes(new DateTime('+3 days')));

echo $dateRange->getSpan()->days;

foreach ($dateRange as $day) {
    echo $day->format('l, F jS, Y');
}
```

Ranges can also be compared against each other.

```
use texdc\range\IntegerRange;

$range1 = new IntegerRange(1, 5);
$range2 = new IntegerRange(8, 3);
$range3 = new IntegerRange(5, 8);

assert($range1->overlaps($range2));
assert($range2->isContraryTo($range1));
assert($range3->abuts($range2));
assert($range1->begins(IntegerRange::merge($range1, $range3)));
assert($range3->ends(IntegerRange::combine([$range1, $range3])));
```

See the tests for more comparisons!

##### Enablement

[](#enablement)

Enablements leverage a range for more robust alternatives to simple boolean flags.

```
use texdc\range\DateEnablement;

class DatedBannerAd extends AbstractBannerAd
{
    /**
     * @var DateEnablement
     */
    private $enablement;

    // ...

    public function render()
    {
        if ($this->enablement->isEnabled()) {
            return parent::render();
        }
    }
}
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98% 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

Every ~208 days

Recently: every ~280 days

Total

7

Last Release

3003d ago

Major Versions

v1.2.1 → v2.0.02017-10-14

PHP version history (3 changes)v1.0.0PHP ~5.4

v1.2.0PHP ~5.6 || ~7.0

v2.0.0PHP ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b00c18dc19530c6fa5cc0cafc053dd9377dace10c90d73182b79f8499d2c26d1?d=identicon)[texdc](/maintainers/texdc)

---

Top Contributors

[![texdc](https://avatars.githubusercontent.com/u/1590605?v=4)](https://github.com/texdc "texdc (49 commits)")[![ryross](https://avatars.githubusercontent.com/u/152982?v=4)](https://github.com/ryross "ryross (1 commits)")

---

Tags

daterangeenablementphprangerangedaterangedate-rangeenablement

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/texdc-range/health.svg)

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

###  Alternatives

[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[kartik-v/yii2-date-range

An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.

894.4M42](/packages/kartik-v-yii2-date-range)[kartik-v/yii2-sortable

Create sortable lists and grids using HTML5 drag and drop API for Yii 2.0.

433.8M13](/packages/kartik-v-yii2-sortable)[kartik-v/yii2-widget-rangeinput

An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split from yii2-widgets)

193.9M3](/packages/kartik-v-yii2-widget-rangeinput)[kartik-v/yii2-field-range

Easily manage Yii 2 ActiveField ranges (from/to) with Bootstrap 3 addons markup and more

232.1M26](/packages/kartik-v-yii2-field-range)[openpsa/ranger

Formatter for date and time ranges with i18n support

76177.6k3](/packages/openpsa-ranger)

PHPackages © 2026

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