PHPackages                             aegisora/in-array-rule - 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. aegisora/in-array-rule

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

aegisora/in-array-rule
======================

Rule-based in-array validation in Aegisora ecosystem

v1.0.0(1mo ago)00MITPHPPHP &gt;=7.4

Since Apr 29Pushed 1mo agoCompare

[ Source](https://github.com/Aegisora/in-array-rule)[ Packagist](https://packagist.org/packages/aegisora/in-array-rule)[ Docs](https://github.com/Aegisora/in-array-rule)[ RSS](/packages/aegisora-in-array-rule/feed)WikiDiscussions main Synced 1w ago

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

Aegisora In-Array Rule
======================

[](#aegisora-in-array-rule)

[![Code Coverage Badge](./badge.svg)](./badge.svg)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan Badge](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/83dd3d35cebed0eab9ee97ff1a5849c1344cda6a8ee9cac2cda20f5aa55b67bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c6174)

In-Array Rule provides a simple, rule-based **array membership validation** implementation for the Aegisora ecosystem.

It is built on top of `aegisora/rule-contract` () and follows its strict validation architecture, ensuring consistent and predictable behavior across applications.

---

✨ Features
----------

[](#-features)

- 🔹 Lightweight and dependency-free (except rule contract)
- 🔹 Strict and soft comparison modes (`in_array` behavior)
- 🔹 Fully compatible with Aegisora validation pipeline
- 🔹 Strict `Context → Result` validation flow
- 🔹 No raw booleans — only structured results
- 🔹 Safe execution via base `Rule` abstraction
- 🔹 Simple factory API (`create`, `createStrict`, `createSoft`)
- 🔹 Ready to use out of the box

---

📦 Installation
--------------

[](#-installation)

```
composer require aegisora/in-array-rule
```

---

🚀 Core Concept
--------------

[](#-core-concept)

This package implements a single validation rule:

- accepts a value via `Context`
- checks whether it exists in a predefined array
- returns a standardized `Result`

Internally uses PHP native function:

```
in_array($value, $array, $strict)
```

---

🏗️ Basic Usage
--------------

[](#️-basic-usage)

```
use Aegisora\Rules\InArrayRule;
use Aegisora\RuleContract\Models\Context;

$rule = InArrayRule::create(['apple', 'banana', 'orange',]);

$result = $rule->validate(Context::create('banana'));

if ($result->isValid()) {
    // value exists in array
} else {
    // value not found
}
```

---

🔒 Strict vs Soft Mode
---------------------

[](#-strict-vs-soft-mode)

### Strict mode (default)

[](#strict-mode-default)

```
$rule = InArrayRule::create([1, 2, 3,]);

$rule->validate(Context::create('1')); // false
```

Strict comparison checks type as well.

---

### Soft mode

[](#soft-mode)

```
$rule = InArrayRule::createSoft([1, 2, 3,]);

$rule->validate(Context::create('1')); // true
```

Allows loose comparison (`==` behavior).

---

🧩 Factory Methods
-----------------

[](#-factory-methods)

```
InArrayRule::create($array);         // strict by default
InArrayRule::createStrict($array);   // explicit strict
InArrayRule::createSoft($array);     // loose comparison
```

---

🏛️ Architecture
---------------

[](#️-architecture)

This package relies on `aegisora/rule-contract` ().

Flow:

1. `validate()` is called
2. `Context` is passed in
3. `executeValidate()` runs
4. `in_array` check is executed
5. `Result` is returned

All logic is safely handled by `Rule` contract.

---

⚖️ License
----------

[](#️-license)

This package is open-source and licensed under the MIT License. See the LICENSE for details.

---

🌱 Contributing
--------------

[](#-contributing)

Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.

---

🌟 Support
---------

[](#-support)

If you find this project useful, please consider giving it a star on GitHub!

It helps the project grow and motivates further development.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 77% 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

Unknown

Total

1

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81402dcd0a07ad550b7f80f5871e7c302770b29d4c73a52fc35ba697f702d56e?d=identicon)[arslanim](/maintainers/arslanim)

---

Top Contributors

[![arslanim](https://avatars.githubusercontent.com/u/22678154?v=4)](https://github.com/arslanim "arslanim (57 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (17 commits)")

---

Tags

aegisoraaegisora-ecosystemarrayin-array-rulephprule-based-in-array-predicate-checkphparrayaegisoraaegisora-ecosystemin-array-validationin-array-rule

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aegisora-in-array-rule/health.svg)

```
[![Health](https://phpackages.com/badges/aegisora-in-array-rule/health.svg)](https://phpackages.com/packages/aegisora-in-array-rule)
```

###  Alternatives

[zakirullin/mess

Convenient array-related routine &amp; better type casting

21330.0k2](/packages/zakirullin-mess)

PHPackages © 2026

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