Skip to content

Commit 4cb0a3d

Browse files
authored
Merge pull request #5 from eclipxe13/master
Version 0.3.3
2 parents 572a3db + a1b83a2 commit 4cb0a3d

24 files changed

Lines changed: 247 additions & 64 deletions

.gitattributes

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
* text=auto
33

44
# Do not put this files on a distribution package (by .gitignore)
5-
/vendor export-ignore
6-
/build export-ignore
7-
/composer.lock export-ignore
5+
/vendor export-ignore
6+
/composer.lock export-ignore
87

98
# Do not put this files on a distribution package
10-
/tests/ export-ignore
11-
/.gitattributes export-ignore
12-
/.gitignore export-ignore
13-
/.php_cs.dist export-ignore
14-
/.scrutinizer.yml export-ignore
15-
/.travis.yml export-ignore
16-
/build-phar export-ignore
17-
/phpcs.xml.dist export-ignore
18-
phpstan.neon.dist export-ignore
19-
/phpunit.xml.dist export-ignore
9+
/build/ export-ignore
10+
/development/ export-ignore
11+
/tests/ export-ignore
12+
/.gitattributes export-ignore
13+
/.gitignore export-ignore
14+
/.php_cs.dist export-ignore
15+
/.scrutinizer.yml export-ignore
16+
/.travis.yml export-ignore
17+
/phpcs.xml.dist export-ignore
18+
/phpstan.neon.dist export-ignore
19+
/phpunit.xml.dist export-ignore

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# do not include this files on git
22
/vendor
3-
/build
43
/composer.lock

.scrutinizer.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ filter:
33
- 'tests/'
44
- 'vendor/'
55

6+
# see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/
67
build:
8+
dependencies:
9+
override:
10+
- composer self-update --no-interaction --no-progress
11+
- composer remove squizlabs/php_codesniffer friendsofphp/php-cs-fixer phpstan/phpstan phpunit/phpunit --dev --no-interaction --no-progress --no-update
12+
- composer install --no-interaction
713
nodes:
814
php:
915
tests:
1016
override:
1117
- php-scrutinizer-run --enable-security-analysis
12-
1318
tools:
14-
external_code_coverage: true
19+
external_code_coverage: true

.travis.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,64 @@
11
language: php
22

3-
php: ["7.0", "7.1", "7.2", "7.3"]
3+
php: ["7.0", "7.1", "7.2", "7.3", "7.4"]
4+
5+
jobs:
6+
allow_failures:
7+
- php: 7.4 # there is a problem with html2pdf, see https://github.com/spipu/html2pdf/issues/530
48

59
addons:
610
apt:
711
packages:
812
- poppler-utils
913

1014
env:
11-
- FULL_BUILD_PHP_VERSION="7.3"
15+
global:
16+
- BUILD_COVERAGE_PHP_VERSION="7.3"
17+
- BUILD_PHAR_PHP_VERSION="7.3"
18+
- BUILD_PHAR_OUTPUT="build/cfditopdf.phar"
1219

1320
before_script:
14-
- phpenv config-rm xdebug.ini
21+
- phpenv config-rm xdebug.ini || true
1522
- travis_retry composer install --no-progress --no-interaction --prefer-dist
1623

