maxvoronov/brackets-checker

Simple library for brackets checking in strings

1.0.0 2018-01-15 03:06 UTC

This package is not auto-updated.

Last update: 2024-04-28 02:37:45 UTC


README

Latest Version Software License Build Status Codacy grade

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.