PHPackages                             mouf/utils.common.conditioninterface - 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. mouf/utils.common.conditioninterface

ActiveMouf-library[Utility &amp; Helpers](/categories/utility)

mouf/utils.common.conditioninterface
====================================

This package contains one interface for condition, and a few classes that implement it. For instance, AndCondition that requires all conditions to be met, and OrCondition that requires at least one condition to be met. A condition is a class that possesses an 'isOk' method. The condition returns true if the condition is met, and false otherwise.

v2.0.2(6y ago)3532.8k↓22.2%9MITPHPPHP &gt;=5.3.0

Since Oct 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/thecodingmachine/utils.common.conditioninterface)[ Packagist](https://packagist.org/packages/mouf/utils.common.conditioninterface)[ Docs](https://github.com/thecodingmachine/utils.common.conditioninterface)[ RSS](/packages/mouf-utilscommonconditioninterface/feed)WikiDiscussions 2.0 Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (9)

What is this package?
=====================

[](#what-is-this-package)

This package contains an interface used by test conditions. Basically, instances of classes implementing this interface can be tested and the instance will return "true" or "false".

The concept is very abstract, but also very powerful. Let's take a sample:

- you might write a "LoggedCondition" class that implements a condition that returns true if the current user is logged, false otherwise.
- you might write a "HasRightCondition" class that implements a condition that returns true if the current user has some set of rights, false otherwise.
- you might write a "TimeCondition" class that implements a condition that returns true only at some time of the day.
- ...

Obviously, this package is useless on its own. It is useful only if you implement the interface in your classes.

But what is it useful for?
--------------------------

[](#but-what-is-it-useful-for)

It gets very useful if some components of your code are just expecting a condition. For instance, let's assume you are developing a menu system. A particular menu item should only be displayed when a user is logged.

If a menu item is represented by an instance of the MenuItem class, there are several way you can tackle this problem. Using OO design, you could extend the MenuItem class to add special behaviour regarding the "must be logged" requirement. But using the ConditionInterface, it gets more powerful. If each MenuItem contains a ConditionInterface, you only need to add a "LoggedCondition" instance to your menu item, and you are done! It gets really interesting when you are using a dependency injection framework like Mouf.

In practice
-----------

[](#in-practice)

Implementing the condition interface is simple stupid: just add a "isOk" method to your code:

```
/**
 * Returns true if the condition is met, false otherwise.
 *
 * @param mixed $caller The condition caller. Optional.
 * @return bool
 */
function isOk($caller = null);

```

Provided classes
----------------

[](#provided-classes)

This package comes with a few utility classes:

- `TrueCondition`: always returns true
- `FalseCondition`: always returns false
- `AndCondition`: performs a logical AND between child conditions
- `OrCondition`: performs a logical OR between child conditions
- `NotCondition`: performs a logical NOT on a condition
- `BoolToCondition`: wraps boolean into condition interface (useful to set it dynamically)

Mouf package
------------

[](#mouf-package)

This package is part of Mouf (), an effort to ensure good developing practices by providing a graphical dependency injection framework.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~709 days

Total

4

Last Release

2454d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (11 commits)")

---

Tags

interfacecondition

### Embed Badge

![Health badge](/badges/mouf-utilscommonconditioninterface/health.svg)

```
[![Health](https://phpackages.com/badges/mouf-utilscommonconditioninterface/health.svg)](https://phpackages.com/packages/mouf-utilscommonconditioninterface)
```

###  Alternatives

[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89152.7M321](/packages/nette-robot-loader)[samrap/acf-fluent

A fluent interface for the Advanced Custom Fields WordPress plugin

28656.0k4](/packages/samrap-acf-fluent)

PHPackages © 2026

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