Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework #32

Merged
merged 1 commit into from
Oct 31, 2024
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
10 changes: 8 additions & 2 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
php-versions: [ '8.3' ]

steps:
- uses: actions/checkout@v2

- name: Setup PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json, tokenizer

- name: Validate composer.json and composer.lock
Expand All @@ -25,8 +30,8 @@ jobs:
- name: 📥 Install dependencies
run: composer install --prefer-dist --no-progress

- name: 🧽 Run code sniffer
run: vendor/bin/phpcs -q --report=checkstyle --standard=PSR12 src/ | vendor/bin/cs2pr
- name: 🧽 Run CS
run: composer run-script fix-cs

php_stan:

Expand All @@ -38,6 +43,7 @@ jobs:
- name: Setup PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json, tokenizer

- name: Validate composer.json and composer.lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
php-versions: [ '8.1', '8.2' ]
php-versions: [ '8.3' ]

steps:
- uses: actions/checkout@v2
Expand Down
55 changes: 55 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([
__DIR__ . \DIRECTORY_SEPARATOR . 'src' . \DIRECTORY_SEPARATOR,
__DIR__ . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR,
])
;

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRules(
[
'@Symfony' => true,
'@Symfony:risky' => true,
'no_unreachable_default_argument_value' => false,
'heredoc_to_nowdoc' => false,
'phpdoc_annotation_without_dot' => false,
'strict_comparison' => true,
'concat_space' => [
'spacing' => 'one',
],
'binary_operator_spaces' => [
'default' => 'align_single_space_minimal',
],
'array_indentation' => true,
'blank_line_before_statement' => [
'statements' => [
'return',
'continue',
'exit',
'for',
'foreach',
'declare',
'if',
'return',
'throw',
'break',
],
],
'yoda_style' => true,
'no_superfluous_phpdoc_tags' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'method_chaining_indentation' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'single_line_throw' => false,
'nullable_type_declaration_for_default_null_value' => true,
'protected_to_private' => false,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
]
)
->setRiskyAllowed(true)
->setFinder($finder)
;
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# Factur-x
# Factur-X PHP Library

> this standard use the european EN 16931 standard for invoicing introperability
## Install with Composer

## 🐿️ In a nutshell
Factur-X est un standard franco-allemand de facture électronique mixte (PDF pour les utilisateurs et données XML pour un traitement automatisé), première implémentation de la Norme Sémantique Européenne EN 16931 publiée par la Commission Européenne le 16 octobre 2017. Factur-x est le même standard que ZUGFeRD 2.1.
```bash
composer require tiime/factur-x
```

## Usage

### Generate Factur-X

Create a Factur-X compliant PDF document by merging provided PDF content with XML data and optionally adding a logo.

```php
use Tiime\FacturX\Writer;

$writer = new Writer();
$facturxContent = $writer->generate(
pdfContent: $pdfContent,
xmlContent: $xml,
addLogo: true
);

file_put_contents('generated_facturx.pdf', $facturxContent);
```

### Extract XML from Factur-X

Extract XML data from a Factur-X compliance PDF document.

```php
use Tiime\FacturX\Reader;

$extractedXml = (new Reader())->extractXML($writer);
```
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"name": "tiime/factur-x",
"description": "French (XML in PDF) usage of european EN 16931 standard",
"description": "PHP library to manage your Factur-X (PDF invoices files)",
"type": "library",
"require": {
"php": "^8.1",
"php": ">=8.3",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-libxml": "*",
"ext-simplexml": "*",
"atgp/factur-x": "^1.0",
"milo/schematron": "^1.0"
"ext-zlib": "*",
"tiime/en-16931": "^0.10.0",
"setasign/fpdf": "^1.8",
"setasign/fpdi": "^2.6",
"ramsey/uuid": "^4.7",
"smalot/pdfparser": "^2.11"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.7",
"staabm/annotate-pull-request-from-checkstyle": "^1.7",
"phpstan/phpstan": "^1.9"
"phpstan/phpstan": "^1.9",
"friendsofphp/php-cs-fixer": "^3.64"
},
"license": "MIT",
"autoload": {
Expand All @@ -39,7 +43,7 @@
],
"scripts": {
"test": "vendor/bin/phpunit tests",
"code_sniffer": "vendor/bin/phpcs -q --report=checkstyle --standard=PSR12 src/",
"fix-cs": "vendor/bin/php-cs-fixer fix",
"phpstan": "vendor/bin/phpstan analyse -l 9 src tests"
}
}
7 changes: 7 additions & 0 deletions src/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Tiime\FacturX;

class Exception extends \Exception
{
}
Loading
Loading