Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .github/workflows/php-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@ jobs:
- name: Run linter
run: composer run-script lint

coverage:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install PHP with pcov
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: pcov

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

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

- name: Run tests with coverage
env:
TEST_CONFIGURATION_ACCESS_TOKEN: ${{ secrets.TEST_CONFIGURATION_ACCESS_TOKEN }}
run: vendor/bin/phpunit --coverage-clover clover.xml

- name: Enforce 80% line coverage gate
run: php scripts/coverage-check.php clover.xml 80

test:
needs: build
runs-on: ${{ matrix.operating-system }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/nbproject/private
/snippets_test
/vendor
/clover.xml
Configuration*.json
!Configuration.example.json
phpunit.log
/phpunit-log.xml
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ test:
composer test
./scripts/run_snippets.sh

.PHONY: cover
cover:
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover clover.xml
php scripts/coverage-check.php clover.xml 80

.PHONY: init
init:
composer install
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Packagist Version](https://img.shields.io/packagist/v/aspose/barcode-cloud-php)](https://packagist.org/packages/aspose/barcode-cloud-php)

- API version: 4.0
- Package version: 26.6.0
- Package version: 26.7.0
- Supported PHP versions: ">=8.0"

## SDK and API Version Compatibility:
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-badges.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pushd "${SCRIPT_DIR}/.." >/dev/null
fi
done

(grep -oP '[^/]+\.yml/badge.svg(?!\?branch=main)' "${readme_file}" || echo ) | while read -r badge_without_branch; do
(grep -oP '[^/]+\.yml/badge.svg(?!\?branch=(main|v4)\b)' "${readme_file}" || echo ) | while read -r badge_without_branch; do
if [ -z "${badge_without_branch}" ]; then continue; fi
>&2 echo "Badge without branch \"${badge_without_branch}\""
exit 1
Expand Down
66 changes: 66 additions & 0 deletions scripts/coverage-check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/**
* Fails the build when line coverage reported in a Clover XML file drops below a threshold.
*
* Line coverage is computed by summing the per-file `<metrics>` `statements` and
* `coveredstatements` attributes across the whole report (Clover treats one executable
* statement as one line), matching the gate used by the Python and Java SDKs.
*
* Usage:
* php scripts/coverage-check.php [clover.xml] [threshold]
*
* Defaults: clover.xml, threshold 80 (percent).
*/

declare(strict_types=1);

$cloverPath = $argv[1] ?? 'clover.xml';
$threshold = isset($argv[2]) ? (float) $argv[2] : 80.0;

if (!is_file($cloverPath)) {
fwrite(STDERR, "Coverage report not found: {$cloverPath}\n");
exit(2);
}

$xml = simplexml_load_file($cloverPath);
if ($xml === false) {
fwrite(STDERR, "Unable to parse coverage report: {$cloverPath}\n");
exit(2);
}

$fileMetrics = $xml->xpath('//file/metrics');
if ($fileMetrics === false || count($fileMetrics) === 0) {
fwrite(STDERR, "No per-file metrics found in {$cloverPath}\n");
exit(2);
}

$statements = 0;
$covered = 0;
foreach ($fileMetrics as $metrics) {
$statements += (int) $metrics['statements'];
$covered += (int) $metrics['coveredstatements'];
}

if ($statements === 0) {
fwrite(STDERR, "Coverage report contains zero statements\n");
exit(2);
}

$percent = $covered / $statements * 100.0;

printf(
"Line coverage: %.2f%% (%d/%d statements), threshold %.2f%%\n",
$percent,
$covered,
$statements,
$threshold
);

if ($percent + 1e-9 < $threshold) {
fwrite(STDERR, sprintf("FAIL: line coverage %.2f%% is below the %.2f%% gate\n", $percent, $threshold));
exit(1);
}

echo "PASS: coverage gate satisfied\n";
exit(0);
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Use this reference when you want the closest existing PHP pattern before writing
- `tests/ScanApiTest.php`: scan via base64 body, multipart, and public URL.
- `tests/ConfigurationTest.php`: configuration defaults, JSON serialization, and environment-variable loading.
- `tests/ExceptionTest.php`: expected API failures and parsed error behavior.
- `tests/ObjectSerializerTests.php`: serializer behavior if model or date formatting changes.
- `tests/ObjectSerializerTest.php`: serializer behavior if model or date formatting changes.
2 changes: 1 addition & 1 deletion src/Aspose/BarCode/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Configuration implements JsonSerializable
*
* @var string
*/
protected $clientVersion = '26.6.0';
protected $clientVersion = '26.7.0';

/**
* ClientId for API
Expand Down
75 changes: 0 additions & 75 deletions src/Aspose/BarCode/Model/ModelInterface.php

This file was deleted.

4 changes: 3 additions & 1 deletion src/Aspose/BarCode/ObjectSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986):
throw new \InvalidArgumentException('Invalid type');
}

$castBool = function ($v) { return $v ? 'true' : 'false'; };
$castBool = function ($v) {
return $v ? 'true' : 'false';
};

$qs = '';
foreach ($params as $k => $v) {
Expand Down
Loading
Loading