Skip to content

Add Interval feature to verify in interval range: isInclusiveOf() and isExclusiveOf()#38

Merged
samsonasik merged 1 commit intomainfrom
add-interval
Feb 12, 2026
Merged

Add Interval feature to verify in interval range: isInclusiveOf() and isExclusiveOf()#38
samsonasik merged 1 commit intomainfrom
add-interval

Conversation

@samsonasik
Copy link
Owner

@samsonasik samsonasik commented Feb 12, 2026

We already have AtLeast and AtMost to verify bottom and top verification count, how about in between, here the Interval feature birth:

1. Interval::isInclusiveOf()

It verify that data has filtered found items within min and max (inclusive).

use ArrayLookup\Interval;

$orders = [
    ['status' => 'paid'],
    ['status' => 'paid'],
    ['status' => 'pending'],
    ['status' => 'paid'],
];

$filter = static fn(array $order): bool => $order['status'] === 'paid';

// inclusive means min and max boundaries are allowed
var_dump(Interval::isInclusiveOf($orders, $filter, 3, 5)) // true
var_dump(Interval::isInclusiveOf($orders, $filter, 2, 5)) // true

2. Interval::isExclusiveOf()

It verify that data has filtered found items between min and max (exclusive).

use ArrayLookup\Interval;

$orders = [
    ['status' => 'paid'],
    ['status' => 'paid'],
    ['status' => 'pending'],
    ['status' => 'paid'],
];

$filter = static fn(array $order): bool => $order['status'] === 'paid';

// exclusive means strictly between min and max
var_dump(Interval::isExclusiveOf($orders, $filter, 3, 5)) // false
var_dump(Interval::isExclusiveOf($orders, $filter, 2, 5)) // true

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c45927f) to head (46b1ec6).
⚠️ Report is 61 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                main       #38    +/-   ##
============================================
  Coverage     100.00%   100.00%            
- Complexity        45        81    +36     
============================================
  Files              4         7     +3     
  Lines            122       236   +114     
============================================
+ Hits             122       236   +114     
Flag Coverage Δ
tests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samsonasik samsonasik marked this pull request as draft February 12, 2026 00:34
@samsonasik samsonasik marked this pull request as ready for review February 12, 2026 00:37
@samsonasik samsonasik merged commit 83ad00b into main Feb 12, 2026
8 checks passed
@samsonasik samsonasik deleted the add-interval branch February 12, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants