Skip to content

Commit 70bafb5

Browse files
authored
Release/1.2.0 (#13)
1 parent 8a29e21 commit 70bafb5

File tree

15 files changed

+187
-121
lines changed

15 files changed

+187
-121
lines changed

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/tests export-ignore
2+
/vendor export-ignore
3+
4+
/LICENSE export-ignore
5+
/Makefile export-ignore
6+
/README.md export-ignore
7+
/phpmd.xml export-ignore
8+
/phpunit.xml export-ignore
9+
/phpstan.neon.dist export-ignore
10+
/infection.json.dist export-ignore
11+
12+
/.github export-ignore
13+
/.gitignore export-ignore
14+
/.gitattributes export-ignore

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
- name: Checkout
1717
uses: actions/checkout@v3
1818

19+
- name: Use PHP 8.2
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: '8.2'
23+
1924
- name: Install dependencies
2025
run: composer update --no-progress --optimize-autoloader
2126

@@ -33,6 +38,11 @@ jobs:
3338
- name: Checkout
3439
uses: actions/checkout@v3
3540

41+
- name: Use PHP 8.2
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: '8.2'
45+
3646
- name: Install dependencies
3747
run: composer update --no-progress --optimize-autoloader
3848

Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
DOCKER_RUN = docker run --rm -it --net=host -v ${PWD}:/app -w /app gustavofreze/php:8.2
22

3-
.PHONY: configure test test-no-coverage review show-reports clean
3+
.PHONY: configure test test-file test-no-coverage review show-reports clean
44

55
configure:
66
@${DOCKER_RUN} composer update --optimize-autoloader
77

8-
test: review
8+
test:
99
@${DOCKER_RUN} composer tests
1010

11-
test-no-coverage: review
11+
test-file:
12+
@${DOCKER_RUN} composer tests-file-no-coverage ${FILE}
13+
14+
test-no-coverage:
1215
@${DOCKER_RUN} composer tests-no-coverage
1316

1417
review:
@@ -19,4 +22,4 @@ show-reports:
1922

2023
clean:
2124
@sudo chown -R ${USER}:${USER} ${PWD}
22-
@rm -rf report vendor
25+
@rm -rf report vendor .phpunit.cache

composer.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"minimum-stability": "stable",
99
"keywords": [
1010
"psr",
11-
"psr-4",
1211
"ksuid",
13-
"psr-12",
1412
"base62",
1513
"unique",
1614
"identifier",
@@ -22,6 +20,10 @@
2220
"homepage": "https://github.com/gustavofreze"
2321
}
2422
],
23+
"support": {
24+
"issues": "https://github.com/tiny-blocks/ksuid/issues",
25+
"source": "https://github.com/tiny-blocks/ksuid"
26+
},
2527
"config": {
2628
"sort-packages": true,
2729
"allow-plugins": {
@@ -39,28 +41,31 @@
3941
}
4042
},
4143
"require": {
42-
"php": "^8.1||^8.2",
43-
"tiny-blocks/encoder": "^1.2"
44+
"php": "^8.2",
45+
"tiny-blocks/encoder": "^2"
4446
},
4547
"require-dev": {
46-
"infection/infection": "^0.26",
47-
"phpmd/phpmd": "^2.13",
48-
"phpunit/phpunit": "^9.6",
49-
"squizlabs/php_codesniffer": "^3.7"
48+
"phpmd/phpmd": "^2.15",
49+
"phpunit/phpunit": "^11",
50+
"phpstan/phpstan": "^1",
51+
"infection/infection": "^0.29",
52+
"squizlabs/php_codesniffer": "^3.10"
5053
},
5154
"suggest": {
5255
"ext-gmp": "Enables faster math with arbitrary-precision integers using GMP."
5356
},
5457
"scripts": {
5558
"phpcs": "phpcs --standard=PSR12 --extensions=php ./src",
5659
"phpmd": "phpmd ./src text phpmd.xml --suffixes php --ignore-violations-on-exit",
60+
"phpstan": "phpstan analyse -c phpstan.neon.dist --quiet --no-progress",
5761
"test": "phpunit --log-junit=report/coverage/junit.xml --coverage-xml=report/coverage/coverage-xml --coverage-html=report/coverage/coverage-html tests",
5862
"test-mutation": "infection --only-covered --logger-html=report/coverage/mutation-report.html --coverage=report/coverage --min-msi=100 --min-covered-msi=100 --threads=4",
5963
"test-no-coverage": "phpunit --no-coverage",
6064
"test-mutation-no-coverage": "infection --only-covered --min-msi=100 --threads=4",
6165
"review": [
6266
"@phpcs",
63-
"@phpmd"
67+
"@phpmd",
68+
"@phpstan"
6469
],
6570
"tests": [
6671
"@test",

infection.json.dist

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
{
22
"timeout": 10,
33
"testFramework": "phpunit",
4-
"tmpDir": "report/",
4+
"tmpDir": "report/infection/",
55
"source": {
66
"directories": [
77
"src"
88
]
99
},
1010
"logs": {
11-
"text": "report/logs/infection-text.log",
12-
"summary": "report/logs/infection-summary.log"
11+
"text": "report/infection/logs/infection-text.log",
12+
"summary": "report/infection/logs/infection-summary.log"
1313
},
1414
"mutators": {
1515
"@default": true,
16-
"Plus": false,
1716
"Minus": false,
18-
"Concat": false,
19-
"CastArray": false,
20-
"GreaterThan": false,
21-
"UnwrapSubstr": false,
22-
"UnwrapStrRepeat": false,
23-
"IncrementInteger": false,
24-
"DecrementInteger": false,
25-
"PublicVisibility": false
17+
"CastArray": false
2618
},
2719
"phpUnit": {
2820
"configDir": "",
2921
"customPath": "./vendor/bin/phpunit"
3022
}
31-
}
23+
}

phpstan.neon.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
parameters:
2+
paths:
3+
- src
4+
level: 9
5+
tmpDir: report/phpstan
6+
ignoreErrors:
7+
- '#return type has no value type specified in iterable type array#'
8+
reportUnmatchedIgnoredErrors: false

phpunit.xml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
bootstrap="vendor/autoload.php"
4-
cacheResultFile="report/.phpunit.result.cache"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
74
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
11-
processIsolation="false"
12-
stopOnFailure="false"
13-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
5+
bootstrap="vendor/autoload.php"
6+
failOnRisky="true"
7+
failOnWarning="true"
8+
cacheDirectory=".phpunit.cache"
9+
beStrictAboutOutputDuringTests="true">
10+
11+
<source>
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
16+
1417
<testsuites>
1518
<testsuite name="default">
16-
<directory suffix="Test.php">tests</directory>
19+
<directory>tests</directory>
1720
</testsuite>
1821
</testsuites>
1922

2023
<coverage>
21-
<include>
22-
<directory suffix=".php">src</directory>
23-
</include>
24+
<report>
25+
<text outputFile="report/coverage.txt"/>
26+
<html outputDirectory="report/html/"/>
27+
<clover outputFile="report/coverage-clover.xml"/>
28+
</report>
2429
</coverage>
30+
31+
<logging>
32+
<junit outputFile="report/execution-result.xml"/>
33+
</logging>
34+
2535
</phpunit>

src/Internal/Exceptions/InvalidKsuidForInspection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Ksuid\Internal\Exceptions;
46

57
use RuntimeException;

src/Internal/Exceptions/InvalidPayloadSize.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Ksuid\Internal\Exceptions;
46

57
use RuntimeException;

src/Internal/Payload.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace TinyBlocks\Ksuid\Internal;
46

57
use TinyBlocks\Encoder\Base62;
68
use TinyBlocks\Ksuid\Internal\Exceptions\InvalidPayloadSize;
79

8-
final class Payload
10+
final readonly class Payload
911
{
1012
public const PAYLOAD_BYTES = 16;
1113

12-
private function __construct(private readonly string $value)
14+
private function __construct(private string $value)
1315
{
1416
$currentSize = strlen($value);
1517

@@ -30,7 +32,8 @@ public static function from(string $value): Payload
3032

3133
public static function fromBytes(string $value): Payload
3234
{
33-
$bytes = Base62::decode(value: $value);
35+
$decoder = Base62::from(value: $value);
36+
$bytes = $decoder->decode();
3437
$payload = substr($bytes, -self::PAYLOAD_BYTES);
3538

3639
return new Payload(value: $payload);

0 commit comments

Comments
 (0)