PHPackages                             fer79/php-optional-helper - 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. fer79/php-optional-helper

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

fer79/php-optional-helper
=========================

Optional helper similar to Laravel, compatible with arrays and objects. Initially thinked to use in Yii2, should work in other projects.

v1.0.0(9mo ago)018MITPHPPHP &gt;=7.4

Since Sep 12Pushed 9mo agoCompare

[ Source](https://github.com/fer79/php-optional-helper)[ Packagist](https://packagist.org/packages/fer79/php-optional-helper)[ RSS](/packages/fer79-php-optional-helper/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Optional helper for PHP
=======================

[](#optional-helper-for-php)

A small utility to implement a helper optional() similar to the one in laravel compatible with **arrays**, **objects**, **methods** and supports `ArrayAccess`.

---

🔒 Limitations
-------------

[](#-limitations)

- Nonexistent properties and methods return null.
- The object is read-only (offsetSet and offsetUnset do nothing).

---

✨ Available Methods
-------------------

[](#-available-methods)

- **Property access**

    ```
      optional($obj)->prop
    ```
- **Method access**

    ```
      optional($obj)->method()
    ```
- **Safe array access**

    ```
      optional($array)['key']
    ```
- **Get internal value**

    ```
      optional($value)->get()
    ```
- **String casting**

    ```
      echo optional($value);

      null → ""
      string / int / float / bool → converted to string
      arrays / objects → JSON
    ```

---

📜 License MIT License © Fernan Gonzalez

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance56

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

294d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/53839788?v=4)[Fernan Gonzalez](/maintainers/fer79)[@fer79](https://github.com/fer79)

---

Top Contributors

[![fer79](https://avatars.githubusercontent.com/u/53839788?v=4)](https://github.com/fer79 "fer79 (3 commits)")

### Embed Badge

![Health badge](/badges/fer79-php-optional-helper/health.svg)

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

PHPackages © 2026

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