PHPackages                             bkuhl/scripture-ranges - 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. bkuhl/scripture-ranges

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

bkuhl/scripture-ranges
======================

A PHP library for handling scripture ranges with exclusions and JSON serialization

1.3.0(6mo ago)01.0k↓70.8%2MITPHPPHP ^8.3CI passing

Since Aug 9Pushed 6mo agoCompare

[ Source](https://github.com/bkuhl/scripture-ranges)[ Packagist](https://packagist.org/packages/bkuhl/scripture-ranges)[ RSS](/packages/bkuhl-scripture-ranges/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (8)Dependencies (2)Versions (13)Used By (2)

Scripture Ranges
================

[](#scripture-ranges)

A PHP library for handling scripture ranges with exclusions and JSON serialization. Create complex scripture ranges with a clean, fluent API.

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

[](#installation)

```
composer require bkuhl/scripture-ranges
```

Creating Ranges (Recommended)
-----------------------------

[](#creating-ranges-recommended)

Use the `ScriptureRangeBuilder` with multiple syntax options:

```
use BKuhl\ScriptureRanges\ScriptureRangeBuilder;
use BKuhl\ScriptureRanges\ChapterRange;

$builder = new ScriptureRangeBuilder([$myBookResolver]);

// 1. Traditional parameter syntax
$collection = $builder
    ->with(BookEnum::JOHN, chapter: 3, verse: 1, toVerse: 36)
    ->without(BookEnum::JOHN, chapter: 3, verse: 16, toVerse: 17)
    ->build();

// 2. Chapter range syntax
$collection = $builder
    ->with(BookEnum::JOHN, chapter: 3, chapterEnd: 5)      // Multiple chapters
    ->with('Matthew', chapter: 5, verse: 1, toVerse: 48)   // Mixed with verse ranges
    ->build();

// 3. ChapterRange object syntax (cleanest for chapter ranges!)
$collection = $builder
    ->with(BookEnum::JOHN, ChapterRange::range(3, 5))      // Chapters 3-5
    ->with('Matthew', chapter: 5, verse: 1, toVerse: 48)   // Use traditional syntax for verses
    ->without(BookEnum::JOHN, chapter: 3, verse: 16)       // Use traditional syntax for single verses
    ->build();

// ChapterRange factory method:
ChapterRange::range(3, 5)             // Chapters 3-5 (full chapters)
```

Book Resolvers
--------------

[](#book-resolvers)

To use flexible input types (strings, enums, integers), implement a `BookResolverInterface`:

```
use BKuhl\ScriptureRanges\Interfaces\BookResolverInterface;

class MyBookResolver implements BookResolverInterface
{
    public function resolve(mixed $book): BookInterface
    {
        if (is_string($book)) {
            return $this->getBookFromString($book);
        }

        if ($book instanceof MyBookEnum) {
            return $this->getBookFromEnum($book);
        }

        throw new InvalidArgumentException('Unable to resolve book');
    }

    public function canResolve(mixed $book): bool
    {
        return is_string($book) || $book instanceof MyBookEnum;
    }
}

// Use with builder
$builder = new ScriptureRangeBuilder([$myResolver]);
```

Working with Collections
------------------------

[](#working-with-collections)

```
// Create a collection with ID and name
$collection = new RangeCollection('reading-plan-123', 'Daily Reading');

// Or create without metadata
$collection = new RangeCollection();

// Set or update name and ID
$collection->setName('Morning Reading');
$collection->setId('morning-plan-456');

// Get name and ID
echo $collection->getName(); // "Morning Reading"
echo $collection->getId();   // "morning-plan-456"

// Check if a verse is in any range
echo $collection->contains($verse); // true/false

// Get formatted reference
echo $collection->reference(); // "John 3:16-17, Matthew 5:1-12"

// JSON serialization includes name and ID
$json = $collection->toJson();
// {
//   "name": "Morning Reading",
//   "id": "morning-plan-456",
//   "ranges": [...]
// }
```

ChapterRange Quick Example
--------------------------

[](#chapterrange-quick-example)

For working with chapter ranges, use the `ChapterRange` class:

```
use BKuhl\ScriptureRanges\ChapterRange;

// Create a chapter range
$range = ChapterRange::range(3, 5);  // Chapters 3-5

// Get start and end chapters
$start = $range->getStart();  // 3
$end = $range->getEnd();      // 5

// Use with ScriptureRangeBuilder
$collection = $builder
    ->with($book, ChapterRange::range(1, 3))    // Full chapters 1-3
    ->with($book, chapter: 4, verse: 1, toVerse: 10)  // Specific verses
    ->build();
```

Combining Ranges
----------------

[](#combining-ranges)

Combine multiple ranges in the same book into a single range:

```
use BKuhl\ScriptureRanges\ScriptureRange;

$range1 = new ScriptureRange($book, 1, 2, 1, 25);
$range2 = new ScriptureRange($book, 3, 4, 1, 24);

$combined = ScriptureRange::combine([$range1, $range2]);
// Result: Genesis 1-4 with gaps between ranges excluded
```

Checking Consecutive Chapters
-----------------------------

[](#checking-consecutive-chapters)

Check if ranges contain a minimum number of consecutive full chapters:

```
// Check a single range
$range = new ScriptureRange($book, 1, 3, 1, 24);
$range->hasConsecutiveChapters(3); // true if chapters 1, 2, 3 are all full

// Check across multiple ranges in a collection
$collection = (new ScriptureRangeBuilder())
    ->with($book, chapter: 1, chapterEnd: 2)
    ->with($book, chapter: 3, chapterEnd: 4)
    ->build();

$collection->hasConsecutiveChapters(4); // true if chapters 1-4 are all full across ranges
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance68

Regular maintenance activity

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

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

Every ~20 days

Recently: every ~35 days

Total

8

Last Release

189d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/524933?v=4)[Ben Kuhl](/maintainers/bkuhl)[@bkuhl](https://github.com/bkuhl)

---

Top Contributors

[![bkuhl](https://avatars.githubusercontent.com/u/524933?v=4)](https://github.com/bkuhl "bkuhl (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bkuhl-scripture-ranges/health.svg)

```
[![Health](https://phpackages.com/badges/bkuhl-scripture-ranges/health.svg)](https://phpackages.com/packages/bkuhl-scripture-ranges)
```

###  Alternatives

[realrashid/cart

Meet Cart — your ultimate solution for seamless shopping cart functionality in Laravel applications. Cart simplifies the complexities of shopping cart operations, from product additions to total calculations, ensuring a frictionless user experience.

1104.1k](/packages/realrashid-cart)

PHPackages © 2026

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