PHPackages                             aegisora/instanceof-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/instanceof-rule

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

aegisora/instanceof-rule
========================

Rule-based instanceof validation in Aegisora ecosystem

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

Since Apr 30Pushed 1mo agoCompare

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

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

Aegisora Instanceof Rule
========================

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

Instanceof Rule provides a simple, rule-based **object type 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)
- 🔹 Native PHP `instanceof` validation
- 🔹 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`)
- 🔹 Ready to use out of the box

---

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

[](#-installation)

```
composer require aegisora/instanceof-rule
```

---

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

[](#-core-concept)

This package implements a single validation rule:

- accepts a value via `Context`
- checks whether it is an instance of a given class
- returns a standardized `Result`

Internally uses PHP native operator:

```
$value instanceof ClassName
```

---

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

[](#️-basic-usage)

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

class User {}

$result = InstanceofRule::create(User::class)->validate(Context::create(new User()));

if ($result->isValid()) {
    // value is instance of User
} else {
    // value is not instance of User
}
```

---

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

[](#-factory-methods)

```
InstanceofRule::create($className);
```

- `$className` — fully qualified class name (FQCN)

---

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

[](#️-architecture)

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

Flow:

1. `validate()` is called
2. `Context` is passed in
3. `executeValidate()` runs
4. `instanceof` 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

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

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

---

Tags

aegisoraaegisora-ecosysteminstanceofinstanceof-rulephprule-based-instanceof-predicate-checkphpinstanceofaegisoraaegisora-ecosysteminstanceof-validationinstanceof-rule

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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