{"id":27091716,"url":"https://github.com/dgame/php-optional","last_synced_at":"2025-04-06T07:53:29.340Z","repository":{"id":56967365,"uuid":"59826394","full_name":"Dgame/php-optional","owner":"Dgame","description":"Rust-like Optional-type for PHP","archived":false,"fork":false,"pushed_at":"2019-11-26T11:13:30.000Z","size":55,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T06:35:51.280Z","etag":null,"topics":["argument-unpacking","optional","php"],"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/Dgame.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}},"created_at":"2016-05-27T10:24:38.000Z","updated_at":"2022-03-08T01:50:49.000Z","dependencies_parsed_at":"2022-08-21T06:10:26.558Z","dependency_job_id":null,"html_url":"https://github.com/Dgame/php-optional","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-optional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-optional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-optional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dgame%2Fphp-optional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dgame","download_url":"https://codeload.github.com/Dgame/php-optional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451626,"owners_count":20940946,"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":["argument-unpacking","optional","php"],"created_at":"2025-04-06T07:53:28.941Z","updated_at":"2025-04-06T07:53:29.334Z","avatar_url":"https://github.com/Dgame.png","language":"PHP","readme":"# php-optional\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Dgame/php-optional/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Dgame/php-optional/?branch=master)\n\n[![Build Status](https://travis-ci.org/Dgame/php-optional.svg?branch=master)](https://travis-ci.org/Dgame/php-optional)\n\nRust-like Optional-type for PHP 7\n\n### Some - a valid Value\n```php\n$some = some(42);\n$this-\u003eassertTrue($some-\u003eisSome());\n$this-\u003eassertEquals(42, $some-\u003eunwrap());\n```\n\n### Some with argument unpacking\n```php\n$some = some(42);\n$this-\u003eassertTrue($some-\u003eisSome($value));\n$this-\u003eassertFalse($some-\u003eisNone());\n$this-\u003eassertEquals(42, $value);\n```\n\n### None - an invalid value\n```php\n$none = none();\n$this-\u003eassertTrue($none-\u003eisNone());\n$this-\u003eassertFalse($none-\u003eisSome());\n```\n\n### None with argument unpacking\n```php\n$none = none();\n$this-\u003eassertTrue($none-\u003eisNone());\n$this-\u003eassertFalse($none-\u003eisSome($value));\n$this-\u003eassertNull($value);\n```\n\n### Maybe - decides for you if your value is a `Some` or a `None`\n```php\n$maybe = maybe(null);\n$this-\u003eassertTrue($maybe-\u003eisNone());\n$maybe = maybe(42);\n$this-\u003eassertTrue($maybe-\u003eisSome());\n$this-\u003eassertEquals(42, $maybe-\u003eunwrap());\n```\n\n### Ensure that a condition is fulfilled\n```php\n$result = some(0)-\u003eensure(function($value) {\n    return $value \u003e 0;\n});\n$this-\u003eassertTrue($result-\u003eisNone());\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-optional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgame%2Fphp-optional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgame%2Fphp-optional/lists"}