{"id":21524175,"url":"https://github.com/alcidesrc/severe","last_synced_at":"2026-02-14T17:30:48.280Z","repository":{"id":240254799,"uuid":"802033830","full_name":"AlcidesRC/severe","owner":"AlcidesRC","description":"This repository offers a collection of PHP classes that enforce strict data types","archived":false,"fork":false,"pushed_at":"2024-08-25T17:14:13.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-07T10:35:10.437Z","etag":null,"topics":["data-types","php8","qa"],"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/AlcidesRC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-05-17T11:46:28.000Z","updated_at":"2024-08-25T17:11:33.000Z","dependencies_parsed_at":"2024-05-17T16:14:12.113Z","dependency_job_id":"0a96b49e-e3da-43fb-91ac-2c88fbd23152","html_url":"https://github.com/AlcidesRC/severe","commit_stats":null,"previous_names":["fonil/severe","alcidesrc/severe"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/AlcidesRC/severe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fsevere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fsevere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fsevere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fsevere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlcidesRC","download_url":"https://codeload.github.com/AlcidesRC/severe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlcidesRC%2Fsevere/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29450871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["data-types","php8","qa"],"created_at":"2024-11-24T01:21:20.977Z","updated_at":"2026-02-14T17:30:48.264Z","avatar_url":"https://github.com/AlcidesRC.png","language":"PHP","readme":"[![Continuous Integration](https://github.com/fonil/severe/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fonil/severe/actions/workflows/ci.yml)\n\n# Severe\n\n\n\u003e Avoid data type conflicts in PHP being more severe \n\n\n[TOC]\n\n\n## Summary\n\nThis repository offers a collection of PHP classes that enforce strict data types, ensuring more reliable and maintainable code. By leveraging these classes, developers can reduce bugs, improve code readability, and enhance overall software quality.\n\n## Requirements\n\nThis library requires PHP^8.3\n\n## Installation\n\nInstall `Severe` using Composer:\n\n```bash\ncomposer require fonil/severe\n```\n\n## Supported Data Types\n\n`Severe` supports the following data types:\n\n| Type       | Category    | Version  |\n| ---------- | ----------- | --------:|\n| Array      | Generic     | 1.0      |\n| Boolean    | Generic     | 1.0      |\n| Closure    | Generic     | 1.0      |\n| Float      | Generic     | 1.0      |\n| Integer    | Generic     | 1.0      |\n| Null       | Generic     | 1.0      |\n| Object     | Generic     | 1.0      |\n| String     | Generic     | 1.0      |\n| Money      | Finances    | 1.0      |\n| Domain     | Internet    | TODO     |\n| Email      | Internet    | TODO     |\n| Document   | File System | TODO     |\n| Image      | File System | TODO     |\n\n### Generic Data Types\n\n#### Usage\n\n##### Setters\n\n`Severe` provides a static public method `set()` that validates the input and creates a data type instance when succeed.\n\n\u003e In case of invalid argument type a `TypeError` is thrown\n\n```php\nuse Severe\\TypeString;\nuse Severe\\TypeBoolean;\nuse Severe\\TypeNull;\n\n$string = TypeString::set($var);\n$bool = TypeBoolean::set($flag);\n$null = TypeNull::set($optional);\n...\n```\n\n##### Getters\n\nAll `Severe` data type instances are `_invokable` classes so you can get the values as follow:\n\n```php\n$value = $string();\n$flag = $bool();\n$optional = $null();\n...\n```\n\n### Ennumeration Classes\n\n#### Currency\n\nTo handle valid currencies a backed enumeration class is provided called `Currency` which allows you to get the `name`, `symbol`, `code` and `decimals` for allowed currencies.\n\n##### Usage\n\n###### Examples\n\n```php\nuse Severe\\Enums\\Currency;\n\n$currency = Currency::EUR;\t\t\t\t\necho $currency-\u003evalue;       // EUR\necho $currency-\u003ecode();      // 978\necho $currency-\u003ename();      // Euro\necho $currency-\u003edecimals();  // 2\n\n$currency = Currency::UYI;\necho $currency-\u003evalue;       // UYI\necho $currency-\u003ecode();      // 940\necho $currency-\u003ename();      // Uruguay Peso en Unidades Indexadas (URUIURUI)\necho $currency-\u003edecimals();  // 0\n\n// Dynamic instantiation\n$currency = Currency::from('TRY');\necho $currency-\u003evalue;       // TRY\necho $currency-\u003ecode();      // 949\necho $currency-\u003ename();      // Turkish Lira\necho $currency-\u003edecimals();  // 2\n```\n\n### Additional Data Types\n\n#### Money\n\nAdditionally, `Severe` provides a custom data type to handle money entities. Those entities has two components:\n\n- Amount: a float number indicating the amount of money\n- Currency: a currency entity\n\n##### Usage\n\n###### Setters\n\nAll of those ways are supported and equivalents:\n\n```php\nuse Severe\\Enums\\Currency;\nuse Severe\\TypeFloat;\nuse Severe\\TypeMoney;\n\n$money = TypeMoney::set(123.456, 'eur');\n$money = TypeMoney::set(123.456, Currency::EUR);\n$money = TypeMoney::set(TypeFloat::set(123.456), 'EUR');\n$money = TypeMoney::set(TypeFloat::set(123.456), Currency::EUR);\n```\n\n###### Getters\n\n```php\n[$amount, $currency] = $money();\n\n// $amount is an instance of TypeFloat\n// $currency is an instance of Currency\n```\n\n###### Examples\n\n```php\n$money = TypeMoney::set(123.456789, 'EUR');\n[$amount, $currency] = $money();\necho $amount();                  // 123.46\necho $currency-\u003evalue;           // EUR\n\n$money = TypeMoney::set(123.456789, 'CLF');\necho $money()[0]-\u003e__invoke();    // 123.4568\necho $money()[1]-\u003edecimals();    // 4\n```\n\n\n## Security Vulnerabilities\n\nPlease review our security policy on how to report security vulnerabilities:\n\n**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY**\n\n### Supported Versions\n\nOnly the latest major version receives security fixes.\n\n### Reporting a Vulnerability\n\nIf you discover a security vulnerability within this project, please [open an issue here](https://github.com/fonil/severe/issues). All security vulnerabilities will be promptly addressed.\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](./LICENSE) file for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcidesrc%2Fsevere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falcidesrc%2Fsevere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falcidesrc%2Fsevere/lists"}