Skip to content

Commit

Permalink
chore: molireali
Browse files Browse the repository at this point in the history
  • Loading branch information
petrknap committed May 21, 2024
1 parent 3b7b422 commit 03e6ef3
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: https://petrknap.github.io/donate.html
7 changes: 4 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Docker
name: composer ci-script

on:
pull_request:

jobs:
build-and-run:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: docker build -t $GITHUB_REPOSITORY:$GITHUB_SHA .
- run: docker run $GITHUB_REPOSITORY:$GITHUB_SHA composer ci-script
- name: Run composer ci-script
run: docker run $GITHUB_REPOSITORY:$GITHUB_SHA composer ci-script
2 changes: 1 addition & 1 deletion .github/workflows/linter-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
image: hadolint/hadolint:latest-alpine
steps:
- uses: actions/checkout@v3
- run: find . -name 'Dockerfile' -or -name '*.dockerfile' -exec hadolint {} \;
- run: find . -name 'Dockerfile' -or -name '*.dockerfile' | xargs -trn 1 hadolint
4 changes: 2 additions & 2 deletions .github/workflows/linter-php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
PHP:
runs-on: ubuntu-latest
container:
image: php:8.0-cli-alpine
image: php:8.1-cli-alpine
steps:
- uses: actions/checkout@v3
- run: find . -name '*.php' -exec php -l {} \;
- run: find . -name '*.php' | xargs -trn 1 php -l
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/bin/
/vendor/
/composer.lock
4 changes: 2 additions & 2 deletions .molireali
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
authors
composer PetrKnap\\SpaydQr
dockerfile php 8.0-cli
dockerfile php 8.1-cli
docker-scripts petrknap/php-spaydqr
donation
git-crlf "*.bat"
github-workflow docker "composer ci-script"
github-workflow linter-docker
github-workflow linter-php 8.0
github-workflow linter-php 8.1
license LGPL-3.0-or-later
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.0-cli
FROM php:8.1-cli

# region included composer
# hadolint ignore=DL3008
Expand Down Expand Up @@ -26,7 +26,7 @@ RUN apt-get update \
libmcrypt-dev \
libpng-dev \
&& docker-php-ext-configure gd \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install -j"$(nproc)" gd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
;
Expand All @@ -36,6 +36,8 @@ RUN docker-php-ext-install \
bcmath \
;

