PHPackages                             o/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. o/option

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

o/option
========

A basic port of the Option type from Rust

14PHP

Since Apr 21Pushed 6y ago2 watchersCompare

[ Source](https://github.com/j-arens/option-php)[ Packagist](https://packagist.org/packages/o/option)[ RSS](/packages/o-option/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Option
======

[](#option)

This is a partial port of the [Option](https://doc.rust-lang.org/std/option/) type from [Rust](https://www.rust-lang.org/). Most of the functionality is here but I skipped porting some of the more Rust-specific methods that don't really make sense in a PHP context.

Usage
-----

[](#usage)

Basic usage is the same as in Rust.

```
use O\Option\{Some, None, OptionInterface};

// basic setting and getting of values
$greeting = new Some('hey there');
$name = new None();

echo $greeting->unwrap(); // echos 'hey there'
echo $name->unwrap(); // throws an OptionException
echo $name->unwrapOr('unknown'); // echos 'unknown'

function divide(int $x, int $y): OptionInterface
{
  if (y === 0) {
    return new None();
  }
  return new Some(x / y);
}

divide(1, 0); // None
divide(1, 1); // Some(1)
```

Linting
-------

[](#linting)

```
$ composer lint

```

Analyzing
---------

[](#analyzing)

```
$ composer analyze

```

Testing
-------

[](#testing)

```
$ composer test:unit

```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffba01ec72f854a8f828d92b2d587f72523aa6ff421900102c676faaccd1d1f9?d=identicon)[jarens](/maintainers/jarens)

---

Top Contributors

[![j-arens](https://avatars.githubusercontent.com/u/15810037?v=4)](https://github.com/j-arens "j-arens (4 commits)")[![josharens](https://avatars.githubusercontent.com/u/60370355?v=4)](https://github.com/josharens "josharens (2 commits)")

### Embed Badge

![Health badge](/badges/o-option/health.svg)

```
[![Health](https://phpackages.com/badges/o-option/health.svg)](https://phpackages.com/packages/o-option)
```

###  Alternatives

[aktuba/php-puppeteer

Extend puphpeteer

182.5k](/packages/aktuba-php-puppeteer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
