PHPackages                             talhag3/string-analyzer - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. talhag3/string-analyzer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

talhag3/string-analyzer
=======================

A simple PHP package that analyzes string composition

v1.0.1(1mo ago)01MITPHPPHP ^8.2CI passing

Since May 28Pushed 1mo agoCompare

[ Source](https://github.com/talhag3/string-analyzer)[ Packagist](https://packagist.org/packages/talhag3/string-analyzer)[ RSS](/packages/talhag3-string-analyzer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

[![CI](https://github.com/talhag3/string-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/talhag3/string-analyzer/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/336c435ba6f85420319b4c022c72f5595b69491948744dc7855e3125526daa81/68747470733a2f2f706f7365722e707567782e6f72672f74616c686167332f737472696e672d616e616c797a65722f762f737461626c65)](https://packagist.org/packages/talhag3/string-analyzer)[![Total Downloads](https://camo.githubusercontent.com/3ac678a8cb3fb2a37ee8345cce9b14c1713a5b21c6c209770a914d7e022cc49d/68747470733a2f2f706f7365722e707567782e6f72672f74616c686167332f737472696e672d616e616c797a65722f646f776e6c6f616473)](https://packagist.org/packages/talhag3/string-analyzer)

📝 String Analyzer
=================

[](#-string-analyzer)

A minimal PHP library that analyzes a given string and returns counts for characters, words, spaces, and special characters.

Built as a **hands-on learning project** to master modern PHP development workflows: Docker, PHPUnit, Xdebug, GitHub Actions, and CI/CD.

---

🚀 Quick Start
-------------

[](#-quick-start)

```
# 1. Clone the repository
git clone
cd string-analyzer

# 2. Build the Docker environment
make build

# 3. Run tests
make test
```

---

📦 Features
----------

[](#-features)

- ✅ Single, pure method: `analyze(string $text): array`
- ✅ UTF-8 safe (`mb_*` &amp; `preg_*` functions)
- ✅ PHPUnit test suite with assertions
- ✅ Xdebug integration for step-debugging &amp; code coverage
- ✅ Fully containerized with Docker &amp; Docker Compose
- ✅ Automated CI via GitHub Actions

---

🛠️ Prerequisites
----------------

[](#️-prerequisites)

- [Docker](https://www.docker.com/products/docker-desktop/) &amp; Docker Compose
- `make` (pre-installed on macOS/Linux; Windows users can run `docker compose` commands directly)
- [VS Code](https://code.visualstudio.com/) + [PHP Debug Extension](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) *(for debugging)*

---

🧪 Testing &amp; Coverage
------------------------

[](#-testing--coverage)

CommandDescription`make test`Run PHPUnit tests in an isolated container`make test-coverage`Generate HTML coverage report in `coverage/``make shell`Drop into an interactive container shell> 💡 Code coverage requires Xdebug. Run `make test-coverage` and open `coverage/index.html` in your browser.

---

🐛 Debugging with VS Code
------------------------

[](#-debugging-with-vs-code)

1. Install the **PHP Debug** extension by `felixfbecker`
2. Open the Debug panel (`Ctrl+Shift+D`), select **Docker: Listen for Xdebug**, and click ▶️
3. Set a breakpoint in `src/StringAnalyzer.php`
4. Run `make test` in the terminal
5. VS Code will pause at your breakpoint. Step, inspect variables, and continue.

*Configuration is pre-loaded in `.vscode/launch.json` and `Dockerfile`.*

---

🐳 Docker Explained (Learning Focus)
-----------------------------------

[](#-docker-explained-learning-focus)

This project uses Docker to guarantee a **consistent, reproducible environment** across machines and CI.

- `Dockerfile` → Bakes PHP 8.2 + extensions (Xdebug, intl, mbstring, Composer) into an image
- `docker-compose.yml` → Orchestrates the container, mounts your code live (`volumes`), and configures Xdebug routing
- `make` commands → Wrap long `docker compose run ...` calls for convenience

> 🔑 **Key Concept:** Code changes sync instantly via `volumes`. You only rebuild (`make build`) when modifying the `Dockerfile` or PHP extensions.

---

🔄 GitHub Actions CI
-------------------

[](#-github-actions-ci)

Pushing to `main` or opening a PR automatically triggers:

- ✅ PHP 8.2 setup with Xdebug
- ✅ Dependency installation
- ✅ PHPUnit execution with coverage
- ✅ Coverage artifact upload

Workflow file: `.github/workflows/ci.yml`

---

📁 Project Structure
-------------------

[](#-project-structure)

```
string-analyzer/
├── src/
│   └── StringAnalyzer.php      # Core logic
├── tests/
│   └── StringAnalyzerTest.php  # PHPUnit tests
├── .github/workflows/ci.yml    # GitHub Actions CI
├── .vscode/launch.json         # VS Code debug config
├── Dockerfile                  # PHP environment + Xdebug
├── docker-compose.yml          # Container orchestration
├── Makefile                    # Developer shortcuts
├── composer.json               # Dependencies & autoloading
└── phpunit.xml                 # Test configuration

```

---

📚 Learning Objectives
---------------------

[](#-learning-objectives)

This project demonstrates:

- How Composer autoloading &amp; `composer.json` work
- Writing &amp; running PHPUnit tests
- Configuring Xdebug for CLI debugging &amp; coverage
- Containerizing PHP apps without local dependency conflicts
- Automating tests with GitHub Actions
- Using `volumes` vs `COPY` in Docker (dev vs prod)

---

📄 License
---------

[](#-license)

MIT License. Free to use, modify, and learn from.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance89

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

57d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16940319?v=4)[MUHAMMAD TALHA](/maintainers/talhag3)[@talhag3](https://github.com/talhag3)

---

Top Contributors

[![talhag3](https://avatars.githubusercontent.com/u/16940319?v=4)](https://github.com/talhag3 "talhag3 (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/talhag3-string-analyzer/health.svg)

```
[![Health](https://phpackages.com/badges/talhag3-string-analyzer/health.svg)](https://phpackages.com/packages/talhag3-string-analyzer)
```

###  Alternatives

[ramsey/conventional-commits

A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook action!

1931.6M156](/packages/ramsey-conventional-commits)[balping/ticketit-app

Ticketit, the simple helpdesk tickets system pre-installed in Laravel

136.6k](/packages/balping-ticketit-app)

PHPackages © 2026

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