PHPackages                             lukaszmakuch/lmcondition - 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. lukaszmakuch/lmcondition

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

lukaszmakuch/lmcondition
========================

Condition library

v0.0.2(10y ago)019MIT

Since Aug 22Compare

[ Source](https://github.com/lukaszmakuch/lmcondition)[ Packagist](https://packagist.org/packages/lukaszmakuch/lmcondition)[ RSS](/packages/lukaszmakuch-lmcondition/feed)WikiDiscussions Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

PHP Condition library
=====================

[](#php-condition-library)

This library allows to build complex conditions connected with AND/OR statements with subconditions support and then check them in some context.

[![travis](https://camo.githubusercontent.com/02b294df7bf9b52c7f6521a61a2398910c57bb72ab98b03ed1f1ffa7d2be14f7/68747470733a2f2f7472617669732d63692e6f72672f6c756b61737a6d616b7563682f6c6d636f6e646974696f6e2e737667)](https://travis-ci.org/lukaszmakuch/lmcondition)

Usage
-----

[](#usage)

### Getting objects

[](#getting-objects)

#### Building conditions

[](#building-conditions)

Let's say we want to match books that are hard to read or those ones with titles longer than 50 characters:

```
$wiseBookCondition = (new ConditionComposite())
    ->addOR(new Difficulty(Difficulty::HARD))
    ->addOR(new TitleOfMoreCharsThan(50));
```

Or easy books with short titles for children:

```
$booksForChildrenCondition = (new ConditionComposite())
    ->addAND(new Difficulty(Difficulty::EASY))
    ->addAND((new TitleOfMoreCharsThan(15))->negate());
```

Or those with really long titles:

```
$titleLogerThan99Condition = new TitleOfMoreCharsThan(99);
```

#### Building context

[](#building-context)

An easy to read book with a long title:

```
$easyBookWithLongTitle = (new Book())
    ->setTitle("A really long title of some book that must be wise.")
    ->markAsEasy();
```

A hard to read book with short title:

```
$hardBookWithShortTitle = (new Book())
    ->markAsHard()
    ->setTitle("How?");
```

An easy to read book with a short title:

```
$easyBookWithShortTitle = (new Book())
    ->markAsEasy()
    ->setTitle("Cats");
```

### Checking

[](#checking)

#### Is a condition true?

[](#is-a-condition-true)

Is this book wise?

```
$wiseBookCondition->isTrueIn($easyBookWithLongTitle); //true
$wiseBookCondition->isTrueIn($hardBookWithShortTitle); //true
$wiseBookCondition->isTrueIn($easyBookWithShortTitle); //false
```

Is it for children?

```
$booksForChildrenCondition->isTrueIn($easyBookWithLongTitle); //false
$booksForChildrenCondition->isTrueIn($hardBookWithShortTitle); //false
$booksForChildrenCondition->isTrueIn($easyBookWithShortTitle); //true
```

Is the title longer than 99 characters?

```
$titleLogerThan99Condition->isTrueIn($easyBookWithLongTitle); //false
$titleLogerThan99Condition->isTrueIn($hardBookWithShortTitle); //false
$titleLogerThan99Condition->isTrueIn($easyBookWithShortTitle);//false
```

#### Does intersection exist between two conditions?

[](#does-intersection-exist-between-two-conditions)

A title of a wise book may be longer than 99 characters.

```
/* @var $intersectDetector IntersectDetector */
$intersectDetector->intersectExists(
    $wiseBookCondition,
    $titleLogerThan99Condition
); //true
```

But books for children have no titles that long.

```
/* @var $intersectDetector IntersectDetector */
$intersectDetector->intersectExists(
    $booksForChildrenCondition,
    $titleLogerThan99Condition
); //false
```

#### Are two conditions equal?

[](#are-two-conditions-equal)

Two condition objects may be equal.

```
/* @var $comparator EqualityComparator */
$comparator->equal(
    $titleLogerThan99Condition,
    new TitleOfMoreCharsThan(99)
); //true
```

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

[](#installation)

Use [composer](https://getcomposer.org) to get the latest version:

```
$ composer require lukaszmakuch/lmcondition

```

Example
-------

[](#example)

The above code is taken from an example code located in ./examples. You can check there all files needed to provide this functionality.

Documentation
-------------

[](#documentation)

For more information check the best documentation - unit tests in ./tests. There's also documentation generated in ./doc.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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 ~0 days

Total

2

Last Release

3922d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e08a5c26bd9824a0345f417660e2d1146f044c886266daf2dd0901720fbcf32?d=identicon)[lukaszmakuch](/maintainers/lukaszmakuch)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lukaszmakuch-lmcondition/health.svg)

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

PHPackages © 2026

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