diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4073ad9..4716fbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: unit-tests: runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: php-version: ['7.4', '8.0'] @@ -70,7 +69,6 @@ jobs: needs: - unit-tests runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.php-version == '8.0' }} strategy: matrix: php-version: ['7.4', '8.0'] diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index c1eb0b7..edf2aff 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fe158b..b79fff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [3.6.0] - 2021-02-28 +### Added +* [#68](https://github.com/shlinkio/shlink-common/issues/68) Added support for `endroid/qr-code` 4.0. + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* [#68](https://github.com/shlinkio/shlink-common/issues/68) Dropped support for `endroid/qr-code` 3.*. + +### Fixed +* *Nothing* + + ## [3.5.0] - 2021-02-12 ### Added * [#60](https://github.com/shlinkio/shlink-common/issues/60) Added support for `pagerfanta/core` as a pagination system. diff --git a/composer.json b/composer.json index fff2812..6ad39ad 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "akrabat/ip-address-middleware": "^2.0", "cakephp/chronos": "^2.0", "doctrine/orm": "^2.8.1", - "endroid/qr-code": "^3.6", + "endroid/qr-code": "^4.0", "fig/http-message-util": "^1.1", "guzzlehttp/guzzle": "^7.0", "laminas/laminas-config": "^3.3", diff --git a/src/Response/QrCodeResponse.php b/src/Response/QrCodeResponse.php index 590a86e..2cb64f5 100644 --- a/src/Response/QrCodeResponse.php +++ b/src/Response/QrCodeResponse.php @@ -4,7 +4,7 @@ namespace Shlinkio\Shlink\Common\Response; -use Endroid\QrCode\QrCodeInterface; +use Endroid\QrCode\Writer\Result\ResultInterface; use Fig\Http\Message\StatusCodeInterface as StatusCode; use Laminas\Diactoros\Response; use Laminas\Diactoros\Stream; @@ -14,19 +14,19 @@ class QrCodeResponse extends Response { use Response\InjectContentTypeTrait; - public function __construct(QrCodeInterface $qrCode, int $status = StatusCode::STATUS_OK, array $headers = []) + public function __construct(ResultInterface $qrCode, int $status = StatusCode::STATUS_OK, array $headers = []) { parent::__construct( $this->createBody($qrCode), $status, - $this->injectContentType($qrCode->getContentType(), $headers), + $this->injectContentType($qrCode->getMimeType(), $headers), ); } - private function createBody(QrCodeInterface $qrCode): StreamInterface + private function createBody(ResultInterface $qrCode): StreamInterface { $body = new Stream('php://temp', 'wb+'); - $body->write($qrCode->writeString()); + $body->write($qrCode->getString()); $body->rewind(); return $body; } diff --git a/test/Response/QrCodeResponseTest.php b/test/Response/QrCodeResponseTest.php index 51e5653..f877f5e 100644 --- a/test/Response/QrCodeResponseTest.php +++ b/test/Response/QrCodeResponseTest.php @@ -4,7 +4,7 @@ namespace ShlinkioTest\Shlink\Common\Response; -use Endroid\QrCode\QrCode; +use Endroid\QrCode\Builder\Builder; use PHPUnit\Framework\TestCase; use Shlinkio\Shlink\Common\Response\QrCodeResponse; @@ -13,10 +13,10 @@ class QrCodeResponseTest extends TestCase /** @test */ public function providedQrCodeIsSetAsBody(): void { - $qrCode = new QrCode('Hello'); + $qrCode = Builder::create()->data('Hello')->build(); $resp = new QrCodeResponse($qrCode); - self::assertEquals($qrCode->getContentType(), $resp->getHeaderLine('Content-Type')); - self::assertEquals($qrCode->writeString(), (string) $resp->getBody()); + self::assertEquals($qrCode->getMimeType(), $resp->getHeaderLine('Content-Type')); + self::assertEquals($qrCode->getString(), (string) $resp->getBody()); } }