diff --git a/README.md b/README.md index 396b9da..f4ea506 100644 --- a/README.md +++ b/README.md @@ -6,37 +6,17 @@ [![Latest Stable Version](https://poser.pugx.org/lacatoire/acriss-code/v)](https://packagist.org/packages/lacatoire/acriss-code) [![License](https://poser.pugx.org/lacatoire/acriss-code/license)](LICENSE) ---- +A PHP library to **parse**, **validate**, and **translate** [ACRISS codes](https://www.acriss.org/car-codes/) (used by rental companies to describe vehicles). Strongly-typed with PHP 8.2+ enums, multilingual (EN, FR, IT, DE), framework-agnostic. -## ✨ What is this? - -`lacatoire/acriss-code` is a PHP library to **parse**, **validate**, and **translate** ACRISS codes (used by rental companies to describe vehicles). -It supports **typed enums**, **Symfony integration**, and **multilingual translations** (EN, FR, IT). - ---- - -## πŸš€ Installation +## Installation ```bash composer require lacatoire/acriss-code ``` -Symfony Flex will register the bundle automatically if you're using Symfony. - ---- - -## βœ… Features - -- βœ… Strongly-typed with PHP enums -- βœ… Decode ACRISS 4-letter codes into structured objects -- βœ… Translate ACRISS codes into human-readable strings (EN, FR, IT) -- βœ… Framework-agnostic core (usable with Laravel, Symfony, or standalone) -- βœ… Symfony integration via bundle -- βœ… 100% tested with PHPUnit - ---- +Symfony Flex registers the bundle automatically. -## 🦩 Usage +## Usage ### Parse a code @@ -54,90 +34,24 @@ echo $code->category->value; ```php use Acriss\AcrissTranslator; -$translator = new AcrissTranslator($translatorService); +$translator = new AcrissTranslator($symfonyTranslator); $labels = $translator->translate($code, 'fr'); echo $labels->category; echo $labels->fuelAirCon; ``` -### Get full details +### Full details (parse + translate) ```php use Acriss\AcrissCodeDetails; $details = (new AcrissCodeDetails($parser, $translator))->get('CDMR', 'it'); -// $details->original is an AcrissCode -// $details->translated is a TranslatedAcrissCode - echo $details->translated->transmission; // "Manuale" ``` ---- - -## 🧬 Data Model - -### AcrissCode -```php -class AcrissCode { - public AcrissCategory $category; - public AcrissType $type; - public TransmissionDrive $transmission; - public FuelAirConditioning $fuelAirCon; -} -``` - -### TranslatedAcrissCode -```php -class TranslatedAcrissCode { - public string $category; - public string $type; - public string $transmission; - public string $fuelAirCon; -} -``` - -### AcrissCodeDetails -```php -class AcrissCodeDetails { - public AcrissCode $original; - public TranslatedAcrissCode $translated; -} -``` - ---- - -## πŸ§ͺ Testing - -```bash -composer install -./vendor/bin/phpunit -``` -## βš™οΈ Framework Integration - -### Symfony - -```php -use Acriss\AcrissTranslator; - -$translator = new AcrissTranslator($this->translator); - -``` -* Compatible with Symfony translation (TranslatorInterface) -* Drop translations in translations/messages.[locale].yaml -* Autowiring-ready if registered as a bundle (optional) - -### Laravel - -```php -use Illuminate\Translation\Translator; -use Acriss\AcrissTranslator; - -$acriss = new AcrissTranslator(app(Translator::class)); -``` -* Use any Laravel translator via adapter or service container -### Stand-alone PHP +## Standalone usage (without framework) ```php use Symfony\Component\Translation\Translator; @@ -150,41 +64,18 @@ $translator->addResource('yaml', __DIR__.'/translations/messages.fr.yaml', 'fr') $acriss = new AcrissTranslator($translator); ``` ---- -## πŸ“ Project Structure +## Supported locales -``` -src/ - Acriss/ - Enum/ // ACRISS enums (category, type, etc.) - Model/ // AcrissCode value object - AcrissCodeParser.php - AcrissTranslator.php - AcrissCodeDetails.php -tests/ // PHPUnit tests -translations/ // Symfony-compatible translations (en, fr, it, de) -``` - ---- - -## 🌐 Supported Locales - -- `en` – English (default) -- `fr` – FranΓ§ais -- `it` – Italiano -- `de` – Deutsch - -Want to add more? PRs welcome πŸ‘Œ +`en`, `fr`, `it`, `de` β€” PRs welcome to add more. ---- +## Testing -## πŸ“„ License - -This library is open-sourced under the MIT license. +```bash +composer install +./vendor/bin/phpunit +``` -## Launch phpunit, phpstan, composer without anything +## License -```bash - docker run --rm -v "${PWD}:/app" -w /app php:8.3-cli bash -c "apt update && apt install -y git unzip curl > /dev/null && curl -sS https://getcomposer.org/installer | php && php composer.phar install && php vendor/bin/phpunit" -``` \ No newline at end of file +MIT