{"id":15525352,"url":"https://github.com/ghostwriter/option","last_synced_at":"2026-01-11T10:51:41.791Z","repository":{"id":37853344,"uuid":"430920645","full_name":"ghostwriter/option","owner":"ghostwriter","description":"Provides an Option type implementation for PHP","archived":false,"fork":false,"pushed_at":"2025-04-22T00:50:45.000Z","size":1026,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"2.0.x","last_synced_at":"2025-04-22T01:30:08.002Z","etag":null,"topics":["ghostwriter","maybe","option","option-type","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostwriter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["ghostwriter"]}},"created_at":"2021-11-23T01:30:14.000Z","updated_at":"2025-04-22T00:50:48.000Z","dependencies_parsed_at":"2024-06-01T16:29:53.721Z","dependency_job_id":"253cc132-4daf-4b00-b0b8-a72daf793d7c","html_url":"https://github.com/ghostwriter/option","commit_stats":{"total_commits":271,"total_committers":2,"mean_commits":135.5,"dds":"0.0036900369003689537","last_synced_commit":"c8df886578e970369667129d575d2ffb0d200666"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Foption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Foption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Foption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Foption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/option/tar.gz/refs/heads/2.0.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250402895,"owners_count":21424770,"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":["ghostwriter","maybe","option","option-type","php"],"created_at":"2024-10-02T10:57:00.301Z","updated_at":"2026-01-11T10:51:41.750Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"readme":"# Option\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/option\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Automation](https://github.com/ghostwriter/option/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/option/actions/workflows/automation.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/option?color=8892bf)](https://www.php.net/supported-versions)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/option?color=blue)](https://packagist.org/packages/ghostwriter/option)\n\nProvides an **`Option`** type implementation for PHP.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/option\n```\n\n### Star ⭐️ this repo if you find it useful\n\nYou can also star (🌟) this repo to find it easier later.\n\n## Usage\n\n```php\nuse Ghostwriter\\Option\\Exception\\NullPointerException;\nuse Ghostwriter\\Option\\None;\nuse Ghostwriter\\Option\\Some;\nuse Ghostwriter\\Option\\Option;\n\n$message = '#BlackLivesMatter';\nOption::new($message); // return `Some`\n\n$some = Some::new($message); // return `Some`\necho $some-\u003eget(); // prints #BlackLivesMatter\n\n$none = None::new(); // return `None`\n\n// calling the `get` method on `None` will throw `NullPointerException`\necho $none-\u003eget(); // throw `NullPointerException`\n\necho $none-\u003egetOr('#BLM'); // prints #BLM\n\n// calling the `new` static method with `null` will return `None`\nOption::new(null); // return `None`\n\n// calling the `new` static method with `null will throw `NullPointerException`\nSome::new(null); // throws `NullPointerException`\n\n// calling the `new` static method with `None will throw `NullPointerException`\nSome::new(None::new()); // throws `NullPointerException`\n\n--- Example\n\nfunction divide(int $x, int $y): OptionInterface\n{\n    if ($y === 0) {\n        return None::new();\n    }\n\n    return Some::new($x / $y);\n}\n\ndivide(1, 0); // None\ndivide(1, 1); // Some(1)\n```\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n### Credits\n\n- [Nathanael Esayeas](https://github.com/ghostwriter)\n- [All Contributors](https://github.com/ghostwriter/option/contributors)\n\n### Changelog\n\nPlease see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.\n\n### License\n\nPlease see [LICENSE](./LICENSE) for more information on the license that applies to this project.\n\n### Security\n\nPlease see [SECURITY.md](./SECURITY.md) for more information on security disclosure process.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Foption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Foption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Foption/lists"}