PHPackages                             fivepercent/enabled-checker - 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. fivepercent/enabled-checker

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

fivepercent/enabled-checker
===========================

Check objects of enabled

v1.0(10y ago)1201MITPHPPHP &gt;=5.4

Since Jun 4Pushed 10y ago6 watchersCompare

[ Source](https://github.com/InnoGr/FivePercent-EnabledChecker)[ Packagist](https://packagist.org/packages/fivepercent/enabled-checker)[ RSS](/packages/fivepercent-enabled-checker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Enabled checker
===============

[](#enabled-checker)

This package provides functionality of checking whether object is enabled or disabled.

For example: when you're trying to perform order for a product and you want to make sure that it's possible (object is able to be ordered). In addition, you can check if category that contains this product could be checked or any other objects that the product depends on).

Installation
------------

[](#installation)

Add **FivePercent/EnabledChecker** in your composer.json:

```
{
    "require": {
        "fivepercent/enabled-checker": "~1.0"
    }
}
```

Now tell composer to download the library by running command below:

```
$ php composer.phar update fivepercent/enabled-checker
```

Basic usage
-----------

[](#basic-usage)

Before using **EnabledChecker**, it's needed to create and configure instance of checker.

**Note:** If it's needed to use many checkers, you should use **ChainChecker**

```
use FivePercent\Component\EnabledChecker\Checker\ChainChecker;
use FivePercent\Component\EnabledChecker\EnabledChecker;

$chainChecker = new ChainChecker();
$enabledChecker = new EnabledChecker($chainChecker);
```

When EnabledChecker is created, you can add checkers to **ChainChecker**.

For example, we have a product and category of this product, with following structure:

```
class Category
{
    public $enabled;
}

class Product
{
    /** @var Category */
    public $category;
    public $enabled;
}
```

And we want to create a custom checker to check if product is enabled:

```
use FivePercent\Component\EnabledChecker\Checker\CheckerInterface;

class ProductEnabledChecker implements CheckerInterface
{
    public function isSupported($object)
    {
        return $object instanceof Product;
    }

    public function check($object)
    {
        /** @var Product $object */
        if ($object->category && !$object->category->enabled) {
            // Category is not enabled
            return false;
        }

        if (!$object->enabled) {
            // Product is not enabled
            return false;
        }

        return true;
    }
}
```

And add this checker instance to **ChainChecker**:

```
$chainChecker->addChecker(new ProductEnabledChecker());
```

After this operation, we can check whether product is enabled or not ;)

**Attention:** method `check` throws exception `FivePercent\Component\EnabledChecker\Exception\NotEnabledException`, if checker returns false.

1. **Product is disabled**

    > ```
    > $product = new Product();
    > $product->enabled = false;
    >
    > $checker->check($product); // Throws exception
    > ```
2. **Product is enabled**

    > ```
    > $product = new Product();
    > $product->enabled = true;
    >
    > $enabledChecker->check($product); // OK
    > ```
3. **Category of product are disabled**

    > ```
    > $product = new Product();
    > $product->enabled = true;
    > $product->category = new Category();
    > $product->category->enabled = false;
    >
    > $enabledChecker->check($product); // Throws exception
    > ```
4. **Category and product are enabled**

    > ```
    > $product = new Product();
    > $product->enabled = true;
    > $product->category = new Category();
    > $product->category->enabled = true;
    >
    > $enabledChecker->check($product); // All OK
    > ```

**Note:** If you want to throw custom exception, you can implement interface `FivePercent\Component\EnabledChecker\ExceptionAwareInterface`.

```
use FivePercent\Component\EnabledChecker\ExceptionAwareInterface;

class Product implements ExceptionAwareInterface
{
    /** @var Category */
    public $category;
    public $enabled;

    public function getExceptionForNotEnabled()
    {
        if ($this->category && !$this->category->enabled) {
            return new \RuntimeException('Category disabled!');
        }

        if (!$this->enabled) {
            return new \RuntimeException('Project disabled.');
        }

        return null;
    }
}
```

**Note:** In simple objects, you can implement `FivePercent\Component\EnabledChecker\EnabledIndicateInterface`, that doesn't require checker creation

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

4002d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16cc6c4d32a2c7f1cd584f31db9428341ad57682521f0f6e607cfe19f1f9157d?d=identicon)[inno-group](/maintainers/inno-group)

---

Top Contributors

[![ZhukV](https://avatars.githubusercontent.com/u/2256109?v=4)](https://github.com/ZhukV "ZhukV (2 commits)")

---

Tags

objectenabledobject enabled

### Embed Badge

![Health badge](/badges/fivepercent-enabled-checker/health.svg)

```
[![Health](https://phpackages.com/badges/fivepercent-enabled-checker/health.svg)](https://phpackages.com/packages/fivepercent-enabled-checker)
```

###  Alternatives

[myclabs/deep-copy

Create deep copies (clones) of your objects

8.9k849.8M169](/packages/myclabs-deep-copy)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

16293.9k6](/packages/yzendev-plain-to-class)[jasny/dotkey

Dot notation access for objects and arrays

14219.5k6](/packages/jasny-dotkey)[peridot-php/object-path

A string syntax to fetch values from array and object hierarchies

1053.6k1](/packages/peridot-php-object-path)

PHPackages © 2026

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