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

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

typedphp/optional
=================

A library to reduce the code required for null-checking.

0.2.1(11y ago)372621MITPHPPHP &gt;=5.4.0CI failing

Since Aug 28Pushed 5y ago3 watchersCompare

[ Source](https://github.com/typedphp/optional)[ Packagist](https://packagist.org/packages/typedphp/optional)[ Docs](https://github.com/typedphp/optional)[ RSS](/packages/typedphp-optional/feed)WikiDiscussions main Synced 5d ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Optional
========

[](#optional)

[![Build Status](https://camo.githubusercontent.com/116f88401e7883e144410476abcf3bb3e4f792985095fdf883b1a33a4fa59fc8/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/116f88401e7883e144410476abcf3bb3e4f792985095fdf883b1a33a4fa59fc8/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)[![Code Quality](https://camo.githubusercontent.com/bda1b781d54a0aaff39c7553f9a690a9f56c6b2851c27fd7f81cf0b4bd0df5ac/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/bda1b781d54a0aaff39c7553f9a690a9f56c6b2851c27fd7f81cf0b4bd0df5ac/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)[![Code Coverage](https://camo.githubusercontent.com/1d2fd38077a43c787af64ef758213636d183d2111306e29b1b8268b327ae8863/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/1d2fd38077a43c787af64ef758213636d183d2111306e29b1b8268b327ae8863/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)[![Version](https://camo.githubusercontent.com/97a54510501ad9e04d60b83bea65d3785ddbfb95464221f40df150a5e7333367/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/97a54510501ad9e04d60b83bea65d3785ddbfb95464221f40df150a5e7333367/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)[![License](https://camo.githubusercontent.com/8a6c5c661052e59e48ef8561e584a7951e2bb38bc503bf56835dd1d53834698e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8a6c5c661052e59e48ef8561e584a7951e2bb38bc503bf56835dd1d53834698e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74797065647068702f6f7074696f6e616c2e7376673f7374796c653d666c61742d737175617265)

This library is inspired by [the code of Johannes Schmitt](https://github.com/schmittjoh/php-option) and [the writing of Igor Wiedler](https://igor.io/2014/01/10/functional-library-null.html). It is intended to reduce the code required for null-checking. Part of [TypedPHP](https://leanpub.com/typedphp).

Examples
--------

[](#examples)

```
