This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
JBZoo/Utils is a PHP utility library providing a collection of functions, mini classes, and snippets for everyday PHP development. It contains 24 utility classes covering array manipulation, string operations, file system operations, date handling, email validation, image processing, and more.
- Namespace: All classes are under
JBZoo\Utilsnamespace - PSR-4 Autoloading: Source code in
src/directory follows PSR-4 standard - Static Method Classes: Each utility class (Arr, Str, FS, etc.) provides static methods for specific functionality
- Function Aliases: The
src/aliases.phpfile provides convenient function aliases for common operations - Constants: Global constants defined in
src/defines.php
The library includes 24 main utility classes:
- Arr: Array manipulation and operations
- Str: String processing and manipulation
- FS: File system operations
- Filter: Data filtering and sanitization
- Dates: Date/time operations
- Email: Email validation and processing
- Env: Environment variable handling
- Http: HTTP header operations
- Image: Image processing utilities
- Url: URL manipulation
- Xml: XML processing
- Cli: Command-line interface utilities
- Plus 12 additional specialized classes (Csv, IP, Ser, Slug, Stats, Sys, Timer, Vars, PhpDocs, etc.)
# Install/update dependencies
make update
# Run all tests
make test
# Run code style checks
make codestyle
# Run all project tests and quality checks
make test-all# Run PHPUnit tests
vendor/bin/phpunit
# Run PHPUnit with specific configuration
vendor/bin/phpunit --configuration phpunit.xml.dist
# Run tests for specific file
vendor/bin/phpunit tests/ArrayTest.phpThe project uses JBZoo Toolbox codestyle standards via Makefile targets:
make codestyle- runs all code quality checks- Code style configuration comes from
vendor/jbzoo/codestyle/src/init.Makefile
- Makefile: Main build configuration with standard targets
- Dependencies: Uses
jbzoo/toolbox-devfor development dependencies - PHP Version: Requires PHP 8.2+ (as of current version)
- Location: All tests in
tests/directory - Naming: Test files follow
*Test.phppattern - Bootstrap: Tests use
tests/autoload.phpfor initialization - Coverage: Configured for full source code coverage analysis
- Each utility class has a corresponding test file (e.g.,
Arr.php→ArrayTest.php) - Tests use PHPUnit framework with comprehensive coverage reporting
- Test isolation and cleanup handled via
revertServerVar()function
- GitHub Actions:
.github/workflows/main.yml - PHP Versions: Tests run on PHP 8.2, 8.3, 8.4
- Matrix Testing: Tests with different composer flags (
--prefer-lowest) - Coverage: Uses Xdebug for coverage reporting
- Quality Gates: Separate jobs for PHPUnit tests, linters, and reports
src/
├── aliases.php # Function aliases for common operations
├── defines.php # Global constants
├── Exception.php # Base exception class
└── [UtilityClass].php # Individual utility classes (Arr, Str, FS, etc.)
- PHP 8.2+: Uses modern PHP features including typed properties and strict types
- PSR Standards: Follows PSR-4 autoloading and coding standards
- Static Methods: All utility functions implemented as static class methods
- Immutable Operations: Most operations return new values rather than modifying input
- Production: Minimal dependencies (only PHP 8.2+)
- Development:
jbzoo/toolbox-devfor testing and code quality tools - Optional:
symfony/processfor CLI operations,jbzoo/datafor data handling
- Create new class in
src/following existing patterns - Add corresponding test file in
tests/ - Update documentation if adding major functionality
- Follow existing code style and static method patterns
- All utility classes follow similar structure with static methods
- Input validation and type checking handled consistently
- Error handling uses custom Exception class when needed
- Comprehensive test coverage expected for all new functionality