1724
script:
18-
- mkdir -p build/tests/
1925
- vendor/bin/phpcs -sp bin/ src/ tests/ bin/ templates/
2026
- vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose
2127
- |
22-
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
23-
php -d zend_extension=xdebug.so vendor/bin/phpunit --testdox --coverage-clover=build/tests/coverage.xml
28+
if [[ $TRAVIS_PHP_VERSION == $BUILD_COVERAGE_PHP_VERSION ]]; then
29+
php -d zend_extension=xdebug.so vendor/bin/phpunit --testdox --coverage-clover=build/coverage.xml
2430
else
2531
vendor/bin/phpunit --testdox
2632
fi
27-
- vendor/bin/phpstan analyse --level max src/ tests/ bin/
33+
- | # do not run on phpstan on PHP 7.0 because it fail with array annotations
34+
if [[ $TRAVIS_PHP_VERSION != "7.0" ]]; then
35+
vendor/bin/phpstan analyse --no-progress --level max src/ tests/ bin/
36+
fi
2837
# build phar
2938
- |
30-
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
31-
bash build-phar
32-
test -f build/cfditopdf.phar
39+
if [[ $TRAVIS_PHP_VERSION == $BUILD_PHAR_PHP_VERSION ]]; then
40+
rm -f "${BUILD_PHAR_OUTPUT}"
41+
bash development/build-phar "${BUILD_PHAR_OUTPUT}"
42+
test -f "${BUILD_PHAR_OUTPUT}"
3343
fi
3444
3545
after_script:
3646
# upload test covegare to scrutinizer
3747
- |
38-
if [[ $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION ]]; then
48+
if [[ $TRAVIS_PHP_VERSION == $BUILD_COVERAGE_PHP_VERSION ]]; then
3949
wget https://scrutinizer-ci.com/ocular.phar
40-
php ocular.phar code-coverage:upload --format=php-clover build/tests/coverage.xml
50+
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml
4151
fi
4252
4353
deploy:
4454
provider: releases
4555
api_key:
4656
secure: V++o2L8UWr9GLicxWDnT3JFf+VnbxAAbkd1py8y14ISar7XzgfJ4A06KvwvQz2CYZpeHNeG3fakl4HyFuVl/cU+UxZtMAgMTpQs7d33pTpaFSKT8eOesNJQzRqhLr8PDUy6zAoDz+gNjMs7laQqh4PhK9+DoM2+EReno86pWqo6uWdSrv+PNYmIHObrWkAKJo4eZcmCV+4BnpVKmcuyKqYvXaTfSF3gPqZMsByGYn7jitiVu/9/t004BIlahXh0oTj8dpvNEUyWg2LTIa88PrlI6MFrS9vBs+4FVBrElxZxNWTtY/vj3FkDuxn84Yjn9s3q+6pinbmM4240O95VVU/qhlrdsx0RDAfgxZ+yH7fx8aD9zcrVG7tD7FuwgIbTUEJxTj0TBlQIB7zkxDoIygxvBqLgpPQ+/8TjCsja0fwqmrbfB6t2MtgJtLFBc5tAFaHeKkky5FvrR2fJaDg8WzsFR70pLbTqQ8BXjkiXIMKLV2NxQaPpbvlBis/Jq9oa39zy9W2OQB6OJs+2xPIL46mw3W5ZANpste4sUPdalx2vTA+gOrokEKYvzkoSf0zJAjGpO8D0PEObtc/AOybpfgFcXFQ15HiA4U65tdgOEZwmrRRzm/kAa8TewP3KaYM3BaEZvz9+3XP2bZuHLfJdjhiWmBoxFkC4opiLVAUoQ3N0=
4757
skip_cleanup: true
48-
file: build/cfditopdf.phar
58+
file: "${BUILD_PHAR_OUTPUT}"
4959
on:
5060
repo: phpcfdi/cfditopdf
51-
condition: $TRAVIS_PHP_VERSION == $FULL_BUILD_PHP_VERSION
61+
condition: $TRAVIS_PHP_VERSION == $BUILD_PHAR_PHP_VERSION
5262
tags: true
5363

