Download the PHP package rodrigomanara/alpha without Composer
On this page you can find all versions of the php package rodrigomanara/alpha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rodrigomanara/alpha
More information about rodrigomanara/alpha
Files in rodrigomanara/alpha
Package alpha
Short Description Class to count and manipulate alpha characters.
License MIT
Informations about the package alpha
Alpha - PHP String Character Analysis Library
A lightweight PHP library for analyzing and categorizing character types within strings. Easily count vowels, consonants, digits, special characters, and more.
Features
- ๐ Character Counting - Count vowels, consonants, numbers, and special characters
- ๐ค Case Analysis - Separate uppercase and lowercase letter counting
- ๐ Word Statistics - Calculate average word length in text
- ๐ฏ Result Storage - Automated collection and retrieval of analysis results
- ๐ Zero Dependencies - No external dependencies required
- โ PSR-4 Compliant - Follows PSR-4 autoloading standards
- ๐งช Fully Tested - Comprehensive PHPUnit test suite included
Installation
Install via Composer (recommended):
Or add to your composer.json:
Then run:
Requirements
- PHP 7.1 or higher
- Composer
Quick Start
Usage Examples
Basic Character Counting
Case Analysis
Special Characters
Word Statistics
Working with Results
Complete Analysis Workflow
API Reference
Character Analysis Methods
checkVowels(string $string): int
Counts lowercase vowels (a, e, i, o, u) in the given string.
- Parameter:
$string- The input string to analyze - Returns: Integer count of vowels found
checkConsonates(string $string): int
Counts lowercase consonants (non-vowel letters) in the given string.
- Parameter:
$string- The input string to analyze - Returns: Integer count of consonants found
checkNumber(string $str): int
Counts numeric digits (0-9) in the given string.
- Parameter:
$str- The input string to analyze - Returns: Integer count of digits found
upper(string $string): int
Counts uppercase letters (A-Z) in the given string.
- Parameter:
$string- The input string to analyze - Returns: Integer count of uppercase letters found
lower(string $string): int
Counts lowercase letters (a-z) in the given string.
- Parameter:
$string- The input string to analyze - Returns: Integer count of lowercase letters found
noalpha(string $string): int
Counts non-alphanumeric characters (special characters, spaces, punctuation) in the given string.
- Parameter:
$string- The input string to analyze - Returns: Integer count of special characters found
calculateWordLetterAverage(string $string): int
Calculates the average number of characters per word in the given string.
- Parameter:
$string- The input string containing words - Returns: Integer average (rounded up) using
ceil()
Result Management Methods
set(string $key, string $value): void
Stores or accumulates character findings by type.
- Parameter:
$key- The character type identifier - Parameter:
$value- The character to store
get(string $key): array
Retrieves stored characters of a specific type.
- Parameter:
$key- The character type identifier - Returns: Array of characters, or empty array if not found
getAll(): array
Retrieves all collected character results.
- Returns: Associative array of all character collections
Testing
This library includes a comprehensive test suite with 30+ tests covering all functionality.
Running Tests
First, install development dependencies:
Run all tests:
Run tests with coverage report:
View test documentation:
Important Notes
Character Case Sensitivity
The library only counts lowercase vowels and consonants (a-z, not A-Z). Use the upper() and lower() methods separately for case analysis.
Examples
Method Naming
Note: The method is named checkConsonates (not "checkConsonants") for historical reasons, but functions identically to a consonant counter.
Performance
- Lightweight: Zero external dependencies
- Efficient: Uses native PHP functions for character analysis
- Memory: Minimal memory footprint, suitable for batch processing
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Rodrigo Manara
- Email: [email protected]
- GitHub: rodrigomanara
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure:
- All tests pass (
composer test) - Code follows PSR-12 standards
- New features include test coverage
- Documentation is updated accordingly
Changelog
Version 1.1.3
- Current stable release
- Full test suite included
- Comprehensive documentation
Support
For issues, feature requests, or questions:
- Open an issue on GitHub
- Check existing issues for solutions
- Review the TESTING.md and AGENTS.md files for development guidance
Roadmap
- [ ] Performance optimizations for large texts
- [ ] Unicode character support
- [ ] Multi-language vowel detection
- [ ] Additional character classification methods
Ready to use! Install via Composer and start analyzing strings today.