Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/php-cs-fixer/.php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in([__DIR__ . '/../../src', __DIR__ . '/../../tests']);

$config = new Config();
$config->setRules(['@Symfony' => true]);
$config->setFinder($finder);
$config->setUsingCache(false);

return $config;
26 changes: 26 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHP Lint & CS Fixer

on:
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist

- name: Run PHP-CS-Fixer
run: |
composer codesniffer-fix
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
vendor
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,19 @@ use Acriss\AcrissCodeParser;
$parser = new AcrissCodeParser();
$code = $parser->parse('CDMR');

// $code is an instance of Acriss\Model\AcrissCode

echo $code->category->value; // COMPACT
echo $code->category->value;
```

### Translate a code

```php
use Acriss\AcrissTranslator;

$translator = new AcrissTranslator($translatorService); // Symfony's TranslatorInterface
$translator = new AcrissTranslator($translatorService);
$labels = $translator->translate($code, 'fr');

// $labels is an instance of Acriss\Model\TranslatedAcrissCode

echo $labels->category; // "Compacte"
echo $labels->fuelAirCon; // "Essence, avec climatisation"
echo $labels->category;
echo $labels->fuelAirCon;
```

### Get full details
Expand Down Expand Up @@ -125,7 +121,7 @@ composer install
```php
use Acriss\AcrissTranslator;

$translator = new AcrissTranslator($this->translator); // Symfony\Contracts\Translation\TranslatorInterface
$translator = new AcrissTranslator($this->translator);

```
* Compatible with Symfony translation (TranslatorInterface)
Expand Down Expand Up @@ -185,4 +181,10 @@ Want to add more? PRs welcome 👌

## 📄 License

This library is open-sourced under the MIT license.
This library is open-sourced under the MIT license.

## Launch phpunit, phpstan, composer without anything

```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"
```
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"symfony/yaml": "*"
"symfony/yaml": "*",
"friendsofphp/php-cs-fixer": "*"
},
"extra": {
"branch-alias": {
Expand All @@ -36,6 +37,13 @@
"bundle": "Acriss\\Bridge\\Symfony\\AcrissCodeBundle"
}
},
"scripts": {
"codesniffer": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix src tests --dry-run --verbose --show-progress=dots --config=.github/php-cs-fixer/.php-cs-fixer.php",
"codesniffer-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix src tests --verbose --show-progress=dots --config=.github/php-cs-fixer/.php-cs-fixer.php",
"phpstan": "php ./vendor/bin/phpstan analyse --configuration .github/phpstan/phpstan.neon",
"phpunit": "php ./vendor/bin/phpunit --configuration ./phpunit.xml.dist ./tests"
},

"minimum-stability": "stable",
"prefer-stable": true
}
Loading