diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..535dd53 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,47 @@ +name: Image Comparator Laravel PR pipeline + +on: + pull_request: + types: + - assigned + - opened + - reopened + - review_requested + - synchronize + +jobs: + phpunit: + runs-on: ubuntu-24.04 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run PHPUnit tests + run: ./vendor/bin/phpunit --testsuite=unit + + phpcs: + runs-on: ubuntu-24.04 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + + - name: Install Composer dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Run PHP CodeSniffer + run: ./vendor/bin/phpcs -p . diff --git a/composer.json b/composer.json index b897228..3c945bc 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": "^8.1", - "sapientpro/image-comparator": "^1.1.0", + "sapientpro/image-comparator": "^1.2", "illuminate/support": "^8.0|^9.0|^10.0|^11.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 2376d48..7ca0afc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "acefd847ae41662a48ce1a0401a17fe3", + "content-hash": "e977de0446708bc1bab6bac84e33d5e8", "packages": [ { "name": "brick/math", @@ -2910,16 +2910,16 @@ }, { "name": "sapientpro/image-comparator", - "version": "v1.1.0", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/sapientpro/image-comparator.git", - "reference": "dfa3be35ad91d18bc4151c19cda2d0c8c121b86f" + "reference": "c897d11cf669fd11609b3d50df19706ae0262628" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sapientpro/image-comparator/zipball/dfa3be35ad91d18bc4151c19cda2d0c8c121b86f", - "reference": "dfa3be35ad91d18bc4151c19cda2d0c8c121b86f", + "url": "https://api.github.com/repos/sapientpro/image-comparator/zipball/c897d11cf669fd11609b3d50df19706ae0262628", + "reference": "c897d11cf669fd11609b3d50df19706ae0262628", "shasum": "" }, "require": { @@ -2951,9 +2951,9 @@ "description": "Compare images using PHP", "support": { "issues": "https://github.com/sapientpro/image-comparator/issues", - "source": "https://github.com/sapientpro/image-comparator/tree/v1.1.0" + "source": "https://github.com/sapientpro/image-comparator/tree/v1.2.0" }, - "time": "2024-09-20T10:44:37+00:00" + "time": "2025-01-13T09:41:14+00:00" }, { "name": "symfony/clock", diff --git a/src/Facades/Comparator.php b/src/Facades/Comparator.php index 72c7122..2db4844 100644 --- a/src/Facades/Comparator.php +++ b/src/Facades/Comparator.php @@ -8,6 +8,7 @@ use SapientPro\ImageComparator\ImageComparator; use SapientPro\ImageComparator\Strategy\HashStrategy; +// phpcs:disable Generic.Files.LineLength.TooLong /** * @method static void setHashStrategy(HashStrategy $hashStrategy) * @method static float compare(GdImage|string $sourceImage, GdImage|string $comparedImage, ImageRotationAngle $rotation = ImageRotationAngle::D0, int $precision = 1) @@ -19,6 +20,7 @@ * @method static GdImage|false squareImage(string $image) * @method static string convertHashToBinaryString(array $hash) */ +// phpcs:enable Generic.Files.LineLength.TooLong class Comparator extends Facade { protected static function getFacadeAccessor(): string diff --git a/tests/Unit/ComparatorTest.php b/tests/Unit/ComparatorTest.php index bc02867..35d8395 100644 --- a/tests/Unit/ComparatorTest.php +++ b/tests/Unit/ComparatorTest.php @@ -16,7 +16,7 @@ public function testCompareImages(): void 'tests/images/amazon-image.png' ); - $this->assertSame(87.5, $similarity); + $this->assertSame(86.994, $similarity); $similarityArray = Comparator::compareArray( 'tests/images/ebay-image.png', @@ -27,8 +27,8 @@ public function testCompareImages(): void ); $this->assertSame([ - 'amazon1' => 87.5, - 'amazon2' => 53.1 + 'amazon1' => 86.994, + 'amazon2' => 43.436 ], $similarityArray); } @@ -39,7 +39,7 @@ public function testDetectSimilarities(): void 'tests/images/amazon-image.png' ); - $this->assertSame(87.5, $similarity); + $this->assertSame(86.994, $similarity); $similarityArray = Comparator::detectArray( 'tests/images/ebay-image.png', @@ -50,8 +50,8 @@ public function testDetectSimilarities(): void ); $this->assertSame([ - 'amazon1' => 87.5, - 'amazon2' => 62.5 + 'amazon1' => 86.994, + 'amazon2' => 48.59 ], $similarityArray); }