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
2 changes: 1 addition & 1 deletion .github/workflows/_publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up php 8.3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,27 @@ jobs:
static-check:
name: Run Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["8.1"]
steps:
- uses: actions/checkout@v4

- name: Set up PHP ${{ matrix.php-version }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
php-version: "8.1"
tools: composer

- name: Cache dependencies
uses: actions/cache@v5
with:
path: ./vendor
key: ${{ runner.os }}-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}

- name: Install dependencies
run: |
composer install
uses: ramsey/composer-install@v3

- name: Run lint
run: |
composer lint

- name: License Check
run: |
./vendor/bin/license-checker check

- name: Check Unused Dependencies
# symfony/console is mistakenly flagged as unused since it is only used in the CLI, not the main app
# Exclude it from checks.
run: ./vendor/bin/composer-unused --excludePackage=symfony/console
34 changes: 0 additions & 34 deletions .github/workflows/_static-dependency-checks.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/_test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- uses: ramsey/composer-install@v3

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Test V2 CLI
shell: sh
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,23 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ghostscript
- name: Set up php ${{ matrix.php-version }}

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: curl, fileinfo, json, imagick
- uses: ramsey/composer-install@v2

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Change ImageMagick security policy on Ubuntu
run: |
DQT='"'
SRC="rights=${DQT}none${DQT} pattern=${DQT}PDF${DQT}"
RPL="rights=${DQT}read|write${DQT} pattern=${DQT}PDF${DQT}"
sudo sed -i "s/$SRC/$RPL/" /etc/ImageMagick-6/policy.xml

- name: Unit testing with phpunit
run: |
./vendor/bin/phpunit -c tests/functional.xml
Expand Down Expand Up @@ -106,16 +111,21 @@ jobs:
submodules: recursive
- name: Install Ghostscript
run: choco install ghostscript --version 10.03.1 -y
- name: Set up php ${{ matrix.php-version }}

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
with:
php-version: ${{ matrix.php-version }}
extensions: curl, fileinfo, json, imagick

- name: Install Ghostscript
run: choco install ghostscript -y
- uses: ramsey/composer-install@v2

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Unit testing with phpunit
run: |
./vendor/bin/phpunit -c tests/functional.xml
4 changes: 3 additions & 1 deletion .github/workflows/_test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- uses: ramsey/composer-install@v2

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Tests V2 code samples
run: |
Expand Down
40 changes: 30 additions & 10 deletions .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up php ${{ matrix.php-version }}

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- uses: ramsey/composer-install@v3

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Unit testing with phpunit
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
./vendor/bin/phpunit -c tests/pdffeatures.xml


with-pdf-linux:
name: Unit Tests on Linux with PDF support
timeout-minutes: 30
Expand All @@ -50,23 +55,28 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ghostscript
- name: Set up php ${{ matrix.php-version }}
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- uses: ramsey/composer-install@v3

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Change ImageMagick security policy on Ubuntu
run: |
DQT='"'
SRC="rights=${DQT}none${DQT} pattern=${DQT}PDF${DQT}"
RPL="rights=${DQT}read|write${DQT} pattern=${DQT}PDF${DQT}"
sudo sed -i "s/$SRC/$RPL/" /etc/ImageMagick-6/policy.xml

- name: Unit testing with phpunit
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
./vendor/bin/phpunit -c tests/phpunit.xml


no-pdf-macos:
name: Unit Tests on MacOS without PDF support
timeout-minutes: 30
Expand All @@ -82,7 +92,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up php ${{ matrix.php-version }}
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
Expand Down Expand Up @@ -122,7 +132,7 @@ jobs:
# run: |
# brew install pkg-config ghostscript imagemagick@7
# export PKG_CONFIG_PATH="/usr/local/opt/imagemagick/lib/pkgconfig"
# - name: Set up php ${{ matrix.php-version }}
# - name: Set up PHP ${{ matrix.php-version }}
# uses: shivammathur/setup-php@v2
# env:
# phpts: zts
Expand Down Expand Up @@ -152,20 +162,25 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up php ${{ matrix.php-version }}

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
with:
php-version: ${{ matrix.php-version }}
extensions: curl, fileinfo, json
- uses: ramsey/composer-install@v3

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Unit testing with phpunit
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
run: |
./vendor/bin/phpunit -c tests/pdffeatures.xml


with-pdf-windows:
name: Unit Tests on Windows with PDF support
timeout-minutes: 30
Expand All @@ -183,19 +198,24 @@ jobs:
submodules: recursive
- name: Install Ghostscript
run: choco install ghostscript --version 10.04.0 -y

