alcamo / range
Ranges of various types
Installs: 2
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/alcamo/range
Requires
- php: 7.3 - 8.0
- alcamo/exception: ^0.1
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2025-10-24 16:11:10 UTC
README
use alcamo\range\NonNegativeRange;
$range = NonNegativeRange::newFromString('3-7');
foreach ([-1, 0, 2, 3, 5, 7, 8] as $value) {
echo "contains $value: " . $range->contains($value) . "\n";
}
This will output:
contains -1: 0
contains 0: 0
contains 2: 0
contains 3: 1
contains 5: 1
contains 7: 1
contains 8: 0
Provided interfaces, traits and classes
- The interface
RangeInterfaceprovides a very basic interface for ranges of any kind. - The trait
RangeTraitprovides a simple implementation which covers most of what is needed forRangeInterface. - The class
NonNegativeRangeprovides an implementation of a range of nonnegative integers, potentially unbounded from above, including the bound(s).