Brackets
A small project for working with brackets., (*1)
Installation
Run the following command from you terminal:, (*2)
bash
composer require "koind/brackets: ^1.0"
, (*3)
or add this to require section in your composer.json file:, (*4)
"koind/brackets": "^1.0"
, (*5)
then run composer update
, (*6)
Usage
The library accepts a string of the form:, (*7)
(()()()()))((((()()()))(()()()(((()))))))
, (*8)
And return true
if the string is correct - all open parentheses are correctly opened and closed, or false
otherwise., (*9)
<?php
require __DIR__ . '/vendor/autoload.php';
$bracket = new \Koind\Brackets();
$result = $bracket->checkString('(()()()()()()(((()()()()()()((()((((()))))))()()))))');
var_dump($result);
Allowable characters
" , (), \t, \r, \n"
Attention! All other characters are not allowed., (*10)
If you try to send an invalid character, an exception of the type will be thrown: InvalidArgumentException
, (*11)
Tests
Run the following command from you terminal:, (*12)
phpunit