From 4e3fd74b468faf895d2ff18be41390d5da0ceefe Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 8 Nov 2023 13:46:54 -0500 Subject: [PATCH 01/27] various changes --- bard.json | 24 ++++++++ composer.json | 61 ++++++++++++------- src/SonsOfPHP/Bard/composer.json | 8 +-- .../Bridge/Symfony/Cqrs/composer.json | 6 +- .../Symfony/EventSourcing/composer.json | 8 +-- src/SonsOfPHP/Bundle/Cqrs/composer.json | 6 +- src/SonsOfPHP/Component/Cache/composer.json | 8 +-- src/SonsOfPHP/Component/Cqrs/composer.json | 5 +- .../Component/EventSourcing/composer.json | 3 + .../Component/FeatureToggle/composer.json | 3 + .../Component/Filesystem/composer.json | 3 + .../Component/HttpMessage/composer.json | 4 +- src/SonsOfPHP/Component/Money/composer.json | 3 + src/SonsOfPHP/Component/Version/composer.json | 3 + src/SonsOfPHP/Contract/Core/composer.json | 5 +- src/SonsOfPHP/Contract/Cqrs/.gitattributes | 2 + src/SonsOfPHP/Contract/Cqrs/.gitignore | 2 + src/SonsOfPHP/Contract/Cqrs/LICENSE | 19 ++++++ src/SonsOfPHP/Contract/Cqrs/README.md | 16 +++++ src/SonsOfPHP/Contract/Cqrs/composer.json | 52 ++++++++++++++++ .../Contract/EventSourcing/.gitattributes | 2 + .../Contract/EventSourcing/.gitignore | 2 + src/SonsOfPHP/Contract/EventSourcing/LICENSE | 19 ++++++ .../Contract/EventSourcing/README.md | 16 +++++ .../Contract/EventSourcing/composer.json | 52 ++++++++++++++++ .../Contract/FeatureToggle/.gitattributes | 2 + .../Contract/FeatureToggle/.gitignore | 2 + src/SonsOfPHP/Contract/FeatureToggle/LICENSE | 19 ++++++ .../Contract/FeatureToggle/README.md | 16 +++++ .../Contract/FeatureToggle/composer.json | 52 ++++++++++++++++ .../Contract/Filesystem/.gitattributes | 2 + src/SonsOfPHP/Contract/Filesystem/.gitignore | 2 + src/SonsOfPHP/Contract/Filesystem/LICENSE | 19 ++++++ src/SonsOfPHP/Contract/Filesystem/README.md | 16 +++++ .../Contract/Filesystem/composer.json | 52 ++++++++++++++++ src/SonsOfPHP/Contract/Money/.gitattributes | 2 + src/SonsOfPHP/Contract/Money/.gitignore | 2 + src/SonsOfPHP/Contract/Money/LICENSE | 19 ++++++ src/SonsOfPHP/Contract/Money/README.md | 16 +++++ src/SonsOfPHP/Contract/Money/composer.json | 52 ++++++++++++++++ src/SonsOfPHP/Contract/Version/.gitattributes | 2 + src/SonsOfPHP/Contract/Version/.gitignore | 2 + src/SonsOfPHP/Contract/Version/LICENSE | 19 ++++++ src/SonsOfPHP/Contract/Version/README.md | 20 ++++++ src/SonsOfPHP/Contract/Version/composer.json | 52 ++++++++++++++++ 45 files changed, 653 insertions(+), 47 deletions(-) create mode 100644 src/SonsOfPHP/Contract/Cqrs/.gitattributes create mode 100644 src/SonsOfPHP/Contract/Cqrs/.gitignore create mode 100644 src/SonsOfPHP/Contract/Cqrs/LICENSE create mode 100644 src/SonsOfPHP/Contract/Cqrs/README.md create mode 100644 src/SonsOfPHP/Contract/Cqrs/composer.json create mode 100644 src/SonsOfPHP/Contract/EventSourcing/.gitattributes create mode 100644 src/SonsOfPHP/Contract/EventSourcing/.gitignore create mode 100644 src/SonsOfPHP/Contract/EventSourcing/LICENSE create mode 100644 src/SonsOfPHP/Contract/EventSourcing/README.md create mode 100644 src/SonsOfPHP/Contract/EventSourcing/composer.json create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/.gitattributes create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/.gitignore create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/LICENSE create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/README.md create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/composer.json create mode 100644 src/SonsOfPHP/Contract/Filesystem/.gitattributes create mode 100644 src/SonsOfPHP/Contract/Filesystem/.gitignore create mode 100644 src/SonsOfPHP/Contract/Filesystem/LICENSE create mode 100644 src/SonsOfPHP/Contract/Filesystem/README.md create mode 100644 src/SonsOfPHP/Contract/Filesystem/composer.json create mode 100644 src/SonsOfPHP/Contract/Money/.gitattributes create mode 100644 src/SonsOfPHP/Contract/Money/.gitignore create mode 100644 src/SonsOfPHP/Contract/Money/LICENSE create mode 100644 src/SonsOfPHP/Contract/Money/README.md create mode 100644 src/SonsOfPHP/Contract/Money/composer.json create mode 100644 src/SonsOfPHP/Contract/Version/.gitattributes create mode 100644 src/SonsOfPHP/Contract/Version/.gitignore create mode 100644 src/SonsOfPHP/Contract/Version/LICENSE create mode 100644 src/SonsOfPHP/Contract/Version/README.md create mode 100644 src/SonsOfPHP/Contract/Version/composer.json diff --git a/bard.json b/bard.json index cddcb915..6512d97f 100644 --- a/bard.json +++ b/bard.json @@ -73,6 +73,30 @@ { "path": "src/SonsOfPHP/Contract/Core", "repository": "git@github.com:SonsOfPHP/core-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/cqrs", + "repository": "git@github.com:SonsOfPHP/cqrs-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/EventSourcing", + "repository": "git@github.com:SonsOfPHP/event-sourcing-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/FeatureToggle", + "repository": "git@github.com:SonsOfPHP/feature-toggle-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/Filesystem", + "repository": "git@github.com:SonsOfPHP/filesystem-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/Money", + "repository": "git@github.com:SonsOfPHP/money-contract.git" + }, + { + "path": "src/SonsOfPHP/Contract/Version", + "repository": "git@github.com:SonsOfPHP/version-contract.git" } ] } diff --git a/composer.json b/composer.json index 482f7dec..e08b993a 100644 --- a/composer.json +++ b/composer.json @@ -34,30 +34,36 @@ "provide": { "psr/event-dispatcher-implementation": "1.0", "psr/clock-implementation": "1.0", - "psr/http-message-implementation": "^1.0|^2.0", + "psr/http-message-implementation": "^1.0 || ^2.0", "psr/http-factory-implementation": "^1.0", - "psr/cache-implementation": "^2.0|^3.0", - "psr/simple-cache-implementation": "^1.0|^2.0|^3.0" + "psr/cache-implementation": "^2.0 || ^3.0", + "psr/simple-cache-implementation": "^1.0 || ^2.0 || ^3.0", + "sonsofphp/cqrs-contract-implementation": "0.3.x-dev", + "sonsofphp/event-sourcing-contract-implementation": "0.3.x-dev", + "sonsofphp/feature-toggle-contract-implementation": "0.3.x-dev", + "sonsofphp/filesystem-contract-implementation": "0.3.x-dev", + "sonsofphp/money-contract-implementation": "0.3.x-dev", + "sonsofphp/version-contract-implementation": "0.3.x-dev" }, "require": { "php": ">=8.1", "ext-json": "*", "psr/event-dispatcher": "^1.0", "doctrine/dbal": "^3", - "symfony/options-resolver": "^5|^6", - "symfony/uid": "^5|^6", - "symfony/console": "^4|^5|^6", - "symfony/dotenv": "^5|^6", - "symfony/finder": "^5|^6", - "symfony/process": "^5|^6", - "symfony/dependency-injection": "^5|^6", - "symfony/http-kernel": "^5|^6", + "symfony/options-resolver": "^5 || ^6", + "symfony/uid": "^5 || ^6", + "symfony/console": "^4 || ^5 || ^6", + "symfony/dotenv": "^5 || ^6", + "symfony/finder": "^5 || ^6", + "symfony/process": "^5 || ^6", + "symfony/dependency-injection": "^5 || ^6", + "symfony/http-kernel": "^5 || ^6", "symfony/security-bundle": "^6", - "symfony/messenger": "^5|^6", + "symfony/messenger": "^5 || ^6", "psr/clock": "^1.0", - "psr/http-message": "^1.0|^2.0", + "psr/http-message": "^1.0 || ^2.0", "psr/http-factory": "^1.0", - "psr/cache": "^2.0|^3.0", + "psr/cache": "^2.0 || ^3.0", "psr/simple-cache": "^3.0" }, "replace": { @@ -78,7 +84,13 @@ "sonsofphp/http-message": "self.version", "sonsofphp/http-factory": "self.version", "sonsofphp/core-contract": "self.version", - "sonsofphp/cache": "self.version" + "sonsofphp/cache": "self.version", + "sonsofphp/cqrs-contract": "self.version", + "sonsofphp/event-sourcing-contract": "self.version", + "sonsofphp/feature-toggle-contract": "self.version", + "sonsofphp/filesystem-contract": "self.version", + "sonsofphp/money-contract": "self.version", + "sonsofphp/version-contract": "self.version" }, "autoload": { "psr-4": { @@ -99,7 +111,13 @@ "SonsOfPHP\\Component\\Json\\": "src/SonsOfPHP/Component/Json", "SonsOfPHP\\Component\\Money\\": "src/SonsOfPHP/Component/Money", "SonsOfPHP\\Component\\Version\\": "src/SonsOfPHP/Component/Version", - "SonsOfPHP\\Contract\\Core\\": "src/SonsOfPHP/Contract/Core" + "SonsOfPHP\\Contract\\Core\\": "src/SonsOfPHP/Contract/Core", + "SonsOfPHP\\Contract\\Cqrs\\": "src/SonsOfPHP/Contract/cqrs", + "SonsOfPHP\\Contract\\EventSourcing\\": "src/SonsOfPHP/Contract/EventSourcing", + "SonsOfPHP\\Contract\\FeatureToggle\\": "src/SonsOfPHP/Contract/FeatureToggle", + "SonsOfPHP\\Contract\\Filesystem\\": "src/SonsOfPHP/Contract/Filesystem", + "SonsOfPHP\\Contract\\Money\\": "src/SonsOfPHP/Contract/Money", + "SonsOfPHP\\Contract\\Version\\": "src/SonsOfPHP/Contract/Version" }, "exclude-from-classmap": [ "src/SonsOfPHP/Bard/Tests", @@ -118,8 +136,7 @@ "src/SonsOfPHP/Component/HttpMessage/Tests", "src/SonsOfPHP/Component/Json/Tests", "src/SonsOfPHP/Component/Money/Tests", - "src/SonsOfPHP/Component/Version/Tests", - "src/SonsOfPHP/Contract/Core/Tests" + "src/SonsOfPHP/Component/Version/Tests" ] }, "extra": { @@ -129,13 +146,13 @@ } }, "require-dev": { - "symfony/http-foundation": "^5|^6", - "symfony/serializer": "^5|^6", + "symfony/http-foundation": "^5 || ^6", + "symfony/serializer": "^5 || ^6", "symfony/phpunit-bridge": "^6", "symfony/error-handler": "^6", - "symfony/messenger": "^5|^6", + "symfony/messenger": "^5 || ^6", "phpunit/phpunit": "^10.4", - "psr/simple-cache": "^1.0|^2.0|^3.0" + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" }, "autoload-dev": { "psr-4": { diff --git a/src/SonsOfPHP/Bard/composer.json b/src/SonsOfPHP/Bard/composer.json index cc2c2a3a..f1d905b6 100644 --- a/src/SonsOfPHP/Bard/composer.json +++ b/src/SonsOfPHP/Bard/composer.json @@ -16,10 +16,10 @@ "sonsofphp/event-dispatcher": "^0.3.x-dev", "sonsofphp/json": "^0.3.x-dev", "sonsofphp/version": "^0.3.x-dev", - "symfony/console": "^4|^5|^6", - "symfony/dotenv": "^5|^6", - "symfony/finder": "^5|^6", - "symfony/process": "^5|^6" + "symfony/console": "^4 || ^5 || ^6", + "symfony/dotenv": "^5 || ^6", + "symfony/finder": "^5 || ^6", + "symfony/process": "^5 || ^6" }, "license": "MIT", "autoload": { diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/composer.json b/src/SonsOfPHP/Bridge/Symfony/Cqrs/composer.json index bbd0db81..4e1d571f 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/composer.json +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/composer.json @@ -39,10 +39,10 @@ "require": { "php": ">=8.1", "sonsofphp/cqrs": "^0.3.x-dev", - "symfony/options-resolver": "^5|^6" + "symfony/options-resolver": "^5 || ^6" }, "require-dev": { - "symfony/messenger": "^5|^6" + "symfony/messenger": "^5 || ^6" }, "extra": { "sort-packages": true, @@ -63,4 +63,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/composer.json b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/composer.json index 7a301dff..df70e14d 100644 --- a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/composer.json +++ b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/composer.json @@ -31,13 +31,13 @@ "require": { "php": ">=8.1", "sonsofphp/event-sourcing": "^0.3.x-dev", - "symfony/uid": "^5|^6", + "symfony/uid": "^5 || ^6", "symfony/security-bundle": "^6" }, "require-dev": { - "symfony/http-foundation": "^5|^6", - "symfony/messenger": "^5|^6", - "symfony/serializer": "^5|^6" + "symfony/http-foundation": "^5 || ^6", + "symfony/messenger": "^5 || ^6", + "symfony/serializer": "^5 || ^6" }, "extra": { "sort-packages": true, diff --git a/src/SonsOfPHP/Bundle/Cqrs/composer.json b/src/SonsOfPHP/Bundle/Cqrs/composer.json index 573f10a6..a8724774 100644 --- a/src/SonsOfPHP/Bundle/Cqrs/composer.json +++ b/src/SonsOfPHP/Bundle/Cqrs/composer.json @@ -39,9 +39,9 @@ "require": { "php": ">=8.1", "sonsofphp/cqrs": "^0.3.x-dev", - "symfony/dependency-injection": "^5|^6", - "symfony/http-kernel": "^5|^6", - "symfony/messenger": "^5|^6" + "symfony/dependency-injection": "^5 || ^6", + "symfony/http-kernel": "^5 || ^6", + "symfony/messenger": "^5 || ^6" }, "suggest": { "sonsofphp/event-sourcing": "Get some of that sweet ass event sourcing action" diff --git a/src/SonsOfPHP/Component/Cache/composer.json b/src/SonsOfPHP/Component/Cache/composer.json index dd1bbc8e..5126f2e8 100644 --- a/src/SonsOfPHP/Component/Cache/composer.json +++ b/src/SonsOfPHP/Component/Cache/composer.json @@ -33,17 +33,17 @@ "prefer-stable": true, "require": { "php": ">=8.1", - "psr/cache": "^2.0|^3.0" + "psr/cache": "^2.0 || ^3.0" }, "require-dev": { - "psr/simple-cache": "^1.0|^2.0|^3.0" + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" }, "suggest": { "sonsofphp/filesystem": "Stores cache files using virtual filesystem" }, "provide": { - "psr/cache-implementation": "^2.0|^3.0", - "psr/simple-cache-implementation": "^1.0|^2.0|^3.0" + "psr/cache-implementation": "^2.0 || ^3.0", + "psr/simple-cache-implementation": "^1.0 || ^2.0 || ^3.0" }, "extra": { "sort-packages": true, diff --git a/src/SonsOfPHP/Component/Cqrs/composer.json b/src/SonsOfPHP/Component/Cqrs/composer.json index d1cf7abd..2bdc29fb 100644 --- a/src/SonsOfPHP/Component/Cqrs/composer.json +++ b/src/SonsOfPHP/Component/Cqrs/composer.json @@ -36,7 +36,10 @@ "php": ">=8.1" }, "require-dev": { - "symfony/messenger": "^5|^6" + "symfony/messenger": "^5 || ^6" + }, + "provide": { + "sonsofphp/cqrs-contract-implementation": "0.3.x-dev" }, "suggest": { "sonsofphp/event-sourcing": "Use with event sourcing", diff --git a/src/SonsOfPHP/Component/EventSourcing/composer.json b/src/SonsOfPHP/Component/EventSourcing/composer.json index 8781c64c..15e88515 100644 --- a/src/SonsOfPHP/Component/EventSourcing/composer.json +++ b/src/SonsOfPHP/Component/EventSourcing/composer.json @@ -35,6 +35,9 @@ "require-dev": { "phpunit/phpunit": "^10.4" }, + "provide": { + "sonsofphp/event-sourcing-contract-implementation": "0.3.x-dev" + }, "suggest": { "sonsofphp/event-sourcing-doctrine": "Adds additional functionality using Doctrine", "sonsofphp/event-sourcing-symfony": "Adds additional functionality using Symfony Components" diff --git a/src/SonsOfPHP/Component/FeatureToggle/composer.json b/src/SonsOfPHP/Component/FeatureToggle/composer.json index e42d64e8..7dc43262 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/composer.json +++ b/src/SonsOfPHP/Component/FeatureToggle/composer.json @@ -37,6 +37,9 @@ "require": { "php": ">=8.1" }, + "provide": { + "sonsofphp/feature-toggle-contract-implementation": "0.3.x-dev" + }, "extra": { "sort-packages": true, "branch-alias": { diff --git a/src/SonsOfPHP/Component/Filesystem/composer.json b/src/SonsOfPHP/Component/Filesystem/composer.json index 83cf02d1..72f3238a 100644 --- a/src/SonsOfPHP/Component/Filesystem/composer.json +++ b/src/SonsOfPHP/Component/Filesystem/composer.json @@ -33,6 +33,9 @@ "require": { "php": ">=8.1" }, + "provide": { + "sonsofphp/filesystem-contract-implementation": "0.3.x-dev" + }, "extra": { "sort-packages": true, "branch-alias": { diff --git a/src/SonsOfPHP/Component/HttpMessage/composer.json b/src/SonsOfPHP/Component/HttpMessage/composer.json index 6b95b118..2aa5b69f 100644 --- a/src/SonsOfPHP/Component/HttpMessage/composer.json +++ b/src/SonsOfPHP/Component/HttpMessage/composer.json @@ -32,14 +32,14 @@ "prefer-stable": true, "require": { "php": ">=8.1", - "psr/http-message": "^1.0|^2.0" + "psr/http-message": "^1.0 || ^2.0" }, "suggest": { "sonsofphp/filesystem": "Managing Uploaded files", "sonsofphp/http-factory": "Create various HTTP Messages using factories (PSR-17)" }, "provide": { - "psr/http-message-implementation": "^1.0|^2.0" + "psr/http-message-implementation": "^1.0 || ^2.0" }, "extra": { "sort-packages": true, diff --git a/src/SonsOfPHP/Component/Money/composer.json b/src/SonsOfPHP/Component/Money/composer.json index 4ad74183..cd3f3998 100644 --- a/src/SonsOfPHP/Component/Money/composer.json +++ b/src/SonsOfPHP/Component/Money/composer.json @@ -34,6 +34,9 @@ "require": { "php": ">=8.1" }, + "provide": { + "sonsofphp/money-contract-implementation": "0.3.x-dev" + }, "extra": { "sort-packages": true, "branch-alias": { diff --git a/src/SonsOfPHP/Component/Version/composer.json b/src/SonsOfPHP/Component/Version/composer.json index 4dc1a71f..1842b02b 100644 --- a/src/SonsOfPHP/Component/Version/composer.json +++ b/src/SonsOfPHP/Component/Version/composer.json @@ -32,6 +32,9 @@ "require": { "php": ">=8.1" }, + "provide": { + "sonsofphp/version-contract-implementation": "0.3.x-dev" + }, "extra": { "sort-packages": true, "branch-alias": { diff --git a/src/SonsOfPHP/Contract/Core/composer.json b/src/SonsOfPHP/Contract/Core/composer.json index f8626186..9863cb66 100644 --- a/src/SonsOfPHP/Contract/Core/composer.json +++ b/src/SonsOfPHP/Contract/Core/composer.json @@ -26,10 +26,7 @@ "autoload": { "psr-4": { "SonsOfPHP\\Contract\\Core\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + } }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/src/SonsOfPHP/Contract/Cqrs/.gitattributes b/src/SonsOfPHP/Contract/Cqrs/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/Cqrs/.gitignore b/src/SonsOfPHP/Contract/Cqrs/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/Cqrs/LICENSE b/src/SonsOfPHP/Contract/Cqrs/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/Cqrs/README.md b/src/SonsOfPHP/Contract/Cqrs/README.md new file mode 100644 index 00000000..9a9eefc0 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/README.md @@ -0,0 +1,16 @@ +Sons of PHP - CQRS Contract +=========================== + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACqrs +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACqrs diff --git a/src/SonsOfPHP/Contract/Cqrs/composer.json b/src/SonsOfPHP/Contract/Cqrs/composer.json new file mode 100644 index 00000000..fec7bbd4 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/cqrs-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/cqrs-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\Cqrs\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file diff --git a/src/SonsOfPHP/Contract/EventSourcing/.gitattributes b/src/SonsOfPHP/Contract/EventSourcing/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/EventSourcing/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/EventSourcing/.gitignore b/src/SonsOfPHP/Contract/EventSourcing/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/EventSourcing/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/EventSourcing/LICENSE b/src/SonsOfPHP/Contract/EventSourcing/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/EventSourcing/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/EventSourcing/README.md b/src/SonsOfPHP/Contract/EventSourcing/README.md new file mode 100644 index 00000000..9a69cdc5 --- /dev/null +++ b/src/SonsOfPHP/Contract/EventSourcing/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Event Sourcing Contract +===================================== + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AEventSourcing +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AEventSourcing diff --git a/src/SonsOfPHP/Contract/EventSourcing/composer.json b/src/SonsOfPHP/Contract/EventSourcing/composer.json new file mode 100644 index 00000000..e800175c --- /dev/null +++ b/src/SonsOfPHP/Contract/EventSourcing/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/event-sourcing-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/event-sourcing-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\EventSourcing\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file diff --git a/src/SonsOfPHP/Contract/FeatureToggle/.gitattributes b/src/SonsOfPHP/Contract/FeatureToggle/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/FeatureToggle/.gitignore b/src/SonsOfPHP/Contract/FeatureToggle/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/FeatureToggle/LICENSE b/src/SonsOfPHP/Contract/FeatureToggle/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/FeatureToggle/README.md b/src/SonsOfPHP/Contract/FeatureToggle/README.md new file mode 100644 index 00000000..3e83359c --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Feature Toggle Contract +===================================== + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AFeatureToggle +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AFeatureToggle diff --git a/src/SonsOfPHP/Contract/FeatureToggle/composer.json b/src/SonsOfPHP/Contract/FeatureToggle/composer.json new file mode 100644 index 00000000..9a31921f --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/feature-toggle-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/feature-toggle-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\FeatureToggle\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file diff --git a/src/SonsOfPHP/Contract/Filesystem/.gitattributes b/src/SonsOfPHP/Contract/Filesystem/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/Filesystem/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/Filesystem/.gitignore b/src/SonsOfPHP/Contract/Filesystem/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/Filesystem/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/Filesystem/LICENSE b/src/SonsOfPHP/Contract/Filesystem/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Filesystem/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/Filesystem/README.md b/src/SonsOfPHP/Contract/Filesystem/README.md new file mode 100644 index 00000000..f7d4ac30 --- /dev/null +++ b/src/SonsOfPHP/Contract/Filesystem/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Filesystem Contract +================================= + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AFilesystem +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AFilesystem diff --git a/src/SonsOfPHP/Contract/Filesystem/composer.json b/src/SonsOfPHP/Contract/Filesystem/composer.json new file mode 100644 index 00000000..a0540438 --- /dev/null +++ b/src/SonsOfPHP/Contract/Filesystem/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/filesystem-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/filesystem-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\Filesystem\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file diff --git a/src/SonsOfPHP/Contract/Money/.gitattributes b/src/SonsOfPHP/Contract/Money/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/Money/.gitignore b/src/SonsOfPHP/Contract/Money/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/Money/LICENSE b/src/SonsOfPHP/Contract/Money/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/Money/README.md b/src/SonsOfPHP/Contract/Money/README.md new file mode 100644 index 00000000..5cf12d2b --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Money Contract +============================ + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AMoney +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AMoney diff --git a/src/SonsOfPHP/Contract/Money/composer.json b/src/SonsOfPHP/Contract/Money/composer.json new file mode 100644 index 00000000..9b352f32 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/money-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/money-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\Money\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file diff --git a/src/SonsOfPHP/Contract/Version/.gitattributes b/src/SonsOfPHP/Contract/Version/.gitattributes new file mode 100644 index 00000000..3a01b372 --- /dev/null +++ b/src/SonsOfPHP/Contract/Version/.gitattributes @@ -0,0 +1,2 @@ +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Contract/Version/.gitignore b/src/SonsOfPHP/Contract/Version/.gitignore new file mode 100644 index 00000000..d8a7996a --- /dev/null +++ b/src/SonsOfPHP/Contract/Version/.gitignore @@ -0,0 +1,2 @@ +composer.lock +vendor/ diff --git a/src/SonsOfPHP/Contract/Version/LICENSE b/src/SonsOfPHP/Contract/Version/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Version/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/Version/README.md b/src/SonsOfPHP/Contract/Version/README.md new file mode 100644 index 00000000..9f91994c --- /dev/null +++ b/src/SonsOfPHP/Contract/Version/README.md @@ -0,0 +1,20 @@ +Sons of PHP - Core Contract +=========================== + +Core Contracts include very generic interfaces that can be used across many +different libraries. These would be the missing PHP interfaces that would be +helpful. + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-message/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACore +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACore diff --git a/src/SonsOfPHP/Contract/Version/composer.json b/src/SonsOfPHP/Contract/Version/composer.json new file mode 100644 index 00000000..c2aa9834 --- /dev/null +++ b/src/SonsOfPHP/Contract/Version/composer.json @@ -0,0 +1,52 @@ +{ + "name": "sonsofphp/version-contract", + "type": "library", + "description": "", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/version-contract", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Contract\\Version\\": "" + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} \ No newline at end of file From 6eee8e3f212151af74c05f8843fb2aa6a5864545 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 8 Nov 2023 14:03:49 -0500 Subject: [PATCH 02/27] more changes --- .github/CODEOWNERS | 2 +- .github/labeler.yml | 6 +- bard.json | 10 +++- composer.json | 7 ++- docs/contracts/{core => common}/index.md | 0 mkdocs.yml | 2 +- src/SonsOfPHP/Component/Common/.gitattributes | 4 ++ src/SonsOfPHP/Component/Common/.gitignore | 3 + .../Core => Component/Common}/LICENSE | 0 src/SonsOfPHP/Component/Common/README.md | 16 +++++ src/SonsOfPHP/Component/Common/composer.json | 58 +++++++++++++++++++ .../Contract/{Core => Common}/.gitattributes | 0 .../Contract/{Core => Common}/.gitignore | 0 .../{Core => Common}/ComparableInterface.php | 2 +- .../{Core => Common}/EquatableInterface.php | 2 +- src/SonsOfPHP/Contract/Common/LICENSE | 19 ++++++ .../Contract/{Core => Common}/README.md | 10 ++-- .../Contract/{Core => Common}/composer.json | 8 +-- src/SonsOfPHP/Contract/Version/README.md | 12 ++-- 19 files changed, 133 insertions(+), 28 deletions(-) rename docs/contracts/{core => common}/index.md (100%) create mode 100644 src/SonsOfPHP/Component/Common/.gitattributes create mode 100644 src/SonsOfPHP/Component/Common/.gitignore rename src/SonsOfPHP/{Contract/Core => Component/Common}/LICENSE (100%) create mode 100644 src/SonsOfPHP/Component/Common/README.md create mode 100644 src/SonsOfPHP/Component/Common/composer.json rename src/SonsOfPHP/Contract/{Core => Common}/.gitattributes (100%) rename src/SonsOfPHP/Contract/{Core => Common}/.gitignore (100%) rename src/SonsOfPHP/Contract/{Core => Common}/ComparableInterface.php (91%) rename src/SonsOfPHP/Contract/{Core => Common}/EquatableInterface.php (95%) create mode 100644 src/SonsOfPHP/Contract/Common/LICENSE rename src/SonsOfPHP/Contract/{Core => Common}/README.md (77%) rename src/SonsOfPHP/Contract/{Core => Common}/composer.json (82%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8fa1a3b0..9657a4b8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -32,4 +32,4 @@ /src/SonsOfPHP/Component/PhoneNumber @JoshuaEstes /src/SonsOfPHP/Component/Queue @JoshuaEstes /src/SonsOfPHP/Component/Version @JoshuaEstes -/src/SonsOfPHP/Contract/Core @JoshuaEstes +/src/SonsOfPHP/Contract/Common @JoshuaEstes diff --git a/.github/labeler.yml b/.github/labeler.yml index 19f9df10..9e514c2d 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -8,7 +8,11 @@ Cache: Clock: - docs/components/clock/* - - src/SonsOfPHP/Component/Clock/* + - src/SonsOfPHP/**/Clock/* + +Common: + - docs/components/common/* + - src/SonsOfPHP/**/Common/* CQRS: - docs/components/cqrs/* diff --git a/bard.json b/bard.json index 6512d97f..a2b03472 100644 --- a/bard.json +++ b/bard.json @@ -13,6 +13,10 @@ "path": "src/SonsOfPHP/Component/Clock", "repository": "git@github.com:SonsOfPHP/clock.git" }, + { + "path": "src/SonsOfPHP/Component/Common", + "repository": "git@github.com:SonsOfPHP/common.git" + }, { "path": "src/SonsOfPHP/Component/Cqrs", "repository": "git@github.com:SonsOfPHP/cqrs.git" @@ -71,11 +75,11 @@ "repository": "git@github.com:SonsOfPHP/version.git" }, { - "path": "src/SonsOfPHP/Contract/Core", - "repository": "git@github.com:SonsOfPHP/core-contract.git" + "path": "src/SonsOfPHP/Contract/Common", + "repository": "git@github.com:SonsOfPHP/common-contract.git" }, { - "path": "src/SonsOfPHP/Contract/cqrs", + "path": "src/SonsOfPHP/Contract/Cqrs", "repository": "git@github.com:SonsOfPHP/cqrs-contract.git" }, { diff --git a/composer.json b/composer.json index e08b993a..571142e8 100644 --- a/composer.json +++ b/composer.json @@ -90,7 +90,8 @@ "sonsofphp/feature-toggle-contract": "self.version", "sonsofphp/filesystem-contract": "self.version", "sonsofphp/money-contract": "self.version", - "sonsofphp/version-contract": "self.version" + "sonsofphp/version-contract": "self.version", + "sonsofphp/common-contract": "self.version" }, "autoload": { "psr-4": { @@ -111,8 +112,8 @@ "SonsOfPHP\\Component\\Json\\": "src/SonsOfPHP/Component/Json", "SonsOfPHP\\Component\\Money\\": "src/SonsOfPHP/Component/Money", "SonsOfPHP\\Component\\Version\\": "src/SonsOfPHP/Component/Version", - "SonsOfPHP\\Contract\\Core\\": "src/SonsOfPHP/Contract/Core", - "SonsOfPHP\\Contract\\Cqrs\\": "src/SonsOfPHP/Contract/cqrs", + "SonsOfPHP\\Contract\\Common\\": "src/SonsOfPHP/Contract/Common", + "SonsOfPHP\\Contract\\Cqrs\\": "src/SonsOfPHP/Contract/Cqrs", "SonsOfPHP\\Contract\\EventSourcing\\": "src/SonsOfPHP/Contract/EventSourcing", "SonsOfPHP\\Contract\\FeatureToggle\\": "src/SonsOfPHP/Contract/FeatureToggle", "SonsOfPHP\\Contract\\Filesystem\\": "src/SonsOfPHP/Contract/Filesystem", diff --git a/docs/contracts/core/index.md b/docs/contracts/common/index.md similarity index 100% rename from docs/contracts/core/index.md rename to docs/contracts/common/index.md diff --git a/mkdocs.yml b/mkdocs.yml index 2aebec9f..4dc6fb75 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -118,4 +118,4 @@ nav: - Version: components/version/index.md - Contracts: - contracts/index.md - - Core: contracts/core/index.md + - Common: contracts/common/index.md diff --git a/src/SonsOfPHP/Component/Common/.gitattributes b/src/SonsOfPHP/Component/Common/.gitattributes new file mode 100644 index 00000000..84c7add0 --- /dev/null +++ b/src/SonsOfPHP/Component/Common/.gitattributes @@ -0,0 +1,4 @@ +/Tests export-ignore +/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/SonsOfPHP/Component/Common/.gitignore b/src/SonsOfPHP/Component/Common/.gitignore new file mode 100644 index 00000000..5414c2c6 --- /dev/null +++ b/src/SonsOfPHP/Component/Common/.gitignore @@ -0,0 +1,3 @@ +composer.lock +phpunit.xml +vendor/ diff --git a/src/SonsOfPHP/Contract/Core/LICENSE b/src/SonsOfPHP/Component/Common/LICENSE similarity index 100% rename from src/SonsOfPHP/Contract/Core/LICENSE rename to src/SonsOfPHP/Component/Common/LICENSE diff --git a/src/SonsOfPHP/Component/Common/README.md b/src/SonsOfPHP/Component/Common/README.md new file mode 100644 index 00000000..1fbb905a --- /dev/null +++ b/src/SonsOfPHP/Component/Common/README.md @@ -0,0 +1,16 @@ +Sons of PHP - Common +==================== + +## Learn More + +* [Documentation][docs] +* [Contributing][contributing] +* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] +* Get Help & Support using [Discussions][discussions] + +[discussions]: https://github.com/orgs/SonsOfPHP/discussions +[mother-repo]: https://github.com/SonsOfPHP/sonsofphp +[contributing]: https://docs.sonsofphp.com/contributing/ +[docs]: https://docs.sonsofphp.com/components/http-factory/ +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACommon +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACommon diff --git a/src/SonsOfPHP/Component/Common/composer.json b/src/SonsOfPHP/Component/Common/composer.json new file mode 100644 index 00000000..762647b9 --- /dev/null +++ b/src/SonsOfPHP/Component/Common/composer.json @@ -0,0 +1,58 @@ +{ + "name": "sonsofphp/common", + "type": "library", + "description": "Common code that is not specific to any one library, but is used by all", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "homepage": "https://github.com/SonsOfPHP/common", + "license": "MIT", + "authors": [ + { + "name": "Joshua Estes", + "email": "joshua@sonsofphp.com" + } + ], + "support": { + "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", + "forum": "https://github.com/orgs/SonsOfPHP/discussions", + "docs": "https://docs.sonsofphp.com" + }, + "autoload": { + "psr-4": { + "SonsOfPHP\\Component\\Common\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1", + }, + "provide": { + "sonsofphp/common-contract-implementation": "^1.0" + }, + "extra": { + "sort-packages": true, + "branch-alias": { + "dev-main": "0.3.x-dev" + } + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/JoshuaEstes" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" + } + ] +} diff --git a/src/SonsOfPHP/Contract/Core/.gitattributes b/src/SonsOfPHP/Contract/Common/.gitattributes similarity index 100% rename from src/SonsOfPHP/Contract/Core/.gitattributes rename to src/SonsOfPHP/Contract/Common/.gitattributes diff --git a/src/SonsOfPHP/Contract/Core/.gitignore b/src/SonsOfPHP/Contract/Common/.gitignore similarity index 100% rename from src/SonsOfPHP/Contract/Core/.gitignore rename to src/SonsOfPHP/Contract/Common/.gitignore diff --git a/src/SonsOfPHP/Contract/Core/ComparableInterface.php b/src/SonsOfPHP/Contract/Common/ComparableInterface.php similarity index 91% rename from src/SonsOfPHP/Contract/Core/ComparableInterface.php rename to src/SonsOfPHP/Contract/Common/ComparableInterface.php index c28e2ffe..a3e4811a 100644 --- a/src/SonsOfPHP/Contract/Core/ComparableInterface.php +++ b/src/SonsOfPHP/Contract/Common/ComparableInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Core; +namespace SonsOfPHP\Contract\Common; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Core/EquatableInterface.php b/src/SonsOfPHP/Contract/Common/EquatableInterface.php similarity index 95% rename from src/SonsOfPHP/Contract/Core/EquatableInterface.php rename to src/SonsOfPHP/Contract/Common/EquatableInterface.php index 295eb59a..c171bca9 100644 --- a/src/SonsOfPHP/Contract/Core/EquatableInterface.php +++ b/src/SonsOfPHP/Contract/Common/EquatableInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Core; +namespace SonsOfPHP\Contract\Common; /** * Equatable Interface is used for objects that can be checked to see if they diff --git a/src/SonsOfPHP/Contract/Common/LICENSE b/src/SonsOfPHP/Contract/Common/LICENSE new file mode 100644 index 00000000..39238382 --- /dev/null +++ b/src/SonsOfPHP/Contract/Common/LICENSE @@ -0,0 +1,19 @@ +Copyright 2022 to Present Joshua Estes + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/SonsOfPHP/Contract/Core/README.md b/src/SonsOfPHP/Contract/Common/README.md similarity index 77% rename from src/SonsOfPHP/Contract/Core/README.md rename to src/SonsOfPHP/Contract/Common/README.md index 9f91994c..b27823ec 100644 --- a/src/SonsOfPHP/Contract/Core/README.md +++ b/src/SonsOfPHP/Contract/Common/README.md @@ -1,7 +1,7 @@ -Sons of PHP - Core Contract -=========================== +Sons of PHP - Common Contract +============================= -Core Contracts include very generic interfaces that can be used across many +Common Contracts include very generic interfaces that can be used across many different libraries. These would be the missing PHP interfaces that would be helpful. @@ -16,5 +16,5 @@ helpful. [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ [docs]: https://docs.sonsofphp.com/components/http-message/ -[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACore -[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACore +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACommon +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACommon diff --git a/src/SonsOfPHP/Contract/Core/composer.json b/src/SonsOfPHP/Contract/Common/composer.json similarity index 82% rename from src/SonsOfPHP/Contract/Core/composer.json rename to src/SonsOfPHP/Contract/Common/composer.json index 9863cb66..9fcbe5dc 100644 --- a/src/SonsOfPHP/Contract/Core/composer.json +++ b/src/SonsOfPHP/Contract/Common/composer.json @@ -1,7 +1,7 @@ { - "name": "sonsofphp/core-contract", + "name": "sonsofphp/common-contract", "type": "library", - "description": "Core Contracts that are not specific to any one library", + "description": "Common Contracts that are not specific to any one library", "keywords": [ "abstractions", "contracts", @@ -10,7 +10,7 @@ "interoperability", "standards" ], - "homepage": "https://github.com/SonsOfPHP/core-contract", + "homepage": "https://github.com/SonsOfPHP/common-contract", "license": "MIT", "authors": [ { @@ -25,7 +25,7 @@ }, "autoload": { "psr-4": { - "SonsOfPHP\\Contract\\Core\\": "" + "SonsOfPHP\\Contract\\Common\\": "" } }, "minimum-stability": "dev", diff --git a/src/SonsOfPHP/Contract/Version/README.md b/src/SonsOfPHP/Contract/Version/README.md index 9f91994c..a2ac25ec 100644 --- a/src/SonsOfPHP/Contract/Version/README.md +++ b/src/SonsOfPHP/Contract/Version/README.md @@ -1,9 +1,5 @@ -Sons of PHP - Core Contract -=========================== - -Core Contracts include very generic interfaces that can be used across many -different libraries. These would be the missing PHP interfaces that would be -helpful. +Sons of PHP - Version Contract +=============================== ## Learn More @@ -16,5 +12,5 @@ helpful. [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ [docs]: https://docs.sonsofphp.com/components/http-message/ -[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACore -[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACore +[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AVersion +[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AVersion From 6902053eec8bcc1dd402f8e7c80d54313630eaad Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 8 Nov 2023 14:17:00 -0500 Subject: [PATCH 03/27] more common interfaces --- bard.json | 4 -- src/SonsOfPHP/Component/Common/.gitattributes | 4 -- src/SonsOfPHP/Component/Common/.gitignore | 3 - src/SonsOfPHP/Component/Common/LICENSE | 19 ------ src/SonsOfPHP/Component/Common/README.md | 16 ----- src/SonsOfPHP/Component/Common/composer.json | 58 ------------------- .../Contract/Common/ArrayableInterface.php | 15 +++++ .../Contract/Common/JsonableInterface.php | 18 ++++++ 8 files changed, 33 insertions(+), 104 deletions(-) delete mode 100644 src/SonsOfPHP/Component/Common/.gitattributes delete mode 100644 src/SonsOfPHP/Component/Common/.gitignore delete mode 100644 src/SonsOfPHP/Component/Common/LICENSE delete mode 100644 src/SonsOfPHP/Component/Common/README.md delete mode 100644 src/SonsOfPHP/Component/Common/composer.json create mode 100644 src/SonsOfPHP/Contract/Common/ArrayableInterface.php create mode 100644 src/SonsOfPHP/Contract/Common/JsonableInterface.php diff --git a/bard.json b/bard.json index a2b03472..1b2131d0 100644 --- a/bard.json +++ b/bard.json @@ -13,10 +13,6 @@ "path": "src/SonsOfPHP/Component/Clock", "repository": "git@github.com:SonsOfPHP/clock.git" }, - { - "path": "src/SonsOfPHP/Component/Common", - "repository": "git@github.com:SonsOfPHP/common.git" - }, { "path": "src/SonsOfPHP/Component/Cqrs", "repository": "git@github.com:SonsOfPHP/cqrs.git" diff --git a/src/SonsOfPHP/Component/Common/.gitattributes b/src/SonsOfPHP/Component/Common/.gitattributes deleted file mode 100644 index 84c7add0..00000000 --- a/src/SonsOfPHP/Component/Common/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/Tests export-ignore -/phpunit.xml.dist export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore diff --git a/src/SonsOfPHP/Component/Common/.gitignore b/src/SonsOfPHP/Component/Common/.gitignore deleted file mode 100644 index 5414c2c6..00000000 --- a/src/SonsOfPHP/Component/Common/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -composer.lock -phpunit.xml -vendor/ diff --git a/src/SonsOfPHP/Component/Common/LICENSE b/src/SonsOfPHP/Component/Common/LICENSE deleted file mode 100644 index 39238382..00000000 --- a/src/SonsOfPHP/Component/Common/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2022 to Present Joshua Estes - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/SonsOfPHP/Component/Common/README.md b/src/SonsOfPHP/Component/Common/README.md deleted file mode 100644 index 1fbb905a..00000000 --- a/src/SonsOfPHP/Component/Common/README.md +++ /dev/null @@ -1,16 +0,0 @@ -Sons of PHP - Common -==================== - -## Learn More - -* [Documentation][docs] -* [Contributing][contributing] -* [Report Issues][issues] and [Submit Pull Requests][pull-requests] in the [Mother Repository][mother-repo] -* Get Help & Support using [Discussions][discussions] - -[discussions]: https://github.com/orgs/SonsOfPHP/discussions -[mother-repo]: https://github.com/SonsOfPHP/sonsofphp -[contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-factory/ -[issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACommon -[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACommon diff --git a/src/SonsOfPHP/Component/Common/composer.json b/src/SonsOfPHP/Component/Common/composer.json deleted file mode 100644 index 762647b9..00000000 --- a/src/SonsOfPHP/Component/Common/composer.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "sonsofphp/common", - "type": "library", - "description": "Common code that is not specific to any one library, but is used by all", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "homepage": "https://github.com/SonsOfPHP/common", - "license": "MIT", - "authors": [ - { - "name": "Joshua Estes", - "email": "joshua@sonsofphp.com" - } - ], - "support": { - "issues": "https://github.com/SonsOfPHP/sonsofphp/issues", - "forum": "https://github.com/orgs/SonsOfPHP/discussions", - "docs": "https://docs.sonsofphp.com" - }, - "autoload": { - "psr-4": { - "SonsOfPHP\\Component\\Common\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev", - "prefer-stable": true, - "require": { - "php": ">=8.1", - }, - "provide": { - "sonsofphp/common-contract-implementation": "^1.0" - }, - "extra": { - "sort-packages": true, - "branch-alias": { - "dev-main": "0.3.x-dev" - } - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/JoshuaEstes" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" - } - ] -} diff --git a/src/SonsOfPHP/Contract/Common/ArrayableInterface.php b/src/SonsOfPHP/Contract/Common/ArrayableInterface.php new file mode 100644 index 00000000..1771476a --- /dev/null +++ b/src/SonsOfPHP/Contract/Common/ArrayableInterface.php @@ -0,0 +1,15 @@ + + */ +interface ArrayableInterface +{ + /** + */ + public function toArray(): array; +} diff --git a/src/SonsOfPHP/Contract/Common/JsonableInterface.php b/src/SonsOfPHP/Contract/Common/JsonableInterface.php new file mode 100644 index 00000000..431c4203 --- /dev/null +++ b/src/SonsOfPHP/Contract/Common/JsonableInterface.php @@ -0,0 +1,18 @@ + + */ +interface JsonableInterface +{ + /** + * Returns a json string of the object + * + * @see https://www.php.net/json_encode + */ + public function toJson(int $flags = 0, int $depth = 512): string; +} From 638d6fb434dfc50ca0d8a0cb17d9b8a2329d1711 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 8 Nov 2023 15:33:52 -0500 Subject: [PATCH 04/27] various changes, needs testing --- .../AbstractOptionsResolverCommandMessage.php | 2 +- ...tractOptionsResolverCommandMessageTest.php | 2 +- .../Component/Cqrs/AbstractMessage.php | 64 +++++++++++++++++++ .../AbstractCommandMessage.php} | 6 +- .../Command/AbstractCommandMessageHandler.php | 15 +++++ .../CommandMessageHandlerInterface.php | 12 ---- .../AbstractQueryMessage.php} | 4 +- .../Query/AbstractQueryMessageHandler.php | 15 +++++ .../Query/QueryMessageHandlerInterface.php | 12 ---- .../CommandMessageHandlerInterface.php | 15 +++++ .../Cqrs/Command/CommandMessageInterface.php | 4 +- .../Cqrs/Exception/CqrsExceptionInterface.php | 14 ++++ .../Contract/Cqrs/MessageHandlerInterface.php | 13 ++++ .../Contract/Cqrs/MessageInterface.php | 61 ++++++++++++++++++ .../Query/QueryMessageHandlerInterface.php | 15 +++++ .../Cqrs/Query/QueryMessageInterface.php | 4 +- 16 files changed, 224 insertions(+), 34 deletions(-) create mode 100644 src/SonsOfPHP/Component/Cqrs/AbstractMessage.php rename src/SonsOfPHP/Component/Cqrs/{MessageInterface.php => Command/AbstractCommandMessage.php} (52%) create mode 100644 src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php delete mode 100644 src/SonsOfPHP/Component/Cqrs/Command/CommandMessageHandlerInterface.php rename src/SonsOfPHP/Component/Cqrs/{MessageHandlerInterface.php => Query/AbstractQueryMessage.php} (53%) create mode 100644 src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php delete mode 100644 src/SonsOfPHP/Component/Cqrs/Query/QueryMessageHandlerInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php rename src/SonsOfPHP/{Component => Contract}/Cqrs/Command/CommandMessageInterface.php (62%) create mode 100644 src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/MessageInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php rename src/SonsOfPHP/{Component => Contract}/Cqrs/Query/QueryMessageInterface.php (62%) diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php index 80e0ce16..348f9514 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php @@ -4,7 +4,7 @@ namespace SonsOfPHP\Bridge\Symfony\Cqrs\Command; -use SonsOfPHP\Component\Cqrs\Command\CommandMessageInterface; +use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; use Symfony\Component\OptionsResolver\OptionsResolver; /** diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php index bf2178e8..f9abc4bb 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage; use SonsOfPHP\Bridge\Symfony\Cqrs\Tests\DummyCommand; -use SonsOfPHP\Component\Cqrs\Command\CommandMessageInterface; +use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; /** * @coversDefaultClass \SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage diff --git a/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php new file mode 100644 index 00000000..8b153d05 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php @@ -0,0 +1,64 @@ + + */ +abstract class AbstractMessage implements MessageInterface, \JsonSerializable, \Serializable +{ + private array $payload = []; + + public function with(string|array $key, mixed $value): static + { + if (is_array($key)) { + $that = clone $this; + $that->payload = $key; + + return $that; + } + + if (array_key_exists($key, $this->payload) && $value === $this->payload[$key]) { + return $this; + } + + $that = clone $this; + $that->payload[$key] = $value; + + return $that; + } + + public function get(?string $key = null): mixed + { + if (null === $key) { + return $this->payload; + } + + if (!array_key_exists($key, $this->payload)) { + throw new \Exception(sprintf('The key "%s" does not exist.', $key)); + } + } + + public function serialize(): ?string + { + if (false === $json = json_encode($this)) { + throw new \Exception('Unable to serialize object'); + } + + return $json; + } + + public function unserialize(string $data): void + { + $this->payload = json_decode($data, true); + } + + public function jsonSerialize(): array + { + return $this->payload; + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/MessageInterface.php b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php similarity index 52% rename from src/SonsOfPHP/Component/Cqrs/MessageInterface.php rename to src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php index 1a6cdc52..c291d45c 100644 --- a/src/SonsOfPHP/Component/Cqrs/MessageInterface.php +++ b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php @@ -4,9 +4,9 @@ namespace SonsOfPHP\Component\Cqrs; +use SonsOfPHP\Component\Cqrs\AbstractMessage; + /** - * Both Command and Queries implement this. - * * @author Joshua Estes */ -interface MessageInterface {} +abstract class AbstractCommandMessage extends AbstractMessage {} diff --git a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php new file mode 100644 index 00000000..f3ccf788 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php @@ -0,0 +1,15 @@ + + */ +abstract class AbstractCommandMessageHandler implements CommandMessageHandlerInterface +{ + abstract public function __invoke(CommandMessageInterface $message): void; +} diff --git a/src/SonsOfPHP/Component/Cqrs/Command/CommandMessageHandlerInterface.php b/src/SonsOfPHP/Component/Cqrs/Command/CommandMessageHandlerInterface.php deleted file mode 100644 index 4fa7b7f5..00000000 --- a/src/SonsOfPHP/Component/Cqrs/Command/CommandMessageHandlerInterface.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -interface CommandMessageHandlerInterface extends MessageHandlerInterface {} diff --git a/src/SonsOfPHP/Component/Cqrs/MessageHandlerInterface.php b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php similarity index 53% rename from src/SonsOfPHP/Component/Cqrs/MessageHandlerInterface.php rename to src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php index 8832cad5..68d90cef 100644 --- a/src/SonsOfPHP/Component/Cqrs/MessageHandlerInterface.php +++ b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php @@ -4,7 +4,9 @@ namespace SonsOfPHP\Component\Cqrs; +use SonsOfPHP\Component\Cqrs\AbstractMessage; + /** * @author Joshua Estes */ -interface MessageHandlerInterface {} +abstract class AbstractQueryMessage extends AbstractMessage {} diff --git a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php new file mode 100644 index 00000000..90ca3add --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php @@ -0,0 +1,15 @@ + + */ +abstract class AbstractQueryMessageHandler implements QueryMessageHandlerInterface +{ + abstract public function __invoke(QueryMessageInterface $message): mixed; +} diff --git a/src/SonsOfPHP/Component/Cqrs/Query/QueryMessageHandlerInterface.php b/src/SonsOfPHP/Component/Cqrs/Query/QueryMessageHandlerInterface.php deleted file mode 100644 index 1fdb7a7a..00000000 --- a/src/SonsOfPHP/Component/Cqrs/Query/QueryMessageHandlerInterface.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -interface QueryMessageHandlerInterface extends MessageHandlerInterface {} diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php new file mode 100644 index 00000000..2022e293 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php @@ -0,0 +1,15 @@ + + */ +interface CommandMessageHandlerInterface extends MessageHandlerInterface +{ + //public function __invoke(CommandMessageInterface $message): void; +} diff --git a/src/SonsOfPHP/Component/Cqrs/Command/CommandMessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php similarity index 62% rename from src/SonsOfPHP/Component/Cqrs/Command/CommandMessageInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php index 4e5aa504..157638b8 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/CommandMessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Command; +namespace SonsOfPHP\Contract\Cqrs\Command; -use SonsOfPHP\Component\Cqrs\MessageInterface; +use SonsOfPHP\Contract\Cqrs\MessageInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php b/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php new file mode 100644 index 00000000..febe24e0 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php @@ -0,0 +1,14 @@ + + */ +interface CqrsExceptionInterface +{ +} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php new file mode 100644 index 00000000..8dda4aa0 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php @@ -0,0 +1,13 @@ + + */ +interface MessageHandlerInterface +{ + //public function __invoke(MessageInterface $message); +} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php new file mode 100644 index 00000000..b8599861 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php @@ -0,0 +1,61 @@ + + */ +interface MessageInterface// extends \JsonSerializable, \Serializable +{ + /** + * Adds a new value for a given key. + * + * If a value already exists, this will overwrite that value. + * + * If the value for key exists, and the values are equal, this should + * not return a new object. + * + * If the $key is an array, it should be a key => value array and will overwrite + * all the existing values + * + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * - If the given key or value is invalid + * + * Examples: + * $message = $message->with('user_id', 42); + * $message = $message->with([ + * 'user_id' => 42, + * 'account_id' => 2131, + * ]); + */ + //public function with(string|array $key, mixed $value): static; + + /** + * Returns the value stored for a given key. + * + * If no key is passed in or if null is passed in, it will return + * all the values + * + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * - If the given key is not part of this message + * + * Examples: + * $userId = $message->get('user_id'); + * $payload = $message->get(); + */ + //public function get(?string $key = null): mixed; +} diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php new file mode 100644 index 00000000..5a129eb1 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php @@ -0,0 +1,15 @@ + + */ +interface QueryMessageHandlerInterface extends MessageHandlerInterface +{ + //public function __invoke(QueryMessageInterface $message): mixed; +} diff --git a/src/SonsOfPHP/Component/Cqrs/Query/QueryMessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php similarity index 62% rename from src/SonsOfPHP/Component/Cqrs/Query/QueryMessageInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php index 4381f434..307df1c8 100644 --- a/src/SonsOfPHP/Component/Cqrs/Query/QueryMessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Query; +namespace SonsOfPHP\Contract\Cqrs\Query; -use SonsOfPHP\Component\Cqrs\MessageInterface; +use SonsOfPHP\Contract\Cqrs\MessageInterface; /** * @author Joshua Estes From 59cb9c21a99772b1d5ab18376e949c6a844ca490 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 8 Nov 2023 17:10:25 -0500 Subject: [PATCH 05/27] updates --- .../Cqrs/Command/AbstractCommandMessage.php | 3 ++- .../Cqrs/Query/AbstractQueryMessage.php | 3 ++- .../Contract/Cqrs/CommandBusInterface.php | 25 +++++++++++++++++++ .../Cqrs/CommandHandlerProviderInterface.php | 20 +++++++++++++++ .../Cqrs/Exception/CqrsExceptionInterface.php | 4 +-- .../Exception/NoHandlerExceptionInterface.php | 13 ++++++++++ .../Contract/Cqrs/MessageInterface.php | 2 +- .../Contract/Cqrs/QueryBusInterface.php | 19 ++++++++++++++ .../Cqrs/QueryHandlerProviderInterface.php | 20 +++++++++++++++ 9 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php create mode 100644 src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php diff --git a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php index c291d45c..918b36cc 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php @@ -5,8 +5,9 @@ namespace SonsOfPHP\Component\Cqrs; use SonsOfPHP\Component\Cqrs\AbstractMessage; +use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; /** * @author Joshua Estes */ -abstract class AbstractCommandMessage extends AbstractMessage {} +abstract class AbstractCommandMessage extends AbstractMessage implements CommandMessageInterface {} diff --git a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php index 68d90cef..29e26d76 100644 --- a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php @@ -5,8 +5,9 @@ namespace SonsOfPHP\Component\Cqrs; use SonsOfPHP\Component\Cqrs\AbstractMessage; +use SonsOfPHP\Contract\Cqrs\Query\QueryMessageInterface; /** * @author Joshua Estes */ -abstract class AbstractQueryMessage extends AbstractMessage {} +abstract class AbstractQueryMessage extends AbstractMessage implements QueryMessageInterface {} diff --git a/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php new file mode 100644 index 00000000..fea0d848 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php @@ -0,0 +1,25 @@ + + */ +interface CommandBusInterface +{ + /** + * A command will never return any data. It can be handled syncrhonously or + * asyncrhonously. + * + * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface + * Exception is thrown if there is no handler for the given command + * + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * If something fucks up, this will be thrown + */ + public function dispatch(CommandMessageInterface $command): void; +} diff --git a/src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php new file mode 100644 index 00000000..951af02f --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php @@ -0,0 +1,20 @@ + + */ +interface CommandHandlerProviderInterface +{ + /** + * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + */ + public function getHandlerForCommand(CommandMessageInterface $command): CommandMessageHandlerInterface; +} diff --git a/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php b/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php index febe24e0..2e1c8e6f 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Exception/CqrsExceptionInterface.php @@ -9,6 +9,4 @@ * * @author Joshua Estes */ -interface CqrsExceptionInterface -{ -} +interface CqrsExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php b/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php new file mode 100644 index 00000000..c70bee4a --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php @@ -0,0 +1,13 @@ + + */ +interface NoHandlerExceptionInterface extends CqrsExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php index b8599861..3346eb32 100644 --- a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php @@ -19,7 +19,7 @@ * * @author Joshua Estes */ -interface MessageInterface// extends \JsonSerializable, \Serializable +interface MessageInterface { /** * Adds a new value for a given key. diff --git a/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php new file mode 100644 index 00000000..b7cfb0a1 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php @@ -0,0 +1,19 @@ + + */ +interface QueryBusInterface +{ + /** + * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + */ + public function handle(QueryMessageInterface $query): mixed; +} diff --git a/src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php new file mode 100644 index 00000000..e4244fca --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php @@ -0,0 +1,20 @@ + + */ +interface QueryHandlerProviderInterface +{ + /** + * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + */ + public function getHandlerForQuery(QueryMessageInterface $command): QueryMessageHandlerInterface; +} From c7da23d108edc9b2551622f45c81547d537e8811 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 9 Nov 2023 11:18:54 -0500 Subject: [PATCH 06/27] various updates --- docs/contracts/common/index.md | 10 +- docs/contracts/cqrs/index.md | 33 ++++ .../AbstractOptionsResolverCommandMessage.php | 3 +- .../Component/Cqrs/AbstractMessage.php | 34 +++- .../Cqrs/Command/AbstractCommandMessage.php | 2 +- .../Cqrs/Tests/AbstractMessageTest.php | 161 ++++++++++++++++++ .../{ => Command}/CommandBusInterface.php | 2 +- .../CommandHandlerProviderInterface.php | 2 +- .../Contract/Cqrs/MessageHandlerInterface.php | 2 +- .../Cqrs/MessageHandlerProviderInterface.php | 17 ++ .../Contract/Cqrs/MessageInterface.php | 11 +- .../Cqrs/{ => Query}/QueryBusInterface.php | 2 +- .../QueryHandlerProviderInterface.php | 2 +- .../Query/QueryMessageHandlerInterface.php | 7 +- src/SonsOfPHP/Contract/Cqrs/README.md | 2 +- .../Contract/EventSourcing/README.md | 2 +- .../Contract/FeatureToggle/README.md | 2 +- src/SonsOfPHP/Contract/Filesystem/README.md | 2 +- src/SonsOfPHP/Contract/Money/README.md | 2 +- src/SonsOfPHP/Contract/Version/README.md | 2 +- 20 files changed, 278 insertions(+), 22 deletions(-) create mode 100644 docs/contracts/cqrs/index.md create mode 100644 src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php rename src/SonsOfPHP/Contract/Cqrs/{ => Command}/CommandBusInterface.php (93%) rename src/SonsOfPHP/Contract/Cqrs/{ => Command}/CommandHandlerProviderInterface.php (92%) create mode 100644 src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php rename src/SonsOfPHP/Contract/Cqrs/{ => Query}/QueryBusInterface.php (90%) rename src/SonsOfPHP/Contract/Cqrs/{ => Query}/QueryHandlerProviderInterface.php (92%) diff --git a/docs/contracts/common/index.md b/docs/contracts/common/index.md index fabe74f4..cc1e0a7d 100644 --- a/docs/contracts/common/index.md +++ b/docs/contracts/common/index.md @@ -1,19 +1,21 @@ --- -title: Core Contracts - Overview +title: Common Contracts - Overview --- -# Core Contracts +# Common Contracts -Core Contracts are generic contracts that are not specific to any one package or +Common Contracts are generic contracts that are not specific to any one package or project. ## Installation ```shell -composer require sonsofphp/core-contract +composer require sonsofphp/common-contract ``` ## Includes Interfaces +* ArrayableInterface * ComparableInterface * EquatableInterface +* JsonableInterface diff --git a/docs/contracts/cqrs/index.md b/docs/contracts/cqrs/index.md new file mode 100644 index 00000000..bea735b0 --- /dev/null +++ b/docs/contracts/cqrs/index.md @@ -0,0 +1,33 @@ +--- +title: Cqrs Contracts - Overview +--- + +In a nut shell, with CQRS you have Commands that will change the state of your +application and Queries that will return information about the state of your +application. + +## Installation + +```shell +composer require sonsofphp/cqrs-contract +``` + +## Messages + +Both Commands and Queries are considered Messages and are handled by Message +Handlers. + +## Message Handlers + +When a message is dispatched/handled, it is handled by a message handler. + +## Message Bus + +The Message Bus is given a Message and will use a Message Handler to handle the +message. If it's a Query Message, the bus will return a result and for Command +Messages, it will not return anything. + +## Message Handler Provider + +Returns the Handler that will handle the Message. They do not actually handle or +process the message. diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php index 348f9514..9eb9d212 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php @@ -6,6 +6,7 @@ use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use SonsOfPHP\Component\Cqrs\Command\AbstractCommandMessage; /** * Abstract Command Message. @@ -20,7 +21,7 @@ * * @author Joshua Estes */ -abstract class AbstractOptionsResolverCommandMessage implements CommandMessageInterface +abstract class AbstractOptionsResolverCommandMessage extends AbstractCommandMessage implements CommandMessageInterface { private array $options = []; diff --git a/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php index 8b153d05..39fa2074 100644 --- a/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php @@ -15,9 +15,29 @@ abstract class AbstractMessage implements MessageInterface, \JsonSerializable, \ public function with(string|array $key, mixed $value): static { + if (is_object($value) && !$value instanceof \Stringable) { + throw new \InvalidArgumentException('$value is invalid'); + } + + if ($value instanceof \Stringable) { + $value = (string) $value; + } + + // @todo make sure $value is null if (is_array($key)) { $that = clone $this; - $that->payload = $key; + foreach ($key as $k => $v) { + // @todo make sure $k is string + if (is_object($v) && !$v instanceof \Stringable) { + throw new \InvalidArgumentException('The array contains invalid values'); + } + + if ($v instanceof \Stringable) { + $v = (string) $v; + } + + $that->payload[$k] = $v; + } return $that; } @@ -41,6 +61,8 @@ public function get(?string $key = null): mixed if (!array_key_exists($key, $this->payload)) { throw new \Exception(sprintf('The key "%s" does not exist.', $key)); } + + return $this->payload[$key]; } public function serialize(): ?string @@ -57,6 +79,16 @@ public function unserialize(string $data): void $this->payload = json_decode($data, true); } + public function __serialize(): array + { + return $this->payload; + } + + public function __unserialize(array $data): void + { + $this->payload = $data; + } + public function jsonSerialize(): array { return $this->payload; diff --git a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php index 918b36cc..b8ffbae4 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs; +namespace SonsOfPHP\Component\Cqrs\Command; use SonsOfPHP\Component\Cqrs\AbstractMessage; use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php new file mode 100644 index 00000000..57e1607e --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php @@ -0,0 +1,161 @@ +getMockForAbstractClass(AbstractMessage::class); + + $this->assertInstanceOf(MessageInterface::class, $msg); + } + + /** + * @covers ::with + */ + public function testWithWillReturnANewInstanceIfNewData(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('value', 'key'); + + $this->assertNotSame($msg, $msg->with('key', 'value')); + $this->assertSame($msg, $msg->with('value', 'key')); + } + + /** + * @covers ::with + * + * @dataProvider invalidValueProvider + */ + public function testWithWillThrowInvalidArgumentExceptionWhenValueIsInvalid(mixed $value): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class); + + $this->expectException('InvalidArgumentException'); + $msg->with('key', $value); + } + + /** + * @covers ::with + */ + public function testWithWorksAsExpectedWhenValueIsStringable(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class); + + $value = new class implements \Stringable { + public function __toString(): string + { + return 'value'; + } + }; + + $message = $msg->with('key', $value); + + $this->assertNotSame($msg, $message); + $this->assertSame('value', $message->get('key')); + } + + /** + * @covers ::get + */ + public function testGet(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->assertSame('value', $msg->get('key')); + } + + /** + * @covers ::get + */ + public function testGetWillReturnAllWhenNoArgument(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->assertArrayHasKey('key', $msg->get()); + } + + /** + * @covers ::get + */ + public function testGetWillThrowExceptionWhenKeyNotFound(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->expectException('Exception'); + $msg->get('nope'); + } + + /** + * @covers ::__serialize + */ + public function testSerializeMagicMethod(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->assertArrayHasKey('key', $msg->__serialize()); + } + + /** + * @covers ::__unserialize + */ + public function testUnserializeMagicMethod(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $message = unserialize(serialize($msg)); + + $this->assertArrayHasKey('key', $message->get()); + } + + /** + * @covers ::serialize + */ + public function testSerialize(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->assertSame('{"key":"value"}', $msg->serialize()); + } + + /** + * @covers ::unserialize + */ + public function testUnserialize(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + $msg->unserialize('{"key":"other value"}'); + + $this->assertSame('other value', $msg->get('key')); + } + + /** + * @covers ::jsonSerialize + */ + public function testjsonSerialize(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with('key', 'value'); + + $this->assertArrayHasKey('key', $msg->jsonSerialize()); + } +} diff --git a/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php similarity index 93% rename from src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php index fea0d848..77c1aa6c 100644 --- a/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs; +namespace SonsOfPHP\Contract\Cqrs\Command; use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; diff --git a/src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php similarity index 92% rename from src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php index 951af02f..f1bcd14a 100644 --- a/src/SonsOfPHP/Contract/Cqrs/CommandHandlerProviderInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs; +namespace SonsOfPHP\Contract\Cqrs\Command; use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; use SonsOfPHP\Contract\Cqrs\Command\CommandMessageHandlerInterface; diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php index 8dda4aa0..e77a4ccf 100644 --- a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php @@ -9,5 +9,5 @@ */ interface MessageHandlerInterface { - //public function __invoke(MessageInterface $message); + public function __invoke(MessageInterface $message): mixed; } diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php new file mode 100644 index 00000000..01135986 --- /dev/null +++ b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php @@ -0,0 +1,17 @@ + + */ +interface MessageHandlerProviderInterface +{ + /** + * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + */ + public function getHandlerForMessage(MessageInterface $message): MessageHandlerInterface; +} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php index 3346eb32..1edd69b6 100644 --- a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php @@ -32,7 +32,12 @@ interface MessageInterface * If the $key is an array, it should be a key => value array and will overwrite * all the existing values * - * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * @param mixed $value + * - If an object is passed in, it must be able to be converted to a + * string. If it's unable to be converted to string, an exception + * is thrown. + * + * @throws \InvalidArgumentException * - If the given key or value is invalid * * Examples: @@ -42,7 +47,7 @@ interface MessageInterface * 'account_id' => 2131, * ]); */ - //public function with(string|array $key, mixed $value): static; + public function with(string|array $key, mixed $value): static; /** * Returns the value stored for a given key. @@ -57,5 +62,5 @@ interface MessageInterface * $userId = $message->get('user_id'); * $payload = $message->get(); */ - //public function get(?string $key = null): mixed; + public function get(?string $key = null): mixed; } diff --git a/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php similarity index 90% rename from src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php index b7cfb0a1..1e80e01a 100644 --- a/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs; +namespace SonsOfPHP\Contract\Cqrs\Query; use SonsOfPHP\Contract\Cqrs\Query\QueryMessageInterface; diff --git a/src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php similarity index 92% rename from src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php index e4244fca..311fc2ca 100644 --- a/src/SonsOfPHP/Contract/Cqrs/QueryHandlerProviderInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs; +namespace SonsOfPHP\Contract\Cqrs\Query; use SonsOfPHP\Contract\Cqrs\Query\QueryMessageInterface; use SonsOfPHP\Contract\Cqrs\Query\QueryMessageHandlerInterface; diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php index 5a129eb1..915c2914 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php @@ -11,5 +11,10 @@ */ interface QueryMessageHandlerInterface extends MessageHandlerInterface { - //public function __invoke(QueryMessageInterface $message): mixed; + /** + * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * When something really fucks up and the handler is unable to handle + * it's shit + */ + public function __invoke(QueryMessageInterface $message): mixed; } diff --git a/src/SonsOfPHP/Contract/Cqrs/README.md b/src/SonsOfPHP/Contract/Cqrs/README.md index 9a9eefc0..dfdabe92 100644 --- a/src/SonsOfPHP/Contract/Cqrs/README.md +++ b/src/SonsOfPHP/Contract/Cqrs/README.md @@ -11,6 +11,6 @@ Sons of PHP - CQRS Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/cqrs/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3ACqrs [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3ACqrs diff --git a/src/SonsOfPHP/Contract/EventSourcing/README.md b/src/SonsOfPHP/Contract/EventSourcing/README.md index 9a69cdc5..7ab66b11 100644 --- a/src/SonsOfPHP/Contract/EventSourcing/README.md +++ b/src/SonsOfPHP/Contract/EventSourcing/README.md @@ -11,6 +11,6 @@ Sons of PHP - Event Sourcing Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/event-sourcing/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AEventSourcing [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AEventSourcing diff --git a/src/SonsOfPHP/Contract/FeatureToggle/README.md b/src/SonsOfPHP/Contract/FeatureToggle/README.md index 3e83359c..f6b6297c 100644 --- a/src/SonsOfPHP/Contract/FeatureToggle/README.md +++ b/src/SonsOfPHP/Contract/FeatureToggle/README.md @@ -11,6 +11,6 @@ Sons of PHP - Feature Toggle Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/feature-toggle/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AFeatureToggle [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AFeatureToggle diff --git a/src/SonsOfPHP/Contract/Filesystem/README.md b/src/SonsOfPHP/Contract/Filesystem/README.md index f7d4ac30..f0fe3bf8 100644 --- a/src/SonsOfPHP/Contract/Filesystem/README.md +++ b/src/SonsOfPHP/Contract/Filesystem/README.md @@ -11,6 +11,6 @@ Sons of PHP - Filesystem Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/filesystem/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AFilesystem [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AFilesystem diff --git a/src/SonsOfPHP/Contract/Money/README.md b/src/SonsOfPHP/Contract/Money/README.md index 5cf12d2b..b56a2c10 100644 --- a/src/SonsOfPHP/Contract/Money/README.md +++ b/src/SonsOfPHP/Contract/Money/README.md @@ -11,6 +11,6 @@ Sons of PHP - Money Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/money/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AMoney [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AMoney diff --git a/src/SonsOfPHP/Contract/Version/README.md b/src/SonsOfPHP/Contract/Version/README.md index a2ac25ec..2ef00a3a 100644 --- a/src/SonsOfPHP/Contract/Version/README.md +++ b/src/SonsOfPHP/Contract/Version/README.md @@ -11,6 +11,6 @@ Sons of PHP - Version Contract [discussions]: https://github.com/orgs/SonsOfPHP/discussions [mother-repo]: https://github.com/SonsOfPHP/sonsofphp [contributing]: https://docs.sonsofphp.com/contributing/ -[docs]: https://docs.sonsofphp.com/components/http-message/ +[docs]: https://docs.sonsofphp.com/contracts/version/ [issues]: https://github.com/SonsOfPHP/sonsofphp/issues?q=is%3Aopen+is%3Aissue+label%3AVersion [pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls?q=is%3Aopen+is%3Apr+label%3AVersion From 578e33eabad83ce2026e0746de6158d3fd1e0759 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 9 Nov 2023 13:47:04 -0500 Subject: [PATCH 07/27] more cqrs stuff --- .../Component/Cqrs/AbstractMessage.php | 10 ++-- .../Cqrs/Tests/AbstractMessageTest.php | 51 +++++++++++++++++++ .../Contract/Cqrs/MessageInterface.php | 2 +- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php index 39fa2074..96007c0d 100644 --- a/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractMessage.php @@ -13,21 +13,23 @@ abstract class AbstractMessage implements MessageInterface, \JsonSerializable, \ { private array $payload = []; - public function with(string|array $key, mixed $value): static + public function with(string|array $key, mixed $value = null): static { if (is_object($value) && !$value instanceof \Stringable) { throw new \InvalidArgumentException('$value is invalid'); } + if (is_array($key) && null !== $value) { + throw new \InvalidArgumentException('$key is invalid, you cannot pass in $value when $key is an array'); + } + if ($value instanceof \Stringable) { $value = (string) $value; } - // @todo make sure $value is null if (is_array($key)) { $that = clone $this; foreach ($key as $k => $v) { - // @todo make sure $k is string if (is_object($v) && !$v instanceof \Stringable) { throw new \InvalidArgumentException('The array contains invalid values'); } @@ -68,7 +70,7 @@ public function get(?string $key = null): mixed public function serialize(): ?string { if (false === $json = json_encode($this)) { - throw new \Exception('Unable to serialize object'); + throw new \RuntimeException('Unable to serialize object'); } return $json; diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php index 57e1607e..74b4989a 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php @@ -31,6 +31,57 @@ public function testItHasTheCorrectInterface(): void $this->assertInstanceOf(MessageInterface::class, $msg); } + /** + * @covers ::with + */ + public function testWithWhenKeyIsAnArrayThatContainsAStringableValue(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with([ + 'key' => new class implements \Stringable { + public function __toString(): string + { + return 'value'; + } + }, + ]); + + $this->assertSame('value', $msg->get('key')); + } + + /** + * @covers ::with + */ + public function testWithWhenKeyIsAnArrayThatContainsAnInvalidValue(): void + { + $this->expectException('InvalidArgumentException'); + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with([ + 'key' => new \stdClass(), + ]); + } + + /** + * @covers ::with + */ + public function testWithWhenKeyIsAnArrayAndValueIsNotNull(): void + { + $this->expectException('InvalidArgumentException'); + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with([ + 'key' => 'value', + ], 'value'); + } + + /** + * @covers ::with + */ + public function testWithWhenKeyIsAnArray(): void + { + $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with([ + 'key' => 'value', + ]); + + $this->assertSame('value', $msg->get('key')); + } + /** * @covers ::with */ diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php index 1edd69b6..fb35ac9a 100644 --- a/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/MessageInterface.php @@ -47,7 +47,7 @@ interface MessageInterface * 'account_id' => 2131, * ]); */ - public function with(string|array $key, mixed $value): static; + public function with(string|array $key, mixed $value = null): static; /** * Returns the value stored for a given key. From d8fdb4645e499c89fbc2a8fae1b4b649be15515d Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 9 Nov 2023 15:29:38 -0500 Subject: [PATCH 08/27] updates --- .../Component/Cqrs/Command/CommandBus.php | 32 +++++++ .../Component/Cqrs/MessageHandlerProvider.php | 53 +++++++++++ .../Cqrs/Tests/MessageHandlerProviderTest.php | 87 +++++++++++++++++++ .../Cqrs/Command/CommandBusInterface.php | 2 +- .../CommandHandlerProviderInterface.php | 20 ----- .../Contract/Cqrs/MessageHandlerInterface.php | 13 --- .../Cqrs/MessageHandlerProviderInterface.php | 15 +++- .../Query/QueryHandlerProviderInterface.php | 20 ----- 8 files changed, 186 insertions(+), 56 deletions(-) create mode 100644 src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php create mode 100644 src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php delete mode 100644 src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php delete mode 100644 src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php delete mode 100644 src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php diff --git a/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php b/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php new file mode 100644 index 00000000..55aa419e --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php @@ -0,0 +1,32 @@ + + */ +class CommandBus implements CommandBusInterface +{ + public function __construct( + private MessageHandlerProviderInterface $provider = new MessageHandlerProvider(), + ) {} + + public function addHandler(object|string $message, callable $handler): void + { + $this->provider->add($message, $handler); + } + + public function dispatch(object $command): void + { + $handler = $this->provider->getHandlerForMessage($command); + + $handler($command, $this); + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php new file mode 100644 index 00000000..68d846ed --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php @@ -0,0 +1,53 @@ + + */ +class MessageHandlerProvider implements MessageHandlerProviderInterface +{ + private array $handlers = []; + + /** + * Register a command with a command handler + * + * Usage: + * $cmd = new CreateUser(); + * $handler = new CreateUserHandler(); + * $provider->register($cmd, $handler); + * --- + * $handler = new CreateUserHandler(); + * $provider->register(CreateUser::class, $handler); + * --- + * $provider->register(CreateUser::class, function (CreateUser $cmd) {}); + */ + public function add(string|object $message, callable $handler): void + { + if (is_object($message)) { + $message = $message::class; + } + + $this->handlers[$message] = $handler; + } + + /** + * {@inheritdoc} + */ + public function getHandlerForMessage(string|object $message): callable + { + if (is_object($message)) { + $message = $message::class; + } + + if (!array_key_exists($message, $this->handlers)) { + throw new \Exception(sprintf('No handler for message "%s" found.', $message)); + } + + return $this->handlers[$message]; + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php new file mode 100644 index 00000000..33ba521a --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php @@ -0,0 +1,87 @@ +assertInstanceOf(MessageHandlerProviderInterface::class, $provider); + } + + /** + * @covers ::add + */ + public function testAddWithObject(): void + { + $provider = new MessageHandlerProvider(); + $provider->add(new \stdClass(), function() {}); + + $property = new \ReflectionProperty($provider, 'handlers'); + $handlers = $property->getValue($provider); + + $this->assertArrayHasKey('stdClass', $handlers); + } + + /** + * @covers ::add + */ + public function testAddWithString(): void + { + $provider = new MessageHandlerProvider(); + $provider->add('stdClass', function() {}); + + $property = new \ReflectionProperty($provider, 'handlers'); + $handlers = $property->getValue($provider); + + $this->assertArrayHasKey('stdClass', $handlers); + } + + /** + * @covers ::getHandlerForMessage + */ + public function testGetHandlerForMessageWhenNoHandlerExists(): void + { + $provider = new MessageHandlerProvider(); + $this->expectException('Exception'); + $this->assertNotNull($provider->getHandlerForMessage('stdClass')); + } + + /** + * @covers ::getHandlerForMessage + */ + public function testGetHandlerForMessageWhenStringIsPassedIn(): void + { + $provider = new MessageHandlerProvider(); + $provider->add(new \stdClass(), function() {}); + + $this->assertNotNull($provider->getHandlerForMessage('stdClass')); + } + + /** + * @covers ::getHandlerForMessage + */ + public function testGetHandlerForMessageWhenObjectIsPassedIn(): void + { + $provider = new MessageHandlerProvider(); + $provider->add(new \stdClass(), function() {}); + + $this->assertNotNull($provider->getHandlerForMessage(new \stdClass())); + } +} diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php index 77c1aa6c..795c7957 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php @@ -21,5 +21,5 @@ interface CommandBusInterface * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface * If something fucks up, this will be thrown */ - public function dispatch(CommandMessageInterface $command): void; + public function dispatch(object $command): void; } diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php deleted file mode 100644 index f1bcd14a..00000000 --- a/src/SonsOfPHP/Contract/Cqrs/Command/CommandHandlerProviderInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface CommandHandlerProviderInterface -{ - /** - * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface - * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface - */ - public function getHandlerForCommand(CommandMessageInterface $command): CommandMessageHandlerInterface; -} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php deleted file mode 100644 index e77a4ccf..00000000 --- a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerInterface.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ -interface MessageHandlerInterface -{ - public function __invoke(MessageInterface $message): mixed; -} diff --git a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php index 01135986..ccfdd1c4 100644 --- a/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/MessageHandlerProviderInterface.php @@ -10,8 +10,19 @@ interface MessageHandlerProviderInterface { /** + * Returns the handler for a given object + * + * Message is the Message that needs to be handled. This can either + * be the message class name or the message object + * * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface - * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface + * When no handler is available for the message + * + * Usage: + * $msg = new CreateUser(); + * $handler = $provider->getHandlerForMessage($msg); + * --- + * $handler = $provider->getHandlerForMessage(CreateUser::class); */ - public function getHandlerForMessage(MessageInterface $message): MessageHandlerInterface; + public function getHandlerForMessage(string|object $message): callable; } diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php b/src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php deleted file mode 100644 index 311fc2ca..00000000 --- a/src/SonsOfPHP/Contract/Cqrs/Query/QueryHandlerProviderInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface QueryHandlerProviderInterface -{ - /** - * @throws \SonsOfPHP\Contract\Cqrs\Exception\NoHandlerExceptionInterface - * @throws \SonsOfPHP\Contract\Cqrs\Exception\CqrsExceptionInterface - */ - public function getHandlerForQuery(QueryMessageInterface $command): QueryMessageHandlerInterface; -} From 571d311d6845ed34ac0558b3f30ac2971bc60b1d Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 9 Nov 2023 15:55:54 -0500 Subject: [PATCH 09/27] various updates --- src/SonsOfPHP/Component/Cqrs/AbstractBus.php | 25 ++++++++ .../Cqrs/Attribute/AsMessageHandler.php | 22 +++++++ .../Component/Cqrs/Command/CommandBus.php | 12 +--- .../Component/Cqrs/Query/QueryBus.php | 24 ++++++++ .../Cqrs/Tests/Command/CommandBusTest.php | 56 ++++++++++++++++++ .../Cqrs/Tests/MessageHandlerProviderTest.php | 29 ++++++++++ .../Cqrs/Tests/Query/QueryBusTest.php | 58 +++++++++++++++++++ 7 files changed, 216 insertions(+), 10 deletions(-) create mode 100644 src/SonsOfPHP/Component/Cqrs/AbstractBus.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Attribute/AsMessageHandler.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php diff --git a/src/SonsOfPHP/Component/Cqrs/AbstractBus.php b/src/SonsOfPHP/Component/Cqrs/AbstractBus.php new file mode 100644 index 00000000..4ee395cc --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/AbstractBus.php @@ -0,0 +1,25 @@ + + */ +abstract class AbstractBus +{ + public function __construct( + protected MessageHandlerProviderInterface $provider = new MessageHandlerProvider(), + ) {} + + public function addHandler(object|string $message, callable $handler): void + { + $this->provider->add($message, $handler); + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/Attribute/AsMessageHandler.php b/src/SonsOfPHP/Component/Cqrs/Attribute/AsMessageHandler.php new file mode 100644 index 00000000..52abcdde --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Attribute/AsMessageHandler.php @@ -0,0 +1,22 @@ + + */ +#[Attribute(Attribute::TARGET_PROPERTY)] +final class AsMessageHandler +{ + public function __construct( + public readonly string $messageClass, + ) {} +} diff --git a/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php b/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php index 55aa419e..523c17f7 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php +++ b/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php @@ -4,6 +4,7 @@ namespace SonsOfPHP\Component\Cqrs\Command; +use SonsOfPHP\Component\Cqrs\AbstractBus; use SonsOfPHP\Component\Cqrs\AbstractMessage; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; use SonsOfPHP\Contract\Cqrs\Command\CommandBusInterface; @@ -12,17 +13,8 @@ /** * @author Joshua Estes */ -class CommandBus implements CommandBusInterface +class CommandBus extends AbstractBus implements CommandBusInterface { - public function __construct( - private MessageHandlerProviderInterface $provider = new MessageHandlerProvider(), - ) {} - - public function addHandler(object|string $message, callable $handler): void - { - $this->provider->add($message, $handler); - } - public function dispatch(object $command): void { $handler = $this->provider->getHandlerForMessage($command); diff --git a/src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php b/src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php new file mode 100644 index 00000000..79730461 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php @@ -0,0 +1,24 @@ + + */ +class QueryBus extends AbstractBus implements QueryBusInterface +{ + public function handle(object $command): mixed + { + $handler = $this->provider->getHandlerForMessage($command); + + return $handler($command, $this); + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php new file mode 100644 index 00000000..71afac5b --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php @@ -0,0 +1,56 @@ +provider = $this->createMock(MessageHandlerProvider::class); + } + + /** + * @covers ::__construct + */ + public function testItHasTheCorrectInterface(): void + { + $bus = new CommandBus(); + + $this->assertInstanceOf(CommandBusInterface::class, $bus); + } + + /** + * @covers ::addHandler + */ + public function testAddHandler(): void + { + $this->provider->expects($this->once())->method('add'); + $bus = new CommandBus($this->provider); + $bus->addHandler(new \stdClass(), function () {}); + } + + /** + * @covers ::dispatch + */ + public function testDispatch(): void + { + $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(function () {}); + $bus = new CommandBus($this->provider); + $bus->dispatch(new \stdClass()); + } +} diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php index 33ba521a..bbfa29ca 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php @@ -25,6 +25,22 @@ public function testItHasTheCorrectInterface(): void $this->assertInstanceOf(MessageHandlerProviderInterface::class, $provider); } + /** + * @covers ::add + */ + public function testAddWithHandlerClass(): void + { + $provider = new MessageHandlerProvider(); + $provider->add(new \stdClass(), new class { + public function __invoke() {} + }); + + $property = new \ReflectionProperty($provider, 'handlers'); + $handlers = $property->getValue($provider); + + $this->assertArrayHasKey('stdClass', $handlers); + } + /** * @covers ::add */ @@ -53,6 +69,19 @@ public function testAddWithString(): void $this->assertArrayHasKey('stdClass', $handlers); } + /** + * @covers ::getHandlerForMessage + */ + public function testGetHandlerForMessageWhenClassIsInvokable(): void + { + $provider = new MessageHandlerProvider(); + $provider->add(new \stdClass(), new class { + public function __invoke() {} + }); + + $this->assertNotNull($provider->getHandlerForMessage('stdClass')); + } + /** * @covers ::getHandlerForMessage */ diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php new file mode 100644 index 00000000..5e32e8f9 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php @@ -0,0 +1,58 @@ +provider = $this->createMock(MessageHandlerProvider::class); + } + + /** + * @covers ::__construct + */ + public function testItHasTheCorrectInterface(): void + { + $bus = new QueryBus(); + + $this->assertInstanceOf(QueryBusInterface::class, $bus); + } + + /** + * @covers ::addHandler + */ + public function testAddHandler(): void + { + $this->provider->expects($this->once())->method('add'); + $bus = new QueryBus($this->provider); + $bus->addHandler(new \stdClass(), function () {}); + } + + /** + * @covers ::handle + */ + public function testHandle(): void + { + $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(function () { + return 'testing'; + }); + $bus = new QueryBus($this->provider); + $this->assertSame('testing', $bus->handle(new \stdClass())); + } +} From 63b1333c5949b28735e6f490e0d70105ab424018 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Thu, 9 Nov 2023 16:43:57 -0500 Subject: [PATCH 10/27] updates --- docs/components/cqrs/command-handlers.md | 9 +- docs/components/cqrs/index.md | 160 ++++++++++++++++-- mkdocs.yml | 5 +- .../Component/Cqrs/AbstractMessage.php | 7 +- 4 files changed, 157 insertions(+), 24 deletions(-) diff --git a/docs/components/cqrs/command-handlers.md b/docs/components/cqrs/command-handlers.md index 445bca84..8fbed9a3 100644 --- a/docs/components/cqrs/command-handlers.md +++ b/docs/components/cqrs/command-handlers.md @@ -10,17 +10,18 @@ command. Command Handlers do NOT return any results. ```php addHandler(CreateUser::class, $handler); -[messenger]: https://symfony.com/doc/current/components/messenger.html -[options_resolver]: https://symfony.com/doc/current/components/options_resolver.html +$command = new CreateUser(); +$commandBus->dispatch($command); +``` + +!!! success "Symfony CQRS Bridge" + Once the CQRS Symfony Bridge is installed, you can use the Command Bus that + comes with that to gain access to additional features and functionality. + +### Query Bus + +```php +addHandler(GetUser::class, $handler); + +$query = (new GetUser())->with('id', 123); +$user = $queryBus->handle($query); + +!!! success "Symfony CQRS Bridge" + Once the CQRS Symfony Bridge is installed, you can use the Query Bus that + comes with that to gain addition features and functionality. +``` + +## Messages + +Both Commands and Queries are considered to be messages. It is HIGHLY +recommended to use the `AbstractMessage` class for both Commands and Queries. +For all examples I will assume you have extended this class. + +```php +with('id', 123); +$command = $command->with('email', 'joshua@sonsofphp.com'); + +$userId = $command->get('id'); // $userId = 123 +``` + +```php +with('id', 123); + +$userId = $query->get('id'); // $userId = 123 +``` + +!!! note + `AbstractMessage` treats the message as a value object. So using `with` will + return a new instance of the class. + +### Additional `AbstractMessage` API + +```php +with([ + 'key' => 'value', + 'another' => 'value', + // ... +]); + +// Getting all the paramters of the message +$parameters = $message->get(); + +// Get a single paramter value +// WARNING: If the parameter is not found, an exception will be thrown +$userId = $message->get('user.id'); +``` + +## Message Handlers + +Both Command and Query Handers are assumed to just be message handlers. + +### Command Handlers + +```php + */ -abstract class AbstractMessage implements MessageInterface, \JsonSerializable, \Serializable +abstract class AbstractMessage implements MessageInterface, \JsonSerializable, \Serializable, \IteratorAggregate { private array $payload = []; @@ -95,4 +95,9 @@ public function jsonSerialize(): array { return $this->payload; } + + public function getIterator(): \Traversable + { + return new \ArrayIterator($this->payload); + } } From cb1974bf3984891cdb2204f858c7a3af31432617 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 10:41:55 -0500 Subject: [PATCH 11/27] good enough --- Makefile | 50 +++++++++++-------- .../AbstractOptionsResolverCommandMessage.php | 4 +- ...tractOptionsResolverCommandMessageTest.php | 2 +- .../UlidEventIdMessageEnricherHandlerTest.php | 2 +- .../UuidEventIdMessageEnricherHandlerTest.php | 2 +- src/SonsOfPHP/Component/Cqrs/AbstractBus.php | 3 -- .../{Command => }/AbstractCommandMessage.php | 5 +- .../AbstractCommandMessageHandler.php | 4 +- .../Cqrs/{Query => }/AbstractQueryMessage.php | 3 +- .../AbstractQueryMessageHandler.php | 4 +- .../Cqrs/{Command => }/CommandBus.php | 8 +-- .../Cqrs/Exception/CqrsException.php | 12 +++++ .../Exception/NoHandlerFoundException.php | 12 +++++ .../Component/Cqrs/MessageHandlerProvider.php | 3 +- .../Component/Cqrs/{Query => }/QueryBus.php | 8 +-- .../Cqrs/Tests/AbstractMessageTest.php | 4 +- .../Tests/{Command => }/CommandBusTest.php | 14 +++--- .../Cqrs/Tests/MessageHandlerProviderTest.php | 19 +++---- .../Cqrs/Tests/{Query => }/QueryBusTest.php | 16 +++--- .../{Command => }/CommandBusInterface.php | 4 +- .../CommandMessageHandlerInterface.php | 4 +- .../{Command => }/CommandMessageInterface.php | 4 +- ...p => NoHandlerFoundExceptionInterface.php} | 2 +- .../Cqrs/{Query => }/QueryBusInterface.php | 4 +- .../QueryMessageHandlerInterface.php | 4 +- .../{Query => }/QueryMessageInterface.php | 4 +- 26 files changed, 103 insertions(+), 98 deletions(-) rename src/SonsOfPHP/Component/Cqrs/{Command => }/AbstractCommandMessage.php (55%) rename src/SonsOfPHP/Component/Cqrs/{Command => }/AbstractCommandMessageHandler.php (72%) rename src/SonsOfPHP/Component/Cqrs/{Query => }/AbstractQueryMessage.php (68%) rename src/SonsOfPHP/Component/Cqrs/{Query => }/AbstractQueryMessageHandler.php (72%) rename src/SonsOfPHP/Component/Cqrs/{Command => }/CommandBus.php (52%) create mode 100644 src/SonsOfPHP/Component/Cqrs/Exception/CqrsException.php create mode 100644 src/SonsOfPHP/Component/Cqrs/Exception/NoHandlerFoundException.php rename src/SonsOfPHP/Component/Cqrs/{Query => }/QueryBus.php (52%) rename src/SonsOfPHP/Component/Cqrs/Tests/{Command => }/CommandBusTest.php (73%) rename src/SonsOfPHP/Component/Cqrs/Tests/{Query => }/QueryBusTest.php (72%) rename src/SonsOfPHP/Contract/Cqrs/{Command => }/CommandBusInterface.php (84%) rename src/SonsOfPHP/Contract/Cqrs/{Command => }/CommandMessageHandlerInterface.php (71%) rename src/SonsOfPHP/Contract/Cqrs/{Command => }/CommandMessageInterface.php (62%) rename src/SonsOfPHP/Contract/Cqrs/Exception/{NoHandlerExceptionInterface.php => NoHandlerFoundExceptionInterface.php} (74%) rename src/SonsOfPHP/Contract/Cqrs/{Query => }/QueryBusInterface.php (78%) rename src/SonsOfPHP/Contract/Cqrs/{Query => }/QueryMessageHandlerInterface.php (81%) rename src/SonsOfPHP/Contract/Cqrs/{Query => }/QueryMessageInterface.php (62%) diff --git a/Makefile b/Makefile index fc89c623..7ec3c69b 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,10 @@ BARD = src/SonsOfPHP/Bard/bin/bard COVERAGE_DIR = docs/coverage +XDEBUG_MODE ?= off +PHPUNIT_TESTSUITE ?= all +PHPUNIT_OPTIONS ?= + .DEFAULT_GOAL = help .PHONY = help @@ -39,16 +43,27 @@ purge: # Purge vendor and lock files rm -rf vendor/ src/SonsOfPHP/Component/*/vendor/ src/SonsOfPHP/Component/*/composer.lock rm -rf vendor/ src/SonsOfPHP/Contract/*/vendor/ src/SonsOfPHP/Contract/*/composer.lock -test: ## Run PHPUnit Tests - XDEBUG_MODE=off \ +test: phpunit ## Run PHPUnit Tests + +test-cache: PHPUNIT_TESTSUITE=cache +test-cache: phpunit + +test-clock: PHPUNIT_TESTSUITE=clock +test-clock: phpunit + +test-cqrs: PHPUNIT_TESTSUITE=cqrs +test-cqrs: phpunit + +phpunit: + XDEBUG_MODE=$(XDEBUG_MODE) \ $(PHP) \ - -dxdebug.mode=off \ + -dxdebug.mode=$(XDEBUG_MODE) \ -dapc.enable_cli=1 \ $(PHPUNIT) \ --cache-result \ - --order-by=defects - -phpunit: test + --order-by=defects \ + --testsuite=$(PHPUNIT_TESTSUITE) \ + $(PHPUNIT_OPTIONS) phpunit-install: XDEBUG_MODE=off $(COMPOSER) install --working-dir=tools/phpunit --no-interaction --prefer-dist --optimize-autoloader @@ -61,23 +76,18 @@ lint: lint-php ## Lint files lint-php: # lint php files find src -name "*.php" -not -path "src/**/vendor/*" | xargs -I{} $(PHP) -l '{}' -coverage: ## Build Code Coverage Report - XDEBUG_MODE=coverage \ - $(PHP) \ - -dxdebug.mode=coverage \ - -dapc.enable_cli=1 \ - $(PHPUNIT) \ - --cache-result \ - --coverage-html $(COVERAGE_DIR) +coverage: XDEBUG_MODE=coverage +coverage: PHPUNIT_OPTIONS=--coverage-html $(COVERAGE_DIR) +coverage: phpunit ## Build Code Coverage Report -coverage-cache: - XDEBUG_MODE=coverage $(PHP) -dxdebug.mode=coverage $(PHPUNIT) --testsuite cache --coverage-html $(COVERAGE_DIR) +coverage-cache: PHPUNIT_TESTSUITE=cache +coverage-cache: coverage -coverage-clock: - XDEBUG_MODE=coverage $(PHP) -dxdebug.mode=coverage $(PHPUNIT) --testsuite clock --coverage-html $(COVERAGE_DIR) +coverage-clock: PHPUNIT_TESTSUITE=clock +coverage-clock: coverage -coverage-cqrs: - XDEBUG_MODE=coverage $(PHP) -dxdebug.mode=coverage $(PHPUNIT) --testsuite cqrs --coverage-html $(COVERAGE_DIR) +coverage-cqrs: PHPUNIT_TESTSUITE=cqrs +coverage-cqrs: coverage coverage-event-dispatcher: XDEBUG_MODE=coverage $(PHP) -dxdebug.mode=coverage $(PHPUNIT) --testsuite event-dispatcher --coverage-html $(COVERAGE_DIR) diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php index 9eb9d212..07befa36 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php @@ -4,9 +4,9 @@ namespace SonsOfPHP\Bridge\Symfony\Cqrs\Command; -use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; +use SonsOfPHP\Contract\Cqrs\CommandMessageInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use SonsOfPHP\Component\Cqrs\Command\AbstractCommandMessage; +use SonsOfPHP\Component\Cqrs\AbstractCommandMessage; /** * Abstract Command Message. diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php index f9abc4bb..b78eb38d 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests/Command/AbstractOptionsResolverCommandMessageTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage; use SonsOfPHP\Bridge\Symfony\Cqrs\Tests\DummyCommand; -use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; +use SonsOfPHP\Contract\Cqrs\CommandMessageInterface; /** * @coversDefaultClass \SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage diff --git a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UlidEventIdMessageEnricherHandlerTest.php b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UlidEventIdMessageEnricherHandlerTest.php index 07cf8c84..2ddc7905 100644 --- a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UlidEventIdMessageEnricherHandlerTest.php +++ b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UlidEventIdMessageEnricherHandlerTest.php @@ -38,7 +38,7 @@ public function testItWillGenerateUlid(): void $message = $this->createMock(MessageInterface::class); $message->expects($this->once()) ->method('withMetadata') - ->with($this->callback(fn ($metadata) => Ulid::isValid($metadata[Metadata::EVENT_ID]))) + ->with($this->callback(fn($metadata) => Ulid::isValid($metadata[Metadata::EVENT_ID]))) ; $handler->enrich($message); diff --git a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UuidEventIdMessageEnricherHandlerTest.php b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UuidEventIdMessageEnricherHandlerTest.php index 13fd82c3..7cf2678a 100644 --- a/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UuidEventIdMessageEnricherHandlerTest.php +++ b/src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests/Message/Enricher/Handler/UuidEventIdMessageEnricherHandlerTest.php @@ -38,7 +38,7 @@ public function testItWillGenerateUuid(): void $message = $this->createMock(MessageInterface::class); $message->expects($this->once()) ->method('withMetadata') - ->with($this->callback(fn ($metadata) => Uuid::isValid($metadata[Metadata::EVENT_ID]))) + ->with($this->callback(fn($metadata) => Uuid::isValid($metadata[Metadata::EVENT_ID]))) ; $handler->enrich($message); diff --git a/src/SonsOfPHP/Component/Cqrs/AbstractBus.php b/src/SonsOfPHP/Component/Cqrs/AbstractBus.php index 4ee395cc..908fedec 100644 --- a/src/SonsOfPHP/Component/Cqrs/AbstractBus.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractBus.php @@ -4,9 +4,6 @@ namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Component\Cqrs\AbstractMessage; -use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; -use SonsOfPHP\Contract\Cqrs\Command\CommandBusInterface; use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; /** diff --git a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php b/src/SonsOfPHP/Component/Cqrs/AbstractCommandMessage.php similarity index 55% rename from src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php rename to src/SonsOfPHP/Component/Cqrs/AbstractCommandMessage.php index b8ffbae4..d8930a7e 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractCommandMessage.php @@ -2,10 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Command; +namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Component\Cqrs\AbstractMessage; -use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; +use SonsOfPHP\Contract\Cqrs\CommandMessageInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php b/src/SonsOfPHP/Component/Cqrs/AbstractCommandMessageHandler.php similarity index 72% rename from src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php rename to src/SonsOfPHP/Component/Cqrs/AbstractCommandMessageHandler.php index f3ccf788..28c73466 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/AbstractCommandMessageHandler.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractCommandMessageHandler.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Command; - -use SonsOfPHP\Contract\Cqrs\MessageHandlerInterface; +namespace SonsOfPHP\Component\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php b/src/SonsOfPHP/Component/Cqrs/AbstractQueryMessage.php similarity index 68% rename from src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php rename to src/SonsOfPHP/Component/Cqrs/AbstractQueryMessage.php index 29e26d76..f3f48eee 100644 --- a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessage.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractQueryMessage.php @@ -4,8 +4,7 @@ namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Component\Cqrs\AbstractMessage; -use SonsOfPHP\Contract\Cqrs\Query\QueryMessageInterface; +use SonsOfPHP\Contract\Cqrs\QueryMessageInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php b/src/SonsOfPHP/Component/Cqrs/AbstractQueryMessageHandler.php similarity index 72% rename from src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php rename to src/SonsOfPHP/Component/Cqrs/AbstractQueryMessageHandler.php index 90ca3add..e4b76bf6 100644 --- a/src/SonsOfPHP/Component/Cqrs/Query/AbstractQueryMessageHandler.php +++ b/src/SonsOfPHP/Component/Cqrs/AbstractQueryMessageHandler.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Query; - -use SonsOfPHP\Contract\Cqrs\MessageHandlerInterface; +namespace SonsOfPHP\Component\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php b/src/SonsOfPHP/Component/Cqrs/CommandBus.php similarity index 52% rename from src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php rename to src/SonsOfPHP/Component/Cqrs/CommandBus.php index 523c17f7..00962e7e 100644 --- a/src/SonsOfPHP/Component/Cqrs/Command/CommandBus.php +++ b/src/SonsOfPHP/Component/Cqrs/CommandBus.php @@ -2,13 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Command; +namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Component\Cqrs\AbstractBus; -use SonsOfPHP\Component\Cqrs\AbstractMessage; -use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; -use SonsOfPHP\Contract\Cqrs\Command\CommandBusInterface; -use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; +use SonsOfPHP\Contract\Cqrs\CommandBusInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Exception/CqrsException.php b/src/SonsOfPHP/Component/Cqrs/Exception/CqrsException.php new file mode 100644 index 00000000..ecd28dc7 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Exception/CqrsException.php @@ -0,0 +1,12 @@ + + */ +class CqrsException extends \Exception implements CqrsExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Cqrs/Exception/NoHandlerFoundException.php b/src/SonsOfPHP/Component/Cqrs/Exception/NoHandlerFoundException.php new file mode 100644 index 00000000..78972fe7 --- /dev/null +++ b/src/SonsOfPHP/Component/Cqrs/Exception/NoHandlerFoundException.php @@ -0,0 +1,12 @@ + + */ +class NoHandlerFoundException extends \Exception implements NoHandlerFoundExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php index 68d846ed..857cce00 100644 --- a/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php +++ b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php @@ -5,6 +5,7 @@ namespace SonsOfPHP\Component\Cqrs; use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; +use SonsOfPHP\Component\Cqrs\Exception\NoHandlerFoundException; /** * @author Joshua Estes @@ -45,7 +46,7 @@ public function getHandlerForMessage(string|object $message): callable } if (!array_key_exists($message, $this->handlers)) { - throw new \Exception(sprintf('No handler for message "%s" found.', $message)); + throw new NoHandlerFoundException(sprintf('No handler for message "%s" found.', $message)); } return $this->handlers[$message]; diff --git a/src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php b/src/SonsOfPHP/Component/Cqrs/QueryBus.php similarity index 52% rename from src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php rename to src/SonsOfPHP/Component/Cqrs/QueryBus.php index 79730461..80325ebc 100644 --- a/src/SonsOfPHP/Component/Cqrs/Query/QueryBus.php +++ b/src/SonsOfPHP/Component/Cqrs/QueryBus.php @@ -2,13 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Query; +namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Component\Cqrs\AbstractMessage; -use SonsOfPHP\Component\Cqrs\AbstractBus; -use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; -use SonsOfPHP\Contract\Cqrs\Query\QueryBusInterface; -use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; +use SonsOfPHP\Contract\Cqrs\QueryBusInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php index 74b4989a..d328c146 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/AbstractMessageTest.php @@ -37,7 +37,7 @@ public function testItHasTheCorrectInterface(): void public function testWithWhenKeyIsAnArrayThatContainsAStringableValue(): void { $msg = $this->getMockForAbstractClass(AbstractMessage::class)->with([ - 'key' => new class implements \Stringable { + 'key' => new class () implements \Stringable { public function __toString(): string { return 'value'; @@ -113,7 +113,7 @@ public function testWithWorksAsExpectedWhenValueIsStringable(): void { $msg = $this->getMockForAbstractClass(AbstractMessage::class); - $value = new class implements \Stringable { + $value = new class () implements \Stringable { public function __toString(): string { return 'value'; diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php similarity index 73% rename from src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php rename to src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php index 71afac5b..b62aaacb 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/Command/CommandBusTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Tests\Command; +namespace SonsOfPHP\Component\Cqrs\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cqrs\Command\CommandBus; -use SonsOfPHP\Contract\Cqrs\Command\CommandBusInterface; +use SonsOfPHP\Component\Cqrs\CommandBus; +use SonsOfPHP\Contract\Cqrs\CommandBusInterface; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; /** - * @coversDefaultClass \SonsOfPHP\Component\Cqrs\Command\CommandBus + * @coversDefaultClass \SonsOfPHP\Component\Cqrs\CommandBus * - * @uses \SonsOfPHP\Component\Cqrs\Command\CommandBus + * @uses \SonsOfPHP\Component\Cqrs\CommandBus * @uses \SonsOfPHP\Component\Cqrs\AbstractBus */ final class CommandBusTest extends TestCase @@ -41,7 +41,7 @@ public function testAddHandler(): void { $this->provider->expects($this->once())->method('add'); $bus = new CommandBus($this->provider); - $bus->addHandler(new \stdClass(), function () {}); + $bus->addHandler(new \stdClass(), function (): void {}); } /** @@ -49,7 +49,7 @@ public function testAddHandler(): void */ public function testDispatch(): void { - $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(function () {}); + $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(function (): void {}); $bus = new CommandBus($this->provider); $bus->dispatch(new \stdClass()); } diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php index bbfa29ca..601134ec 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; +use SonsOfPHP\Contract\Cqrs\Exception\NoHandlerFoundExceptionInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Cqrs\MessageHandlerProvider @@ -31,8 +32,8 @@ public function testItHasTheCorrectInterface(): void public function testAddWithHandlerClass(): void { $provider = new MessageHandlerProvider(); - $provider->add(new \stdClass(), new class { - public function __invoke() {} + $provider->add(new \stdClass(), new class () { + public function __invoke(): void {} }); $property = new \ReflectionProperty($provider, 'handlers'); @@ -47,7 +48,7 @@ public function __invoke() {} public function testAddWithObject(): void { $provider = new MessageHandlerProvider(); - $provider->add(new \stdClass(), function() {}); + $provider->add(new \stdClass(), function (): void {}); $property = new \ReflectionProperty($provider, 'handlers'); $handlers = $property->getValue($provider); @@ -61,7 +62,7 @@ public function testAddWithObject(): void public function testAddWithString(): void { $provider = new MessageHandlerProvider(); - $provider->add('stdClass', function() {}); + $provider->add('stdClass', function (): void {}); $property = new \ReflectionProperty($provider, 'handlers'); $handlers = $property->getValue($provider); @@ -75,8 +76,8 @@ public function testAddWithString(): void public function testGetHandlerForMessageWhenClassIsInvokable(): void { $provider = new MessageHandlerProvider(); - $provider->add(new \stdClass(), new class { - public function __invoke() {} + $provider->add(new \stdClass(), new class () { + public function __invoke(): void {} }); $this->assertNotNull($provider->getHandlerForMessage('stdClass')); @@ -88,7 +89,7 @@ public function __invoke() {} public function testGetHandlerForMessageWhenNoHandlerExists(): void { $provider = new MessageHandlerProvider(); - $this->expectException('Exception'); + $this->expectException(NoHandlerFoundExceptionInterface::class); $this->assertNotNull($provider->getHandlerForMessage('stdClass')); } @@ -98,7 +99,7 @@ public function testGetHandlerForMessageWhenNoHandlerExists(): void public function testGetHandlerForMessageWhenStringIsPassedIn(): void { $provider = new MessageHandlerProvider(); - $provider->add(new \stdClass(), function() {}); + $provider->add(new \stdClass(), function (): void {}); $this->assertNotNull($provider->getHandlerForMessage('stdClass')); } @@ -109,7 +110,7 @@ public function testGetHandlerForMessageWhenStringIsPassedIn(): void public function testGetHandlerForMessageWhenObjectIsPassedIn(): void { $provider = new MessageHandlerProvider(); - $provider->add(new \stdClass(), function() {}); + $provider->add(new \stdClass(), function (): void {}); $this->assertNotNull($provider->getHandlerForMessage(new \stdClass())); } diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php similarity index 72% rename from src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php rename to src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php index 5e32e8f9..dd1b97e5 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/Query/QueryBusTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php @@ -2,17 +2,17 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Cqrs\Tests\Query; +namespace SonsOfPHP\Component\Cqrs\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cqrs\Query\QueryBus; -use SonsOfPHP\Contract\Cqrs\Query\QueryBusInterface; +use SonsOfPHP\Component\Cqrs\QueryBus; +use SonsOfPHP\Contract\Cqrs\QueryBusInterface; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; /** - * @coversDefaultClass \SonsOfPHP\Component\Cqrs\Query\QueryBus + * @coversDefaultClass \SonsOfPHP\Component\Cqrs\QueryBus * - * @uses \SonsOfPHP\Component\Cqrs\Query\QueryBus + * @uses \SonsOfPHP\Component\Cqrs\QueryBus * @uses \SonsOfPHP\Component\Cqrs\AbstractBus */ final class QueryBusTest extends TestCase @@ -41,7 +41,7 @@ public function testAddHandler(): void { $this->provider->expects($this->once())->method('add'); $bus = new QueryBus($this->provider); - $bus->addHandler(new \stdClass(), function () {}); + $bus->addHandler(new \stdClass(), function (): void {}); } /** @@ -49,9 +49,7 @@ public function testAddHandler(): void */ public function testHandle(): void { - $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(function () { - return 'testing'; - }); + $this->provider->expects($this->once())->method('getHandlerForMessage')->willReturn(fn() => 'testing'); $bus = new QueryBus($this->provider); $this->assertSame('testing', $bus->handle(new \stdClass())); } diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php similarity index 84% rename from src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php rename to src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php index 795c7957..bef1755a 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Command/CommandBusInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/CommandBusInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Command; - -use SonsOfPHP\Contract\Cqrs\Command\CommandMessageInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/CommandMessageHandlerInterface.php similarity index 71% rename from src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php rename to src/SonsOfPHP/Contract/Cqrs/CommandMessageHandlerInterface.php index 2022e293..a896b956 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageHandlerInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/CommandMessageHandlerInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Command; - -use SonsOfPHP\Contract\Cqrs\MessageHandlerInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/CommandMessageInterface.php similarity index 62% rename from src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php rename to src/SonsOfPHP/Contract/Cqrs/CommandMessageInterface.php index 157638b8..67807bd8 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Command/CommandMessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/CommandMessageInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Command; - -use SonsOfPHP\Contract\Cqrs\MessageInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php b/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerFoundExceptionInterface.php similarity index 74% rename from src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php rename to src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerFoundExceptionInterface.php index c70bee4a..8c014242 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerExceptionInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/Exception/NoHandlerFoundExceptionInterface.php @@ -10,4 +10,4 @@ * * @author Joshua Estes */ -interface NoHandlerExceptionInterface extends CqrsExceptionInterface {} +interface NoHandlerFoundExceptionInterface extends CqrsExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php b/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php similarity index 78% rename from src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php rename to src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php index 1e80e01a..03d98336 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Query/QueryBusInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/QueryBusInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Query; - -use SonsOfPHP\Contract\Cqrs\Query\QueryMessageInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php b/src/SonsOfPHP/Contract/Cqrs/QueryMessageHandlerInterface.php similarity index 81% rename from src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php rename to src/SonsOfPHP/Contract/Cqrs/QueryMessageHandlerInterface.php index 915c2914..fba60f67 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageHandlerInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/QueryMessageHandlerInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Query; - -use SonsOfPHP\Contract\Cqrs\MessageHandlerInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php b/src/SonsOfPHP/Contract/Cqrs/QueryMessageInterface.php similarity index 62% rename from src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php rename to src/SonsOfPHP/Contract/Cqrs/QueryMessageInterface.php index 307df1c8..5ccdfeb4 100644 --- a/src/SonsOfPHP/Contract/Cqrs/Query/QueryMessageInterface.php +++ b/src/SonsOfPHP/Contract/Cqrs/QueryMessageInterface.php @@ -2,9 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Contract\Cqrs\Query; - -use SonsOfPHP\Contract\Cqrs\MessageInterface; +namespace SonsOfPHP\Contract\Cqrs; /** * @author Joshua Estes From faff85fd2bb4669e9bf3f291f5f7e787e3956491 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 10:43:46 -0500 Subject: [PATCH 12/27] remove dead files --- docs/components/cqrs/command-handlers.md | 64 -------------------- docs/components/cqrs/commands.md | 77 ------------------------ docs/components/cqrs/queries.md | 18 ------ docs/components/cqrs/query-handlers.md | 56 ----------------- 4 files changed, 215 deletions(-) delete mode 100644 docs/components/cqrs/command-handlers.md delete mode 100644 docs/components/cqrs/commands.md delete mode 100644 docs/components/cqrs/queries.md delete mode 100644 docs/components/cqrs/query-handlers.md diff --git a/docs/components/cqrs/command-handlers.md b/docs/components/cqrs/command-handlers.md deleted file mode 100644 index 8fbed9a3..00000000 --- a/docs/components/cqrs/command-handlers.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: Command Handlers ---- - -# Command Handlers - -Once you create a Command, you need to create a Command Handler to handle that -command. Command Handlers do NOT return any results. - -```php -dispatch($command); - -// If you need to apply one or more stamps, this must be done -// before the command is dispatched. -$commandBus - ->withStamps([$stamp]) - ->dispatch($command); -``` diff --git a/docs/components/cqrs/commands.md b/docs/components/cqrs/commands.md deleted file mode 100644 index e5a9a0f9..00000000 --- a/docs/components/cqrs/commands.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: Commands ---- - -# Commands - -All Commands must implement the [`CommandMessageInterface`][CommandMessageInterface]. - -## Basic Command - -Simple Commands can be created quickly and easily. - -```php -userId = $userId; - } -} -``` - -## Options Resolver Command - -!!! attention - The `AbstractOptionsResolverCommand` reqires the `sonsofphp/cqrs-symfony` - package. - -The Options Resolver Command allows you to create more complex commands. For -example. - -```php -define('user_id') - ->required() - ->allowedTypes('int') - ->allowedValues(function ($value) { - return $value > 0; - }); - - } -} -``` - -To use the command, you just create a new instance of the command. - -```php - 1234]); - -// ... - -// Get an option -$userId = $command->getOption('user_id'); - -// Get ALL options -$options = $command->getOptions(): - -// Check if option exists -$command->hasOption('user_id'); -``` - -[CommandMessageInterface]: https://github.com/SonsOfPHP/sonsofphp/blob/main/packages/cqrs/Command/CommandMessageInterface.php diff --git a/docs/components/cqrs/queries.md b/docs/components/cqrs/queries.md deleted file mode 100644 index f2f5b274..00000000 --- a/docs/components/cqrs/queries.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Queries ---- - -# Queries - -```php -handle($query); -``` From 2ef1957fe4ac59be7efe54cb967591b503530872 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 10:48:36 -0500 Subject: [PATCH 13/27] docs --- docs/components/cqrs/index.md | 2 +- docs/contracts/cqrs/index.md | 2 +- mkdocs.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/components/cqrs/index.md b/docs/components/cqrs/index.md index 7fa3b50d..80a93123 100644 --- a/docs/components/cqrs/index.md +++ b/docs/components/cqrs/index.md @@ -1,5 +1,5 @@ --- -title: CQRS +title: Cqrs Component --- Command Query Responsibility Segregation is a simple concept. When you want diff --git a/docs/contracts/cqrs/index.md b/docs/contracts/cqrs/index.md index bea735b0..8ae01810 100644 --- a/docs/contracts/cqrs/index.md +++ b/docs/contracts/cqrs/index.md @@ -1,5 +1,5 @@ --- -title: Cqrs Contracts - Overview +title: Cqrs Contract --- In a nut shell, with CQRS you have Commands that will change the state of your diff --git a/mkdocs.yml b/mkdocs.yml index f161b276..34ffbf2e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: Sons of PHP - Documentation +site_name: Sons of PHP site_url: https://docs.sonsofphp.com/ site_author: Joshua Estes site_description: Sons of PHP creates and maintains helpful packages for PHP. From 3d42b63ff49438555156eb18fd808defa357c7a0 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 11:01:19 -0500 Subject: [PATCH 14/27] updates --- src/SonsOfPHP/Component/FeatureToggle/Context.php | 2 ++ .../FeatureToggle/Exception/FeatureToggleException.php | 4 +++- src/SonsOfPHP/Component/FeatureToggle/Feature.php | 4 ++++ .../Provider/InMemoryFeatureToggleProvider.php | 3 ++- .../Component/FeatureToggle/Tests/ContextTest.php | 2 +- .../Component/FeatureToggle/Tests/FeatureTest.php | 4 ++-- .../Provider/InMemoryFeatureToggleProviderTest.php | 4 ++-- .../Tests/Toggle/AlwaysDisabledToggleTest.php | 2 +- .../Tests/Toggle/AlwaysEnabledToggleTest.php | 2 +- .../FeatureToggle/Toggle/AlwaysDisabledToggle.php | 4 ++-- .../FeatureToggle/Toggle/AlwaysEnabledToggle.php | 4 ++-- .../FeatureToggle/ContextInterface.php | 2 +- .../Exception/FeatureToggleExceptionInterface.php | 10 ++++++++++ .../FeatureToggle/FeatureInterface.php | 2 +- .../FeatureToggle}/FeatureToggleProviderInterface.php | 4 ++-- .../FeatureToggle/ToggleInterface.php | 2 +- 16 files changed, 37 insertions(+), 18 deletions(-) rename src/SonsOfPHP/{Component => Contract}/FeatureToggle/ContextInterface.php (87%) create mode 100644 src/SonsOfPHP/Contract/FeatureToggle/Exception/FeatureToggleExceptionInterface.php rename src/SonsOfPHP/{Component => Contract}/FeatureToggle/FeatureInterface.php (90%) rename src/SonsOfPHP/{Component/FeatureToggle/Provider => Contract/FeatureToggle}/FeatureToggleProviderInterface.php (78%) rename src/SonsOfPHP/{Component => Contract}/FeatureToggle/ToggleInterface.php (85%) diff --git a/src/SonsOfPHP/Component/FeatureToggle/Context.php b/src/SonsOfPHP/Component/FeatureToggle/Context.php index c00767ab..ddb459f4 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Context.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Context.php @@ -4,6 +4,8 @@ namespace SonsOfPHP\Component\FeatureToggle; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; + /** * @author Joshua Estes */ diff --git a/src/SonsOfPHP/Component/FeatureToggle/Exception/FeatureToggleException.php b/src/SonsOfPHP/Component/FeatureToggle/Exception/FeatureToggleException.php index f4336826..4e4cb5fc 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Exception/FeatureToggleException.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Exception/FeatureToggleException.php @@ -4,7 +4,9 @@ namespace SonsOfPHP\Component\FeatureToggle\Exception; +use SonsOfPHP\Contract\FeatureToggle\Exception\FeatureToggleExceptionInterface; + /** * @author Joshua Estes */ -class FeatureToggleException extends \Exception {} +class FeatureToggleException extends \Exception implements FeatureToggleExceptionInterface {} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Feature.php b/src/SonsOfPHP/Component/FeatureToggle/Feature.php index c95c0e7a..47648c9f 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Feature.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Feature.php @@ -4,6 +4,10 @@ namespace SonsOfPHP\Component\FeatureToggle; +use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; + /** * Feature. * diff --git a/src/SonsOfPHP/Component/FeatureToggle/Provider/InMemoryFeatureToggleProvider.php b/src/SonsOfPHP/Component/FeatureToggle/Provider/InMemoryFeatureToggleProvider.php index 9f6a84e3..4879521d 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Provider/InMemoryFeatureToggleProvider.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Provider/InMemoryFeatureToggleProvider.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\FeatureToggle\Provider; -use SonsOfPHP\Component\FeatureToggle\FeatureInterface; +use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; +use SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php index d89491ea..842ee242 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Context; -use SonsOfPHP\Component\FeatureToggle\ContextInterface; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; /** * @coversDefaultClass \SonsOfPHP\Component\FeatureToggle\Context diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/FeatureTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/FeatureTest.php index fee35644..90d03805 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/FeatureTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/FeatureTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Feature; -use SonsOfPHP\Component\FeatureToggle\FeatureInterface; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; /** * @coversDefaultClass \SonsOfPHP\Component\FeatureToggle\Feature diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php index 4d8fa666..354cf307 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php @@ -6,9 +6,9 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Feature; -use SonsOfPHP\Component\FeatureToggle\Provider\FeatureToggleProviderInterface; +use SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface; use SonsOfPHP\Component\FeatureToggle\Provider\InMemoryFeatureToggleProvider; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; use PHPUnit\Framework\MockObject; /** diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysDisabledToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysDisabledToggleTest.php index 4aaa4e3f..2f305a63 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysDisabledToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysDisabledToggleTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysDisabledToggle; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; /** * @coversDefaultClass \SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysDisabledToggle diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysEnabledToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysEnabledToggleTest.php index 87bd194b..bb74dc88 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysEnabledToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AlwaysEnabledToggleTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysEnabledToggle; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; /** * @coversDefaultClass \SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysEnabledToggle diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysDisabledToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysDisabledToggle.php index 77181c9e..ff536a6a 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysDisabledToggle.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysDisabledToggle.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\FeatureToggle\Toggle; -use SonsOfPHP\Component\FeatureToggle\ContextInterface; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; /** * Always Disabled. diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysEnabledToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysEnabledToggle.php index 3e80255d..05991445 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysEnabledToggle.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AlwaysEnabledToggle.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\FeatureToggle\Toggle; -use SonsOfPHP\Component\FeatureToggle\ContextInterface; -use SonsOfPHP\Component\FeatureToggle\ToggleInterface; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; +use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; /** * Always enabled. diff --git a/src/SonsOfPHP/Component/FeatureToggle/ContextInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php similarity index 87% rename from src/SonsOfPHP/Component/FeatureToggle/ContextInterface.php rename to src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php index 1613f015..87a49d58 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/ContextInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\FeatureToggle; +namespace SonsOfPHP\Contract\FeatureToggle; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Contract/FeatureToggle/Exception/FeatureToggleExceptionInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/Exception/FeatureToggleExceptionInterface.php new file mode 100644 index 00000000..ee18cef0 --- /dev/null +++ b/src/SonsOfPHP/Contract/FeatureToggle/Exception/FeatureToggleExceptionInterface.php @@ -0,0 +1,10 @@ + + */ +interface FeatureToggleExceptionInterface {} diff --git a/src/SonsOfPHP/Component/FeatureToggle/FeatureInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/FeatureInterface.php similarity index 90% rename from src/SonsOfPHP/Component/FeatureToggle/FeatureInterface.php rename to src/SonsOfPHP/Contract/FeatureToggle/FeatureInterface.php index c3a8ce2a..05add3fd 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/FeatureInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/FeatureInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\FeatureToggle; +namespace SonsOfPHP\Contract\FeatureToggle; /** * Feature Interface. diff --git a/src/SonsOfPHP/Component/FeatureToggle/Provider/FeatureToggleProviderInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php similarity index 78% rename from src/SonsOfPHP/Component/FeatureToggle/Provider/FeatureToggleProviderInterface.php rename to src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php index afbed491..1249cdc1 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Provider/FeatureToggleProviderInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\FeatureToggle\Provider; +namespace SonsOfPHP\Contract\FeatureToggle; -use SonsOfPHP\Component\FeatureToggle\FeatureInterface; +use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; /** * Feature Toggle Provider Interface. diff --git a/src/SonsOfPHP/Component/FeatureToggle/ToggleInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/ToggleInterface.php similarity index 85% rename from src/SonsOfPHP/Component/FeatureToggle/ToggleInterface.php rename to src/SonsOfPHP/Contract/FeatureToggle/ToggleInterface.php index 5ca4d68f..bf26fd85 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/ToggleInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/ToggleInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\FeatureToggle; +namespace SonsOfPHP\Contract\FeatureToggle; /** * @author Joshua Estes From 5abd14286466c7e435082a90df14a3db880a57b7 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 11:19:11 -0500 Subject: [PATCH 15/27] cs fixes --- .../FeatureToggle/Toggle/ChainToggle.php | 33 +++++++++++++++++++ .../FeatureToggle/Toggle/DateRangeToggle.php | 28 ++++++++++++++++ .../Component/FeatureToggle/composer.json | 2 +- .../FeatureToggleProviderInterface.php | 2 -- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php new file mode 100644 index 00000000..65eddfe0 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php @@ -0,0 +1,33 @@ + + */ +class ChainToggle implements ToggleInterface +{ + public function __construct( + private array $toggles, + ) {} + + public function isEnabled(?ContextInterface $context = null): bool + { + // @todo What if I only want to return true if ALL the toggles are true? + foreach ($this->toggles as $toggle) { + if ($toggle->isEnabled($context)) { + return true; + } + } + + return false; + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php new file mode 100644 index 00000000..2efc63a8 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php @@ -0,0 +1,28 @@ + + */ +class DateRangeToggle implements ToggleInterface +{ + public function __construct( + private \DateTimeImmutable $start, + private \DateTimeImmutable $stop, + ) {} + + public function isEnabled(?ContextInterface $context = null): bool + { + $now = new \DateTimeImmutable(); + + return ($this->start >= $now && $now <= $this->stop); + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/composer.json b/src/SonsOfPHP/Component/FeatureToggle/composer.json index 7dc43262..46be7ed7 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/composer.json +++ b/src/SonsOfPHP/Component/FeatureToggle/composer.json @@ -56,4 +56,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} diff --git a/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php index 1249cdc1..fe361aee 100644 --- a/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/FeatureToggleProviderInterface.php @@ -4,8 +4,6 @@ namespace SonsOfPHP\Contract\FeatureToggle; -use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; - /** * Feature Toggle Provider Interface. * From 3ff50ac4b73ccb112fb6573ee43536bd30c50596 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 11:32:28 -0500 Subject: [PATCH 16/27] updates --- .../Component/FeatureToggle/Context.php | 21 +++++++++++++++++-- .../FeatureToggle/Tests/ContextTest.php | 18 ++++++++++++++++ .../FeatureToggle/ContextInterface.php | 20 ++++++++++++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/SonsOfPHP/Component/FeatureToggle/Context.php b/src/SonsOfPHP/Component/FeatureToggle/Context.php index ddb459f4..6774cfb4 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Context.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Context.php @@ -13,6 +13,9 @@ final class Context implements ContextInterface { public function __construct(private array $data = []) {} + /** + * $context[$offset] = $value; + */ public function offsetSet($offset, $value): void { if (null === $offset) { @@ -22,16 +25,26 @@ public function offsetSet($offset, $value): void $this->data[$offset] = $value; } + /** + * isset($context[$offset]) + * empty($context[$offset]) + */ public function offsetExists($offset): bool { return \array_key_exists($offset, $this->data); } + /** + * unset($context[$offset]); + */ public function offsetUnset($offset): void { unset($this->data[$offset]); } + /** + * $value = $context[$offset]; + */ public function offsetGet($offset): mixed { return $this->data[$offset] ?? null; @@ -47,12 +60,16 @@ public function jsonSerialize(): mixed return $this->data; } - public function get(string $key): mixed + public function get(string $key, mixed $default = null): mixed { + if (!$this->has($key)) { + return $default; + } + return $this->offsetGet($key); } - public function set(string $key, $value): ContextInterface + public function set(string $key, mixed $value): ContextInterface { $this->offsetSet($key, $value); diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php index 842ee242..f30717ca 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php @@ -40,4 +40,22 @@ public function testItWorksCorrectly(): void $context->set('test', 'value'); $this->assertSame('value', $context->get('test')); } + + /** + * @covers ::get + */ + public function testGetWhenThereIsNoValueForKey(): void + { + $context = new Context(); + $this->assertNull($context->get('test')); + } + + /** + * @covers ::get + */ + public function testGetWhenThereIsNoValueForKeyAndDefaultValueIsProvided(): void + { + $context = new Context(); + $this->assertTrue($context->get('test', true)); + } } diff --git a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php index 87a49d58..ca304920 100644 --- a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php @@ -5,13 +5,29 @@ namespace SonsOfPHP\Contract\FeatureToggle; /** + * Context is used to pass additional paramters to a toggle + * + * @todo Does it need all the extra interfaces? Doubtful + * * @author Joshua Estes */ interface ContextInterface extends \ArrayAccess, \IteratorAggregate, \JsonSerializable { - public function get(string $key); + /** + * Get Context Parameters + * + * If the key does not exist, the $default should be returned + * + * @throws \InvalidArgumentException if key or default is invalid + */ + public function get(string $key, mixed $default = null); - public function set(string $key, $value): self; + /** + * @throws \InvalidArgumentException if key or value is invalid + * + * @todo If this is a value object, it should be "with" instead of "set" + */ + public function set(string $key, mixed $value): self; public function has(string $key): bool; } From baf4d542d8620eee2c7d6bee7b45d0a474ad8822 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 14:58:32 -0500 Subject: [PATCH 17/27] feature toggle stuff --- .../Component/FeatureToggle/Context.php | 55 ++------------- .../FeatureToggle/Tests/ContextTest.php | 70 ++++++++++++++++--- .../Tests/Toggle/AffirmativeToggleTest.php | 59 ++++++++++++++++ .../Tests/Toggle/ChainToggleTest.php | 59 ++++++++++++++++ .../Tests/Toggle/DateRangeToggleTest.php | 58 +++++++++++++++ .../Tests/Toggle/MockToggleTest.php | 61 ++++++++++++++++ .../Toggle/AffirmativeToggle.php | 32 +++++++++ .../FeatureToggle/Toggle/ChainToggle.php | 1 - .../FeatureToggle/Toggle/DateRangeToggle.php | 2 +- .../FeatureToggle/Toggle/MockToggle.php | 23 ++++++ .../FeatureToggle/ContextInterface.php | 18 +++-- 11 files changed, 372 insertions(+), 66 deletions(-) create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Toggle/AffirmativeToggle.php create mode 100644 src/SonsOfPHP/Component/FeatureToggle/Toggle/MockToggle.php diff --git a/src/SonsOfPHP/Component/FeatureToggle/Context.php b/src/SonsOfPHP/Component/FeatureToggle/Context.php index 6774cfb4..162147c0 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Context.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Context.php @@ -13,71 +13,28 @@ final class Context implements ContextInterface { public function __construct(private array $data = []) {} - /** - * $context[$offset] = $value; - */ - public function offsetSet($offset, $value): void + public function get(?string $key = null, mixed $default = null): mixed { - if (null === $offset) { - throw new \Exception('Requires a key'); + if (null === $key) { + return $this->data; } - $this->data[$offset] = $value; - } - - /** - * isset($context[$offset]) - * empty($context[$offset]) - */ - public function offsetExists($offset): bool - { - return \array_key_exists($offset, $this->data); - } - - /** - * unset($context[$offset]); - */ - public function offsetUnset($offset): void - { - unset($this->data[$offset]); - } - - /** - * $value = $context[$offset]; - */ - public function offsetGet($offset): mixed - { - return $this->data[$offset] ?? null; - } - - public function getIterator(): \Traversable - { - return new \ArrayIterator($this->data); - } - - public function jsonSerialize(): mixed - { - return $this->data; - } - - public function get(string $key, mixed $default = null): mixed - { if (!$this->has($key)) { return $default; } - return $this->offsetGet($key); + return $this->data[$key]; } public function set(string $key, mixed $value): ContextInterface { - $this->offsetSet($key, $value); + $this->data[$key] = $value; return $this; } public function has(string $key): bool { - return $this->offsetExists($key); + return \array_key_exists($key, $this->data); } } diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php index f30717ca..38bb3642 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/ContextTest.php @@ -26,19 +26,25 @@ public function testItHasTheCorrectInterface(): void } /** - * @covers ::get - * @covers ::has - * @covers ::set + * @covers ::__construct */ - public function testItWorksCorrectly(): void + public function testConstruct(): void { - $context = new Context(); - - $this->assertFalse($context->has('test')); - $this->assertNull($context->get('test'), 'Assert NULL is returned if not set'); + $context = new Context([ + 'key' => 'value', + ]); + $this->assertSame('value', $context->get('key')); + } - $context->set('test', 'value'); - $this->assertSame('value', $context->get('test')); + /** + * @covers ::get + */ + public function testGetWhenThereIsValueForKey(): void + { + $context = new Context([ + 'key' => 'value', + ]); + $this->assertSame('value', $context->get('key')); } /** @@ -58,4 +64,48 @@ public function testGetWhenThereIsNoValueForKeyAndDefaultValueIsProvided(): void $context = new Context(); $this->assertTrue($context->get('test', true)); } + + /** + * @covers ::get + */ + public function testGetWithNoArgumentsWillReturnAll(): void + { + $context = new Context(); + $context->set('key', 'value'); + $parameters = $context->get(); + $this->assertIsArray($parameters); + $this->assertArrayHasKey('key', $parameters); + } + + /** + * @covers ::set + */ + public function testWorksAsExpected(): void + { + $context = new Context(); + $context->set('key', 'value'); + $this->assertSame('value', $context->get('key')); + } + + /** + * @covers ::has + */ + public function testHasWillReturnTrueWhenKeyExists(): void + { + $context = new Context([ + 'key' => 'value', + ]); + $this->assertTrue($context->has('key')); + } + + /** + * @covers ::has + */ + public function testHasWillReturnFalseWhenKeyExists(): void + { + $context = new Context([ + 'key' => 'value', + ]); + $this->assertFalse($context->has('value')); + } } diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php new file mode 100644 index 00000000..efe6832a --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php @@ -0,0 +1,59 @@ +assertInstanceOf(ToggleInterface::class, $toggle); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWhenAllTogglesAreEnabled(): void + { + $toggle = new AffirmativeToggle([ + new MockToggle(enabled: true), + new MockToggle(enabled: true), + new MockToggle(enabled: true), + ]); + + $this->assertTrue($toggle->isEnabled()); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWhenOneToggleIsDisabled(): void + { + $toggle = new AffirmativeToggle([ + new MockToggle(enabled: true), + new MockToggle(enabled: false), + new MockToggle(enabled: true), + ]); + + $this->assertFalse($toggle->isEnabled()); + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php new file mode 100644 index 00000000..d123b7e1 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php @@ -0,0 +1,59 @@ +assertInstanceOf(ToggleInterface::class, $toggle); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWhenAtLeastOneIsEnabled(): void + { + $toggle = new ChainToggle([ + new MockToggle(enabled: false), + new MockToggle(enabled: false), + new MockToggle(enabled: true), + ]); + + $this->assertTrue($toggle->isEnabled()); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWhenAllTogglesAreDisabled(): void + { + $toggle = new ChainToggle([ + new MockToggle(enabled: false), + new MockToggle(enabled: false), + new MockToggle(enabled: false), + ]); + + $this->assertFalse($toggle->isEnabled()); + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php new file mode 100644 index 00000000..3dd3c4d5 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php @@ -0,0 +1,58 @@ +assertInstanceOf(ToggleInterface::class, $toggle); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWorksAsExpected(): void + { + $toggle = new DateRangeToggle( + start: new \DateTimeImmutable('-90 days'), + stop: new \DateTimeImmutable('+90 days'), + ); + + $this->assertTrue($toggle->isEnabled()); + } + + /** + * @covers ::isEnabled + */ + public function testIsEnabledWorksAsExpectedWhenOutsideDateRange(): void + { + $toggle = new DateRangeToggle( + start: new \DateTimeImmutable('-90 days'), + stop: new \DateTimeImmutable('-30 days'), + ); + + $this->assertFalse($toggle->isEnabled()); + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php new file mode 100644 index 00000000..244c1d43 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php @@ -0,0 +1,61 @@ +assertInstanceOf(ToggleInterface::class, $toggle); + } + + /** + * @covers ::__construct + * @covers ::isEnabled + */ + public function testIsEnabledWillReturnTrueByDefault(): void + { + $toggle = new MockToggle(); + + $this->assertTrue($toggle->isEnabled()); + } + + /** + * @covers ::__construct + * @covers ::isEnabled + */ + public function testIsEnabledWillReturnTrueWhenEnabledIsSetToTrue(): void + { + $toggle = new MockToggle(enabled: true); + + $this->assertTrue($toggle->isEnabled()); + } + + /** + * @covers ::__construct + * @covers ::isEnabled + */ + public function testIsEnabledWillReturnFalseWhenEnabledIsSetToFalse(): void + { + $toggle = new MockToggle(enabled: false); + + $this->assertFalse($toggle->isEnabled()); + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/AffirmativeToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AffirmativeToggle.php new file mode 100644 index 00000000..e15235e1 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/AffirmativeToggle.php @@ -0,0 +1,32 @@ + + */ +class AffirmativeToggle implements ToggleInterface +{ + public function __construct( + private array $toggles, + ) {} + + public function isEnabled(?ContextInterface $context = null): bool + { + foreach ($this->toggles as $toggle) { + if (!$toggle->isEnabled($context)) { + return false; + } + } + + return true; + } +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php index 65eddfe0..35d90d33 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/ChainToggle.php @@ -21,7 +21,6 @@ public function __construct( public function isEnabled(?ContextInterface $context = null): bool { - // @todo What if I only want to return true if ALL the toggles are true? foreach ($this->toggles as $toggle) { if ($toggle->isEnabled($context)) { return true; diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php index 2efc63a8..99be2729 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/DateRangeToggle.php @@ -23,6 +23,6 @@ public function isEnabled(?ContextInterface $context = null): bool { $now = new \DateTimeImmutable(); - return ($this->start >= $now && $now <= $this->stop); + return ($this->start <= $now && $now <= $this->stop); } } diff --git a/src/SonsOfPHP/Component/FeatureToggle/Toggle/MockToggle.php b/src/SonsOfPHP/Component/FeatureToggle/Toggle/MockToggle.php new file mode 100644 index 00000000..11626ca3 --- /dev/null +++ b/src/SonsOfPHP/Component/FeatureToggle/Toggle/MockToggle.php @@ -0,0 +1,23 @@ + + */ +class MockToggle implements ToggleInterface +{ + public function __construct( + private bool $enabled = true, + ) {} + + public function isEnabled(?ContextInterface $context = null): bool + { + return $this->enabled; + } +} diff --git a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php index ca304920..9ce80398 100644 --- a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php @@ -7,11 +7,9 @@ /** * Context is used to pass additional paramters to a toggle * - * @todo Does it need all the extra interfaces? Doubtful - * * @author Joshua Estes */ -interface ContextInterface extends \ArrayAccess, \IteratorAggregate, \JsonSerializable +interface ContextInterface// extends \ArrayAccess, \IteratorAggregate, \JsonSerializable { /** * Get Context Parameters @@ -24,10 +22,20 @@ public function get(string $key, mixed $default = null); /** * @throws \InvalidArgumentException if key or value is invalid - * - * @todo If this is a value object, it should be "with" instead of "set" */ public function set(string $key, mixed $value): self; + /** + * If Context is a value object, with should be used instead. + * + * If key and value are the same, no need to clone, just return the same + * object as nothing has changed + * + * @throws \InvalidArgumentException if key or value is invalid + */ + //public function with(array|string $key, mixed $value = null): static; + + /** + */ public function has(string $key): bool; } From f89a4878e1c47775762a667b4a1576b82870187a Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 15:04:36 -0500 Subject: [PATCH 18/27] updates --- src/SonsOfPHP/Component/Cqrs/composer.json | 4 ++-- src/SonsOfPHP/Component/EventSourcing/composer.json | 4 ++-- src/SonsOfPHP/Component/FeatureToggle/composer.json | 2 +- src/SonsOfPHP/Component/Filesystem/composer.json | 4 ++-- src/SonsOfPHP/Component/Money/composer.json | 4 ++-- src/SonsOfPHP/Component/Version/composer.json | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/SonsOfPHP/Component/Cqrs/composer.json b/src/SonsOfPHP/Component/Cqrs/composer.json index 2bdc29fb..b0db9049 100644 --- a/src/SonsOfPHP/Component/Cqrs/composer.json +++ b/src/SonsOfPHP/Component/Cqrs/composer.json @@ -39,7 +39,7 @@ "symfony/messenger": "^5 || ^6" }, "provide": { - "sonsofphp/cqrs-contract-implementation": "0.3.x-dev" + "sonsofphp/cqrs-implementation": "0.3.x-dev" }, "suggest": { "sonsofphp/event-sourcing": "Use with event sourcing", @@ -61,4 +61,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} diff --git a/src/SonsOfPHP/Component/EventSourcing/composer.json b/src/SonsOfPHP/Component/EventSourcing/composer.json index 15e88515..56075820 100644 --- a/src/SonsOfPHP/Component/EventSourcing/composer.json +++ b/src/SonsOfPHP/Component/EventSourcing/composer.json @@ -36,7 +36,7 @@ "phpunit/phpunit": "^10.4" }, "provide": { - "sonsofphp/event-sourcing-contract-implementation": "0.3.x-dev" + "sonsofphp/event-sourcing-implementation": "0.3.x-dev" }, "suggest": { "sonsofphp/event-sourcing-doctrine": "Adds additional functionality using Doctrine", @@ -58,4 +58,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} diff --git a/src/SonsOfPHP/Component/FeatureToggle/composer.json b/src/SonsOfPHP/Component/FeatureToggle/composer.json index 46be7ed7..9670021e 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/composer.json +++ b/src/SonsOfPHP/Component/FeatureToggle/composer.json @@ -38,7 +38,7 @@ "php": ">=8.1" }, "provide": { - "sonsofphp/feature-toggle-contract-implementation": "0.3.x-dev" + "sonsofphp/feature-toggle-implementation": "0.3.x-dev" }, "extra": { "sort-packages": true, diff --git a/src/SonsOfPHP/Component/Filesystem/composer.json b/src/SonsOfPHP/Component/Filesystem/composer.json index 72f3238a..afc9907f 100644 --- a/src/SonsOfPHP/Component/Filesystem/composer.json +++ b/src/SonsOfPHP/Component/Filesystem/composer.json @@ -34,7 +34,7 @@ "php": ">=8.1" }, "provide": { - "sonsofphp/filesystem-contract-implementation": "0.3.x-dev" + "sonsofphp/filesystem-implementation": "0.3.x-dev" }, "extra": { "sort-packages": true, @@ -52,4 +52,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} diff --git a/src/SonsOfPHP/Component/Money/composer.json b/src/SonsOfPHP/Component/Money/composer.json index cd3f3998..135d991b 100644 --- a/src/SonsOfPHP/Component/Money/composer.json +++ b/src/SonsOfPHP/Component/Money/composer.json @@ -35,7 +35,7 @@ "php": ">=8.1" }, "provide": { - "sonsofphp/money-contract-implementation": "0.3.x-dev" + "sonsofphp/money-implementation": "0.3.x-dev" }, "extra": { "sort-packages": true, @@ -53,4 +53,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} diff --git a/src/SonsOfPHP/Component/Version/composer.json b/src/SonsOfPHP/Component/Version/composer.json index 1842b02b..a5a5c0be 100644 --- a/src/SonsOfPHP/Component/Version/composer.json +++ b/src/SonsOfPHP/Component/Version/composer.json @@ -33,7 +33,7 @@ "php": ">=8.1" }, "provide": { - "sonsofphp/version-contract-implementation": "0.3.x-dev" + "sonsofphp/version-implementation": "0.3.x-dev" }, "extra": { "sort-packages": true, @@ -51,4 +51,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} \ No newline at end of file +} From b750dbc0525bc349a7d56cb42b8eae6681c796a1 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 15:08:03 -0500 Subject: [PATCH 19/27] updates --- src/SonsOfPHP/Component/Cqrs/composer.json | 3 ++- src/SonsOfPHP/Component/EventSourcing/composer.json | 1 + src/SonsOfPHP/Component/FeatureToggle/composer.json | 3 ++- src/SonsOfPHP/Component/Filesystem/composer.json | 3 ++- src/SonsOfPHP/Component/Money/composer.json | 3 ++- src/SonsOfPHP/Component/Version/composer.json | 3 ++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/SonsOfPHP/Component/Cqrs/composer.json b/src/SonsOfPHP/Component/Cqrs/composer.json index b0db9049..01719ff9 100644 --- a/src/SonsOfPHP/Component/Cqrs/composer.json +++ b/src/SonsOfPHP/Component/Cqrs/composer.json @@ -33,7 +33,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.1" + "php": ">=8.1", + "sonsofphp/cqrs-contract": "0.3.x-dev" }, "require-dev": { "symfony/messenger": "^5 || ^6" diff --git a/src/SonsOfPHP/Component/EventSourcing/composer.json b/src/SonsOfPHP/Component/EventSourcing/composer.json index 56075820..45517427 100644 --- a/src/SonsOfPHP/Component/EventSourcing/composer.json +++ b/src/SonsOfPHP/Component/EventSourcing/composer.json @@ -30,6 +30,7 @@ "prefer-stable": true, "require": { "php": ">=8.1", + "sonsofphp/event-sourcing-contract": "^0.3.x-dev", "sonsofphp/event-dispatcher": "^0.3.x-dev" }, "require-dev": { diff --git a/src/SonsOfPHP/Component/FeatureToggle/composer.json b/src/SonsOfPHP/Component/FeatureToggle/composer.json index 9670021e..cdadf009 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/composer.json +++ b/src/SonsOfPHP/Component/FeatureToggle/composer.json @@ -35,7 +35,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.1" + "php": ">=8.1", + "sonsofphp/feature-toggle-contract": "0.3.x-dev" }, "provide": { "sonsofphp/feature-toggle-implementation": "0.3.x-dev" diff --git a/src/SonsOfPHP/Component/Filesystem/composer.json b/src/SonsOfPHP/Component/Filesystem/composer.json index afc9907f..967ac2a6 100644 --- a/src/SonsOfPHP/Component/Filesystem/composer.json +++ b/src/SonsOfPHP/Component/Filesystem/composer.json @@ -31,7 +31,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.1" + "php": ">=8.1", + "sonsofphp/filesystem-contract": "0.3.x-dev" }, "provide": { "sonsofphp/filesystem-implementation": "0.3.x-dev" diff --git a/src/SonsOfPHP/Component/Money/composer.json b/src/SonsOfPHP/Component/Money/composer.json index 135d991b..d8b4499e 100644 --- a/src/SonsOfPHP/Component/Money/composer.json +++ b/src/SonsOfPHP/Component/Money/composer.json @@ -32,7 +32,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.1" + "php": ">=8.1", + "sonsofphp/money-contract": "0.3.x-dev" }, "provide": { "sonsofphp/money-implementation": "0.3.x-dev" diff --git a/src/SonsOfPHP/Component/Version/composer.json b/src/SonsOfPHP/Component/Version/composer.json index a5a5c0be..3fd0a014 100644 --- a/src/SonsOfPHP/Component/Version/composer.json +++ b/src/SonsOfPHP/Component/Version/composer.json @@ -30,7 +30,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=8.1" + "php": ">=8.1", + "sonsofphp/version-contract": "0.3.x-dev" }, "provide": { "sonsofphp/version-implementation": "0.3.x-dev" From 750bd597d3c6ce23593bc65a4f46bc026ad86ffd Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 15:10:12 -0500 Subject: [PATCH 20/27] moving interfaces out --- src/SonsOfPHP/{Component => Contract}/Money/AmountInterface.php | 0 src/SonsOfPHP/{Component => Contract}/Money/CurrencyInterface.php | 0 .../Money}/CurrencyProviderInterface.php | 0 src/SonsOfPHP/{Component => Contract}/Money/MoneyInterface.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/SonsOfPHP/{Component => Contract}/Money/AmountInterface.php (100%) rename src/SonsOfPHP/{Component => Contract}/Money/CurrencyInterface.php (100%) rename src/SonsOfPHP/{Component/Money/CurrencyProvider => Contract/Money}/CurrencyProviderInterface.php (100%) rename src/SonsOfPHP/{Component => Contract}/Money/MoneyInterface.php (100%) diff --git a/src/SonsOfPHP/Component/Money/AmountInterface.php b/src/SonsOfPHP/Contract/Money/AmountInterface.php similarity index 100% rename from src/SonsOfPHP/Component/Money/AmountInterface.php rename to src/SonsOfPHP/Contract/Money/AmountInterface.php diff --git a/src/SonsOfPHP/Component/Money/CurrencyInterface.php b/src/SonsOfPHP/Contract/Money/CurrencyInterface.php similarity index 100% rename from src/SonsOfPHP/Component/Money/CurrencyInterface.php rename to src/SonsOfPHP/Contract/Money/CurrencyInterface.php diff --git a/src/SonsOfPHP/Component/Money/CurrencyProvider/CurrencyProviderInterface.php b/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php similarity index 100% rename from src/SonsOfPHP/Component/Money/CurrencyProvider/CurrencyProviderInterface.php rename to src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php diff --git a/src/SonsOfPHP/Component/Money/MoneyInterface.php b/src/SonsOfPHP/Contract/Money/MoneyInterface.php similarity index 100% rename from src/SonsOfPHP/Component/Money/MoneyInterface.php rename to src/SonsOfPHP/Contract/Money/MoneyInterface.php From 95b558b5b6c88db867038e95b033af2ad8270409 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 15:23:31 -0500 Subject: [PATCH 21/27] updates --- src/SonsOfPHP/Component/Money/Amount.php | 1 + src/SonsOfPHP/Component/Money/Money.php | 3 +++ src/SonsOfPHP/Component/Money/Tests/AmountTest.php | 2 +- src/SonsOfPHP/Component/Money/Tests/CurrencyTest.php | 2 +- src/SonsOfPHP/Component/Money/Tests/MoneyTest.php | 2 +- src/SonsOfPHP/Contract/Money/AmountInterface.php | 6 +++--- src/SonsOfPHP/Contract/Money/CurrencyInterface.php | 4 ++-- .../Contract/Money/CurrencyProviderInterface.php | 10 +++++----- src/SonsOfPHP/Contract/Money/MoneyInterface.php | 6 +++--- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/SonsOfPHP/Component/Money/Amount.php b/src/SonsOfPHP/Component/Money/Amount.php index d0d65e26..d26c7b8f 100644 --- a/src/SonsOfPHP/Component/Money/Amount.php +++ b/src/SonsOfPHP/Component/Money/Amount.php @@ -18,6 +18,7 @@ use SonsOfPHP\Component\Money\Query\Amount\IsNegativeAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsPositiveAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsZeroAmountQuery; +use SonsOfPHP\Contract\Money\AmountInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Money.php b/src/SonsOfPHP/Component/Money/Money.php index 7fb8f243..31ad0096 100644 --- a/src/SonsOfPHP/Component/Money/Money.php +++ b/src/SonsOfPHP/Component/Money/Money.php @@ -18,6 +18,9 @@ use SonsOfPHP\Component\Money\Query\Money\IsPositiveMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\IsZeroMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\MoneyQueryInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\AmountInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Tests/AmountTest.php b/src/SonsOfPHP/Component/Money/Tests/AmountTest.php index df62570f..700bf28c 100644 --- a/src/SonsOfPHP/Component/Money/Tests/AmountTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/AmountTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Amount diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyTest.php index c0ff7716..299e6ccc 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Currency diff --git a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php index 1b84961c..25b4a964 100644 --- a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php @@ -8,7 +8,7 @@ use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Money diff --git a/src/SonsOfPHP/Contract/Money/AmountInterface.php b/src/SonsOfPHP/Contract/Money/AmountInterface.php index 2d590862..f5f7a456 100644 --- a/src/SonsOfPHP/Contract/Money/AmountInterface.php +++ b/src/SonsOfPHP/Contract/Money/AmountInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money; +namespace SonsOfPHP\Contract\Money; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * Amount. diff --git a/src/SonsOfPHP/Contract/Money/CurrencyInterface.php b/src/SonsOfPHP/Contract/Money/CurrencyInterface.php index c89ddbb9..c1d55275 100644 --- a/src/SonsOfPHP/Contract/Money/CurrencyInterface.php +++ b/src/SonsOfPHP/Contract/Money/CurrencyInterface.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money; +namespace SonsOfPHP\Contract\Money; -use SonsOfPHP\Component\Money\Query\Currency\CurrencyQueryInterface; +use SonsOfPHP\Contract\Money\Query\Currency\CurrencyQueryInterface; /** * Currency Interface. diff --git a/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php b/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php index cd09bc9c..b8d7afb1 100644 --- a/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php +++ b/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money\CurrencyProvider; +namespace SonsOfPHP\Contract\Money; -use SonsOfPHP\Component\Money\CurrencyInterface; -use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\Exception\UnknownCurrencyException; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; +use SonsOfPHP\Contract\Money\Exception\UnknownCurrencyExceptionInterface; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** * Currency Provider. diff --git a/src/SonsOfPHP/Contract/Money/MoneyInterface.php b/src/SonsOfPHP/Contract/Money/MoneyInterface.php index a4881a01..70f3ebfb 100644 --- a/src/SonsOfPHP/Contract/Money/MoneyInterface.php +++ b/src/SonsOfPHP/Contract/Money/MoneyInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money; +namespace SonsOfPHP\Contract\Money; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; -use SonsOfPHP\Component\Money\Query\Money\MoneyQueryInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * Money Interface. From 1261c202e283c1c781e710abe5426bbb65c30f3a Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Fri, 10 Nov 2023 16:08:51 -0500 Subject: [PATCH 22/27] checkpoint --- .../Tests/Toggle/AffirmativeToggleTest.php | 1 - .../Tests/Toggle/ChainToggleTest.php | 1 - .../Tests/Toggle/DateRangeToggleTest.php | 1 - .../Tests/Toggle/MockToggleTest.php | 1 - src/SonsOfPHP/Component/Money/Amount.php | 4 ++-- .../AbstractCurrencyProvider.php | 4 ++-- .../Money/Exception/ArithmeticException.php | 4 ++-- .../Money/Exception/MoneyException.php | 4 ++-- .../Exception/UnknownCurrencyException.php | 4 +++- src/SonsOfPHP/Component/Money/Money.php | 4 ++-- .../Operator/Amount/AddAmountOperator.php | 3 ++- .../Operator/Amount/DivideAmountOperator.php | 3 ++- .../Amount/MultiplyAmountOperator.php | 3 ++- .../Amount/SubtractAmountOperator.php | 3 ++- .../Money/Operator/Money/AddMoneyOperator.php | 3 ++- .../Operator/Money/DivideMoneyOperator.php | 3 ++- .../Operator/Money/MultiplyMoneyOperator.php | 3 ++- .../Operator/Money/SubtractMoneyOperator.php | 3 ++- .../Query/Amount/AmountQueryInterface.php | 20 ------------------- .../Query/Currency/CurrencyQueryInterface.php | 20 ------------------- .../CurrencyProviderQueryInterface.php | 20 ------------------- .../CurrencyProvider/GetCurrencyQuery.php | 5 +++-- .../CurrencyProvider/HasCurrencyQuery.php | 5 +++-- .../Money/Query/Money/MoneyQueryInterface.php | 20 ------------------- .../Component/Money/Query/QueryInterface.php | 16 --------------- .../ChainCurrencyProviderTest.php | 12 +++++------ .../CurrencyProvider/CurrencyProviderTest.php | 12 +++++------ .../XCurrencyProviderTest.php | 4 ++-- .../Query/Amount/IsEqualToAmountQueryTest.php | 2 +- .../Amount/IsGreaterThanAmountQueryTest.php | 2 +- .../IsGreaterThanOrEqualToAmountQueryTest.php | 2 +- .../Amount/IsLessThanAmountQueryTest.php | 2 +- .../IsLessThanOrEqualToAmountQueryTest.php | 2 +- .../Amount/IsNegativeAmountQueryTest.php | 2 +- .../Amount/IsPositiveAmountQueryTest.php | 2 +- .../Query/Amount/IsZeroAmountQueryTest.php | 2 +- .../CurrencyProvider/GetCurrencyQueryTest.php | 8 ++++---- .../CurrencyProvider/HasCurrencyQueryTest.php | 6 +++--- .../FeatureToggle/ContextInterface.php | 2 +- .../Money/CurrencyProviderInterface.php | 11 +++++----- .../ArithmeticExceptionInterface.php | 14 +++++++++++++ .../Exception/MoneyExceptionInterface.php | 12 +++++++++++ .../UnknownCurrencyExceptionInterface.php | 10 ++++++++++ .../Amount/AmountOperatorInterface.php | 8 ++++---- .../Operator/Money/MoneyOperatorInterface.php | 8 ++++---- .../Query/Amount/AmountQueryInterface.php | 19 ++++++++++++++++++ .../Query/Currency/CurrencyQueryInterface.php | 19 ++++++++++++++++++ .../CurrencyProviderQueryInterface.php | 19 ++++++++++++++++++ .../Money/Query/Money/MoneyQueryInterface.php | 19 ++++++++++++++++++ 49 files changed, 190 insertions(+), 167 deletions(-) delete mode 100644 src/SonsOfPHP/Component/Money/Query/Amount/AmountQueryInterface.php delete mode 100644 src/SonsOfPHP/Component/Money/Query/Currency/CurrencyQueryInterface.php delete mode 100644 src/SonsOfPHP/Component/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php delete mode 100644 src/SonsOfPHP/Component/Money/Query/Money/MoneyQueryInterface.php delete mode 100644 src/SonsOfPHP/Component/Money/Query/QueryInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Exception/ArithmeticExceptionInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Exception/MoneyExceptionInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Exception/UnknownCurrencyExceptionInterface.php rename src/SonsOfPHP/{Component => Contract}/Money/Operator/Amount/AmountOperatorInterface.php (51%) rename src/SonsOfPHP/{Component => Contract}/Money/Operator/Money/MoneyOperatorInterface.php (51%) create mode 100644 src/SonsOfPHP/Contract/Money/Query/Amount/AmountQueryInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Query/Currency/CurrencyQueryInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php create mode 100644 src/SonsOfPHP/Contract/Money/Query/Money/MoneyQueryInterface.php diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php index efe6832a..4cb35df4 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/AffirmativeToggleTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\FeatureToggle\Tests\Toggle; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\AffirmativeToggle; use SonsOfPHP\Component\FeatureToggle\Toggle\MockToggle; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php index d123b7e1..291a635a 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/ChainToggleTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\FeatureToggle\Tests\Toggle; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\ChainToggle; use SonsOfPHP\Component\FeatureToggle\Toggle\MockToggle; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php index 3dd3c4d5..006c67ff 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/DateRangeToggleTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\FeatureToggle\Tests\Toggle; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\DateRangeToggle; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php index 244c1d43..2a761c39 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Toggle/MockToggleTest.php @@ -5,7 +5,6 @@ namespace SonsOfPHP\Component\FeatureToggle\Tests\Toggle; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\FeatureToggle\Context; use SonsOfPHP\Component\FeatureToggle\Toggle\MockToggle; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; diff --git a/src/SonsOfPHP/Component/Money/Amount.php b/src/SonsOfPHP/Component/Money/Amount.php index d26c7b8f..d888302e 100644 --- a/src/SonsOfPHP/Component/Money/Amount.php +++ b/src/SonsOfPHP/Component/Money/Amount.php @@ -5,11 +5,11 @@ namespace SonsOfPHP\Component\Money; use SonsOfPHP\Component\Money\Operator\Amount\AddAmountOperator; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\DivideAmountOperator; use SonsOfPHP\Component\Money\Operator\Amount\MultiplyAmountOperator; use SonsOfPHP\Component\Money\Operator\Amount\SubtractAmountOperator; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsEqualToAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanOrEqualToAmountQuery; diff --git a/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php b/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php index 87dbae0a..8310672e 100644 --- a/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php +++ b/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Money\CurrencyProvider; -use SonsOfPHP\Component\Money\CurrencyInterface; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\Query\CurrencyProviderQueryInterface; use SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery; use SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery; diff --git a/src/SonsOfPHP/Component/Money/Exception/ArithmeticException.php b/src/SonsOfPHP/Component/Money/Exception/ArithmeticException.php index f929511b..1d227d81 100644 --- a/src/SonsOfPHP/Component/Money/Exception/ArithmeticException.php +++ b/src/SonsOfPHP/Component/Money/Exception/ArithmeticException.php @@ -4,7 +4,7 @@ namespace SonsOfPHP\Component\Money\Exception; -use Exception; +use SonsOfPHP\Contract\Money\Exception\ArithmeticExceptionInterface; /** * Arithmetic Exception. @@ -13,4 +13,4 @@ * * @author Joshua Estes */ -class ArithmeticException extends \Exception {} +class ArithmeticException extends \Exception implements ArithmeticExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Money/Exception/MoneyException.php b/src/SonsOfPHP/Component/Money/Exception/MoneyException.php index 67ffac7d..523a4eb3 100644 --- a/src/SonsOfPHP/Component/Money/Exception/MoneyException.php +++ b/src/SonsOfPHP/Component/Money/Exception/MoneyException.php @@ -4,11 +4,11 @@ namespace SonsOfPHP\Component\Money\Exception; -use Exception; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; /** * Money Exception. * * @author Joshua Estes */ -class MoneyException extends \Exception {} +class MoneyException extends \Exception implements MoneyExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Money/Exception/UnknownCurrencyException.php b/src/SonsOfPHP/Component/Money/Exception/UnknownCurrencyException.php index 51501995..28ce70d1 100644 --- a/src/SonsOfPHP/Component/Money/Exception/UnknownCurrencyException.php +++ b/src/SonsOfPHP/Component/Money/Exception/UnknownCurrencyException.php @@ -4,7 +4,9 @@ namespace SonsOfPHP\Component\Money\Exception; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; + /** * @author Joshua Estes */ -class UnknownCurrencyException extends \Exception {} +class UnknownCurrencyException extends \Exception implements MoneyExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Money/Money.php b/src/SonsOfPHP/Component/Money/Money.php index 31ad0096..7e918f22 100644 --- a/src/SonsOfPHP/Component/Money/Money.php +++ b/src/SonsOfPHP/Component/Money/Money.php @@ -6,7 +6,7 @@ use SonsOfPHP\Component\Money\Operator\Money\AddMoneyOperator; use SonsOfPHP\Component\Money\Operator\Money\DivideMoneyOperator; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\MultiplyMoneyOperator; use SonsOfPHP\Component\Money\Operator\Money\SubtractMoneyOperator; use SonsOfPHP\Component\Money\Query\Money\IsEqualToMoneyQuery; @@ -17,7 +17,7 @@ use SonsOfPHP\Component\Money\Query\Money\IsNegativeMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\IsPositiveMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\IsZeroMoneyQuery; -use SonsOfPHP\Component\Money\Query\Money\MoneyQueryInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; use SonsOfPHP\Contract\Money\MoneyInterface; use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\AmountInterface; diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/AddAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/AddAmountOperator.php index 153c4148..2d5cbce2 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/AddAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/AddAmountOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/DivideAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/DivideAmountOperator.php index c5b82ebd..689f59b3 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/DivideAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/DivideAmountOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php index 217dafd6..6c74ce77 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\AmountInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php index 86de4083..b1133234 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\AmountInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Money/AddMoneyOperator.php b/src/SonsOfPHP/Component/Money/Operator/Money/AddMoneyOperator.php index 7682418c..9a54ccf1 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Money/AddMoneyOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Money/AddMoneyOperator.php @@ -6,7 +6,8 @@ use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Money/DivideMoneyOperator.php b/src/SonsOfPHP/Component/Money/Operator/Money/DivideMoneyOperator.php index fbb5c3af..224760c3 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Money/DivideMoneyOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Money/DivideMoneyOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Money; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Money/MultiplyMoneyOperator.php b/src/SonsOfPHP/Component/Money/Operator/Money/MultiplyMoneyOperator.php index a0d57984..2e1d0302 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Money/MultiplyMoneyOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Money/MultiplyMoneyOperator.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Money; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Money/SubtractMoneyOperator.php b/src/SonsOfPHP/Component/Money/Operator/Money/SubtractMoneyOperator.php index e35ce0e1..5822b388 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Money/SubtractMoneyOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Money/SubtractMoneyOperator.php @@ -6,7 +6,8 @@ use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/AmountQueryInterface.php b/src/SonsOfPHP/Component/Money/Query/Amount/AmountQueryInterface.php deleted file mode 100644 index 64d72009..00000000 --- a/src/SonsOfPHP/Component/Money/Query/Amount/AmountQueryInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface AmountQueryInterface extends QueryInterface -{ - /** - * @throws MoneyException - */ - public function queryFrom(AmountInterface $amount); -} diff --git a/src/SonsOfPHP/Component/Money/Query/Currency/CurrencyQueryInterface.php b/src/SonsOfPHP/Component/Money/Query/Currency/CurrencyQueryInterface.php deleted file mode 100644 index 94f73036..00000000 --- a/src/SonsOfPHP/Component/Money/Query/Currency/CurrencyQueryInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface CurrencyQueryInterface extends QueryInterface -{ - /** - * @throws MoneyException - */ - public function queryFrom(CurrencyInterface $currency); -} diff --git a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php deleted file mode 100644 index 27f0e18e..00000000 --- a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface CurrencyProviderQueryInterface extends QueryInterface -{ - /** - * @throws MoneyException - */ - public function queryFrom(CurrencyProviderInterface $provider); -} diff --git a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php index b4b39ac0..3805849c 100644 --- a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php @@ -5,9 +5,10 @@ namespace SonsOfPHP\Component\Money\Query\CurrencyProvider; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; -use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php index cf289917..e9c34cca 100644 --- a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php @@ -5,9 +5,10 @@ namespace SonsOfPHP\Component\Money\Query\CurrencyProvider; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; -use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/MoneyQueryInterface.php b/src/SonsOfPHP/Component/Money/Query/Money/MoneyQueryInterface.php deleted file mode 100644 index afd22840..00000000 --- a/src/SonsOfPHP/Component/Money/Query/Money/MoneyQueryInterface.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface MoneyQueryInterface extends QueryInterface -{ - /** - * @throws MoneyException - */ - public function queryFrom(MoneyInterface $money); -} diff --git a/src/SonsOfPHP/Component/Money/Query/QueryInterface.php b/src/SonsOfPHP/Component/Money/Query/QueryInterface.php deleted file mode 100644 index 50098562..00000000 --- a/src/SonsOfPHP/Component/Money/Query/QueryInterface.php +++ /dev/null @@ -1,16 +0,0 @@ - - */ -interface QueryInterface -{ - /* - * All Query classes should define queryFrom - */ - // public function queryFrom(mixed $input); -} diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php index 1226c078..b77e9b62 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php @@ -6,12 +6,12 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Component\Money\CurrencyProvider\ChainCurrencyProvider; use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProvider; -use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; -use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\CurrencyProvider\ChainCurrencyProvider @@ -124,7 +124,7 @@ public function testHasCurrencyWithInvalidInput(): void new XCurrencyProvider(), ]); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $this->assertFalse($provider->hasCurrency('xxxxxx')); } @@ -173,7 +173,7 @@ public function testGetCurrencyWithUnknowCurrency(): void new XCurrencyProvider(), ]); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $provider->getCurrency('zzz'); } @@ -188,7 +188,7 @@ public function testGetCurrencyWithValueError(): void new XCurrencyProvider(), ]); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $provider->getCurrency('xxxxxxxx'); } } diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php index 87da7fa2..4b620242 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php @@ -6,10 +6,10 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProvider; -use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProviderInterface; -use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProvider @@ -91,7 +91,7 @@ public function testHasCurrencyWithInvalidInput(): void { $provider = new CurrencyProvider(); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $this->assertFalse($provider->hasCurrency('xxxxxx')); } @@ -131,7 +131,7 @@ public function testGetCurrencyWithUnknowCurrency(): void { $provider = new CurrencyProvider(); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $provider->getCurrency('xxx'); } @@ -143,7 +143,7 @@ public function testGetCurrencyWithValueError(): void { $provider = new CurrencyProvider(); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $provider->getCurrency('xxxxxxxx'); } } diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php index 140b4f95..ba0814a0 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Money\Tests\CurrencyProvider; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Money\CurrencyInterface; -use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php index cc246051..56e4b1f3 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsEqualToAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php index 199d3f94..f71620cf 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php index ff30813b..32cf6c97 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanOrEqualToAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php index a563774c..ffa67d9f 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsLessThanAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php index eaed30d4..2c9dc7b1 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsLessThanOrEqualToAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php index c0328815..98f691c9 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsNegativeAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php index 0074a75b..043d9914 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsPositiveAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php index 75f4cd1a..dcb10014 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Query\Amount\AmountQueryInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsZeroAmountQuery; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php index 08d14e5c..8ef0b0d7 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; -use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; use SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery; /** @@ -64,7 +64,7 @@ public function testConstructWithCurrencyString(): void */ public function testConstructWithInvalidValue(): void { - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $query = new GetCurrencyQuery('1234'); } @@ -75,7 +75,7 @@ public function testQueryFromWillThrowExceptionWhenCurrencyNotFound(): void { $query = new GetCurrencyQuery('usd'); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $output = $query->queryFrom(new XCurrencyProvider()); } } diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php index 842d99d2..06b0f0e4 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; -use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; use SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery; /** @@ -64,7 +64,7 @@ public function testConstructWithCurrencyString(): void */ public function testConstructWithInvalidValue(): void { - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $query = new HasCurrencyQuery('1234'); } diff --git a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php index 9ce80398..14e44063 100644 --- a/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php +++ b/src/SonsOfPHP/Contract/FeatureToggle/ContextInterface.php @@ -9,7 +9,7 @@ * * @author Joshua Estes */ -interface ContextInterface// extends \ArrayAccess, \IteratorAggregate, \JsonSerializable +interface ContextInterface // extends \ArrayAccess, \IteratorAggregate, \JsonSerializable { /** * Get Context Parameters diff --git a/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php b/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php index b8d7afb1..d3684399 100644 --- a/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php +++ b/src/SonsOfPHP/Contract/Money/CurrencyProviderInterface.php @@ -4,9 +4,7 @@ namespace SonsOfPHP\Contract\Money; -use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; -use SonsOfPHP\Contract\Money\Exception\UnknownCurrencyExceptionInterface; use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** @@ -19,8 +17,9 @@ interface CurrencyProviderInterface /** * Returns all of the currencies this Currency Provide will provide. * - * @throw MoneyException This method may throw an exception if, for example it's making queries - * to a database, if it's unable to return any currencies + * @throw MoneyExceptionInterface + * This method may throw an exception if, for example it's making queries + * to a database, if it's unable to return any currencies * * @return CurrencyInterface[] */ @@ -35,7 +34,7 @@ public function getCurrencies(): iterable; * @throw MoneyException * @throw UnknownCurrencyException */ - public function hasCurrency($currency): bool; + public function hasCurrency(CurrencyInterface|string $currency): bool; /** * Returns the currency or thows MoneyException is currency does not @@ -46,7 +45,7 @@ public function hasCurrency($currency): bool; * @throw MoneyException * @throw UnknownCurrencyException */ - public function getCurrency($currency): CurrencyInterface; + public function getCurrency(CurrencyInterface|string $currency): CurrencyInterface; /** * In case you need to run your own queries against this provider the query diff --git a/src/SonsOfPHP/Contract/Money/Exception/ArithmeticExceptionInterface.php b/src/SonsOfPHP/Contract/Money/Exception/ArithmeticExceptionInterface.php new file mode 100644 index 00000000..19237aaf --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Exception/ArithmeticExceptionInterface.php @@ -0,0 +1,14 @@ + + */ +interface ArithmeticExceptionInterface extends MoneyExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Money/Exception/MoneyExceptionInterface.php b/src/SonsOfPHP/Contract/Money/Exception/MoneyExceptionInterface.php new file mode 100644 index 00000000..63ff1041 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Exception/MoneyExceptionInterface.php @@ -0,0 +1,12 @@ + + */ +interface MoneyExceptionInterface {} diff --git a/src/SonsOfPHP/Contract/Money/Exception/UnknownCurrencyExceptionInterface.php b/src/SonsOfPHP/Contract/Money/Exception/UnknownCurrencyExceptionInterface.php new file mode 100644 index 00000000..b287b2d4 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Exception/UnknownCurrencyExceptionInterface.php @@ -0,0 +1,10 @@ + + */ +interface UnknownCurrencyExceptionInterface extends MoneyExceptionInterface {} diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/AmountOperatorInterface.php b/src/SonsOfPHP/Contract/Money/Operator/Amount/AmountOperatorInterface.php similarity index 51% rename from src/SonsOfPHP/Component/Money/Operator/Amount/AmountOperatorInterface.php rename to src/SonsOfPHP/Contract/Money/Operator/Amount/AmountOperatorInterface.php index ed5f0ecd..be298f24 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/AmountOperatorInterface.php +++ b/src/SonsOfPHP/Contract/Money/Operator/Amount/AmountOperatorInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money\Operator\Amount; +namespace SonsOfPHP\Contract\Money\Operator\Amount; -use SonsOfPHP\Component\Money\AmountInterface; -use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; /** * @author Joshua Estes @@ -13,7 +13,7 @@ interface AmountOperatorInterface { /** - * @throws MoneyException + * @throws MoneyExceptionInterface */ public function apply(AmountInterface $amount): AmountInterface; } diff --git a/src/SonsOfPHP/Component/Money/Operator/Money/MoneyOperatorInterface.php b/src/SonsOfPHP/Contract/Money/Operator/Money/MoneyOperatorInterface.php similarity index 51% rename from src/SonsOfPHP/Component/Money/Operator/Money/MoneyOperatorInterface.php rename to src/SonsOfPHP/Contract/Money/Operator/Money/MoneyOperatorInterface.php index bc62a726..df17d9d3 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Money/MoneyOperatorInterface.php +++ b/src/SonsOfPHP/Contract/Money/Operator/Money/MoneyOperatorInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace SonsOfPHP\Component\Money\Operator\Money; +namespace SonsOfPHP\Contract\Money\Operator\Money; -use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; /** * @author Joshua Estes @@ -13,7 +13,7 @@ interface MoneyOperatorInterface { /** - * @throws MoneyException + * @throws MoneyExceptionInterface */ public function apply(MoneyInterface $money): MoneyInterface; } diff --git a/src/SonsOfPHP/Contract/Money/Query/Amount/AmountQueryInterface.php b/src/SonsOfPHP/Contract/Money/Query/Amount/AmountQueryInterface.php new file mode 100644 index 00000000..ae4e8272 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Query/Amount/AmountQueryInterface.php @@ -0,0 +1,19 @@ + + */ +interface AmountQueryInterface +{ + /** + * @throws MoneyExceptionInterface + */ + public function queryFrom(AmountInterface $amount); +} diff --git a/src/SonsOfPHP/Contract/Money/Query/Currency/CurrencyQueryInterface.php b/src/SonsOfPHP/Contract/Money/Query/Currency/CurrencyQueryInterface.php new file mode 100644 index 00000000..bd253722 --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Query/Currency/CurrencyQueryInterface.php @@ -0,0 +1,19 @@ + + */ +interface CurrencyQueryInterface +{ + /** + * @throws MoneyExceptionInterface + */ + public function queryFrom(CurrencyInterface $currency); +} diff --git a/src/SonsOfPHP/Contract/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php b/src/SonsOfPHP/Contract/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php new file mode 100644 index 00000000..f13d949b --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Query/CurrencyProvider/CurrencyProviderQueryInterface.php @@ -0,0 +1,19 @@ + + */ +interface CurrencyProviderQueryInterface +{ + /** + * @throws MoneyExceptionInterface + */ + public function queryFrom(CurrencyProviderInterface $provider); +} diff --git a/src/SonsOfPHP/Contract/Money/Query/Money/MoneyQueryInterface.php b/src/SonsOfPHP/Contract/Money/Query/Money/MoneyQueryInterface.php new file mode 100644 index 00000000..b7a3cfaf --- /dev/null +++ b/src/SonsOfPHP/Contract/Money/Query/Money/MoneyQueryInterface.php @@ -0,0 +1,19 @@ + + */ +interface MoneyQueryInterface +{ + /** + * @throws MoneyExceptionInterface + */ + public function queryFrom(MoneyInterface $money); +} From 31312f976e020d559a74a047554a3149ebbd7505 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Sat, 11 Nov 2023 15:46:00 -0500 Subject: [PATCH 23/27] money stuff --- .php-cs-fixer.dist.php | 1 + .../AbstractOptionsResolverCommandMessage.php | 2 +- .../Component/Cache/Adapter/ApcuAdapter.php | 2 +- .../Component/Cache/Adapter/ChainAdapter.php | 2 +- .../Component/Cache/Adapter/NullAdapter.php | 2 +- src/SonsOfPHP/Component/Cache/SimpleCache.php | 2 +- .../Cache/Tests/Adapter/ApcuAdapterTest.php | 6 +-- .../Cache/Tests/Adapter/ArrayAdapterTest.php | 6 +-- .../Cache/Tests/Adapter/ChainAdapterTest.php | 8 ++-- .../Cache/Tests/Adapter/NullAdapterTest.php | 6 +-- .../Component/Cache/Tests/CacheItemTest.php | 2 +- .../Component/Cache/Tests/SimpleCacheTest.php | 4 +- src/SonsOfPHP/Component/Clock/FixedClock.php | 2 +- .../Component/Cqrs/MessageHandlerProvider.php | 2 +- .../Component/Cqrs/Tests/CommandBusTest.php | 2 +- .../Cqrs/Tests/MessageHandlerProviderTest.php | 2 +- .../Component/Cqrs/Tests/QueryBusTest.php | 2 +- .../Tests/EventDispatcherTest.php | 2 +- .../Tests/ListenerProviderTest.php | 2 +- .../Tests/Test/CountEventsRaisedTest.php | 2 +- .../Tests/Test/EventRaisedTest.php | 2 +- .../Component/FeatureToggle/Feature.php | 2 +- .../InMemoryFeatureToggleProviderTest.php | 4 +- .../Filesystem/Adapter/AdapterInterface.php | 2 +- .../Filesystem/Adapter/CopyAwareInterface.php | 2 +- .../Filesystem/Adapter/MoveAwareInterface.php | 2 +- .../Component/Filesystem/Filesystem.php | 2 +- .../Tests/Adapter/ChainAdapterTest.php | 4 +- .../Tests/Adapter/ReadOnlyAdapterTest.php | 4 +- .../Tests/Adapter/WormAdapterTest.php | 4 +- .../Filesystem/Tests/ContextTest.php | 4 +- .../Filesystem/Tests/FilesystemTest.php | 4 +- .../Tests/RequestFactoryTraitTest.php | 2 +- .../HttpFactory/Tests/ResponseFactoryTest.php | 4 +- .../Tests/ServerRequestFactoryTest.php | 4 +- .../HttpFactory/Tests/StreamFactoryTest.php | 4 +- .../Tests/UploadedFileFactoryTest.php | 6 +-- .../HttpFactory/Tests/UriFactoryTest.php | 4 +- .../HttpFactory/UploadedFileFactoryTrait.php | 2 +- .../HttpMessage/Tests/MessageTest.php | 2 +- .../HttpMessage/Tests/RequestTest.php | 4 +- .../HttpMessage/Tests/ResponseTest.php | 2 +- .../HttpMessage/Tests/ServerRequestTest.php | 2 +- .../HttpMessage/Tests/StreamTest.php | 2 +- .../HttpMessage/Tests/UploadedFileTest.php | 4 +- .../Component/HttpMessage/Tests/UriTest.php | 2 +- .../Component/HttpMessage/UploadedFile.php | 2 +- src/SonsOfPHP/Component/Money/Amount.php | 4 +- src/SonsOfPHP/Component/Money/Currency.php | 3 +- .../AbstractCurrencyProvider.php | 5 +- .../ChainCurrencyProvider.php | 2 + src/SonsOfPHP/Component/Money/Money.php | 8 ++-- .../Amount/MultiplyAmountOperator.php | 2 +- .../Amount/SubtractAmountOperator.php | 2 +- .../Query/Amount/IsEqualToAmountQuery.php | 3 +- .../Query/Amount/IsGreaterThanAmountQuery.php | 3 +- .../IsGreaterThanOrEqualToAmountQuery.php | 3 +- .../Query/Amount/IsLessThanAmountQuery.php | 3 +- .../Amount/IsLessThanOrEqualToAmountQuery.php | 3 +- .../Query/Amount/IsNegativeAmountQuery.php | 3 +- .../Query/Amount/IsPositiveAmountQuery.php | 3 +- .../Money/Query/Amount/IsZeroAmountQuery.php | 3 +- .../Query/Currency/IsEqualToCurrencyQuery.php | 3 +- .../CurrencyProvider/GetCurrencyQuery.php | 2 +- .../CurrencyProvider/HasCurrencyQuery.php | 2 +- .../Money/Query/Money/IsEqualToMoneyQuery.php | 3 +- .../Query/Money/IsGreaterThanMoneyQuery.php | 3 +- .../IsGreaterThanOrEqualToMoneyQuery.php | 3 +- .../Query/Money/IsLessThanMoneyQuery.php | 3 +- .../Money/IsLessThanOrEqualToMoneyQuery.php | 3 +- .../Query/Money/IsNegativeMoneyQuery.php | 3 +- .../Query/Money/IsPositiveMoneyQuery.php | 3 +- .../Money/Query/Money/IsZeroMoneyQuery.php | 3 +- .../ChainCurrencyProviderTest.php | 4 +- .../CurrencyProvider/CurrencyProviderTest.php | 2 +- .../XCurrencyProviderTest.php | 2 +- .../Component/Money/Tests/MoneyTest.php | 14 +++--- .../Operator/Amount/AddAmountOperatorTest.php | 2 +- .../Amount/DivideAmountOperatorTest.php | 2 +- .../Amount/MultiplyAmountOperatorTest.php | 2 +- .../Amount/SubtractAmountOperatorTest.php | 2 +- .../Operator/Money/AddMoneyOperatorTest.php | 2 +- .../Money/DivideMoneyOperatorTest.php | 2 +- .../Money/MultiplyMoneyOperatorTest.php | 2 +- .../Money/SubtractMoneyOperatorTest.php | 2 +- .../Query/Amount/IsEqualToAmountQueryTest.php | 2 +- .../Amount/IsGreaterThanAmountQueryTest.php | 2 +- .../IsGreaterThanOrEqualToAmountQueryTest.php | 2 +- .../Amount/IsLessThanAmountQueryTest.php | 2 +- .../IsLessThanOrEqualToAmountQueryTest.php | 2 +- .../Amount/IsNegativeAmountQueryTest.php | 2 +- .../Amount/IsPositiveAmountQueryTest.php | 2 +- .../Query/Amount/IsZeroAmountQueryTest.php | 2 +- .../Currency/IsEqualToCurrencyQueryTest.php | 2 +- .../CurrencyProvider/GetCurrencyQueryTest.php | 2 +- .../CurrencyProvider/HasCurrencyQueryTest.php | 2 +- .../Query/Money/IsEqualToMoneyQueryTest.php | 45 ++++++++++++++++++ .../Money/IsGreaterThanMoneyQueryTest.php | 46 +++++++++++++++++++ .../IsGreaterThanOrEqualToMoneyQueryTest.php | 46 +++++++++++++++++++ .../Query/Money/IsLessThanMoneyQueryTest.php | 46 +++++++++++++++++++ .../IsLessThanOrEqualToMoneyQueryTest.php | 46 +++++++++++++++++++ .../Query/Money/IsNegativeMoneyQueryTest.php | 44 ++++++++++++++++++ .../Query/Money/IsPositiveMoneyQueryTest.php | 44 ++++++++++++++++++ .../Query/Money/IsZeroMoneyQueryTest.php | 44 ++++++++++++++++++ 104 files changed, 513 insertions(+), 130 deletions(-) create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php create mode 100644 src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 5adc73c1..4b24932c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -16,5 +16,6 @@ // Rules 'no_unused_imports' => true, + 'ordered_imports' => true, 'php_unit_test_class_requires_covers' => true, ])->setFinder($finder); diff --git a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php index 07befa36..cb0a40bd 100644 --- a/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php +++ b/src/SonsOfPHP/Bridge/Symfony/Cqrs/Command/AbstractOptionsResolverCommandMessage.php @@ -4,9 +4,9 @@ namespace SonsOfPHP\Bridge\Symfony\Cqrs\Command; +use SonsOfPHP\Component\Cqrs\AbstractCommandMessage; use SonsOfPHP\Contract\Cqrs\CommandMessageInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use SonsOfPHP\Component\Cqrs\AbstractCommandMessage; /** * Abstract Command Message. diff --git a/src/SonsOfPHP/Component/Cache/Adapter/ApcuAdapter.php b/src/SonsOfPHP/Component/Cache/Adapter/ApcuAdapter.php index bc872955..e38b4800 100644 --- a/src/SonsOfPHP/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/SonsOfPHP/Component/Cache/Adapter/ApcuAdapter.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Cache\Adapter; -use SonsOfPHP\Component\Cache\CacheItem; use Psr\Cache\CacheItemInterface; +use SonsOfPHP\Component\Cache\CacheItem; use SonsOfPHP\Component\Cache\Exception\CacheException; /** diff --git a/src/SonsOfPHP/Component/Cache/Adapter/ChainAdapter.php b/src/SonsOfPHP/Component/Cache/Adapter/ChainAdapter.php index 63b1a3f8..fb36dae2 100644 --- a/src/SonsOfPHP/Component/Cache/Adapter/ChainAdapter.php +++ b/src/SonsOfPHP/Component/Cache/Adapter/ChainAdapter.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Cache\Adapter; -use SonsOfPHP\Component\Cache\CacheItem; use Psr\Cache\CacheItemInterface; +use SonsOfPHP\Component\Cache\CacheItem; use SonsOfPHP\Component\Cache\Exception\CacheException; /** diff --git a/src/SonsOfPHP/Component/Cache/Adapter/NullAdapter.php b/src/SonsOfPHP/Component/Cache/Adapter/NullAdapter.php index 926b507d..c0a50e0b 100644 --- a/src/SonsOfPHP/Component/Cache/Adapter/NullAdapter.php +++ b/src/SonsOfPHP/Component/Cache/Adapter/NullAdapter.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Cache\Adapter; -use SonsOfPHP\Component\Cache\CacheItem; use Psr\Cache\CacheItemInterface; +use SonsOfPHP\Component\Cache\CacheItem; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cache/SimpleCache.php b/src/SonsOfPHP/Component/Cache/SimpleCache.php index c30f3d1d..0452031d 100644 --- a/src/SonsOfPHP/Component/Cache/SimpleCache.php +++ b/src/SonsOfPHP/Component/Cache/SimpleCache.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Cache; -use Psr\SimpleCache\CacheInterface; use Psr\Cache\CacheItemPoolInterface; +use Psr\SimpleCache\CacheInterface; /** * PSR-16 Simple Cache diff --git a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ApcuAdapterTest.php b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ApcuAdapterTest.php index 2b47512d..4d1e6560 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ApcuAdapterTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ApcuAdapterTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\Adapter\ApcuAdapter; -use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; -use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; +use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; +use SonsOfPHP\Component\Cache\Adapter\ApcuAdapter; /** * @requires extension apcu diff --git a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ArrayAdapterTest.php b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ArrayAdapterTest.php index 49c9d73b..ebd61dbf 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ArrayAdapterTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ArrayAdapterTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\Adapter\ArrayAdapter; -use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; -use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; +use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; +use SonsOfPHP\Component\Cache\Adapter\ArrayAdapter; /** * @coversDefaultClass \SonsOfPHP\Component\Cache\Adapter\ArrayAdapter diff --git a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ChainAdapterTest.php b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ChainAdapterTest.php index e60d2537..bea92ee9 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/Adapter/ChainAdapterTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/Adapter/ChainAdapterTest.php @@ -5,11 +5,11 @@ namespace SonsOfPHP\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\Adapter\ChainAdapter; -use SonsOfPHP\Component\Cache\Adapter\ArrayAdapter; -use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; -use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; +use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; +use SonsOfPHP\Component\Cache\Adapter\ArrayAdapter; +use SonsOfPHP\Component\Cache\Adapter\ChainAdapter; use SonsOfPHP\Component\Cache\Exception\CacheException; /** diff --git a/src/SonsOfPHP/Component/Cache/Tests/Adapter/NullAdapterTest.php b/src/SonsOfPHP/Component/Cache/Tests/Adapter/NullAdapterTest.php index 421c9cf9..5e7a54e0 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/Adapter/NullAdapterTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/Adapter/NullAdapterTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\Cache\Tests\Adapter; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\Adapter\NullAdapter; -use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; -use Psr\Cache\CacheItemPoolInterface; use Psr\Cache\CacheItemInterface; +use Psr\Cache\CacheItemPoolInterface; +use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; +use SonsOfPHP\Component\Cache\Adapter\NullAdapter; /** * @coversDefaultClass \SonsOfPHP\Component\Cache\Adapter\NullAdapter diff --git a/src/SonsOfPHP/Component/Cache/Tests/CacheItemTest.php b/src/SonsOfPHP/Component/Cache/Tests/CacheItemTest.php index 25bb979a..7f719e67 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/CacheItemTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/CacheItemTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Cache\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\CacheItem; use Psr\Cache\CacheItemInterface; +use SonsOfPHP\Component\Cache\CacheItem; use SonsOfPHP\Component\Cache\Exception\InvalidArgumentException; /** diff --git a/src/SonsOfPHP/Component/Cache/Tests/SimpleCacheTest.php b/src/SonsOfPHP/Component/Cache/Tests/SimpleCacheTest.php index 7d7880ae..dfa828f6 100644 --- a/src/SonsOfPHP/Component/Cache/Tests/SimpleCacheTest.php +++ b/src/SonsOfPHP/Component/Cache/Tests/SimpleCacheTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\Cache\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Cache\SimpleCache; +use Psr\Cache\CacheItemInterface; use Psr\SimpleCache\CacheInterface; use SonsOfPHP\Component\Cache\Adapter\AdapterInterface; -use Psr\Cache\CacheItemInterface; +use SonsOfPHP\Component\Cache\SimpleCache; /** * @coversDefaultClass \SonsOfPHP\Component\Cache\SimpleCache diff --git a/src/SonsOfPHP/Component/Clock/FixedClock.php b/src/SonsOfPHP/Component/Clock/FixedClock.php index b68d20c9..409831df 100644 --- a/src/SonsOfPHP/Component/Clock/FixedClock.php +++ b/src/SonsOfPHP/Component/Clock/FixedClock.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Clock; -use SonsOfPHP\Component\Clock\Exception\ClockException; use Psr\Clock\ClockInterface; +use SonsOfPHP\Component\Clock\Exception\ClockException; /** * Fixed Clock. diff --git a/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php index 857cce00..c78ea597 100644 --- a/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php +++ b/src/SonsOfPHP/Component/Cqrs/MessageHandlerProvider.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Cqrs; -use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; use SonsOfPHP\Component\Cqrs\Exception\NoHandlerFoundException; +use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php index b62aaacb..f935828b 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/CommandBusTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Cqrs\CommandBus; -use SonsOfPHP\Contract\Cqrs\CommandBusInterface; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; +use SonsOfPHP\Contract\Cqrs\CommandBusInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Cqrs\CommandBus diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php index 601134ec..6313d073 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/MessageHandlerProviderTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; -use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; use SonsOfPHP\Contract\Cqrs\Exception\NoHandlerFoundExceptionInterface; +use SonsOfPHP\Contract\Cqrs\MessageHandlerProviderInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Cqrs\MessageHandlerProvider diff --git a/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php b/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php index dd1b97e5..e970164b 100644 --- a/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php +++ b/src/SonsOfPHP/Component/Cqrs/Tests/QueryBusTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\Cqrs\Tests; use PHPUnit\Framework\TestCase; +use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; use SonsOfPHP\Component\Cqrs\QueryBus; use SonsOfPHP\Contract\Cqrs\QueryBusInterface; -use SonsOfPHP\Component\Cqrs\MessageHandlerProvider; /** * @coversDefaultClass \SonsOfPHP\Component\Cqrs\QueryBus diff --git a/src/SonsOfPHP/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/SonsOfPHP/Component/EventDispatcher/Tests/EventDispatcherTest.php index be28da70..9a760b6a 100644 --- a/src/SonsOfPHP/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/SonsOfPHP/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use Psr\EventDispatcher\EventDispatcherInterface; use SonsOfPHP\Component\EventDispatcher\EventDispatcher; -use SonsOfPHP\Component\EventDispatcher\ListenerProvider; use SonsOfPHP\Component\EventDispatcher\EventSubscriberInterface; +use SonsOfPHP\Component\EventDispatcher\ListenerProvider; /** * @coversDefaultClass \SonsOfPHP\Component\EventDispatcher\EventDispatcher diff --git a/src/SonsOfPHP/Component/EventDispatcher/Tests/ListenerProviderTest.php b/src/SonsOfPHP/Component/EventDispatcher/Tests/ListenerProviderTest.php index 4928d144..53badc17 100644 --- a/src/SonsOfPHP/Component/EventDispatcher/Tests/ListenerProviderTest.php +++ b/src/SonsOfPHP/Component/EventDispatcher/Tests/ListenerProviderTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use Psr\EventDispatcher\ListenerProviderInterface; -use SonsOfPHP\Component\EventDispatcher\ListenerProvider; use SonsOfPHP\Component\EventDispatcher\EventSubscriberInterface; +use SonsOfPHP\Component\EventDispatcher\ListenerProvider; /** * @coversDefaultClass \SonsOfPHP\Component\EventDispatcher\ListenerProvider diff --git a/src/SonsOfPHP/Component/EventSourcing/Tests/Test/CountEventsRaisedTest.php b/src/SonsOfPHP/Component/EventSourcing/Tests/Test/CountEventsRaisedTest.php index f00bfdb7..69a764ca 100644 --- a/src/SonsOfPHP/Component/EventSourcing/Tests/Test/CountEventsRaisedTest.php +++ b/src/SonsOfPHP/Component/EventSourcing/Tests/Test/CountEventsRaisedTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\EventSourcing\Tests\Test; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\EventSourcing\Test\CountEventsRaised; use SonsOfPHP\Component\EventSourcing\Aggregate\AggregateInterface; +use SonsOfPHP\Component\EventSourcing\Test\CountEventsRaised; /** * @coversDefaultClass \SonsOfPHP\Component\EventSourcing\Test\CountEventsRaised diff --git a/src/SonsOfPHP/Component/EventSourcing/Tests/Test/EventRaisedTest.php b/src/SonsOfPHP/Component/EventSourcing/Tests/Test/EventRaisedTest.php index 7ec7f41f..006792c4 100644 --- a/src/SonsOfPHP/Component/EventSourcing/Tests/Test/EventRaisedTest.php +++ b/src/SonsOfPHP/Component/EventSourcing/Tests/Test/EventRaisedTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\EventSourcing\Tests\Test; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\EventSourcing\Test\EventRaised; use SonsOfPHP\Component\EventSourcing\Aggregate\AggregateInterface; +use SonsOfPHP\Component\EventSourcing\Test\EventRaised; /** * @coversDefaultClass \SonsOfPHP\Component\EventSourcing\Test\EventRaised diff --git a/src/SonsOfPHP/Component/FeatureToggle/Feature.php b/src/SonsOfPHP/Component/FeatureToggle/Feature.php index 47648c9f..893aa02a 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Feature.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Feature.php @@ -4,9 +4,9 @@ namespace SonsOfPHP\Component\FeatureToggle; +use SonsOfPHP\Contract\FeatureToggle\ContextInterface; use SonsOfPHP\Contract\FeatureToggle\FeatureInterface; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; -use SonsOfPHP\Contract\FeatureToggle\ContextInterface; /** * Feature. diff --git a/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php b/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php index 354cf307..2c311417 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php +++ b/src/SonsOfPHP/Component/FeatureToggle/Tests/Provider/InMemoryFeatureToggleProviderTest.php @@ -4,12 +4,12 @@ namespace SonsOfPHP\Component\FeatureToggle\Tests\Provider; +use PHPUnit\Framework\MockObject; use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\FeatureToggle\Feature; -use SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface; use SonsOfPHP\Component\FeatureToggle\Provider\InMemoryFeatureToggleProvider; +use SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface; use SonsOfPHP\Contract\FeatureToggle\ToggleInterface; -use PHPUnit\Framework\MockObject; /** * @coversDefaultClass \SonsOfPHP\Component\FeatureToggle\Provider\InMemoryFeatureToggleProvider diff --git a/src/SonsOfPHP/Component/Filesystem/Adapter/AdapterInterface.php b/src/SonsOfPHP/Component/Filesystem/Adapter/AdapterInterface.php index 84872081..e91e54e2 100644 --- a/src/SonsOfPHP/Component/Filesystem/Adapter/AdapterInterface.php +++ b/src/SonsOfPHP/Component/Filesystem/Adapter/AdapterInterface.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Filesystem\Adapter; use SonsOfPHP\Component\Filesystem\ContextInterface; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Exception\FileNotFoundException; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * Base Adapter Interface that all adapters implement. diff --git a/src/SonsOfPHP/Component/Filesystem/Adapter/CopyAwareInterface.php b/src/SonsOfPHP/Component/Filesystem/Adapter/CopyAwareInterface.php index 76f0b86b..0a9236fe 100644 --- a/src/SonsOfPHP/Component/Filesystem/Adapter/CopyAwareInterface.php +++ b/src/SonsOfPHP/Component/Filesystem/Adapter/CopyAwareInterface.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Filesystem\Adapter; use SonsOfPHP\Component\Filesystem\ContextInterface; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Exception\FileNotFoundException; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * If an adapter supports the ability to copy a file from one place to another diff --git a/src/SonsOfPHP/Component/Filesystem/Adapter/MoveAwareInterface.php b/src/SonsOfPHP/Component/Filesystem/Adapter/MoveAwareInterface.php index 5fd83db4..ee10d296 100644 --- a/src/SonsOfPHP/Component/Filesystem/Adapter/MoveAwareInterface.php +++ b/src/SonsOfPHP/Component/Filesystem/Adapter/MoveAwareInterface.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Filesystem\Adapter; use SonsOfPHP\Component\Filesystem\ContextInterface; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Exception\FileNotFoundException; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * If an adapter supports the ability to move a file from one place to another diff --git a/src/SonsOfPHP/Component/Filesystem/Filesystem.php b/src/SonsOfPHP/Component/Filesystem/Filesystem.php index bd589823..bdfe3fe7 100644 --- a/src/SonsOfPHP/Component/Filesystem/Filesystem.php +++ b/src/SonsOfPHP/Component/Filesystem/Filesystem.php @@ -4,10 +4,10 @@ namespace SonsOfPHP\Component\Filesystem; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Adapter\AdapterInterface; use SonsOfPHP\Component\Filesystem\Adapter\CopyAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\MoveAwareInterface; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ChainAdapterTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ChainAdapterTest.php index c67ce9b6..75b8c36c 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ChainAdapterTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ChainAdapterTest.php @@ -6,11 +6,11 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Filesystem\Adapter\AdapterInterface; +use SonsOfPHP\Component\Filesystem\Adapter\ChainAdapter; use SonsOfPHP\Component\Filesystem\Adapter\CopyAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\DirectoryAwareInterface; -use SonsOfPHP\Component\Filesystem\Adapter\MoveAwareInterface; -use SonsOfPHP\Component\Filesystem\Adapter\ChainAdapter; use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; +use SonsOfPHP\Component\Filesystem\Adapter\MoveAwareInterface; use SonsOfPHP\Component\Filesystem\Exception\FileNotFoundException; /** diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ReadOnlyAdapterTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ReadOnlyAdapterTest.php index 18278733..939058de 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ReadOnlyAdapterTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ReadOnlyAdapterTest.php @@ -4,12 +4,12 @@ namespace SonsOfPHP\Component\Filesystem\Tests; -use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; -use PHPUnit\Framework\TestCase; use PHPUnit\Framework\MockObject; +use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Filesystem\Adapter\AdapterInterface; use SonsOfPHP\Component\Filesystem\Adapter\CopyAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\DirectoryAwareInterface; +use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; use SonsOfPHP\Component\Filesystem\Adapter\MoveAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\ReadOnlyAdapter; use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/WormAdapterTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/WormAdapterTest.php index 55daa3ae..dbaae807 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/WormAdapterTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/WormAdapterTest.php @@ -4,14 +4,14 @@ namespace SonsOfPHP\Component\Filesystem\Tests; -use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Filesystem\Adapter\AdapterInterface; use SonsOfPHP\Component\Filesystem\Adapter\CopyAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\DirectoryAwareInterface; +use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; use SonsOfPHP\Component\Filesystem\Adapter\MoveAwareInterface; use SonsOfPHP\Component\Filesystem\Adapter\WormAdapter; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * @coversDefaultClass \SonsOfPHP\Component\Filesystem\Adapter\WormAdapter diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/ContextTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/ContextTest.php index 98c78e1b..e61dc5a2 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/ContextTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/ContextTest.php @@ -4,10 +4,10 @@ namespace SonsOfPHP\Component\Filesystem\Tests; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Filesystem\ContextInterface; use SonsOfPHP\Component\Filesystem\Context; +use SonsOfPHP\Component\Filesystem\ContextInterface; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; /** * @coversDefaultClass \SonsOfPHP\Component\Filesystem\Context diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/FilesystemTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/FilesystemTest.php index 4f2e3327..47250795 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/FilesystemTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\Filesystem\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\Filesystem\FilesystemInterface; -use SonsOfPHP\Component\Filesystem\Filesystem; use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter; +use SonsOfPHP\Component\Filesystem\Filesystem; +use SonsOfPHP\Component\Filesystem\FilesystemInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Filesystem\Filesystem diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/RequestFactoryTraitTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/RequestFactoryTraitTest.php index f78e92a0..16709f7e 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/RequestFactoryTraitTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/RequestFactoryTraitTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\RequestFactoryTrait; use Psr\Http\Message\RequestInterface; +use SonsOfPHP\Component\HttpFactory\RequestFactoryTrait; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\RequestFactoryTrait diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/ResponseFactoryTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/ResponseFactoryTest.php index cd669429..13bb0373 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/ResponseFactoryTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/ResponseFactoryTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\ResponseFactory; -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseFactoryInterface; +use Psr\Http\Message\ResponseInterface; +use SonsOfPHP\Component\HttpFactory\ResponseFactory; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\ResponseFactory diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/ServerRequestFactoryTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/ServerRequestFactoryTest.php index 7a0208e0..da7cecd6 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/ServerRequestFactoryTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/ServerRequestFactoryTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\ServerRequestFactory; -use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestFactoryInterface; +use Psr\Http\Message\ServerRequestInterface; +use SonsOfPHP\Component\HttpFactory\ServerRequestFactory; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\ServerRequestFactory diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/StreamFactoryTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/StreamFactoryTest.php index e41b82ed..dd47d3ca 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/StreamFactoryTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/StreamFactoryTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\StreamFactory; -use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamFactoryInterface; +use Psr\Http\Message\StreamInterface; +use SonsOfPHP\Component\HttpFactory\StreamFactory; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\StreamFactory diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/UploadedFileFactoryTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/UploadedFileFactoryTest.php index a92e83d7..67acc772 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/UploadedFileFactoryTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/UploadedFileFactoryTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\UploadedFileFactory; -use Psr\Http\Message\UploadedFileInterface; -use Psr\Http\Message\UploadedFileFactoryInterface; use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileFactoryInterface; +use Psr\Http\Message\UploadedFileInterface; +use SonsOfPHP\Component\HttpFactory\UploadedFileFactory; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\UploadedFileFactory diff --git a/src/SonsOfPHP/Component/HttpFactory/Tests/UriFactoryTest.php b/src/SonsOfPHP/Component/HttpFactory/Tests/UriFactoryTest.php index e8a242a7..b3d4b5ca 100644 --- a/src/SonsOfPHP/Component/HttpFactory/Tests/UriFactoryTest.php +++ b/src/SonsOfPHP/Component/HttpFactory/Tests/UriFactoryTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\HttpFactory\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpFactory\UriFactory; -use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriFactoryInterface; +use Psr\Http\Message\UriInterface; +use SonsOfPHP\Component\HttpFactory\UriFactory; /** * @coversDefaultClass \SonsOfPHP\Component\HttpFactory\UriFactory diff --git a/src/SonsOfPHP/Component/HttpFactory/UploadedFileFactoryTrait.php b/src/SonsOfPHP/Component/HttpFactory/UploadedFileFactoryTrait.php index 23dc0f83..e7ce2181 100644 --- a/src/SonsOfPHP/Component/HttpFactory/UploadedFileFactoryTrait.php +++ b/src/SonsOfPHP/Component/HttpFactory/UploadedFileFactoryTrait.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\HttpFactory; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; use SonsOfPHP\Component\HttpMessage\UploadedFile; /** diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/MessageTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/MessageTest.php index 7562d5d0..c743e621 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/MessageTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/MessageTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\Message; use Psr\Http\Message\MessageInterface; use Psr\Http\Message\StreamInterface; +use SonsOfPHP\Component\HttpMessage\Message; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\Message diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/RequestTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/RequestTest.php index 689536e0..cdfd6742 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/RequestTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/RequestTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\Request; -use SonsOfPHP\Component\HttpMessage\Uri; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UriInterface; +use SonsOfPHP\Component\HttpMessage\Request; +use SonsOfPHP\Component\HttpMessage\Uri; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\Request diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/ResponseTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/ResponseTest.php index 1a8e2ae4..0bc2b50c 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/ResponseTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/ResponseTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\Response; use Psr\Http\Message\ResponseInterface; +use SonsOfPHP\Component\HttpMessage\Response; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\Response diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/ServerRequestTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/ServerRequestTest.php index 936e032a..5d6208bb 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/ServerRequestTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/ServerRequestTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\ServerRequest; use Psr\Http\Message\ServerRequestInterface; +use SonsOfPHP\Component\HttpMessage\ServerRequest; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\ServerRequest diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/StreamTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/StreamTest.php index 8244525e..513d8c05 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/StreamTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/StreamTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\Stream; use Psr\Http\Message\StreamInterface; +use SonsOfPHP\Component\HttpMessage\Stream; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\Stream diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/UploadedFileTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/UploadedFileTest.php index d1fd1306..d1fde08e 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/UploadedFileTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/UploadedFileTest.php @@ -5,10 +5,10 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; use SonsOfPHP\Component\HttpMessage\UploadedFile; use SonsOfPHP\Component\HttpMessage\UploadedFileError; -use Psr\Http\Message\UploadedFileInterface; -use Psr\Http\Message\StreamInterface; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\UploadedFile diff --git a/src/SonsOfPHP/Component/HttpMessage/Tests/UriTest.php b/src/SonsOfPHP/Component/HttpMessage/Tests/UriTest.php index a323d9b9..d3ba5379 100644 --- a/src/SonsOfPHP/Component/HttpMessage/Tests/UriTest.php +++ b/src/SonsOfPHP/Component/HttpMessage/Tests/UriTest.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\HttpMessage\Tests; use PHPUnit\Framework\TestCase; -use SonsOfPHP\Component\HttpMessage\Uri; use Psr\Http\Message\UriInterface; +use SonsOfPHP\Component\HttpMessage\Uri; /** * @coversDefaultClass \SonsOfPHP\Component\HttpMessage\Uri diff --git a/src/SonsOfPHP/Component/HttpMessage/UploadedFile.php b/src/SonsOfPHP/Component/HttpMessage/UploadedFile.php index ac963011..48563905 100644 --- a/src/SonsOfPHP/Component/HttpMessage/UploadedFile.php +++ b/src/SonsOfPHP/Component/HttpMessage/UploadedFile.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\HttpMessage; -use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; /** * {@inheritdoc} diff --git a/src/SonsOfPHP/Component/Money/Amount.php b/src/SonsOfPHP/Component/Money/Amount.php index d888302e..5fe7cecd 100644 --- a/src/SonsOfPHP/Component/Money/Amount.php +++ b/src/SonsOfPHP/Component/Money/Amount.php @@ -5,11 +5,9 @@ namespace SonsOfPHP\Component\Money; use SonsOfPHP\Component\Money\Operator\Amount\AddAmountOperator; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\DivideAmountOperator; use SonsOfPHP\Component\Money\Operator\Amount\MultiplyAmountOperator; use SonsOfPHP\Component\Money\Operator\Amount\SubtractAmountOperator; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsEqualToAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanOrEqualToAmountQuery; @@ -19,6 +17,8 @@ use SonsOfPHP\Component\Money\Query\Amount\IsPositiveAmountQuery; use SonsOfPHP\Component\Money\Query\Amount\IsZeroAmountQuery; use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Currency.php b/src/SonsOfPHP/Component/Money/Currency.php index b384e1e1..470536db 100644 --- a/src/SonsOfPHP/Component/Money/Currency.php +++ b/src/SonsOfPHP/Component/Money/Currency.php @@ -4,8 +4,9 @@ namespace SonsOfPHP\Component\Money; -use SonsOfPHP\Component\Money\Query\Currency\CurrencyQueryInterface; use SonsOfPHP\Component\Money\Query\Currency\IsEqualToCurrencyQuery; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\Query\Currency\CurrencyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php b/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php index 8310672e..ca077e69 100644 --- a/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php +++ b/src/SonsOfPHP/Component/Money/CurrencyProvider/AbstractCurrencyProvider.php @@ -4,10 +4,11 @@ namespace SonsOfPHP\Component\Money\CurrencyProvider; -use SonsOfPHP\Contract\Money\CurrencyInterface; -use SonsOfPHP\Contract\Money\Query\CurrencyProviderQueryInterface; use SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery; use SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; +use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/CurrencyProvider/ChainCurrencyProvider.php b/src/SonsOfPHP/Component/Money/CurrencyProvider/ChainCurrencyProvider.php index 27179923..cbfa2172 100644 --- a/src/SonsOfPHP/Component/Money/CurrencyProvider/ChainCurrencyProvider.php +++ b/src/SonsOfPHP/Component/Money/CurrencyProvider/ChainCurrencyProvider.php @@ -4,6 +4,8 @@ namespace SonsOfPHP\Component\Money\CurrencyProvider; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; + /** * Chain Currency Provider. * diff --git a/src/SonsOfPHP/Component/Money/Money.php b/src/SonsOfPHP/Component/Money/Money.php index 7e918f22..b4e57beb 100644 --- a/src/SonsOfPHP/Component/Money/Money.php +++ b/src/SonsOfPHP/Component/Money/Money.php @@ -6,7 +6,6 @@ use SonsOfPHP\Component\Money\Operator\Money\AddMoneyOperator; use SonsOfPHP\Component\Money\Operator\Money\DivideMoneyOperator; -use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\MultiplyMoneyOperator; use SonsOfPHP\Component\Money\Operator\Money\SubtractMoneyOperator; use SonsOfPHP\Component\Money\Query\Money\IsEqualToMoneyQuery; @@ -17,10 +16,11 @@ use SonsOfPHP\Component\Money\Query\Money\IsNegativeMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\IsPositiveMoneyQuery; use SonsOfPHP\Component\Money\Query\Money\IsZeroMoneyQuery; -use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; -use SonsOfPHP\Contract\Money\MoneyInterface; -use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php index 6c74ce77..70120c86 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/MultiplyAmountOperator.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php b/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php index b1133234..7881fad3 100644 --- a/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php +++ b/src/SonsOfPHP/Component/Money/Operator/Amount/SubtractAmountOperator.php @@ -5,8 +5,8 @@ namespace SonsOfPHP\Component\Money\Operator\Amount; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsEqualToAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsEqualToAmountQuery.php index 0ed67802..f6e86581 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsEqualToAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsEqualToAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanAmountQuery.php index 83068f36..6fba3d12 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php index ce298398..15204625 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsGreaterThanOrEqualToAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanAmountQuery.php index d5e0740d..dee98c25 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanOrEqualToAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanOrEqualToAmountQuery.php index ed393a86..c27ae797 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanOrEqualToAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsLessThanOrEqualToAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsNegativeAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsNegativeAmountQuery.php index 8ef5f27f..82fbf59f 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsNegativeAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsNegativeAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsPositiveAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsPositiveAmountQuery.php index 577603a1..d5d16881 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsPositiveAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsPositiveAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Amount/IsZeroAmountQuery.php b/src/SonsOfPHP/Component/Money/Query/Amount/IsZeroAmountQuery.php index 9c17f271..34baf643 100644 --- a/src/SonsOfPHP/Component/Money/Query/Amount/IsZeroAmountQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Amount/IsZeroAmountQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Amount; -use SonsOfPHP\Component\Money\AmountInterface; +use SonsOfPHP\Contract\Money\AmountInterface; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Currency/IsEqualToCurrencyQuery.php b/src/SonsOfPHP/Component/Money/Query/Currency/IsEqualToCurrencyQuery.php index 9cb1c1b2..94746b7a 100644 --- a/src/SonsOfPHP/Component/Money/Query/Currency/IsEqualToCurrencyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Currency/IsEqualToCurrencyQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Currency; -use SonsOfPHP\Component\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\Query\Currency\CurrencyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php index 3805849c..6e978295 100644 --- a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/GetCurrencyQuery.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\Money\Query\CurrencyProvider; use SonsOfPHP\Component\Money\Currency; +use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\CurrencyProviderInterface; -use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** diff --git a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php index e9c34cca..1e4fbb1a 100644 --- a/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/CurrencyProvider/HasCurrencyQuery.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\Money\Query\CurrencyProvider; use SonsOfPHP\Component\Money\Currency; +use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\CurrencyProviderInterface; -use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; /** diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsEqualToMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsEqualToMoneyQuery.php index e5be0531..cd8334eb 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsEqualToMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsEqualToMoneyQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanMoneyQuery.php index b8f312ba..dd8ac01e 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanMoneyQuery.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php index d8f87449..76ea907d 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsGreaterThanOrEqualToMoneyQuery.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanMoneyQuery.php index 09bd36d6..a79fc4ed 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanMoneyQuery.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanOrEqualToMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanOrEqualToMoneyQuery.php index 95748d0c..38f88b9b 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanOrEqualToMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsLessThanOrEqualToMoneyQuery.php @@ -5,7 +5,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; use SonsOfPHP\Component\Money\Exception\MoneyException; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php index 7096b1a4..773a2cd2 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsPositiveMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsPositiveMoneyQuery.php index 43cc9e52..b1597f44 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsPositiveMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsPositiveMoneyQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsZeroMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsZeroMoneyQuery.php index 2f235f33..9d7f29d6 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsZeroMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsZeroMoneyQuery.php @@ -4,7 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; -use SonsOfPHP\Component\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php index b77e9b62..2d3f25e2 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/ChainCurrencyProviderTest.php @@ -6,11 +6,11 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Component\Money\CurrencyProvider\ChainCurrencyProvider; use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProvider; -use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; +use SonsOfPHP\Contract\Money\CurrencyInterface; +use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php index 4b620242..0d450167 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/CurrencyProviderTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Component\Money\CurrencyProvider\CurrencyProvider; +use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\CurrencyProviderInterface; use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php index ba0814a0..60e312b6 100644 --- a/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/CurrencyProvider/XCurrencyProviderTest.php @@ -5,9 +5,9 @@ namespace SonsOfPHP\Component\Money\Tests\CurrencyProvider; use PHPUnit\Framework\TestCase; +use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; use SonsOfPHP\Contract\Money\CurrencyInterface; use SonsOfPHP\Contract\Money\CurrencyProviderInterface; -use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; /** * @coversDefaultClass \SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider diff --git a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php index 25b4a964..88fd88b8 100644 --- a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Exception\MoneyException; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Contract\Money\MoneyInterface; @@ -143,7 +143,7 @@ public function testGreaterThanWithDifferentCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->isGreaterThan($money2); } @@ -171,7 +171,7 @@ public function testGreaterThanOrEqualsWithDifferentCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->isGreaterThanOrEqualTo($money2); } @@ -198,7 +198,7 @@ public function testLessThanWithDifferentCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->isLessThan($money2); } @@ -226,7 +226,7 @@ public function testLessThanOrEqualsWithDifferentCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->isLessThanOrEqualTo($money2); } @@ -297,7 +297,7 @@ public function testAddWithDifferenctCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->add($money2); } @@ -323,7 +323,7 @@ public function testSubtractWithDifferenctCurrencies(): void $money1 = Money::USD(100); $money2 = Money::EUR(100); - $this->expectException(MoneyException::class); + $this->expectException(MoneyExceptionInterface::class); $money1->subtract($money2); } diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/AddAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/AddAmountOperatorTest.php index 63f2aea6..b593eeed 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/AddAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/AddAmountOperatorTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Operator\Amount\AddAmountOperator; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Amount\AddAmountOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php index d6d3b01c..4a8c7325 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\DivideAmountOperator; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php index 5bf7fe67..ba551ab2 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\MultiplyAmountOperator; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php index 47914fe7..b85d8f0b 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Component\Money\Operator\Amount\AmountOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\SubtractAmountOperator; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/AddMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/AddMoneyOperatorTest.php index adef34e9..e3f29f50 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/AddMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/AddMoneyOperatorTest.php @@ -9,7 +9,7 @@ use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Operator\Money\AddMoneyOperator; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Money\AddMoneyOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/DivideMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/DivideMoneyOperatorTest.php index 2b58087c..7948d979 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/DivideMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/DivideMoneyOperatorTest.php @@ -8,7 +8,7 @@ use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Operator\Money\DivideMoneyOperator; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Money\DivideMoneyOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php index 23807632..90d87f39 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\MultiplyMoneyOperator; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php index 9eff15d2..2d2c22a2 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php @@ -8,7 +8,7 @@ use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Component\Money\Operator\Money\MoneyOperatorInterface; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\SubtractMoneyOperator; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php index 56e4b1f3..669e8a85 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsEqualToAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsEqualToAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsEqualToAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php index f71620cf..fc17a297 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php index 32cf6c97..c975fe43 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsGreaterThanOrEqualToAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanOrEqualToAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsGreaterThanOrEqualToAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php index ffa67d9f..1318ed67 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsLessThanAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsLessThanAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php index 2c9dc7b1..6f422fc4 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsLessThanOrEqualToAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsLessThanOrEqualToAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsLessThanOrEqualToAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php index 98f691c9..f5ed3247 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsNegativeAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsNegativeAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsNegativeAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php index 043d9914..28944e8e 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsPositiveAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsPositiveAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsPositiveAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php index dcb10014..87e66965 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Amount/IsZeroAmountQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; use SonsOfPHP\Component\Money\Query\Amount\IsZeroAmountQuery; +use SonsOfPHP\Contract\Money\Query\Amount\AmountQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Amount\IsZeroAmountQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Currency/IsEqualToCurrencyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Currency/IsEqualToCurrencyQueryTest.php index badb655c..055424b6 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Currency/IsEqualToCurrencyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Currency/IsEqualToCurrencyQueryTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Query\Currency\CurrencyQueryInterface; use SonsOfPHP\Component\Money\Query\Currency\IsEqualToCurrencyQuery; +use SonsOfPHP\Contract\Money\Query\Currency\CurrencyQueryInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\Currency\IsEqualToCurrencyQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php index 8ef0b0d7..31ca2e67 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/GetCurrencyQueryTest.php @@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; +use SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery; use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\CurrencyProvider\GetCurrencyQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php index 06b0f0e4..9c2681d2 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/CurrencyProvider/HasCurrencyQueryTest.php @@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\CurrencyProvider\XCurrencyProvider; +use SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery; use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; use SonsOfPHP\Contract\Money\Query\CurrencyProvider\CurrencyProviderQueryInterface; -use SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Query\CurrencyProvider\HasCurrencyQuery diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php new file mode 100644 index 00000000..62d91ea7 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php @@ -0,0 +1,45 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsEqualToMoneyQuery(new Money(100, Currency::USD())); + + $this->assertTrue($query->queryFrom(new Money(100, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php new file mode 100644 index 00000000..12ad8537 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php @@ -0,0 +1,46 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsGreaterThanMoneyQuery(new Money(100, Currency::USD())); + + $this->assertTrue($query->queryFrom(new Money(200, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php new file mode 100644 index 00000000..ed4f6633 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php @@ -0,0 +1,46 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsGreaterThanOrEqualToMoneyQuery(new Money(100, Currency::USD())); + + $this->assertTrue($query->queryFrom(new Money(2000, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php new file mode 100644 index 00000000..b17496b5 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php @@ -0,0 +1,46 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsLessThanMoneyQuery(new Money(100, Currency::USD())); + + $this->assertTrue($query->queryFrom(new Money(50, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php new file mode 100644 index 00000000..a3904125 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php @@ -0,0 +1,46 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsLessThanOrEqualToMoneyQuery(new Money(100, Currency::USD())); + + $this->assertTrue($query->queryFrom(new Money(10, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php new file mode 100644 index 00000000..ac91187a --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php @@ -0,0 +1,44 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsNegativeMoneyQuery(); + + $this->assertTrue($query->queryFrom(new Money(-10, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php new file mode 100644 index 00000000..cd3ffe4b --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php @@ -0,0 +1,44 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsPositiveMoneyQuery(); + + $this->assertTrue($query->queryFrom(new Money(10, Currency::USD()))); + } +} diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php new file mode 100644 index 00000000..f7303ca0 --- /dev/null +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php @@ -0,0 +1,44 @@ +assertInstanceOf(MoneyQueryInterface::class, $query); + } + + /** + * @covers ::queryFrom + */ + public function testQuery(): void + { + $query = new IsZeroMoneyQuery(); + + $this->assertTrue($query->queryFrom(new Money(0, Currency::USD()))); + } +} From 5e96345f066ed2fb1aa33386c1e68e3f2787fb10 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Sat, 11 Nov 2023 15:47:03 -0500 Subject: [PATCH 24/27] cs fixes --- .../Component/Money/Query/Money/IsNegativeMoneyQuery.php | 2 +- src/SonsOfPHP/Component/Money/Tests/MoneyTest.php | 2 +- .../Money/Tests/Operator/Amount/DivideAmountOperatorTest.php | 2 +- .../Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php | 2 +- .../Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php | 2 +- .../Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php | 2 +- .../Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php | 2 +- .../Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php | 1 - .../Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php | 1 - .../Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php | 1 - .../Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php | 1 - .../Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php | 1 - .../Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php | 1 - .../Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php | 1 - .../Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php | 1 - 15 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php b/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php index 773a2cd2..441e4602 100644 --- a/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php +++ b/src/SonsOfPHP/Component/Money/Query/Money/IsNegativeMoneyQuery.php @@ -4,8 +4,8 @@ namespace SonsOfPHP\Component\Money\Query\Money; -use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; use SonsOfPHP\Contract\Money\MoneyInterface; +use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; /** * @author Joshua Estes diff --git a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php index 88fd88b8..8f8ab3ad 100644 --- a/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/MoneyTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; use SonsOfPHP\Component\Money\Money; +use SonsOfPHP\Contract\Money\Exception\MoneyExceptionInterface; use SonsOfPHP\Contract\Money\MoneyInterface; /** diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php index 4a8c7325..e143641e 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/DivideAmountOperatorTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\DivideAmountOperator; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Amount\DivideAmountOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php index ba551ab2..21844e66 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/MultiplyAmountOperatorTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\MultiplyAmountOperator; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Amount\MultiplyAmountOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php index b85d8f0b..0f5cc314 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Amount/SubtractAmountOperatorTest.php @@ -6,8 +6,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Amount; -use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; use SonsOfPHP\Component\Money\Operator\Amount\SubtractAmountOperator; +use SonsOfPHP\Contract\Money\Operator\Amount\AmountOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Amount\SubtractAmountOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php index 90d87f39..4ca68b93 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/MultiplyMoneyOperatorTest.php @@ -7,8 +7,8 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\MultiplyMoneyOperator; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Money\MultiplyMoneyOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php index 2d2c22a2..5bbc6b9a 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Operator/Money/SubtractMoneyOperatorTest.php @@ -8,8 +8,8 @@ use SonsOfPHP\Component\Money\Currency; use SonsOfPHP\Component\Money\Exception\MoneyException; use SonsOfPHP\Component\Money\Money; -use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; use SonsOfPHP\Component\Money\Operator\Money\SubtractMoneyOperator; +use SonsOfPHP\Contract\Money\Operator\Money\MoneyOperatorInterface; /** * @coversDefaultClass \SonsOfPHP\Component\Money\Operator\Money\SubtractMoneyOperator diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php index 62d91ea7..b1ca02df 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsEqualToMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsEqualToMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php index 12ad8537..4df2f9de 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsGreaterThanMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php index ed4f6633..674fdaaf 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsGreaterThanOrEqualToMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsGreaterThanOrEqualToMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php index b17496b5..196d6fec 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsLessThanMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php index a3904125..59f3ad0e 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsLessThanOrEqualToMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsLessThanOrEqualToMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php index ac91187a..d2b6fbda 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsNegativeMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsNegativeMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php index cd3ffe4b..8f9ee2e0 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsPositiveMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsPositiveMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; diff --git a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php index f7303ca0..cd7f8991 100644 --- a/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php +++ b/src/SonsOfPHP/Component/Money/Tests/Query/Money/IsZeroMoneyQueryTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use SonsOfPHP\Component\Money\Currency; -use SonsOfPHP\Component\Money\Amount; use SonsOfPHP\Component\Money\Money; use SonsOfPHP\Component\Money\Query\Money\IsZeroMoneyQuery; use SonsOfPHP\Contract\Money\Query\Money\MoneyQueryInterface; From 1824f6ab9c376ad507167dc871bfa64ffc5a6d6e Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Sat, 11 Nov 2023 15:49:09 -0500 Subject: [PATCH 25/27] updates --- composer.json | 12 ++++++------ src/SonsOfPHP/Component/Cqrs/composer.json | 2 +- src/SonsOfPHP/Component/EventSourcing/composer.json | 2 +- src/SonsOfPHP/Component/FeatureToggle/composer.json | 2 +- src/SonsOfPHP/Component/Filesystem/composer.json | 2 +- src/SonsOfPHP/Component/Money/composer.json | 2 +- src/SonsOfPHP/Component/Version/composer.json | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 571142e8..f32a4830 100644 --- a/composer.json +++ b/composer.json @@ -38,12 +38,12 @@ "psr/http-factory-implementation": "^1.0", "psr/cache-implementation": "^2.0 || ^3.0", "psr/simple-cache-implementation": "^1.0 || ^2.0 || ^3.0", - "sonsofphp/cqrs-contract-implementation": "0.3.x-dev", - "sonsofphp/event-sourcing-contract-implementation": "0.3.x-dev", - "sonsofphp/feature-toggle-contract-implementation": "0.3.x-dev", - "sonsofphp/filesystem-contract-implementation": "0.3.x-dev", - "sonsofphp/money-contract-implementation": "0.3.x-dev", - "sonsofphp/version-contract-implementation": "0.3.x-dev" + "sonsofphp/cqrs-implementation": "0.3.x-dev", + "sonsofphp/event-sourcing-implementation": "0.3.x-dev", + "sonsofphp/feature-toggle-implementation": "0.3.x-dev", + "sonsofphp/filesystem-implementation": "0.3.x-dev", + "sonsofphp/money-implementation": "0.3.x-dev", + "sonsofphp/version-implementation": "0.3.x-dev" }, "require": { "php": ">=8.1", diff --git a/src/SonsOfPHP/Component/Cqrs/composer.json b/src/SonsOfPHP/Component/Cqrs/composer.json index 01719ff9..daad3e72 100644 --- a/src/SonsOfPHP/Component/Cqrs/composer.json +++ b/src/SonsOfPHP/Component/Cqrs/composer.json @@ -62,4 +62,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Component/EventSourcing/composer.json b/src/SonsOfPHP/Component/EventSourcing/composer.json index 45517427..bd6f9f36 100644 --- a/src/SonsOfPHP/Component/EventSourcing/composer.json +++ b/src/SonsOfPHP/Component/EventSourcing/composer.json @@ -59,4 +59,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Component/FeatureToggle/composer.json b/src/SonsOfPHP/Component/FeatureToggle/composer.json index cdadf009..dd1ed776 100644 --- a/src/SonsOfPHP/Component/FeatureToggle/composer.json +++ b/src/SonsOfPHP/Component/FeatureToggle/composer.json @@ -57,4 +57,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Component/Filesystem/composer.json b/src/SonsOfPHP/Component/Filesystem/composer.json index 967ac2a6..758f58ca 100644 --- a/src/SonsOfPHP/Component/Filesystem/composer.json +++ b/src/SonsOfPHP/Component/Filesystem/composer.json @@ -53,4 +53,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Component/Money/composer.json b/src/SonsOfPHP/Component/Money/composer.json index d8b4499e..8e8e44d9 100644 --- a/src/SonsOfPHP/Component/Money/composer.json +++ b/src/SonsOfPHP/Component/Money/composer.json @@ -54,4 +54,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file diff --git a/src/SonsOfPHP/Component/Version/composer.json b/src/SonsOfPHP/Component/Version/composer.json index 3fd0a014..cfe72c9e 100644 --- a/src/SonsOfPHP/Component/Version/composer.json +++ b/src/SonsOfPHP/Component/Version/composer.json @@ -52,4 +52,4 @@ "url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp" } ] -} +} \ No newline at end of file From c420c5fe40067b240a045f16e38c754922f89896 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Sat, 11 Nov 2023 15:51:53 -0500 Subject: [PATCH 26/27] workflow for code coverage --- .github/workflows/codecov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ed83daeb..864c0678 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -37,10 +37,10 @@ jobs: key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} restore-keys: | ${{ runner.os }}-php- - - run: make install - - run: php tools/phpunit/vendor/bin/phpunit --coverage-clover coverage.xml + - run: make install phpunit env: XDEBUG_MODE: coverage + PHPUNIT_OPTIONS: --coverage-clover coverage.xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: From 468ec6c9b2fcdaaf7c9793429e24ac9b18bffb9a Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Sat, 11 Nov 2023 16:07:17 -0500 Subject: [PATCH 27/27] updates --- .github/CODEOWNERS | 55 ++++++++++++-------------------- .github/pull_request_template.md | 13 +++----- 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9657a4b8..244f95ee 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,35 +1,22 @@ -/.github @JoshuaEstes -/tools @JoshuaEstes -/docs @JoshuaEstes +* @sonsofphp/Members + +# Make Documentation Team +docs/ @sonsofphp/Members + +# Each project needs a Team /src/SonsOfPHP/Bard @JoshuaEstes -/src/SonsOfPHP/Bridge/Doctrine/EventSourcing @JoshuaEstes -/src/SonsOfPHP/Bridge/Doctrine/FeatureToggle @JoshuaEstes -/src/SonsOfPHP/Bridge/Doctrine/Money @JoshuaEstes -/src/SonsOfPHP/Bridge/Symfony/Cqrs @JoshuaEstes -/src/SonsOfPHP/Bridge/Symfony/EventSourcing @JoshuaEstes -/src/SonsOfPHP/Bridge/Symfony/Filesystem @JoshuaEstes -/src/SonsOfPHP/Bundle/Cqrs @JoshuaEstes -/src/SonsOfPHP/Bundle/FeatureToggle @JoshuaEstes -/src/SonsOfPHP/Bundle/Filesystem @JoshuaEstes -/src/SonsOfPHP/Component/Autoloader @JoshuaEstes -/src/SonsOfPHP/Component/Cache @JoshuaEstes -/src/SonsOfPHP/Component/Clock @JoshuaEstes -/src/SonsOfPHP/Component/Cqrs @JoshuaEstes -/src/SonsOfPHP/Component/Cvs @JoshuaEstes -/src/SonsOfPHP/Component/EventDispatcher @JoshuaEstes -/src/SonsOfPHP/Component/EventSourcing @JoshuaEstes -/src/SonsOfPHP/Component/FeatureToggle @JoshuaEstes -/src/SonsOfPHP/Component/Faker @JoshuaEstes -/src/SonsOfPHP/Component/Filesystem @JoshuaEstes -/src/SonsOfPHP/Component/HttpClient @JoshuaEstes -/src/SonsOfPHP/Component/HttpFactory @JoshuaEstes -/src/SonsOfPHP/Component/HttpHandler @JoshuaEstes -/src/SonsOfPHP/Component/HttpMessage @JoshuaEstes -/src/SonsOfPHP/Component/Json @JoshuaEstes -/src/SonsOfPHP/Component/Logger @JoshuaEstes -/src/SonsOfPHP/Component/Money @JoshuaEstes -/src/SonsOfPHP/Component/Pdf @JoshuaEstes -/src/SonsOfPHP/Component/PhoneNumber @JoshuaEstes -/src/SonsOfPHP/Component/Queue @JoshuaEstes -/src/SonsOfPHP/Component/Version @JoshuaEstes -/src/SonsOfPHP/Contract/Common @JoshuaEstes + +# Each project/component/contract needs a Team +/src/SonsOfPHP/**/Cache @JoshuaEstes +/src/SonsOfPHP/**/Clock @JoshuaEstes +/src/SonsOfPHP/**/Common @JoshuaEstes +/src/SonsOfPHP/**/Cqrs @JoshuaEstes +/src/SonsOfPHP/**/EventDispatcher @JoshuaEstes +/src/SonsOfPHP/**/EventSourcing @JoshuaEstes +/src/SonsOfPHP/**/FeatureToggle @JoshuaEstes +/src/SonsOfPHP/**/Filesystem @JoshuaEstes +/src/SonsOfPHP/**/HttpFactory @JoshuaEstes +/src/SonsOfPHP/**/HttpMessage @JoshuaEstes +/src/SonsOfPHP/**/HttpJson @JoshuaEstes +/src/SonsOfPHP/**/Money @JoshuaEstes +/src/SonsOfPHP/**/Version @JoshuaEstes diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5030033b..6b1a5e68 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,13 +1,8 @@ ## Description - -## Checklist - -- [ ] Updated the correct CHANGELOG file -- [ ] Updated documentation +## Checklist +- [ ] Updated CHANGELOG files +- [ ] Updated Documentation +- [ ] Unit Tests Created