{"id":21967879,"url":"https://github.com/aurimasniekis/throws","last_synced_at":"2026-06-29T07:31:25.086Z","repository":{"id":62489573,"uuid":"180641686","full_name":"aurimasniekis/throws","owner":"aurimasniekis","description":null,"archived":false,"fork":false,"pushed_at":"2019-04-10T19:09:43.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-20T15:41:34.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aurimasniekis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-10T18:34:12.000Z","updated_at":"2019-04-10T19:08:45.000Z","dependencies_parsed_at":"2022-11-02T11:15:29.788Z","dependency_job_id":null,"html_url":"https://github.com/aurimasniekis/throws","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aurimasniekis/throws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurimasniekis%2Fthrows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurimasniekis%2Fthrows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurimasniekis%2Fthrows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurimasniekis%2Fthrows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aurimasniekis","download_url":"https://codeload.github.com/aurimasniekis/throws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aurimasniekis%2Fthrows/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34918101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-29T13:36:19.236Z","updated_at":"2026-06-29T07:31:25.067Z","avatar_url":"https://github.com/aurimasniekis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Throws\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nPHP Library which provides functions which **Throws** exception\n\n## Install\n\nVia Composer\n\n```bash\n$ composer require aurimasniekis/throws\n```\n\n## Usage\n\nIt is pretty simple all the functions are defined under `Throws\\\\` namespace.\n\nSimplest function is `thr` which accept exception as argument and just throws it:\n\n```php\n\u003c?php\n\nuse function Throws\\thr;\n\nthr(new Exception(\"FooBar\"));\n```\n\nor u can throw specific exception with formatted string directly:\n\n```php\n\u003c?php\n\nuse function Throws\\thrException;\n\nthrException('Oh now \"%s\" error occurred', 'Big Error'); \n```\n\n#### Available methods:\n\n```php\nthr(new Exception('FooBar'));\n\nthrBadFunctionCallException('FooBar');\n\nthrBadMethodCallException('FooBar');\n\nthrDomainException('FooBar');\n\nthrInvalidArgumentException('FooBar');\n\nthrLengthException('FooBar');\n\nthrLogicException('FooBar');\n\nthrOutOfBoundsException('FooBar');\n\nthrOutOfRangeException('FooBar');\n\nthrOverflowException('FooBar');\n\nthrRangeException('FooBar');\n\nthrRuntimeException('FooBar');\n\nthrUnderflowException('FooBar');\n\nthrUnexpectedValueException('FooBar');\n\nthrErrorException('FooBar');\n\nthrError('FooBar');\n\nthrArgumentCountError('FooBar');\n\nthrArithmeticError('FooBar');\n\nthrAssertionError('FooBar');\n\nthrDivisionByZeroError('FooBar');\n\nthrCompileError('FooBar');\n\nthrParseError('FooBar');\n\nthrTypeError('FooBar');\n```\n\n## Why?\n\nYou probably asking why this kind of library is even needed? Here is couple of examples:\n\n```php\n// Instead of this\nif ($foo !== 'bar') {\n    throw new InvalidArgumentException(\n        sprintf(\n            'Oh no $foo is \"%s\"',\n            $foo\n        )\n    );   \n}\n\n// Much simpler\n$foo !== 'bar' || thrInvalidArgumentException('Oh no $foo is \"%s\"', $foo);\n```\n\nor this\n\n```php\n// Instead of this\nif (false === isset($array['key'])) {\n    throw new InvalidArgumentException('Oh no key is missing');\n} \n\n// Much simpler\n$array['key'] ?? thrInvalidArgumentException('Oh no key is missing');\n  \n```\n\n## Testing\n\nRun test cases\n\n```bash\n$ composer test\n```\n\nRun test cases with coverage (HTML format)\n\n\n```bash\n$ composer test-coverage\n```\n\nRun PHP style checker\n\n```bash\n$ composer check-style\n```\n\nRun PHP style fixer\n\n```bash\n$ composer fix-style\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n\n## License\n\nPlease see [License File](LICENSE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/aurimasniekis/throws.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/aurimasniekis/throws/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/aurimasniekis/throws.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/aurimasniekis/throws.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/aurimasniekis/throws.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/aurimasniekis/throws\n[link-travis]: https://travis-ci.org/aurimasniekis/throws\n[link-scrutinizer]: https://scrutinizer-ci.com/g/aurimasniekis/throws/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/aurimasniekis/throws\n[link-downloads]: https://packagist.org/packages/aurimasniekis/throws\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faurimasniekis%2Fthrows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faurimasniekis%2Fthrows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faurimasniekis%2Fthrows/lists"}