diff --git a/composer.json b/composer.json index 889f837..714e12e 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,11 @@ "psr/container": "^1.1 || ^2.0.0" }, "require-dev": { - "phpunit/phpunit": "^10.2", + "boundwize/structarmed": "^0.18.11", + "laminas/laminas-coding-standard": "^2.5", "phpstan/phpstan": "^2.1.33", "phpstan/phpstan-phpunit": "^2.0.10", - "laminas/laminas-coding-standard": "^2.5" + "phpunit/phpunit": "^10.2" }, "autoload": { "psr-4": { diff --git a/src/Totp.php b/src/Totp.php index bc450c3..e7ba0b4 100644 --- a/src/Totp.php +++ b/src/Totp.php @@ -190,7 +190,7 @@ public function generateRecoveryCodes(int $count = 8, int $length = 10, string $ public function hashRecoveryCodes(array $codes): array { - return array_map(fn($code) => password_hash($code, PASSWORD_DEFAULT), $codes); + return array_map(static fn($code) => password_hash($code, PASSWORD_DEFAULT), $codes); } public function validateRecoveryCode(string $inputCode, array &$hashedCodes): bool diff --git a/structarmed.php b/structarmed.php new file mode 100644 index 0000000..ba99065 --- /dev/null +++ b/structarmed.php @@ -0,0 +1,25 @@ +withPresets(Preset::PSR4(), Preset::CODEQUALITY()) + + ->layer('Totp', 'src/Totp.php') + ->layer('TotpFactory', 'src/TotpFactory.php') + ->layer('ConfigProvider', 'src/ConfigProvider.php') + ->ruleset([ + 'Totp' => [], + 'TotpFactory' => ['Totp'], + 'ConfigProvider' => ['+TotpFactory'], + ]) + + ->layer('tests', 'test') + ->rule( + 'tests_must_be_final', + new MustBeFinalRule(layer: 'tests') + ); diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index 96f189f..73aa791 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -9,7 +9,7 @@ use Dot\Totp\TotpFactory; use PHPUnit\Framework\TestCase; -class ConfigProviderTest extends TestCase +final class ConfigProviderTest extends TestCase { private ConfigProvider $provider; diff --git a/test/TotpFactoryTest.php b/test/TotpFactoryTest.php index 0131e97..063b6ec 100644 --- a/test/TotpFactoryTest.php +++ b/test/TotpFactoryTest.php @@ -11,7 +11,7 @@ use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; -class TotpFactoryTest extends TestCase +final class TotpFactoryTest extends TestCase { /** * @throws ContainerExceptionInterface diff --git a/test/TotpTest.php b/test/TotpTest.php index ac3770e..8481919 100644 --- a/test/TotpTest.php +++ b/test/TotpTest.php @@ -12,7 +12,7 @@ use function password_verify; use function strlen; -class TotpTest extends TestCase +final class TotpTest extends TestCase { public function testConstructorDefaults(): void {