{"id":26530083,"url":"https://github.com/try-php/predict-exception","last_synced_at":"2026-05-16T20:32:04.714Z","repository":{"id":57073121,"uuid":"108311790","full_name":"try-php/predict-exception","owner":"try-php","description":"Simplified predictions if a piece of codes throws an Exception","archived":false,"fork":false,"pushed_at":"2018-02-08T21:49:28.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T13:06:27.525Z","etag":null,"topics":["php7","test","testing","tryphp"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/try-php.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-25T18:49:00.000Z","updated_at":"2022-02-12T14:41:00.000Z","dependencies_parsed_at":"2022-08-24T10:51:36.557Z","dependency_job_id":null,"html_url":"https://github.com/try-php/predict-exception","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/try-php/predict-exception","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try-php%2Fpredict-exception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try-php%2Fpredict-exception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try-php%2Fpredict-exception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try-php%2Fpredict-exception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/try-php","download_url":"https://codeload.github.com/try-php/predict-exception/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/try-php%2Fpredict-exception/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33117824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: 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":["php7","test","testing","tryphp"],"created_at":"2025-03-21T17:29:30.387Z","updated_at":"2026-05-16T20:32:04.692Z","avatar_url":"https://github.com/try-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# predict-exception\n\n\u003e Simplified predictions if a piece of codes throws an Exception\n\n[![Build Status](https://travis-ci.org/try-php/predict-exception.svg?branch=master)](https://travis-ci.org/try-php/predict-exception)\n\n## Install\n\n```bash\n$ composer require try/predict-exception\n```\n\n## Usage\n\n```php\n\u003c?php\nrequire_once '/path/to/autoload.php';\n\nuse TryPhp\\PredictExeptionTrait;\n\n$assertions = new class() {\n\tuse PredictExeptionTrait();\n} \n\n$assertions-\u003epredictException(function () {\n\tthrow new \\RuntimeException('Oooops. Something broke.')\n}, \\RuntimeException::class); // won't throw an exception\n\n$assertions-\u003epredictException(function () {\n}, \\Exception::class); // will throw an exception\n\n$assertions-\u003epredictException(function () {\n\tthrow new \\RuntimeException('something else happened.');\n}, \\Exception::class); // will throw an exception\n```\n\n## API\n\n### Methods\n\n#### `predictException($capture, $exceptionClass)`\n\nMethod to check if a given piece of code throws an Throwable of the expected type.\n\n##### Arguments\n\n| Arguments | Type | Description |\n|---|---|---|\n| $capture | `callable` | Closure in which the Throwable shall be thrown. |\n| $exceptionClass | `string` | Class of the Throwable that is expected to be thrown. |\n\n## License\n\nGPL-2.0 © Willi Eßer","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftry-php%2Fpredict-exception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftry-php%2Fpredict-exception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftry-php%2Fpredict-exception/lists"}