PHPackages                             noisystate/skipped-attributes - 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. noisystate/skipped-attributes

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

noisystate/skipped-attributes
=============================

A simple package to define arrays with optional attributes in an elegant way

638PHP

Since Oct 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/noisystate/skipped-attributes)[ Packagist](https://packagist.org/packages/noisystate/skipped-attributes)[ RSS](/packages/noisystate-skipped-attributes/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Skip array attributes in an elegant way
---------------------------------------

[](#skip-array-attributes-in-an-elegant-way)

### Installation

[](#installation)

```
composer require noisystate/skipped-attributes

```

### Basic usage

[](#basic-usage)

```
$data = unskipped_attributes([
    'one' => 1,
    'two' => 2,
    'three' => $someCondition ? 3 : skip_attribute(),
]);
// If $someCondition is true
// $data contains ['one' => 1, 'two' => 2, 'three' => 3]
// Otherwise
// $data contains ['one' => 1, 'two' => 2]
```

### Why use it

[](#why-use-it)

It happens so often when you are building a definition-array and adding attributes conditionally to it. This leads to using many if conditions and simplifying the definition not to confuse the code reader and enforcing him/her to walk through all these conditions even if he is not interested in that level of detail.

This super simple library lets you define arrays with conditionally added attributes (key-value pairs) in a short simple format so that the code reader can have an overview about the array and the attributes inside it without having to walk through many if conditions.

### Example use case

[](#example-use-case)

This is a common use case for laravel developers when implementing FormRequest rules method, And you want the code reader to see the rules' definition array returned by the method directly without having him/her to walk through many if conditions.

```
// Using skipped-attributes

public function rules()
{
    return unskipped_attributes([
        'name' => 'required|string',
        'email' => 'required|email',
        'is_active' => $authenticatedUser->canSetActive()
            ? 'required|boolean'
            : skip_attribute(),
        'is_visible' => $authenticatedUser->canSetVisibility()
            ? 'required|boolean'
            : skip_attribute(),
        'subscription_ends_at' => $authenticatedUser->canSetSubscriptionExpiry()
            ? 'required|date'
            : skip_attribute(),
    ]);

}
```

```
// Without using skipped-attributes

public function rules()
{
    $rules = [
        'name' => 'required|string',
        'email' => 'required|email',
    ];

    if($authenticatedUser->canSetActive()){
        $rules['is_active'] = 'required|boolean'
    }

    if($authenticatedUser->canSetVisibility()){
        $rules['is_visible'] = 'required|boolean';
    }

    if($authenticatedUser->canSetSubscriptionExpiry()){
        $rules['subscription_ends_at'] = 'required|date';
    }

    return $rules;
}
```

This is just one common use case, But you can use it so many other situations.

### If you don't like using the helper functions

[](#if-you-dont-like-using-the-helper-functions)

```
use Noisystate\SkippedAttributes\UnskippedAttributes;
use Noisystate\SkippedAttributes\SkippedAttribte;

$data = UnskippedAttributes::from([
    'one' => 1,
    'two' => 2,
    'three' => $someCondition ? 3 : new SkippedAttribte(),
])->all();
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/08aeea317aec2cb63818cb56140ca70b52976976b3cdef2c85c924c609c29f52?d=identicon)[error17191](/maintainers/error17191)

---

Top Contributors

[![error17191](https://avatars.githubusercontent.com/u/9117744?v=4)](https://github.com/error17191 "error17191 (5 commits)")

### Embed Badge

![Health badge](/badges/noisystate-skipped-attributes/health.svg)

```
[![Health](https://phpackages.com/badges/noisystate-skipped-attributes/health.svg)](https://phpackages.com/packages/noisystate-skipped-attributes)
```

###  Alternatives

[webtorque7/inpage-modules

Adds module blocks to a SilverStripe website.

191.3k](/packages/webtorque7-inpage-modules)

PHPackages © 2026

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