PHPackages                             aegisora/scalar-equality-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. aegisora/scalar-equality-rule

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

aegisora/scalar-equality-rule
=============================

Rule-based scalar equality validation in Aegisora ecosystem

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

Since May 1Pushed 1mo agoCompare

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

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

Aegisora Scalar Equality Rule
=============================

[](#aegisora-scalar-equality-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)

Scalar Equality Rule provides a simple, rule-based **scalar value comparison** 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 scalar comparison using `===`
- 🔹 Supports both equality and inequality checks
- 🔹 Fully compatible with Aegisora validation pipeline
- 🔹 Strict `Context → Result` validation flow
- 🔹 No raw booleans — only structured results
- 🔹 Safe execution via base `Rule` abstraction
- 🔹 Convenient factory methods (`createEqual`, `createNotEqual`)
- 🔹 Built-in validation of input values

---

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

[](#-installation)

```
composer require aegisora/scalar-equality-rule
```

---

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

[](#-core-concept)

This package implements scalar comparison validation:

- accepts a value via `Context`
- compares it to an expected scalar value
- uses strict comparison (`===`)
- returns a standardized `Result`

Supported values:

- scalar types (`int`, `float`, `string`, `bool`)
- `null`

Any non-scalar value will result in an exception.

---

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

[](#️-basic-usage)

### ✅ Equality check

[](#-equality-check)

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

$result = ScalarEqualityRule::createEqual(42)->validate(Context::create(42));

if ($result->isValid()) {
    // values are equal
} else {
    // values are NOT equal
}
```

---

### ❌ Inequality check

[](#-inequality-check)

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

$result = ScalarEqualityRule::createNotEqual(42)->validate(Context::create(100));

if ($result->isValid()) {
    // values are NOT equal (as expected)
} else {
    // values are equal (unexpected)
}
```

---

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

[](#-factory-methods)

```
ScalarEqualityRule::createEqual($expectedValue);
ScalarEqualityRule::createNotEqual($expectedValue);
```

- `$expectedValue` — scalar value or `null`

---

⚠️ Validation Rules
-------------------

[](#️-validation-rules)

Both expected value and input value must be:

- scalar (`int`, `float`, `string`, `bool`)
- or `null`

Otherwise, an exception will be thrown:

```
Aegisora\RuleContract\Exceptions\InvalidRuleContextException
```

---

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

[](#️-architecture)

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

Validation flow:

1. `validate()` is called
2. `Context` is passed in
3. `executeValidate()` runs
4. Values are validated as scalar or null
5. Strict comparison (`===`) is performed
6. `Result` is returned

All logic is safely encapsulated within the base `Rule` abstraction.

---

⚖️ 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

Maintenance92

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 83.8% 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

39d 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 (83 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")

---

Tags

aegisoraaegisora-ecosystemphprule-based-scalar-equality-predicate-checkscalar-equalityscalar-equality-rulephpaegisoraaegisora-ecosystemscalar-equalityscalar-equality-validationscalar-equality-rule

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aegisora-scalar-equality-rule/health.svg)

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

PHPackages © 2026

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