{"id":15525358,"url":"https://github.com/ghostwriter/result","last_synced_at":"2026-03-17T20:03:09.260Z","repository":{"id":37797970,"uuid":"430920511","full_name":"ghostwriter/result","owner":"ghostwriter","description":"Provides a Result type implementation for PHP","archived":false,"fork":false,"pushed_at":"2026-03-17T04:44:56.000Z","size":65389,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"2.0.x","last_synced_at":"2026-03-17T19:32:29.218Z","etag":null,"topics":["ghostwriter","php","result","result-type"],"latest_commit_sha":null,"homepage":"https://github.com/ghostwriter/result","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["ghostwriter"]}},"created_at":"2021-11-23T01:29:41.000Z","updated_at":"2026-03-17T04:43:53.000Z","dependencies_parsed_at":"2024-04-09T16:44:26.610Z","dependency_job_id":"5ac3ba17-20b9-4b8a-b944-a368dc65fd29","html_url":"https://github.com/ghostwriter/result","commit_stats":{"total_commits":192,"total_committers":1,"mean_commits":192.0,"dds":0.0,"last_synced_commit":"8b0633ee17ba1bb4bd9dd7d0e71c5e270e3ed3dd"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ghostwriter/result","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fresult","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fresult/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fresult/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fresult/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/result/tar.gz/refs/heads/2.0.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fresult/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30630031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: 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":["ghostwriter","php","result","result-type"],"created_at":"2024-10-02T10:57:03.312Z","updated_at":"2026-03-17T20:03:09.217Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"readme":"# Result\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/result\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Automation](https://github.com/ghostwriter/result/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/result/actions/workflows/automation.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/result?color=8892bf)](https://www.php.net/supported-versions)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/result?color=blue)](https://packagist.org/packages/ghostwriter/result)\n\nProvides a **`Result`** type implementation for PHP using [`ghostwriter/option`](https://github.com/ghostwriter/option)\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/result\n```\n\n## Usage\n\n```php\nuse Ghostwriter\\Result\\Failure;\nuse Ghostwriter\\Result\\Success;\n\n// --- Success ---\n$success = Success::new('Hello world!');\n$success-\u003eget(); // 'Hello world!'\n\n// --- Failure ---\n$failure = Failure::new(new ExampleException());\n$failure-\u003eget(); // throws: ResultException\n$failure-\u003egetOr('Fallback'); // 'Fallback'\n$failure-\u003egetError(); // returns: instance of ExampleException\n\n// --- Example ---\nfunction divide(int $x, int $y): ResultInterface\n{\n    if ($y === 0) {\n        return Result::failure(new DivisionByZeroError);\n    }\n\n    return Result::success($x / $y);\n}\n\ndivide(1, 0); // Error(DivisionByZeroError)\ndivide(1, 1); // Success(1)\n```\n\n### Credits\n\n- [Nathanael Esayeas](https://github.com/ghostwriter)\n- [All Contributors](https://github.com/ghostwriter/result/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%2Fresult","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Fresult","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fresult/lists"}