{"id":40669498,"url":"https://github.com/gosuperscript/interval","last_synced_at":"2026-01-21T09:30:53.420Z","repository":{"id":285527571,"uuid":"956606905","full_name":"gosuperscript/interval","owner":"gosuperscript","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-19T10:27:03.000Z","size":62,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-01T06:52:27.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gosuperscript.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-28T14:41:28.000Z","updated_at":"2025-06-19T10:24:45.000Z","dependencies_parsed_at":"2025-04-01T08:42:09.433Z","dependency_job_id":"0b361546-b858-4b51-895c-200e7e6c81ef","html_url":"https://github.com/gosuperscript/interval","commit_stats":null,"previous_names":["gosuperscript/interval"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/gosuperscript/interval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuperscript%2Finterval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuperscript%2Finterval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuperscript%2Finterval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuperscript%2Finterval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gosuperscript","download_url":"https://codeload.github.com/gosuperscript/interval/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gosuperscript%2Finterval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-21T09:30:50.318Z","updated_at":"2026-01-21T09:30:53.402Z","avatar_url":"https://github.com/gosuperscript.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Interval Library\n\nA PHP library for working with mathematical intervals. It provides an elegant way to create, compare, and work with intervals using standard mathematical notation.\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require superscript/interval\n```\n\n## Requirements\n\n- PHP 8.3 or higher\n\n## Usage\n\n### Creating Intervals\n\nYou can create intervals from string notation:\n\n```php\nuse Superscript\\Interval\\Interval;\n\n// Create from string notation\n$interval = Interval::fromString('[1,5]');  // Closed interval\n$interval = Interval::fromString('(1,5)');  // Open interval \n$interval = Interval::fromString('[1,5)');  // Right-open interval\n$interval = Interval::fromString('(1,5]');  // Left-open interval\n$interval = Interval::fromString('[1,)');  // Left-bounded interval (infinite upper bound)\n$interval = Interval::fromString('(,1]');  // Right-bounded interval (infinite lower bound)\n```\n\n### Interval Notation\n\nThe library supports four types of interval notation:\n\n- `[a,b]` - **Closed interval**: includes both endpoints `a` and `b`. Example: `[1,5]` includes all numbers from 1 to 5, including 1 and 5.\n- `(a,b)` - **Open interval**: excludes both endpoints `a` and `b`. Example: `(1,5)` includes all numbers greater than 1 and less than 5, but not 1 or 5 themselves.\n- `[a,b)` - **Right-open interval**: includes `a` but not `b`. Example: `[1,5)` includes 1 and all values up to (but not including) 5.\n- `(a,b]` - **Left-open interval**: excludes `a` but includes `b`. Example: `(1,5]` includes all values greater than 1 up to and including 5.\n\nThe inclusion or exclusion of the endpoints determines how comparisons behave. For example, if an interval is `(1,5)`, calling `$interval-\u003eisGreaterThan(1)` will return `true` because 1 is not part of the interval. However, if the interval is `[1,5]`, then `$interval-\u003eisGreaterThanOrEqualTo(1)` will return `true` since 1 is included.\n\nUnderstanding this notation is crucial for interpreting comparison behavior correctly.\n\nThe library also supports unbounded intervals using empty endpoints. These are interpreted as extending to infinity:\n  \n- `[a,)` - Left-bounded interval: includes `a` and extends infinitely to the right.\n- `(,b]` - Right-bounded interval: includes `b` and extends infinitely to the left.\n- `(,)`  - Fully unbounded interval: represents all real numbers.\n  \nInternally, unbounded sides are represented using `PHP_INT_MIN` or `PHP_INT_MAX`.\n\n### Interval Comparisons\n\n```php\n$interval = Interval::fromString('[2,5]');\n\n$interval-\u003eisGreaterThan(1);      // true\n$interval-\u003eisGreaterThanOrEqualTo(2);  // true\n$interval-\u003eisLessThan(6);         // true\n$interval-\u003eisLessThanOrEqualTo(5);     // true\n```\n\nComparisons such as `$interval-\u003eisGreaterThan($value)` evaluate whether *all* values within the interval are greater than the given value. So `[2,5]` is greater than `1` (because every number from 2 to 5 is greater than 1), but not greater than `2` unless the interval is open on the left side (e.g., `(2,5)`).\n\nSimilarly, `$interval-\u003eisLessThan($value)` checks whether all values in the interval are less than the given value. `(1,5)` is less than `6`, but not less than `5` unless the interval excludes `5` (e.g., `(1,5)` or `[1,5)`.\n\nThis logic allows for precise control over numeric comparisons, especially when you want to reason about bounds inclusivity.\n\n## Testing\n\nRun the test suite:\n\n```bash\ncomposer test\n```\n\nThis includes:\n- Static analysis (`composer test:types`)\n- Unit tests with coverage (`composer test:unit`)\n- Mutation testing (`composer test:infection`)\n\n## License\n\nMIT\n\n## About\n\nThis package is developed and maintained by Superscript.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosuperscript%2Finterval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgosuperscript%2Finterval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgosuperscript%2Finterval/lists"}