PHPackages                             a1812/logic-interpreter - 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. a1812/logic-interpreter

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

a1812/logic-interpreter
=======================

Logic operations

v1.0.1(5y ago)022MITPHPPHP &gt;=8.0

Since Feb 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/a1812/logic-interpreter)[ Packagist](https://packagist.org/packages/a1812/logic-interpreter)[ RSS](/packages/a1812-logic-interpreter/feed)WikiDiscussions main Synced 6d ago

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

logic-interpreter
=================

[](#logic-interpreter)

Install
-------

[](#install)

```
$ composer require a1812/logic-interpreter
```

Usage
-----

[](#usage)

```
namespace App;

use A1812\LogicInterpreter\AndExp;
use A1812\LogicInterpreter\Context;
use A1812\LogicInterpreter\ImplicationExp;
use A1812\LogicInterpreter\NotExp;
use A1812\LogicInterpreter\VariableExp;
use A1812\LogicInterpreter\Visitor\SignVisitor;
use A1812\LogicInterpreter\Visitor\StringVisitor;

require 'vendor/autoload.php';

$context = new Context();

$a = new VariableExp('A');
$b = new VariableExp('B');

/*
 * NOT((A → B) AND (B → A))
 *
 * from https://logic-proof.symfony.site/186
 *
 * Case A  B  ~ ((A → B) ∧ (B → A))
 * 1    T  T  F
 * 2    T  F  T
 * 3    F  T  T
 * 4    F  F  F
 */

$exp = new NotExp(
    new AndExp(
        new ImplicationExp($a, $b),
        new ImplicationExp($b, $a)
    )
);

$context
    ->assign($a, true)
    ->assign($b, false)
;

// output: "(NOT ((A IMPLICATION B) AND (B IMPLICATION A)))"
echo $exp->accept(new StringVisitor());

// output: " = true"
echo ' = ' . $exp->interpret($context) ? 'true' : 'false' . PHP_EOL;

$context
    ->assign($a, true)
    ->assign($b, true)
;

// output: "(NOT ((A IMPLICATION B) AND (B IMPLICATION A)))"
echo $exp->accept(new StringVisitor());

// output: " = false"
echo ' = ' . $exp->interpret($context) ? 'true' : 'false' . PHP_EOL;

// output: (~ ((A → B) ∧ (B → A)) - false
echo $exp->accept(new SignVisitor()) . ' = ' . ($exp->interpret($context) ? 'true' : 'false') . PHP_EOL;
```

test
----

[](#test)

```
$ php ./vendor/bin/phpunit --testdox
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~58 days

Total

2

Last Release

1860d ago

PHP version history (2 changes)v1.0.0PHP ^7.4.0

v1.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f606b139da512f6836cafc99f39574f9784350422347bd52721ca0f7d2005f0?d=identicon)[a1812](/maintainers/a1812)

---

Top Contributors

[![a1812](https://avatars.githubusercontent.com/u/42714329?v=4)](https://github.com/a1812 "a1812 (24 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/a1812-logic-interpreter/health.svg)

```
[![Health](https://phpackages.com/badges/a1812-logic-interpreter/health.svg)](https://phpackages.com/packages/a1812-logic-interpreter)
```

###  Alternatives

[kern046/changelog-parser

PHP library used to parse a CHANGELOG.md file and return JSON output

106.3k1](/packages/kern046-changelog-parser)

PHPackages © 2026

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