PHPackages                             mkjpryor/option - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mkjpryor/option

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mkjpryor/option
===============

Simple option and result types for PHP

071PHP

Since Mar 31Pushed 10y agoCompare

[ Source](https://github.com/mkjpryor/option)[ Packagist](https://packagist.org/packages/mkjpryor/option)[ RSS](/packages/mkjpryor-option/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

mkjpryor/option
===============

[](#mkjpryoroption)

Simple option and result classes for PHP, inspired by Scala's Option, Haskell's Maybe and Rust's Result.

The Option type provides additional functionality over nullable types for operating on values that may or may not be present.

The Result type also includes a reason for the failure (an exception), and allows errors to be propagated without worrying about specifically handling them.

Installation
------------

[](#installation)

`mkjpryor/option` can be installed via [Composer](https://getcomposer.org/):

```
php composer.phar require mkjpryor/option dev-master
```

Usage
-----

[](#usage)

### Creating an Option or a Result

[](#creating-an-option-or-a-result)

```
