phptailors / logic
First-order logic
dev-master
2024-06-07 01:12 UTC
Requires
- php: ^8.3
- ext-pcre: *
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- phptailors/phpunit-inheritance: ^3
- phpunit/phpunit: ^11.1.1
- psalm/plugin-phpunit: ^0.19.0
- vimeo/psalm: ^6.x-dev
This package is auto-updated.
Last update: 2025-04-07 22:32:38 UTC
README
Logic
First-order logic implementation in PHP
Under development
The project is in initial phase. No releases yet!
Quick intro
This library lets you construct and evaluate logical expressions. You may find it useful when you need to impose constraints on user input or arguments/options passed to a program or API.
Example
<?php use Tailors\Logic\Logic; $l = new Logic(); $formula = $l->and($l->bool($l->var('a')), $l->bool($l->var('b'))); var_export($formula->expressionString()); echo "\n"; var_export($formula->evaluate(['a' => 1, 'b' => true])); echo "\n"; var_export($formula->evaluate(['a' => true, 'b' => 0])); echo "\n";
The result of above is
'bool(a) && bool(b)' true false