{"id":15014512,"url":"https://github.com/marcinorlowski/php-type-asserts","last_synced_at":"2026-01-05T04:50:12.553Z","repository":{"id":60194184,"uuid":"541595953","full_name":"MarcinOrlowski/php-type-asserts","owner":"MarcinOrlowski","description":"PHP Data Type validation asserts","archived":false,"fork":false,"pushed_at":"2023-12-30T18:46:01.000Z","size":46,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T13:16:39.114Z","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/MarcinOrlowski.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2022-09-26T13:16:52.000Z","updated_at":"2022-11-04T20:04:06.000Z","dependencies_parsed_at":"2024-11-28T23:22:14.375Z","dependency_job_id":"ff3108cc-2c6b-438d-82f0-b21e18a59ad3","html_url":"https://github.com/MarcinOrlowski/php-type-asserts","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"a985cf560b1c59d12422a3810857d5730b5551c8"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fphp-type-asserts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fphp-type-asserts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fphp-type-asserts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fphp-type-asserts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcinOrlowski","download_url":"https://codeload.github.com/MarcinOrlowski/php-type-asserts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959457,"owners_count":20538629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-09-24T19:45:43.265Z","updated_at":"2026-01-05T04:50:12.518Z","avatar_url":"https://github.com/MarcinOrlowski.png","language":"PHP","readme":"# PHP Type Asserts #\n\n[![Latest Stable Version](https://poser.pugx.org/marcin-orlowski/php-type-asserts/v/stable)](https://packagist.org/packages/marcin-orlowski/php-type-asserts)\n[![License](https://poser.pugx.org/marcin-orlowski/php-type-asserts/license)](https://packagist.org/packages/marcin-orlowski/php-type-asserts)\n\nPHP Data type assertions.\n\n---\n\nThis package provides helper methods to validate variable data type. While there are handy native\nmethods like `is_string()` or `is_array()`, you can have then check for single type at a time.\nThis package allows to validate against type union (i.e. `STRING|INT`) or ensure that priovided\n`string` refers to existing class. Also, contrary to native methods, if there's no match and\nvariable contains data of non-welcomed type, exception is thrown which lets you simplify your\ncode flow.\n\n## Installation ##\n\n```bash\ncomposer require --dev marcin-orlowski/type-asserts\n```\n\n----\n\n## Usage example ##\n\nThe following code ensures `$var` is of either `int` or `float` type before math is done:\n\n```php\nuse MarcinOrlowski\\TypeAsserts\\Type;\nuse MarcinOrlowski\\TypeAsserts\\Validator;\n\n$var = 'foo';\n\nValidator::assertIsType($var, [Type::INT, Type::FLOAT]);\n$result = $var * 5;\n```\n\nThe following code ensures `$var` refers to existing class, before we try to instantiate it:\n\n```php\nuse MarcinOrlowski\\TypeAsserts\\Type;\nuse MarcinOrlowski\\TypeAsserts\\Validator;\n\n$cls = 'non-existing';\n\nValidator::assertIsType($cls, Type::EXISTING_CLASS);\n$obj = new $cls;\n```\n\n----\n\n## License ##\n\n* Written and copyrighted \u0026copy;2014-2022 by Marcin Orlowski\n* Open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Fphp-type-asserts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinorlowski%2Fphp-type-asserts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Fphp-type-asserts/lists"}