PHPackages                             o/result - 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/result

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

o/result
========

A basic port of the Result type from Rust

02PHP

Since Jan 29Pushed 6y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Result
======

[](#result)

This is a partial port of the [Result](https://doc.rust-lang.org/std/result/) 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\Result\{ResultInterface, Ok, Err};

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

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

// function that returns a Result
function divide(int $x, int $y): ResultInterface
{
  if ($y === 0) {
    return new Err('cannot divide by zero');
  }
  return new Ok(x / y);
}

divide(1, 0); // Err('cannot divide by zero')
divide(1, 1); // Ok(1)
```

Linting
-------

[](#linting)

```
$ composer lint

```

Analysing
---------

[](#analysing)

```
$ composer analyse

```

Testing
-------

[](#testing)

```
$ composer test:unit

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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://avatars.githubusercontent.com/u/17725498?v=4)[jarens](/maintainers/jarens)[@jarens](https://github.com/jarens)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[cevin/geohash

Geohash library for php

222.1k](/packages/cevin-geohash)

PHPackages © 2026

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