A truth table is a mathematical table used in logic which sets out the functional values of logical expressions on each of their functional arguments. Wikipedia.
Via composer:
$ composer require programarivm/truth-table
Create a binary table with two input variables:
use TruthTable\BinaryTable;
$t = (new BinaryTable(2))->getTable();
Get the result of the table:
use TruthTable\BinaryTable;
$r = (new BinaryTable(2))->getResult();
Set specific indexes to true
and get the result:
use TruthTable\BinaryTable;
$true = [0, 1];
$r = (new BinaryTable(2))
->setTrue($true)
->getResult();
Set specific indexes to false
and get the result:
use TruthTable\BinaryTable;
$false = [0, 1];
$r = (new BinaryTable(2))
->setFalse($false)
->getResult();
Create a ternary table with two input variables:
use TruthTable\TernaryTable;
$t = (new TernaryTable(2))->getTable();
Get the result of the table:
use TruthTable\TernaryTable;
$r = (new TernaryTable(2))->getResult();
Set specific indexes to true
and get the result:
use TruthTable\TernaryTable;
$true = [0, 1];
$r = (new TernaryTable(2))
->setTrue($true)
->getResult();
Set specific indexes to false
and get the result:
use TruthTable\TernaryTable;
$false = [0, 1];
$r = (new TernaryTable(2))
->setFalse($false)
->getResult();
Set specific indexes to unknown and get the result:
use TruthTable\TernaryTable;
$unknown = [0, 1];
$r = (new TernaryTable(2))
->setUnknown($unknown)
->getResult();
For further details please look at the unit tests.
The GNU General Public License.