Skip to content

Commit 24c5651

Browse files
committed
Add AGENTS.md file
1 parent ecfbcb8 commit 24c5651

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to IA agents when working with code in this repository.
4+
5+
## Project Overview
6+
7+
wallet-kit is a PHP 8.3+ library that provides a fluent builder API for modeling Apple Wallet, Google Wallet, and Samsung Wallet JSON payloads. It focuses on payload normalization using Symfony Serializer — it does **not** handle signing, bundling (.pkpass), or API calls.
8+
9+
## Commands
10+
11+
```bash
12+
# Run tests (PHPUnit 12)
13+
vendor/bin/phpunit
14+
15+
# Run a single test
16+
vendor/bin/phpunit --filter=TestClassName
17+
vendor/bin/phpunit --filter=TestClassName::testMethodName
18+
19+
# Static analysis (PHPStan level 5)
20+
castor qa:phpstan
21+
22+
# Code style check / fix
23+
castor qa:cs:check
24+
castor qa:cs:fix
25+
26+
# API spec drift detection
27+
castor spec:check:google # Google Wallet discovery doc revision
28+
castor spec:check:apple # Apple pass.json phpstan shapes
29+
castor spec:check:samsung # Samsung model keyset
30+
castor spec:baseline:google # Refresh Google baseline
31+
castor spec:baseline:apple # Refresh Apple keyset
32+
castor spec:baseline:samsung # Refresh Samsung keyset
33+
```
34+
35+
CI runs 4 jobs: cs-check, spec-check, phpstan, and tests (PHP 8.3/8.4/8.5 matrix).
36+
37+
## Architecture
38+
39+
### Builder Pattern (entry point)
40+
41+
```
42+
WalletPass::{vertical}(WalletPlatformContext, ...args)
43+
→ ConcreteBuilder (extends AbstractWalletBuilder)
44+
→ .with*() / .add*() fluent methods (via CommonWalletBuilderTrait)
45+
→ .build() → BuiltWalletPass
46+
→ .apple() → Pass
47+
→ .google() → GoogleWalletPair (vertical + issuerClass + passObject)
48+
→ .samsung() → Card
49+
```
50+
51+
**7 verticals:** Generic, Offer, Loyalty, EventTicket, Flight, Transit, GiftCard — each has its own builder in `src/Builder/{Vertical}/`.
52+
53+
**WalletPlatformContext** is an immutable container built with `->withApple(...)`, `->withGoogle(...)`, `->withSamsung(...)`. Only configured platforms produce output; accessing unconfigured platforms throws typed exceptions.
54+
55+
### Namespace Layout
56+
57+
| Namespace | Purpose |
58+
|-----------|---------|
59+
| `Builder\` | WalletPass entry point, platform contexts, BuiltWalletPass |
60+
| `Builder\Internal\` | CommonWalletState, barcode mappers, helpers |
61+
| `Builder\{Vertical}\` | Vertical-specific builders |
62+
| `Pass\Apple\Model\` | Apple Pass models (Pass, PassStructure, Field, Barcode, enums) |
63+
| `Pass\Apple\Normalizer\` | Symfony Serializer normalizers for Apple |
64+
| `Pass\Android\Model\` | Google Wallet class/object models by vertical |
65+
| `Pass\Android\Normalizer\` | Google normalizers |
66+
| `Pass\Samsung\Model\` | Samsung Card envelope + 8 card type attributes |
67+
| `Pass\Samsung\Normalizer\` | Samsung normalizers |
68+
| `Common\` | Shared value objects (Color) |
69+
| `Exception\` | Typed exceptions implementing WalletKitException |
70+
71+
### Serialization
72+
73+
All JSON output is produced via Symfony Serializer normalizers (100+ normalizers total). Tests use `BuilderTestSerializerFactory` in `tests/Builder/` which wires up the full normalizer stack.
74+
75+
### Platform Differences
76+
77+
- **Apple Wallet:** Single `Pass` object → one `pass.json`
78+
- **Google Wallet:** Class + Object pairs per vertical (e.g., `EventTicketClass` + `EventTicketObject`), wrapped in `GoogleWalletPair`
79+
- **Samsung Wallet:** Unified `Card` envelope with type-specific attributes, 8 card types (7 cross-platform + DigitalId and PayAsYouGo are Samsung-only)
80+
81+
### Key Conventions
82+
83+
- PHPStan level 5 with extensive `@phpstan-type` shape annotations for validation
84+
- Enums used throughout (CardTypeEnum, PassTypeEnum, GoogleVerticalEnum, ReviewStatusEnum, etc.)
85+
- `mutateApple()` and `mutateSamsung()` callbacks allow post-build platform-specific customization
86+
- Color value object supports `rgb()`, `hex()`, and `googleColor()` output formats

0 commit comments

Comments
 (0)