Skip to content

Commit 9e796c9

Browse files
authored
docs(claude): Add CLAUDE guidance file (#55)
- Add CLAUDE.md describing project overview, development commands, testing architecture, CI/CD, and guidelines for Claude Code to interact with this repository - Update .gitignore to ignore .claude artifacts generated by Claude
1 parent ddda753 commit 9e796c9

23 files changed

+181
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ build
1515
vendor
1616
composer.lock
1717
*.cache
18+
.claude

CLAUDE.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
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.
8+
9+
### Key Architecture
10+
11+
- **Namespace**: All classes are under `JBZoo\Utils` namespace
12+
- **PSR-4 Autoloading**: Source code in `src/` directory follows PSR-4 standard
13+
- **Static Method Classes**: Each utility class (Arr, Str, FS, etc.) provides static methods for specific functionality
14+
- **Function Aliases**: The `src/aliases.php` file provides convenient function aliases for common operations
15+
- **Constants**: Global constants defined in `src/defines.php`
16+
17+
### Core Utility Classes
18+
19+
The library includes 24 main utility classes:
20+
- **Arr**: Array manipulation and operations
21+
- **Str**: String processing and manipulation
22+
- **FS**: File system operations
23+
- **Filter**: Data filtering and sanitization
24+
- **Dates**: Date/time operations
25+
- **Email**: Email validation and processing
26+
- **Env**: Environment variable handling
27+
- **Http**: HTTP header operations
28+
- **Image**: Image processing utilities
29+
- **Url**: URL manipulation
30+
- **Xml**: XML processing
31+
- **Cli**: Command-line interface utilities
32+
- Plus 12 additional specialized classes (Csv, IP, Ser, Slug, Stats, Sys, Timer, Vars, PhpDocs, etc.)
33+
34+
## Development Commands
35+
36+
### Core Development Tasks
37+
```bash
38+
# Install/update dependencies
39+
make update
40+
41+
# Run all tests
42+
make test
43+
44+
# Run code style checks
45+
make codestyle
46+
47+
# Run all project tests and quality checks
48+
make test-all
49+
```
50+
51+
### Testing
52+
```bash
53+
# Run PHPUnit tests
54+
vendor/bin/phpunit
55+
56+
# Run PHPUnit with specific configuration
57+
vendor/bin/phpunit --configuration phpunit.xml.dist
58+
59+
# Run tests for specific file
60+
vendor/bin/phpunit tests/ArrayTest.php
61+
```
62+
63+
### Code Quality
64+
The project uses JBZoo Toolbox codestyle standards via Makefile targets:
65+
- `make codestyle` - runs all code quality checks
66+
- Code style configuration comes from `vendor/jbzoo/codestyle/src/init.Makefile`
67+
68+
### Build System
69+
- **Makefile**: Main build configuration with standard targets
70+
- **Dependencies**: Uses `jbzoo/toolbox-dev` for development dependencies
71+
- **PHP Version**: Requires PHP 8.2+ (as of current version)
72+
73+
## Testing Architecture
74+
75+
### Test Structure
76+
- **Location**: All tests in `tests/` directory
77+
- **Naming**: Test files follow `*Test.php` pattern
78+
- **Bootstrap**: Tests use `tests/autoload.php` for initialization
79+
- **Coverage**: Configured for full source code coverage analysis
80+
81+
### Test Organization
82+
- Each utility class has a corresponding test file (e.g., `Arr.php``ArrayTest.php`)
83+
- Tests use PHPUnit framework with comprehensive coverage reporting
84+
- Test isolation and cleanup handled via `revertServerVar()` function
85+
86+
### CI/CD Pipeline
87+
- **GitHub Actions**: `.github/workflows/main.yml`
88+
- **PHP Versions**: Tests run on PHP 8.2, 8.3, 8.4
89+
- **Matrix Testing**: Tests with different composer flags (`--prefer-lowest`)
90+
- **Coverage**: Uses Xdebug for coverage reporting
91+
- **Quality Gates**: Separate jobs for PHPUnit tests, linters, and reports
92+
93+
## File Structure Patterns
94+
95+
### Source Code Organization
96+
```
97+
src/
98+
├── aliases.php # Function aliases for common operations
99+
├── defines.php # Global constants
100+
├── Exception.php # Base exception class
101+
└── [UtilityClass].php # Individual utility classes (Arr, Str, FS, etc.)
102+
```
103+
104+
### Development Standards
105+
- **PHP 8.2+**: Uses modern PHP features including typed properties and strict types
106+
- **PSR Standards**: Follows PSR-4 autoloading and coding standards
107+
- **Static Methods**: All utility functions implemented as static class methods
108+
- **Immutable Operations**: Most operations return new values rather than modifying input
109+
110+
### Key Dependencies
111+
- **Production**: Minimal dependencies (only PHP 8.2+)
112+
- **Development**: `jbzoo/toolbox-dev` for testing and code quality tools
113+
- **Optional**: `symfony/process` for CLI operations, `jbzoo/data` for data handling
114+
115+
## Working with the Codebase
116+
117+
### Adding New Utilities
118+
1. Create new class in `src/` following existing patterns
119+
2. Add corresponding test file in `tests/`
120+
3. Update documentation if adding major functionality
121+
4. Follow existing code style and static method patterns
122+
123+
### Common Development Patterns
124+
- All utility classes follow similar structure with static methods
125+
- Input validation and type checking handled consistently
126+
- Error handling uses custom Exception class when needed
127+
- Comprehensive test coverage expected for all new functionality

src/Arr.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/**
2020
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
2121
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
22+
* @psalm-suppress UnusedClass
2223
*/
2324
final class Arr
2425
{

src/Cli.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Symfony\Component\Process\Exception\ProcessFailedException;
2020
use Symfony\Component\Process\Process;
2121

22+
/**
23+
* @psalm-suppress UnusedClass
24+
*/
2225
final class Cli
2326
{
2427
public const STDIN = 0;

src/Csv.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616

1717
namespace JBZoo\Utils;
1818

19+
/**
20+
* @psalm-suppress UnusedClass
21+
*/
1922
final class Csv
2023
{
2124
public const LENGTH_LIMIT = 10000000;
2225

2326
/**
2427
* Simple parser for CSV files.
28+
* @psalm-suppress PossiblyNullIterator
29+
* @psalm-suppress PossiblyNullArrayAccess
2530
*/
2631
public static function parse(
2732
string $csvFile,

src/Dates.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
namespace JBZoo\Utils;
1818

19+
/**
20+
* @psalm-suppress UnusedClass
21+
*/
1922
final class Dates
2023
{
2124
public const MINUTE = 60;

src/Email.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
namespace JBZoo\Utils;
1818

19+
/**
20+
* @psalm-suppress UnusedClass
21+
*/
1922
final class Email
2023
{
2124
/**

src/Env.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
namespace JBZoo\Utils;
1818

19+
/**
20+
* @psalm-suppress UnusedClass
21+
*/
1922
final class Env
2023
{
2124
public const VAR_NULL = 1;

src/FS.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
2121
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2222
* @SuppressWarnings(PHPMD.ShortClassName)
23+
* @psalm-suppress UnusedClass
2324
*/
2425
final class FS
2526
{

src/Filter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
/**
2323
* @SuppressWarnings(PHPMD.TooManyMethods)
2424
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
25+
* @psalm-suppress UnusedClass
2526
*/
2627
final class Filter
2728
{

0 commit comments

Comments
 (0)