PHPackages                             aviator/optionally - 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. aviator/optionally

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

aviator/optionally
==================

A container for keyed booleans.

0.1.1(8y ago)118MITPHPPHP &gt;=7.0.0

Since Dec 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/danielsdeboer/optionally)[ Packagist](https://packagist.org/packages/aviator/optionally)[ Docs](https://github.com/danielsdeboer/optionally)[ RSS](/packages/aviator-optionally/feed)WikiDiscussions master Synced 2mo ago

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

[![Build Status](https://camo.githubusercontent.com/9cf9db3426e3095b685f708fe497b5b418b901ca60665e6e1f76c71b9ee0c09a/68747470733a2f2f7472617669732d63692e6f72672f64616e69656c736465626f65722f6f7074696f6e616c6c792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/danielsdeboer/optionally)[![Latest Stable Version](https://camo.githubusercontent.com/6469b6e484d15a7cf9a0108f1fbf1bb2d7e8e8e31f205986b7864ca82fa86ec1/68747470733a2f2f706f7365722e707567782e6f72672f61766961746f722f6f7074696f6e616c6c792f762f737461626c65)](https://packagist.org/packages/aviator/optionally)[![License](https://camo.githubusercontent.com/c8c9a1d3386d6431f441d59ea452a3deea2f39c131d9093d2dca236372541653/68747470733a2f2f706f7365722e707567782e6f72672f61766961746f722f6f7074696f6e616c6c792f6c6963656e7365)](https://packagist.org/packages/aviator/optionally)

Overview
--------

[](#overview)

Optionally is a keyed store of booleans. It can be used for anything but usually to store options.

### Installation

[](#installation)

Via Composer:

```
composer require aviator/optionally

```

### Testing

[](#testing)

Via Composer:

```
composer test

```

### Usage

[](#usage)

Instantiate `Optionally` with or without an array. You can add the array later with `add()` or `replaceWith()` (see below).

The array should have string keys and boolean values. It's important to note that any pairs with non-string keys and non-boolean values will be silently discarded—they will **not** be coerced.

```
$options = Optionally::make([
    'option1' => true,
    'option2' => false,
    0 => false,
    'test' => 'value'
]);

// [0 => false] and ['test' => 'value'] will be discarded.
```

Get the underlying array with `all()`:

```
$options->all();

// ['option1' => true, 'option2' => false]
```

Get the keys of the underlying array with `keys()`:

```
$options->keys();

// ['option1', 'option2']
```

Get the value of a key if it exists (or null if it doesn't) with `get()`:

```
$options->get('option1');

// true

$options->get('someOptionThatDoesntExist');

// null
```

Find whether or not a key exists with `has()`:

```
$options->has('option2');

// true

$options->has('someOptionThatDoesntExist');

// false
```

Trash the existing options and replace them with `replaceWith()`:

```
$options->replaceWith(['option3' => true, 'option4' => false]);

$options->all();

// ['option3' => true, 'option4' => false]
```

Add a new array to the existing options array, overwriting existing keys with `add()`:

```
$options->add(['option1' => false, 'option3' => true]);

$options->all();

// ['option1' => false, 'option2' => false, 'option3' => true]
```

Set a single key value pair with `set()`:

```
$options->set('option3', false);

$options->all();

// ['option1' => true, 'option2' => false, 'option3' => false]
```

Trash a single key value pair with `remove()`:

```
$options->remove('option1');

$options->all();

// ['option2' => true]
```

An instance of `Optionally` is iterable:

```
foreach ($options as $key => $value) {
    /* ... */
}
```

It's also countable:

```
count($foreach);

// 2
```

Other
-----

[](#other)

### License

[](#license)

This package is licensed with the [MIT License (MIT)](LICENSE).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~0 days

Total

2

Last Release

3084d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebd3fe214b5768e700ae43c7fdc4b83d249972a6a97a0faef372d0ec19256eca?d=identicon)[danielsdeboer](/maintainers/danielsdeboer)

---

Top Contributors

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

---

Tags

booleanskeyvaluestoreoptionsphpphp7phpoptionsPHP7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aviator-optionally/health.svg)

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

PHPackages © 2026

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