- name: Create Ghostscript alias
run: |
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs.exe" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
New-Item -ItemType SymbolicLink -Path "C:\Windows\gs" -Target "C:\Program Files\gs\gs10.04.0\bin\gswin64c.exe"
shell: powershell
- name: Set up php ${{ matrix.php-version }}

- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
env:
phpts: zts
with:
php-version: ${{ matrix.php-version }}
extensions: curl, fileinfo, json, imagick
- uses: ramsey/composer-install@v3

- name: Install dependencies
uses: ramsey/composer-install@v3

- name: Unit testing with phpunit
env:
MINDEE_API_KEY: ${{ secrets.MINDEE_API_KEY_SE_TESTS }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
static-analysis:
uses: ./.github/workflows/_static-analysis.yml
needs: workflow-lint
static-dependency-checks:
uses: ./.github/workflows/_static-dependency-checks.yml
needs: static-analysis
test-units:
uses: ./.github/workflows/_test-units.yml
needs: static-analysis
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
"composer/ca-bundle": "^1.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.38",
"phpunit/phpunit": "^9.6",
"madewithlove/license-checker": "^v1.0",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"rector/rector": "^2.4",
"projektgopher/whisky": "^0.7.4"
"friendsofphp/php-cs-fixer": "~v3.95.25",
"phpunit/phpunit": "~9.6.35",
"madewithlove/license-checker": "~v1.6",
"phpstan/phpstan": "~2.2.8",
"phpstan/phpstan-deprecation-rules": "~2.0.5",
"rector/rector": "~2.5.9",
"projektgopher/whisky": "~0.7.4",
"icanhazstring/composer-unused": "~0.9.0"
},
"suggest": {
"ext-imagick": "Required for PDF rasterization and image processing features",
Expand Down
12 changes: 8 additions & 4 deletions src/V1/Parsing/Standard/TaxField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Mindee\V1\Parsing\Standard;

use Mindee\V1\Parsing\SummaryHelperV1;

use function array_key_exists;
use function is_scalar;

Expand Down Expand Up @@ -92,10 +94,12 @@ public function toTableLine(): string
{
$printable = $this->printableValues();

return '| ' . mb_str_pad($printable['basis'], 13, ' ', STR_PAD_RIGHT, "UTF-8")
. ' | ' . mb_str_pad($printable['code'], 6, ' ', STR_PAD_RIGHT, "UTF-8")
. ' | ' . mb_str_pad($printable['rate'], 8, ' ', STR_PAD_RIGHT, "UTF-8")
. ' | ' . mb_str_pad($printable['value'], 13, ' ', STR_PAD_RIGHT, "UTF-8") . ' |';
$outStr = "| ";
$outStr .= SummaryHelperV1::padString($printable['basis'], 13);
$outStr .= SummaryHelperV1::padString($printable['code'], 6);
$outStr .= SummaryHelperV1::padString($printable['rate'], 8);
$outStr .= SummaryHelperV1::padString($printable['value'], 13);
return rtrim(SummaryHelperV1::cleanOutString($outStr));
}

/**
Expand Down
10 changes: 9 additions & 1 deletion src/V1/Parsing/SummaryHelperV1.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Mindee\Parsing\SummaryHelper;

use function function_exists;
use function strlen;

/**
* Utility class to handle information display.
*/
Expand All @@ -21,6 +24,11 @@ class SummaryHelperV1 extends SummaryHelper
*/
public static function padString(string $inputString, int $colSize, string $separator = "|"): string
{
return mb_str_pad($inputString, $colSize, " ", STR_PAD_RIGHT, "UTF-8") . " $separator ";
if (function_exists('mb_str_pad')) {
return mb_str_pad($inputString, $colSize, " ", STR_PAD_RIGHT, "UTF-8") . " $separator ";
}

$paddedLength = $colSize + (strlen($inputString) - mb_strlen($inputString, 'UTF-8'));
return str_pad($inputString, $paddedLength, ' ', STR_PAD_RIGHT) . " $separator ";
}
}
2 changes: 1 addition & 1 deletion tests/V2/Product/Extraction/RagDocumentsFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function testRagDocumentLifecycleMustSucceed(): void
)
);
self::assertNotNull($patchStatusResponse);
self::assertEquals("Active", $patchStatusResponse->status);
self::assertEquals("Processing", $patchStatusResponse->status);

$deleteResponse = $this->client->deleteExtractionRagDocument($documentId);
self::assertTrue($deleteResponse);
Expand Down
Loading