maxvoronov / brackets-checker
Simple library for brackets checking in strings
1.0.0
2018-01-15 03:06 UTC
Requires
- php: ^7.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.2
This package is not auto-updated.
Last update: 2024-11-10 05:40:30 UTC
README
Install
The preferred way to install this extension is through composer:
composer require maxvoronov/brackets-checker
Usage
This package based on pure PHP. Library can check the correctness of the brackets sentence.
use MaxVoronov\BracketsChecker\Checker; $bracketsChecker = new Checker(); $bracketsChecker->check("(( ))( )"); // Returns true $bracketsChecker->check("() )"); // Returns false
Also you can check custom brackets pairs and available filtering symbols:
$brackets = ["(" => ")", "[" => "]", "<" => ">"]; $availableChars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", " "]; $bracketsChecker = new Checker($brackets, $availableChars); $bracketsChecker->check("([2 + 3] * <10> / (9 - 4)))"); // Returns true
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.