# region included composer-library
WORKDIR /app
COPY . .
RUN composer update --prefer-lowest
# endregion
40 changes: 27 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"WARNING": "This file is updated automatically. All keys will be overwritten, except of 'conflict', 'keywords', 'require', 'require-dev' and 'scripts'.",
"WARNING": "This file is updated automatically. All keys will be overwritten, except of 'conflict', 'keywords', 'require', 'require-dev', 'scripts' and 'suggest'.",
"autoload": {
"psr-4": {
"PetrKnap\\SpaydQr\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"PetrKnap\\SpaydQr\\Test\\": "tests"
"PetrKnap\\SpaydQr\\": "tests"
}
},
"config": {
"allow-plugins": false,
"sort-packages": true
},
"description": "Short Payment Descriptor (SPayD) with QR output",
"funding": [
{
"type": "other",
"url": "https://petrknap.github.io/donate.html"
}
],
"homepage": "https://github.com/petrknap/php-spaydqr",
"homepage": "https://github.com/petrknap/php-spayd-qr",
"keywords": [
"spayd",
"qrcode",
Expand All @@ -27,27 +31,37 @@
"license": "LGPL-3.0-or-later",
"name": "petrknap/spayd-qr",
"require": {
"php": ">=8.0",
"endroid/qr-code": "^4.1",
"php": ">=8.1",
"endroid/qr-code": "^5.0",
"moneyphp/money": "^4.0",
"sunfoxcz/spayd-php": "^2.0"
},
"require-dev": {
"nunomaduro/phpinsights": "^2.11",
"petrknap/shorts": "^2.1",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.7",
"phpstan/phpstan": "^1.10"
"squizlabs/php_codesniffer": "^3.7"
},
"scripts": {
"test": [
"phpunit --colors=always --testdox tests"
],
"validate": [
"phpcs --colors --standard=PSR12 --exclude=PSR12.Files.OpenTag,PSR12.Files.FileHeader,Generic.Files.LineLength src tests",
"phpstan analyse --level max src",
"phpstan analyse --level 5 tests"
],
"ci-script": [
"@validate",
"@check-requirements",
"@check-implementation",
"@test-implementation"
],
"check-requirements": [
"composer outdated \"petrknap/*\" --major-only --strict --ansi --no-interaction"
],
"check-implementation": [
"phpcs --colors --standard=PSR12 --exclude=Generic.Files.LineLength src tests",
"phpstan analyse --level max src --ansi --no-interaction",
"phpstan analyse --level 5 tests --ansi --no-interaction",
"phpinsights analyse src --ansi --no-interaction"
],
"test-implementation": [
"@test"
]
}
Expand Down
17 changes: 12 additions & 5 deletions src/SpaydQr.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace PetrKnap\SpaydQr;

use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Builder\BuilderInterface;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\Writer\PngWriter;
use Endroid\QrCode\Writer\WriterInterface;
use Endroid\QrCode\Writer\Result\ResultInterface;
use Endroid\QrCode\Writer\WriterInterface;
use Money\Currencies\ISOCurrencies;
use Money\Formatter\DecimalMoneyFormatter;
use Money\Money;
use Sunfox\Spayd\Spayd;

/**
* @todo make it final
*/
class SpaydQr implements SpaydQrInterface
{
/** @internal */
protected function __construct(
/** @internal */ protected Spayd $spayd,
/** @internal */ protected BuilderInterface $qrCodeBuilder,
/** @internal */
protected Spayd $spayd,
/** @internal */
protected BuilderInterface $qrCodeBuilder,
string $iban,
Money $money
) {
Expand Down Expand Up @@ -59,7 +66,7 @@ public function setInvoice(
$normalize = function (string $input): string {
return str_replace(
['*', '%2A', '%2a'],
['' , '' , '' ],
['', '', ''],
$input
);
};
Expand Down
17 changes: 14 additions & 3 deletions src/SpaydQrInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

namespace PetrKnap\SpaydQr;

Expand Down Expand Up @@ -28,7 +30,10 @@ interface SpaydQrInterface
public static function create(string $iban, Money $money): self;

public function setVariableSymbol(int $variableSymbol): self;
/** @see https://qr-faktura.cz/ */

/**
* @see https://qr-faktura.cz/
*/
public function setInvoice(
string $id,
\DateTimeInterface $issueDate,
Expand All @@ -38,11 +43,17 @@ public function setInvoice(
?string $buyerVatIdentificationNumber,
?string $description
): self;
/** @todo create own enum of writers */

/**
* @todo create own enum of writers
*/
public function setWriter(WriterInterface $writer): self;

public function getContentType(): string;

public function getContent(int $size = self::QR_SIZE, int $margin = self::QR_MARGIN): string;

public function getDataUri(int $size = self::QR_SIZE, int $margin = self::QR_MARGIN): string;

public function writeFile(string $path, int $size = self::QR_SIZE, int $margin = self::QR_MARGIN): void;
}
33 changes: 0 additions & 33 deletions tests/ExamplesTest.php

This file was deleted.

1 change: 0 additions & 1 deletion tests/ExamplesTest/readme_1.html

This file was deleted.

26 changes: 26 additions & 0 deletions tests/ReadmeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace PetrKnap\SpaydQr;

use PetrKnap\Shorts\PhpUnit\MarkdownFileTestInterface;
use PetrKnap\Shorts\PhpUnit\MarkdownFileTestTrait;
use PHPUnit\Framework\TestCase;

class ReadmeTest extends TestCase implements MarkdownFileTestInterface
{
use MarkdownFileTestTrait;

public static function getPathToMarkdownFile(): string
{
return __DIR__ . '/../README.md';
}

public static function getExpectedOutputsOfPhpExamples(): iterable
{
return [
'example' => file_get_contents(__DIR__ . '/ReadmeTest/example.html'),
];
}
}
1 change: 1 addition & 0 deletions tests/ReadmeTest/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGIUlEQVR4nO3dQXLjOBAAQWnD//+y9zB3aMyBUE0587qxEm2zBocmwOf39/cD6Hw9Ho/n81lfxnXX/hFZ/Mgn/1UachnXbL/4ax/4AXfvf/VlwG8nQoiJEGIihJgIISZCiIkQYiKE2Nf6Pw8ZGV8byG4f427/wFvPoLffG/M/8JqXf0orIcRECDERQkyEEBMhxEQIMRFCTIQQezGsXzg5ud7+gYuLv/ZzDdngv31z+pDHCbbfG6PuXishxEQIMRFCTIQQEyHERAgxEUJMhBC7Pqyfb/vYffsG/+3fNWQiv/1Jg89mJYSYCCEmQoiJEGIihJgIISZCiIkQYp88rJ+/OX1hyDkDHGAlhJgIISZCiIkQYiKEmAghJkKIiRBi14f1Q14IvrB9gL5wckv7/P3415y8o0bdvVZCiIkQYiKEmAghJkKIiRBiIoSYCCH2Ylhvz/VfGjKRH7J9fsjpBHe5e62EEBMhxEQIMRFCTIQQEyHERAgxEULsOWqL8X3dZS78U0Om/599l1oJISZCiIkQYiKEmAghJkKIiRBiIoTY12PMoHnIXHjhUw/P3277RvghRxC86TdvJYSYCCEmQoiJEGIihJgIISZCiIkQYqffWb/9pepDvmvIC9xPvs7+pO0/16hnIayEEBMhxEQIMRFCTIQQEyHERAgxEULsLcfgn3yp+vY5/skN/vMPE1gYMscfws56uDERQkyEEBMhxEQIMRFCTIQQEyHEBr2zfsih5dcMGbvf+tGF7ebc22tWQoiJEGIihJgIISZCiIkQYiKEmAgh9vz+/j45ub5myLz75Bvhh5xaP+S4g5Pfdf4DrYQQEyHERAgxEUJMhBATIcRECDERQuz6O+sXtk9dT26RHvI287vsCs/desT/h5UQYiKEmAghJkKIiRBiIoSYCCEmQoi92Fk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YCCEmQoiJEGIvhvWf+q7wIfPuhZMPBgyZyC+cvAzH4MOvI0KIiRBiIoSYCCEmQoiJEGIihNhz/p5l+GxWQoj9D2II2FTI2au4AAAAAElFTkSuQmCC">
7 changes: 4 additions & 3 deletions tests/SpaydQrTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php declare(strict_types=1);
<?php

namespace PetrKnap\SpaydQr\Test;
declare(strict_types=1);

namespace PetrKnap\SpaydQr;

use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Builder\BuilderInterface;
use Endroid\QrCode\Writer\Result\ResultInterface;
use Endroid\QrCode\Writer\SvgWriter;
use Endroid\QrCode\Writer\WriterInterface;
use Money\Money;
use PetrKnap\SpaydQr\SpaydQr;
use PHPUnit\Framework\TestCase;
use Sunfox\Spayd\Spayd;

Expand Down

0 comments on commit 03e6ef3

Please sign in to comment.