{"id":25341316,"url":"https://github.com/jdecool/guard-clauses","last_synced_at":"2026-02-13T13:07:10.044Z","repository":{"id":275845888,"uuid":"927380856","full_name":"jdecool/guard-clauses","owner":"jdecool","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-07T20:37:47.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-01T13:49:43.621Z","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/jdecool.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-02-04T21:26:08.000Z","updated_at":"2025-02-07T20:37:50.000Z","dependencies_parsed_at":"2025-06-15T20:06:32.284Z","dependency_job_id":"4c21b2de-48a7-4dfa-a1e8-98ce608db642","html_url":"https://github.com/jdecool/guard-clauses","commit_stats":null,"previous_names":["jdecool/guard-clauses"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jdecool/guard-clauses","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fguard-clauses","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fguard-clauses/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fguard-clauses/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fguard-clauses/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdecool","download_url":"https://codeload.github.com/jdecool/guard-clauses/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdecool%2Fguard-clauses/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29407256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"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":"2025-02-14T08:36:46.493Z","updated_at":"2026-02-13T13:07:10.017Z","avatar_url":"https://github.com/jdecool.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guard Clauses\n\n[![Latest Stable Version](https://poser.pugx.org/jdecool/guard-clauses/v/stable)](https://packagist.org/packages/jdecool/guard-clauses)\n[![Build Status](https://github.com/jdecool/guard-clauses/workflows/CI/badge.svg?ref=main)](https://github.com/jdecool/guard-clauses/actions?ref=main)\n[![Total Downloads](https://poser.pugx.org/jdecool/guard-clauses/downloads)](https://packagist.org/packages/jdecool/guard-clauses)\n[![License](https://poser.pugx.org/jdecool/guard-clauses/license)](https://packagist.org/packages/jdecool/guard-clauses)\n[![Latest Unstable Version](https://poser.pugx.org/jdecool/guard-clauses/v/unstable)](https://packagist.org/packages/jdecool/guard-clauses)\n\nA PHP library providing a clean and expressive way to implement guard clauses in your code. Built on top of [webmozart/assert](https://github.com/webmozart/assert), this library offers a fluent interface for input validation and defensive programming.\n\n## Installation\n\nYou can install the package via Composer:\n\n```bash\ncomposer require jdecool/guard-clauses\n```\n\n## Requirements\n\n- PHP 8.1 or higher\n\n## Usage\n\nThe library provides a `Guard` class with static methods for various assertions:\n\n```php\nuse JDecool\\GuardClauses\\Guard;\n\n// Basic type checks\n$validatedValue = Guard::string($value);\n$validatedValue = Guard::integer($value);\n$validatedValue = Guard::float($value);\n$validatedValue = Guard::boolean($value);\n$validatedValue = Guard::object($value);\n\n// String validations\n$validatedValue = Guard::stringNotEmpty($value);\n$validatedValue = Guard::contains($string, $substring);\n$validatedValue = Guard::startsWith($string, $prefix);\n$validatedValue = Guard::endsWith($string, $suffix);\n\n// Numeric comparisons\n$validatedValue = Guard::greaterThan($number, $limit);\n$validatedValue = Guard::lessThan($number, $limit);\n$validatedValue = Guard::range($number, $min, $max);\n\n// Array operations\n$validatedValue = Guard::isArray($value);\n$validatedValue = Guard::count($array, $expectedCount);\n$validatedValue = Guard::keyExists($array, $key);\n\n// And many more...\n```\n\nEach assertion method accepts an optional message parameter that will be used in the exception if the assertion fails:\n\n```php\n$validatedValue = Guard::string($value, 'The value must be a string');\n```\n\n## Error Handling\n\nWhen an assertion fails, a `GuardClausesException` is thrown, which extends from `InvalidArgumentException`.\n\n## Development\n\nTo contribute to the development of this library:\n\n1. Clone the repository\n2. Install dependencies: `composer install`\n3. Run tests: `composer test`\n4. Run static analysis: `composer lint`\n\n## License\n\nThis package is open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdecool%2Fguard-clauses","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdecool%2Fguard-clauses","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdecool%2Fguard-clauses/lists"}