PHPackages                             adrianschubek/optional - 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. adrianschubek/optional

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

adrianschubek/optional
======================

Adds optional() functionality

1.0(5y ago)110MITPHPPHP &gt;=7.4

Since Jul 18Pushed 5y agoCompare

[ Source](https://github.com/adrianschubek/optional)[ Packagist](https://packagist.org/packages/adrianschubek/optional)[ Docs](https://docs.adriansoftware.de/optional)[ RSS](/packages/adrianschubek-optional/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Optional
========

[](#optional)

[![Latest Stable Version](https://camo.githubusercontent.com/28d97a1e3a95b7cbd4d96c93f8e577a3b76eb5aaead196136f84582a57a7a4bb/68747470733a2f2f706f7365722e707567782e6f72672f61647269616e7363687562656b2f6f7074696f6e616c2f76)](//packagist.org/packages/adrianschubek/optional)[![License](https://camo.githubusercontent.com/7a31322a891af93ddc728fe152c8f44b58c58f14f9879c15ee38b33c3d75c0bf/68747470733a2f2f706f7365722e707567782e6f72672f61647269616e7363687562656b2f6f7074696f6e616c2f6c6963656e7365)](//packagist.org/packages/adrianschubek/optional)
An optional helper supporting [macros](https://github.com/adrianschubek/macro).

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

[](#installation)

```
composer require adrianschubek/optional

```

Example
-------

[](#example)

```
// UserRepository::find(123) returns `null`

$balance = optional(UserRepository::find(123))->getBankAccount()->getBalance(); // Ok, no error. returns null

$balance = UserRepository::find(123)->getBankAccount()->getBalance(); // Error
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2127d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/500782457c7bfa139f0c77fc085cceaf6114c39ff2e7551c32bedb36af2a759b?d=identicon)[adrian.schubek](/maintainers/adrian.schubek)

---

Top Contributors

[![adrianschubek](https://avatars.githubusercontent.com/u/19362349?v=4)](https://github.com/adrianschubek "adrianschubek (2 commits)")

### Embed Badge

![Health badge](/badges/adrianschubek-optional/health.svg)

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

###  Alternatives

[dudapiotr/zftable

Flexible tool to generate table

7530.9k](/packages/dudapiotr-zftable)[mouadziani/xstate

State machine library to play with any complex behavior of your PHP objects

866.7k](/packages/mouadziani-xstate)[pugx/godfather

Strategy pattern component as library and symfony2 bundle

2538.7k1](/packages/pugx-godfather)[akhaled/livewire-sweetalert

Integration Sweetalert with Livewire

181.9k4](/packages/akhaled-livewire-sweetalert)

PHPackages © 2026

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