5464
notifications:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018, 2019 PHPCFDI
3+
Copyright (c) 2018 - 2020 PHPCFDI
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ $converter = new \PhpCfdi\CfdiToPdf\Converter(
6363
$converter->createPdfAs($cfdiData, 'output.pdf');
6464
```
6565

66+
To change the way data is translated from `CfdiData` to HTML you could provide a specialized translator to
67+
`Html2PdfBuilder` when the object is constructed.
68+
69+
In the following example is using the default HTML translator that uses Plates, only changing the directory
70+
where templates are located and the template name. The expected result must be compatible with Html2Pdf.
71+
72+
```php
73+
<?php declare(strict_types=1);
74+
$htmlTranslator = new \PhpCfdi\CfdiToPdf\Builders\HtmlTranslators\PlatesHtmlTranslator(
75+
'directory_where_templates_are_located',
76+
'main_template_name'
77+
);
78+
$converter = new \PhpCfdi\CfdiToPdf\Converter(
79+
new \PhpCfdi\CfdiToPdf\Builders\Html2PdfBuilder($htmlTranslator)
80+
);
81+
```
82+
6683
## PHP Support
6784

6885
This library is compatible with PHP versions 7.0 and above.
@@ -85,15 +102,15 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
85102
[source]: https://github.com/phpcfdi/cfditopdf
86103
[release]: https://github.com/phpcfdi/cfditopdf/releases
87104
[license]: https://github.com/phpcfdi/cfditopdf/blob/master/LICENSE
88-
[build]: https://travis-ci.org/phpcfdi/cfditopdf?branch=master
105+
[build]: https://travis-ci.com/phpcfdi/cfditopdf?branch=master
89106
[quality]: https://scrutinizer-ci.com/g/phpcfdi/cfditopdf/
90107
[coverage]: https://scrutinizer-ci.com/g/phpcfdi/cfditopdf/code-structure/master/code-coverage/src
91108
[downloads]: https://packagist.org/packages/phpcfdi/cfditopdf
92109

93110
[badge-source]: https://img.shields.io/badge/source-phpcfdi/cfditopdf-blue?style=flat-square
94111
[badge-release]: https://img.shields.io/github/release/phpcfdi/cfditopdf?style=flat-square
95112
[badge-license]: https://img.shields.io/github/license/phpcfdi/cfditopdf?style=flat-square
96-
[badge-build]: https://img.shields.io/travis/phpcfdi/cfditopdf/master?style=flat-square
113+
[badge-build]: https://img.shields.io/travis/com/phpcfdi/cfditopdf/master?style=flat-square
97114
[badge-quality]: https://img.shields.io/scrutinizer/g/phpcfdi/cfditopdf/master?style=flat-square
98115
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/phpcfdi/cfditopdf/master?style=flat-square
99116
[badge-downloads]: https://img.shields.io/packagist/dt/phpcfdi/cfditopdf?style=flat-square

build/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"phpunit/phpunit": "^6.5|^7.0",
2626
"squizlabs/php_codesniffer": "^3.0",
2727
"friendsofphp/php-cs-fixer": "^2.4",
28-
"phpstan/phpstan-shim": "^0.9|^0.10|^0.11"
28+
"phpstan/phpstan": "^0.9|^0.10|^0.11|^0.12"
2929
},
3030
"autoload": {
3131
"psr-4": {

build-phar renamed to development/build-phar

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PHAR_BUILDER_LOCATION="https://github.com/MacFJA/PharBuilder/releases/latest/dow
44
PHAR_BUILDER_BIN="build/phar-builder"
55

66
# this is set in composer.json
7-
PHAR_DESTINATION="build/cfditopdf.phar"
7+
PHAR_DESTINATION="$1"
88

99
if [ ! -e "$PHAR_BUILDER_BIN" ]; then
1010
mkdir -p "$(dirname "$PHAR_BUILDER_BIN")"

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Version 0.3.3 2020-02-18
2+
3+
- Isolate the translation from CFDI to HTML into an interface `HtmlTranslatorInterface`.
4+
- Implements `PlatesHtmlTranslator` with the current code to translate CFDI to HTML.
5+
- Can setup the `Html2PdfBuilder` by changing the `HtmlTranslatorInterface` to use other templates or other engine.
6+
- Update license year.
7+
- Update Travis-CI & Scrutinizer CI.
8+
- Update phpstan (version 0.12, do not use phpstan-shim).
9+
- Update todo list.
10+
111
# Version 0.3.2 2019-11-14
212

313
- Add *Complemento de pagos* to the generated HTML, thanks @blacktrue

0 commit comments

Comments
 (0)