From c76cbb7ef5ebc4cfa9346d0e7876ba4dd694ad5b Mon Sep 17 00:00:00 2001 From: TangRufus Date: Mon, 13 Oct 2025 04:53:13 +0100 Subject: [PATCH 1/3] Refactor: Move `ReleasesInterface` under `Releases` namespace --- src/Console/Mode.php | 2 +- src/Console/Source.php | 2 +- src/Matrix.php | 1 + src/Releases/OfflineReleases.php | 1 - src/Releases/PhpNetReleases.php | 1 - src/{ => Releases}/ReleasesInterface.php | 2 +- tests/Unit/MatrixTest.php | 2 +- tests/Unit/MinorOnlyMatrixTest.php | 2 +- tests/Unit/Releases/OfflineReleasesTest.php | 2 +- tests/Unit/Releases/PhpNetReleasesTest.php | 2 +- 10 files changed, 8 insertions(+), 9 deletions(-) rename src/{ => Releases}/ReleasesInterface.php (77%) diff --git a/src/Console/Mode.php b/src/Console/Mode.php index 6649afc..111d719 100644 --- a/src/Console/Mode.php +++ b/src/Console/Mode.php @@ -7,7 +7,7 @@ use TypistTech\PhpMatrix\Matrix; use TypistTech\PhpMatrix\MatrixInterface; use TypistTech\PhpMatrix\MinorOnlyMatrix; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; enum Mode: string { diff --git a/src/Console/Source.php b/src/Console/Source.php index 0d193cb..26b546d 100644 --- a/src/Console/Source.php +++ b/src/Console/Source.php @@ -6,7 +6,7 @@ use TypistTech\PhpMatrix\Releases\OfflineReleases; use TypistTech\PhpMatrix\Releases\PhpNetReleases; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; enum Source: string { diff --git a/src/Matrix.php b/src/Matrix.php index ce78757..4d70256 100644 --- a/src/Matrix.php +++ b/src/Matrix.php @@ -5,6 +5,7 @@ namespace TypistTech\PhpMatrix; use Composer\Semver\Semver; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; use UnexpectedValueException; readonly class Matrix implements MatrixInterface diff --git a/src/Releases/OfflineReleases.php b/src/Releases/OfflineReleases.php index 9a66b19..b8da6e4 100644 --- a/src/Releases/OfflineReleases.php +++ b/src/Releases/OfflineReleases.php @@ -5,7 +5,6 @@ namespace TypistTech\PhpMatrix\Releases; use TypistTech\PhpMatrix\Exceptions\RuntimeException; -use TypistTech\PhpMatrix\ReleasesInterface; class OfflineReleases implements ReleasesInterface { diff --git a/src/Releases/PhpNetReleases.php b/src/Releases/PhpNetReleases.php index f0f00a5..09cccde 100644 --- a/src/Releases/PhpNetReleases.php +++ b/src/Releases/PhpNetReleases.php @@ -8,7 +8,6 @@ use GuzzleHttp\ClientInterface; use GuzzleHttp\Promise\Utils; use Psr\Http\Message\ResponseInterface; -use TypistTech\PhpMatrix\ReleasesInterface; class PhpNetReleases implements ReleasesInterface { diff --git a/src/ReleasesInterface.php b/src/Releases/ReleasesInterface.php similarity index 77% rename from src/ReleasesInterface.php rename to src/Releases/ReleasesInterface.php index 49ac86d..a77bf10 100644 --- a/src/ReleasesInterface.php +++ b/src/Releases/ReleasesInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace TypistTech\PhpMatrix; +namespace TypistTech\PhpMatrix\Releases; interface ReleasesInterface { diff --git a/tests/Unit/MatrixTest.php b/tests/Unit/MatrixTest.php index aae6c50..bf1a489 100644 --- a/tests/Unit/MatrixTest.php +++ b/tests/Unit/MatrixTest.php @@ -8,7 +8,7 @@ use TypistTech\PhpMatrix\Exceptions\UnexpectedValueException; use TypistTech\PhpMatrix\Matrix; use TypistTech\PhpMatrix\MatrixInterface; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(Matrix::class); diff --git a/tests/Unit/MinorOnlyMatrixTest.php b/tests/Unit/MinorOnlyMatrixTest.php index ea2c76b..b6280ee 100644 --- a/tests/Unit/MinorOnlyMatrixTest.php +++ b/tests/Unit/MinorOnlyMatrixTest.php @@ -7,7 +7,7 @@ use Mockery; use TypistTech\PhpMatrix\MatrixInterface; use TypistTech\PhpMatrix\MinorOnlyMatrix; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(MinorOnlyMatrix::class); diff --git a/tests/Unit/Releases/OfflineReleasesTest.php b/tests/Unit/Releases/OfflineReleasesTest.php index 05eb4ef..c56c861 100644 --- a/tests/Unit/Releases/OfflineReleasesTest.php +++ b/tests/Unit/Releases/OfflineReleasesTest.php @@ -5,7 +5,7 @@ namespace Tests\Feature\Releases; use TypistTech\PhpMatrix\Releases\OfflineReleases; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(OfflineReleases::class); diff --git a/tests/Unit/Releases/PhpNetReleasesTest.php b/tests/Unit/Releases/PhpNetReleasesTest.php index 6b9f01f..b26c393 100644 --- a/tests/Unit/Releases/PhpNetReleasesTest.php +++ b/tests/Unit/Releases/PhpNetReleasesTest.php @@ -5,7 +5,7 @@ namespace Tests\Feature\Releases; use TypistTech\PhpMatrix\Releases\PhpNetReleases; -use TypistTech\PhpMatrix\ReleasesInterface; +use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(PhpNetReleases::class); From 85199548b929558b5b16df5d1578e844cfd2c2d3 Mon Sep 17 00:00:00 2001 From: TangRufus Date: Mon, 13 Oct 2025 04:59:32 +0100 Subject: [PATCH 2/3] Refactor: Move matrices under `Matrices` namespace --- src/Console/MatrixFactory.php | 2 +- src/Console/Mode.php | 6 +++--- src/{ => Matrices}/Matrix.php | 5 +++-- src/{ => Matrices}/MatrixInterface.php | 2 +- src/{ => Matrices}/MinorOnlyMatrix.php | 4 ++-- tests/Unit/{ => Matrices}/MatrixTest.php | 6 +++--- tests/Unit/{ => Matrices}/MinorOnlyMatrixTest.php | 6 +++--- 7 files changed, 16 insertions(+), 15 deletions(-) rename src/{ => Matrices}/Matrix.php (78%) rename src/{ => Matrices}/MatrixInterface.php (80%) rename src/{ => Matrices}/MinorOnlyMatrix.php (87%) rename tests/Unit/{ => Matrices}/MatrixTest.php (95%) rename tests/Unit/{ => Matrices}/MinorOnlyMatrixTest.php (94%) diff --git a/src/Console/MatrixFactory.php b/src/Console/MatrixFactory.php index 9888c53..5dd60b8 100644 --- a/src/Console/MatrixFactory.php +++ b/src/Console/MatrixFactory.php @@ -4,7 +4,7 @@ namespace TypistTech\PhpMatrix\Console; -use TypistTech\PhpMatrix\MatrixInterface; +use TypistTech\PhpMatrix\Matrices\MatrixInterface; class MatrixFactory { diff --git a/src/Console/Mode.php b/src/Console/Mode.php index 111d719..f29d3a1 100644 --- a/src/Console/Mode.php +++ b/src/Console/Mode.php @@ -4,9 +4,9 @@ namespace TypistTech\PhpMatrix\Console; -use TypistTech\PhpMatrix\Matrix; -use TypistTech\PhpMatrix\MatrixInterface; -use TypistTech\PhpMatrix\MinorOnlyMatrix; +use TypistTech\PhpMatrix\Matrices\Matrix; +use TypistTech\PhpMatrix\Matrices\MatrixInterface; +use TypistTech\PhpMatrix\Matrices\MinorOnlyMatrix; use TypistTech\PhpMatrix\Releases\ReleasesInterface; enum Mode: string diff --git a/src/Matrix.php b/src/Matrices/Matrix.php similarity index 78% rename from src/Matrix.php rename to src/Matrices/Matrix.php index 4d70256..479b7ec 100644 --- a/src/Matrix.php +++ b/src/Matrices/Matrix.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace TypistTech\PhpMatrix; +namespace TypistTech\PhpMatrix\Matrices; use Composer\Semver\Semver; +use TypistTech\PhpMatrix\Exceptions\UnexpectedValueException as AppUnexpectedValueException; use TypistTech\PhpMatrix\Releases\ReleasesInterface; use UnexpectedValueException; @@ -25,7 +26,7 @@ public function satisfiedBy(string $constraint): array $constraint ); } catch (UnexpectedValueException $e) { - throw new Exceptions\UnexpectedValueException( + throw new AppUnexpectedValueException( $e->getMessage(), previous: $e ); diff --git a/src/MatrixInterface.php b/src/Matrices/MatrixInterface.php similarity index 80% rename from src/MatrixInterface.php rename to src/Matrices/MatrixInterface.php index d673fdb..2c4b047 100644 --- a/src/MatrixInterface.php +++ b/src/Matrices/MatrixInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace TypistTech\PhpMatrix; +namespace TypistTech\PhpMatrix\Matrices; interface MatrixInterface { diff --git a/src/MinorOnlyMatrix.php b/src/Matrices/MinorOnlyMatrix.php similarity index 87% rename from src/MinorOnlyMatrix.php rename to src/Matrices/MinorOnlyMatrix.php index 14f1ae9..1c2b18f 100644 --- a/src/MinorOnlyMatrix.php +++ b/src/Matrices/MinorOnlyMatrix.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace TypistTech\PhpMatrix; +namespace TypistTech\PhpMatrix\Matrices; -readonly class MinorOnlyMatrix extends Matrix implements MatrixInterface +readonly class MinorOnlyMatrix extends Matrix { /** * @return string[] diff --git a/tests/Unit/MatrixTest.php b/tests/Unit/Matrices/MatrixTest.php similarity index 95% rename from tests/Unit/MatrixTest.php rename to tests/Unit/Matrices/MatrixTest.php index bf1a489..51cf2eb 100644 --- a/tests/Unit/MatrixTest.php +++ b/tests/Unit/Matrices/MatrixTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use Mockery; use TypistTech\PhpMatrix\Exceptions\UnexpectedValueException; -use TypistTech\PhpMatrix\Matrix; -use TypistTech\PhpMatrix\MatrixInterface; +use TypistTech\PhpMatrix\Matrices\Matrix; +use TypistTech\PhpMatrix\Matrices\MatrixInterface; use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(Matrix::class); diff --git a/tests/Unit/MinorOnlyMatrixTest.php b/tests/Unit/Matrices/MinorOnlyMatrixTest.php similarity index 94% rename from tests/Unit/MinorOnlyMatrixTest.php rename to tests/Unit/Matrices/MinorOnlyMatrixTest.php index b6280ee..44b419b 100644 --- a/tests/Unit/MinorOnlyMatrixTest.php +++ b/tests/Unit/Matrices/MinorOnlyMatrixTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use Mockery; -use TypistTech\PhpMatrix\MatrixInterface; -use TypistTech\PhpMatrix\MinorOnlyMatrix; +use TypistTech\PhpMatrix\Matrices\MatrixInterface; +use TypistTech\PhpMatrix\Matrices\MinorOnlyMatrix; use TypistTech\PhpMatrix\Releases\ReleasesInterface; covers(MinorOnlyMatrix::class); From 4c8c5820f38ab65e0af08f046ba7851f9e66a332 Mon Sep 17 00:00:00 2001 From: TangRufus Date: Mon, 13 Oct 2025 05:01:35 +0100 Subject: [PATCH 3/3] Fix namespaces in `tests/Unit` --- tests/Unit/ComposerTest.php | 2 +- tests/Unit/Releases/OfflineReleasesTest.php | 2 +- tests/Unit/Releases/PhpNetReleasesTest.php | 2 +- tests/Unit/VersionsTest.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Unit/ComposerTest.php b/tests/Unit/ComposerTest.php index 828071e..2b00899 100644 --- a/tests/Unit/ComposerTest.php +++ b/tests/Unit/ComposerTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use TypistTech\PhpMatrix\Composer; use TypistTech\PhpMatrix\Exceptions\InvalidArgumentException; diff --git a/tests/Unit/Releases/OfflineReleasesTest.php b/tests/Unit/Releases/OfflineReleasesTest.php index c56c861..7e1e994 100644 --- a/tests/Unit/Releases/OfflineReleasesTest.php +++ b/tests/Unit/Releases/OfflineReleasesTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use TypistTech\PhpMatrix\Releases\OfflineReleases; use TypistTech\PhpMatrix\Releases\ReleasesInterface; diff --git a/tests/Unit/Releases/PhpNetReleasesTest.php b/tests/Unit/Releases/PhpNetReleasesTest.php index b26c393..71d9f96 100644 --- a/tests/Unit/Releases/PhpNetReleasesTest.php +++ b/tests/Unit/Releases/PhpNetReleasesTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use TypistTech\PhpMatrix\Releases\PhpNetReleases; use TypistTech\PhpMatrix\Releases\ReleasesInterface; diff --git a/tests/Unit/VersionsTest.php b/tests/Unit/VersionsTest.php index cb18bcf..1fbc94d 100644 --- a/tests/Unit/VersionsTest.php +++ b/tests/Unit/VersionsTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Feature\Releases; +namespace Tests\Unit\Releases; use TypistTech\PhpMatrix\Versions; use UnexpectedValueException;