PHPackages                             reddias/is-balanced - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. reddias/is-balanced

ActiveLibrary

reddias/is-balanced
===================

This PHP package provides a utility function to check if a string of parentheses is balanced and includes an implementation of a stack data structure.

00PHP

Since Jul 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/reddias/isBalanced)[ Packagist](https://packagist.org/packages/reddias/is-balanced)[ RSS](/packages/reddias-is-balanced/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Library `isBalanced`
====================

[](#library-isbalanced)

A PHP library providing a stack data structure and a utility function to check if a string of parentheses is balanced.

---

Usage
-----

[](#usage)

### Stack Class

[](#stack-class)

#### Basic Example:

[](#basic-example)

```
$stack = new Stack();
$stack->push('element1');
$stack->push('element2');
$stack->push('element3');

echo $stack->pop(); // Outputs: element3
echo $stack->top(); // Outputs: element2
echo $stack->isEmpty() ? 'Empty' : 'Not Empty'; // Outputs: Not Empty
```

#### Methods:

[](#methods)

- `push($value)`: Adds an element to the top of the stack.
- `pop()`: Removes and returns the element at the top of the stack.
- `top()`: Returns the top element of the stack without any changes.
- `isEmpty()`: Checks if the stack is empty or not.

### isBalanced function

[](#isbalanced-function)

#### Basic Example:

[](#basic-example-1)

```
$result1 = isBalanced('(())');
var_dump($result1); // Outputs: bool(true)

$result2 = isBalanced('((())');
var_dump($result2); // Outputs: bool(false)
```

#### Function signature:

[](#function-signature)

```
function isBalanced(string $value): bool
```

Parameters:

- `string $value`: the string to check for balanced parentheses Returns:
- `bool`: Returns true if the string is balanced or empty, false otherwise (Note that only parentheses are excepted)

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ac7cdb0c190d3643badc11810decabc8b016cf439b2641f721c4c1336c05ac1?d=identicon)[pilover](/maintainers/pilover)

### Embed Badge

![Health badge](/badges/reddias-is-balanced/health.svg)

```
[![Health](https://phpackages.com/badges/reddias-is-balanced/health.svg)](https://phpackages.com/packages/reddias-is-balanced)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
