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

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

monsieurluge/optional
=====================

Optional-oriented objects

v1.0.0(6y ago)03UnlicensePHP

Since Mar 10Pushed 6y ago1 watchersCompare

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

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

Optional
========

[](#optional)

[![logo](logo.png)](logo.png)

The goal of the Optional library is to handle elegantly optional parameters in order to avoid control structures like `if` or `switch`, and to avoid multiple return types.

The code also becomes more declarative.

Examples
--------

[](#examples)

### Sending user data to a template

[](#sending-user-data-to-a-template)

Context: We want to display user data but the phone number is an optional one.

#### As usually seen

[](#as-usually-seen)

```
