PHPackages                             cubicmushroom/options-trait - 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. cubicmushroom/options-trait

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

cubicmushroom/options-trait
===========================

Trait to make it easy to add options arrays to object classes

1.0.2(11y ago)1231MITPHP

Since Feb 23Pushed 11y ago1 watchersCompare

[ Source](https://github.com/cubicmushroom/options-trait)[ Packagist](https://packagist.org/packages/cubicmushroom/options-trait)[ RSS](/packages/cubicmushroom-options-trait/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (1)

[![Build Status](https://camo.githubusercontent.com/cc2a24c5316d9da6065ed801c071415295dd5ff13054c2a0e71e04d6269514c2/68747470733a2f2f7472617669732d63692e6f72672f63756269636d757368726f6f6d2f6f7074696f6e732d74726169742e737667)](https://travis-ci.org/cubicmushroom/options-trait)

Options Trait
=============

[](#options-trait)

This trait is used to provide basic options setting, getting, checking, and merging with defaults

Properties
----------

[](#properties)

The trait add the following properties to the class...

### $options

[](#options)

An array to the stroe the array of options in.

Methods
-------

[](#methods)

The trait adds the following methods to the class...

### hasOption

[](#hasoption)

Returns: boolean

Checks if an option is set or not

### getOption

[](#getoption)

Returns: mixed

Gets a requested option.

If a second arguments is passed, will return this as the default if the option is not set. If not passed, null is returned.

### setOption

[](#setoption)

Return: $this

Sets an option value

### setOptions

[](#setoptions)

Return: $this

Sets the options to the values given.

An optional second parameter allows for default values to be passed for options not included in the $options array.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

3

Last Release

4095d ago

### Community

Maintainers

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

---

Top Contributors

[![toby-griffiths](https://avatars.githubusercontent.com/u/4817007?v=4)](https://github.com/toby-griffiths "toby-griffiths (14 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/cubicmushroom-options-trait/health.svg)

```
[![Health](https://phpackages.com/badges/cubicmushroom-options-trait/health.svg)](https://phpackages.com/packages/cubicmushroom-options-trait)
```

###  Alternatives

[dm/ajaxcom

Controls Ajax from PHP

1816.4k](/packages/dm-ajaxcom)[slack/hack-json-schema

Hack JSON Schema generator

302.4k](/packages/slack-hack-json-schema)[proai/lumen-annotations

Route and event binding annotations for Laravel Lumen

1012.4k](/packages/proai-lumen-annotations)

PHPackages © 2026

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