jan-wennrich/logic-gates
最新稳定版本:1.0.0
Composer 安装命令:
composer require jan-wennrich/logic-gates
包简介
Library to simulate circuits using gates like AND, OR, XOR.
README 文档
README
A tiny PHP library for building and simulating digital circuits from simple logic gates (e.g., AND, OR, NOT, XOR) and composing them into larger combinational networks.
✨ Features
- All common boolean gates:
AND&NANDOR&NORXOR&XNORNOT&BUFFERIMPLY&NIMPLYTRUE&FALSE
- Compose gates into circuits by wiring outputs to inputs
- Zero dependencies
- Unit tested
📦 Installation
This project is a standard Composer library.
composer require jan-wennrich/logic-gates
🚀 Example
The example shows how the AND gate works:
<?php require __DIR__ . '/vendor/autoload.php'; use JanW\LogicGates\AndGate; use JanW\LogicGates\BinaryFalseGate; use JanW\LogicGates\BinaryTrueGate; $falseInput = new BinaryFalseGate(); $trueInput = new BinaryTrueGate(); (new AndGate($falseInput, $falseInput))->getOutput()); // returns "false" (new AndGate($falseInput, $trueInput))->getOutput()); // returns "false" (new AndGate($trueInput, $falseInput))->getOutput()); // returns "false" (new AndGate($trueInput, $trueInput))->getOutput()); // returns "true"
🧪 Testing
This library is thoroughly tested in multiple ways:
- Unit tests via
PHPUnit - Static analysis via
PHPStan PSR-12code style viaPHP_CodeSniffer- Dependency validity via
Composer Dependency Analyser composer.jsonschema viacomposer validate
The tests can be executed after cloning this repository and installing all dev-dependencies:
git clone git@github.com:JanWennrich/Logic-Gates.git composer install
All tests can be run via the Composer test script:
composer test
Specific tests can be run via their corresponding binaries in vendor/bin/.
To run PHPUnit for example use this command:
vendor/bin/phpunit
📄 License
GPL-3.0 - see LICENSE
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-10-04