From 4f99213fe1caafd061a506481bbb42886a88c37a Mon Sep 17 00:00:00 2001 From: thepercival Date: Wed, 29 May 2024 15:40:42 +0200 Subject: [PATCH] fix(validation): first validate than create --- composer.lock | 1093 +++++++++++++---- domain/Batch/SelfReferee.php | 60 +- domain/Combinations/Mapper.php | 31 +- domain/Combinations/PlaceCombination.php | 14 +- .../PlaceCombinationCounterMap.php | 209 ---- domain/Combinations/PlaceCounterMap.php | 209 ---- .../AssignedCounter.php | 169 +-- .../CounterForPlace.php} | 13 +- .../CounterForPlaceCombination.php} | 9 +- domain/Counters/GamePlacesCounterForPoule.php | 64 + .../Maps/PlaceCombinationCounterMap.php | 110 ++ domain/Counters/Maps/PlaceCounterMap.php | 114 ++ .../Maps/RangedPlaceCombinationCounterMap.php | 98 ++ .../Maps/RangedPlaceCounterMap.php} | 57 +- .../PlaceCombinationCountersReport.php | 143 +++ .../Counters/Reports/PlaceCountersReport.php | 158 +++ .../RangedPlaceCombinationCountersReport.php} | 78 +- .../Reports/RangedPlaceCountersReport.php | 126 ++ domain/Game.php | 2 +- domain/GameRound/Against.php | 1 - .../Output/Combinations/GameRoundOutput.php | 2 +- domain/Output/Combinations/HomeAwayOutput.php | 11 +- domain/Output/ScheduleOutput.php | 11 +- domain/Planning/TimeoutConfig.php | 4 +- domain/Planning/Validity.php | 44 +- domain/Poule/GameCounter.php | 34 - domain/Poule/PouleCounter.php | 67 - domain/Resource/GameCounter.php | 7 +- domain/Resource/GameCounter/Place.php | 2 +- domain/Schedule/Game.php | 4 - domain/Schedule/Sport.php | 3 - tests/cases/PlaceCounterTest.php | 11 +- tests/cases/Poule/PouleCounterTest.php | 18 +- .../cases/Resource/GameCounter/PlaceTest.php | 4 +- tests/cases/Resource/GameCounterTest.php | 2 +- 35 files changed, 1951 insertions(+), 1031 deletions(-) delete mode 100644 domain/Combinations/PlaceCombinationCounterMap.php delete mode 100644 domain/Combinations/PlaceCounterMap.php rename domain/{Combinations => Counters}/AssignedCounter.php (52%) rename domain/{PlaceCounter.php => Counters/CounterForPlace.php} (60%) rename domain/{Combinations/PlaceCombinationCounter.php => Counters/CounterForPlaceCombination.php} (79%) create mode 100644 domain/Counters/GamePlacesCounterForPoule.php create mode 100644 domain/Counters/Maps/PlaceCombinationCounterMap.php create mode 100644 domain/Counters/Maps/PlaceCounterMap.php create mode 100644 domain/Counters/Maps/RangedPlaceCombinationCounterMap.php rename domain/{Combinations/PlaceCounterMap/Ranged.php => Counters/Maps/RangedPlaceCounterMap.php} (63%) create mode 100644 domain/Counters/Reports/PlaceCombinationCountersReport.php create mode 100644 domain/Counters/Reports/PlaceCountersReport.php rename domain/{Combinations/PlaceCombinationCounterMap/Ranged.php => Counters/Reports/RangedPlaceCombinationCountersReport.php} (50%) create mode 100644 domain/Counters/Reports/RangedPlaceCountersReport.php delete mode 100644 domain/Poule/GameCounter.php delete mode 100644 domain/Poule/PouleCounter.php diff --git a/composer.lock b/composer.lock index 18413f0..cff3e0f 100644 --- a/composer.lock +++ b/composer.lock @@ -278,16 +278,16 @@ }, { "name": "doctrine/dbal", - "version": "3.8.3", + "version": "3.8.4", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "db922ba9436b7b18a23d1653a0b41ff2369ca41c" + "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/db922ba9436b7b18a23d1653a0b41ff2369ca41c", - "reference": "db922ba9436b7b18a23d1653a0b41ff2369ca41c", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/b05e48a745f722801f55408d0dbd8003b403dbbd", + "reference": "b05e48a745f722801f55408d0dbd8003b403dbbd", "shasum": "" }, "require": { @@ -371,7 +371,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.8.3" + "source": "https://github.com/doctrine/dbal/tree/3.8.4" }, "funding": [ { @@ -387,7 +387,7 @@ "type": "tidelift" } ], - "time": "2024-03-03T15:55:06+00:00" + "time": "2024-04-25T07:04:44+00:00" }, { "name": "doctrine/deprecations", @@ -438,16 +438,16 @@ }, { "name": "doctrine/event-manager", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", - "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/b680156fa328f1dfd874fd48c7026c41570b9c6e", + "reference": "b680156fa328f1dfd874fd48c7026c41570b9c6e", "shasum": "" }, "require": { @@ -457,10 +457,10 @@ "doctrine/common": "<2.9" }, "require-dev": { - "doctrine/coding-standard": "^10", + "doctrine/coding-standard": "^12", "phpstan/phpstan": "^1.8.8", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^4.28" + "phpunit/phpunit": "^10.5", + "vimeo/psalm": "^5.24" }, "type": "library", "autoload": { @@ -509,7 +509,7 @@ ], "support": { "issues": "https://github.com/doctrine/event-manager/issues", - "source": "https://github.com/doctrine/event-manager/tree/2.0.0" + "source": "https://github.com/doctrine/event-manager/tree/2.0.1" }, "funding": [ { @@ -525,7 +525,7 @@ "type": "tidelift" } ], - "time": "2022-10-12T20:59:15+00:00" + "time": "2024-05-22T20:47:39+00:00" }, { "name": "doctrine/inflector", @@ -767,16 +767,16 @@ }, { "name": "doctrine/orm", - "version": "2.19.4", + "version": "2.19.5", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "b27489348658cd718d18005de37b94f7f8561467" + "reference": "94986af28452da42a46a4489d1c958a2e5d710e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/b27489348658cd718d18005de37b94f7f8561467", - "reference": "b27489348658cd718d18005de37b94f7f8561467", + "url": "https://api.github.com/repos/doctrine/orm/zipball/94986af28452da42a46a4489d1c958a2e5d710e5", + "reference": "94986af28452da42a46a4489d1c958a2e5d710e5", "shasum": "" }, "require": { @@ -862,9 +862,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/2.19.4" + "source": "https://github.com/doctrine/orm/tree/2.19.5" }, - "time": "2024-04-15T13:11:10+00:00" + "time": "2024-04-30T06:49:54+00:00" }, { "name": "doctrine/persistence", @@ -1377,16 +1377,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.28.0", + "version": "1.29.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", "shasum": "" }, "require": { @@ -1418,9 +1418,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0" }, - "time": "2024-04-03T18:51:33+00:00" + "time": "2024-05-06T12:04:23+00:00" }, { "name": "psr/cache", @@ -1576,16 +1576,16 @@ }, { "name": "symfony/console", - "version": "v7.0.6", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5" + "reference": "c981e0e9380ce9f146416bde3150c79197ce9986" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/fde915cd8e7eb99b3d531d3d5c09531429c3f9e5", - "reference": "fde915cd8e7eb99b3d531d3d5c09531429c3f9e5", + "url": "https://api.github.com/repos/symfony/console/zipball/c981e0e9380ce9f146416bde3150c79197ce9986", + "reference": "c981e0e9380ce9f146416bde3150c79197ce9986", "shasum": "" }, "require": { @@ -1649,7 +1649,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.0.6" + "source": "https://github.com/symfony/console/tree/v7.0.7" }, "funding": [ { @@ -1665,7 +1665,74 @@ "type": "tidelift" } ], - "time": "2024-04-01T11:04:53+00:00" + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2140,21 +2207,22 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.2", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e" + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/11bbf19a0fb7b36345861e85c5768844c552906e", - "reference": "11bbf19a0fb7b36345861e85c5768844c552906e", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^1.1|^2.0" + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -2162,7 +2230,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -2202,7 +2270,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.2" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" }, "funding": [ { @@ -2218,20 +2286,20 @@ "type": "tidelift" } ], - "time": "2023-12-19T21:51:00+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/string", - "version": "v7.0.4", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "f5832521b998b0bec40bee688ad5de98d4cf111b" + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/f5832521b998b0bec40bee688ad5de98d4cf111b", - "reference": "f5832521b998b0bec40bee688ad5de98d4cf111b", + "url": "https://api.github.com/repos/symfony/string/zipball/e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63", "shasum": "" }, "require": { @@ -2288,7 +2356,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.0.4" + "source": "https://github.com/symfony/string/tree/v7.0.7" }, "funding": [ { @@ -2304,20 +2372,20 @@ "type": "tidelift" } ], - "time": "2024-02-01T13:17:36+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "thepercival/php-sports-helpers", - "version": "v1.2.52", + "version": "v1.2.55", "source": { "type": "git", "url": "https://github.com/thepercival/php-sports-helpers.git", - "reference": "ae6c6fc864a67bd049671ab201cba92788623189" + "reference": "702ddd0f51052e2c420cef5bb0c135456bfa38b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thepercival/php-sports-helpers/zipball/ae6c6fc864a67bd049671ab201cba92788623189", - "reference": "ae6c6fc864a67bd049671ab201cba92788623189", + "url": "https://api.github.com/repos/thepercival/php-sports-helpers/zipball/702ddd0f51052e2c420cef5bb0c135456bfa38b0", + "reference": "702ddd0f51052e2c420cef5bb0c135456bfa38b0", "shasum": "" }, "require": { @@ -2368,9 +2436,9 @@ "support": { "email": "coendunnink@gmail.com", "issues": "https://github.com/thepercival/php-sports-helpers/issues", - "source": "https://github.com/thepercival/php-sports-helpers/tree/v1.2.52" + "source": "https://github.com/thepercival/php-sports-helpers/tree/v1.2.55" }, - "time": "2024-04-23T13:01:06+00:00" + "time": "2024-05-26T19:25:39+00:00" } ], "packages-dev": [ @@ -2534,6 +2602,70 @@ ], "time": "2024-04-13T18:00:56+00:00" }, + { + "name": "clue/ndjson-react", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\React\\NDJson\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", + "keywords": [ + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" + ], + "support": { + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-12-23T10:58:28+00:00" + }, { "name": "composer/package-versions-deprecated", "version": "1.11.99.5", @@ -2761,16 +2893,16 @@ }, { "name": "composer/xdebug-handler", - "version": "3.0.4", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255" + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255", - "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", "shasum": "" }, "require": { @@ -2807,7 +2939,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.4" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" }, "funding": [ { @@ -2823,7 +2955,7 @@ "type": "tidelift" } ], - "time": "2024-03-26T18:29:49+00:00" + "time": "2024-05-06T16:37:16+00:00" }, { "name": "dnoegel/php-xdg-base-dir", @@ -2862,6 +2994,53 @@ }, "time": "2019-12-04T15:06:13+00:00" }, + { + "name": "evenement/evenement", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Evenement\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" + }, + "time": "2023-08-08T05:53:35+00:00" + }, { "name": "felixfbecker/advanced-json-rpc", "version": "v3.2.1", @@ -3026,25 +3205,32 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.54.0", + "version": "v3.57.2", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08" + "reference": "22f7f3145606df92b02fb1bd22c30abfce956d3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2aecbc8640d7906c38777b3dcab6f4ca79004d08", - "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/22f7f3145606df92b02fb1bd22c30abfce956d3c", + "reference": "22f7f3145606df92b02fb1bd22c30abfce956d3c", "shasum": "" }, "require": { + "clue/ndjson-react": "^1.0", "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.3", "ext-filter": "*", "ext-json": "*", "ext-tokenizer": "*", + "fidry/cpu-core-counter": "^1.0", "php": "^7.4 || ^8.0", + "react/child-process": "^0.6.5", + "react/event-loop": "^1.0", + "react/promise": "^2.0 || ^3.0", + "react/socket": "^1.0", + "react/stream": "^1.0", "sebastian/diff": "^4.0 || ^5.0 || ^6.0", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", @@ -3107,7 +3293,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.54.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.57.2" }, "funding": [ { @@ -3115,7 +3301,7 @@ "type": "github" } ], - "time": "2024-04-17T08:12:13+00:00" + "time": "2024-05-20T20:41:57+00:00" }, { "name": "myclabs/deep-copy", @@ -3456,16 +3642,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.0", + "version": "5.4.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", "shasum": "" }, "require": { @@ -3514,9 +3700,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" }, - "time": "2024-04-09T21:13:58+00:00" + "time": "2024-05-21T05:55:05+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3622,16 +3808,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.11.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec", + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec", "shasum": "" }, "require": { @@ -3676,25 +3862,25 @@ "type": "github" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-05-24T13:23:04+00:00" }, { "name": "phpstan/phpstan-doctrine", - "version": "1.3.69", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-doctrine.git", - "reference": "ac567407e750b94e2133dace33b19082ad9ed751" + "reference": "4b66f5c996865a6085983cc90b5c8a242d1959e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/ac567407e750b94e2133dace33b19082ad9ed751", - "reference": "ac567407e750b94e2133dace33b19082ad9ed751", + "url": "https://api.github.com/repos/phpstan/phpstan-doctrine/zipball/4b66f5c996865a6085983cc90b5c8a242d1959e7", + "reference": "4b66f5c996865a6085983cc90b5c8a242d1959e7", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.64" + "phpstan/phpstan": "^1.11" }, "conflict": { "doctrine/collections": "<1.0", @@ -3746,27 +3932,27 @@ "description": "Doctrine extensions for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-doctrine/issues", - "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.3.69" + "source": "https://github.com/phpstan/phpstan-doctrine/tree/1.4.0" }, - "time": "2024-04-18T12:56:14+00:00" + "time": "2024-04-24T14:05:48+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "1.3.16", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "d5242a59d035e46774f2e634b374bc39ff62cb95" + "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/d5242a59d035e46774f2e634b374bc39ff62cb95", - "reference": "d5242a59d035e46774f2e634b374bc39ff62cb95", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/f3ea021866f4263f07ca3636bf22c64be9610c11", + "reference": "f3ea021866f4263f07ca3636bf22c64be9610c11", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.11" }, "conflict": { "phpunit/phpunit": "<7.0" @@ -3798,27 +3984,27 @@ "description": "PHPUnit extensions and rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.16" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.0" }, - "time": "2024-02-23T09:51:20+00:00" + "time": "2024-04-20T06:39:00+00:00" }, { "name": "phpstan/phpstan-strict-rules", - "version": "1.5.5", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-strict-rules.git", - "reference": "2e193a07651a6f4be3baa44ddb21d822681f5918" + "reference": "363f921dd8441777d4fc137deb99beb486c77df1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/2e193a07651a6f4be3baa44ddb21d822681f5918", - "reference": "2e193a07651a6f4be3baa44ddb21d822681f5918", + "url": "https://api.github.com/repos/phpstan/phpstan-strict-rules/zipball/363f921dd8441777d4fc137deb99beb486c77df1", + "reference": "363f921dd8441777d4fc137deb99beb486c77df1", "shasum": "" }, "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.10.60" + "phpstan/phpstan": "^1.11" }, "require-dev": { "nikic/php-parser": "^4.13.0", @@ -3847,9 +4033,9 @@ "description": "Extra strict and opinionated rules for PHPStan", "support": { "issues": "https://github.com/phpstan/phpstan-strict-rules/issues", - "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.5.5" + "source": "https://github.com/phpstan/phpstan-strict-rules/tree/1.6.0" }, - "time": "2024-04-19T15:12:26+00:00" + "time": "2024-04-20T06:37:51+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4383,6 +4569,536 @@ }, "time": "2019-01-08T18:20:26+00:00" }, + { + "name": "react/cache", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/child-process", + "version": "v0.6.5", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/socket": "^1.8", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.5" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-09-16T13:41:56+00:00" + }, + { + "name": "react/dns", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "c134600642fa615b46b41237ef243daa65bb64ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/c134600642fa615b46b41237ef243daa65bb64ec", + "reference": "c134600642fa615b46b41237ef243daa65bb64ec", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4 || ^3 || ^2", + "react/promise-timer": "^1.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.12.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-29T12:41:06+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.5.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-13T13:48:05+00:00" + }, + { + "name": "react/promise", + "version": "v3.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-05-24T10:39:05+00:00" + }, + { + "name": "react/socket", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/216d3aec0b87f04a40ca04f481e6af01bdd1d038", + "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.11", + "react/event-loop": "^1.2", + "react/promise": "^3 || ^2.6 || ^1.2.1", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4 || ^3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.15.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-12-15T11:02:10+00:00" + }, + { + "name": "react/stream", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-06-16T10:52:11+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.1", @@ -5301,16 +6017,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.2.3", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab" + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/c95fd4db94ec199f798d4b5b4a81757bd20d88ab", - "reference": "c95fd4db94ec199f798d4b5b4a81757bd20d88ab", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", "shasum": "" }, "require": { @@ -5323,6 +6039,11 @@ "spatie/pest-plugin-snapshots": "^1.1" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, "autoload": { "psr-4": { "Spatie\\ArrayToXml\\": "src" @@ -5348,7 +6069,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.2.3" + "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" }, "funding": [ { @@ -5360,87 +6081,20 @@ "type": "github" } ], - "time": "2024-02-07T10:39:02+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v3.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-05-01T10:20:27+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v7.0.3", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "834c28d533dd0636f910909d01b9ff45cc094b5e" + "reference": "db2a7fab994d67d92356bb39c367db115d9d30f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/834c28d533dd0636f910909d01b9ff45cc094b5e", - "reference": "834c28d533dd0636f910909d01b9ff45cc094b5e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db2a7fab994d67d92356bb39c367db115d9d30f9", + "reference": "db2a7fab994d67d92356bb39c367db115d9d30f9", "shasum": "" }, "require": { @@ -5491,7 +6145,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.3" + "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.7" }, "funding": [ { @@ -5507,20 +6161,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T15:02:46+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.4.2", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "4e64b49bf370ade88e567de29465762e316e4224" + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/4e64b49bf370ade88e567de29465762e316e4224", - "reference": "4e64b49bf370ade88e567de29465762e316e4224", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8f93aec25d41b72493c6ddff14e916177c9efc50", + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50", "shasum": "" }, "require": { @@ -5530,7 +6184,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -5567,7 +6221,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.2" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.0" }, "funding": [ { @@ -5583,26 +6237,27 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/filesystem", - "version": "v7.0.6", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "408105dff4c104454100730bdfd1a9cdd993f04d" + "reference": "cc168be6fbdcdf3401f50ae863ee3818ed4338f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/408105dff4c104454100730bdfd1a9cdd993f04d", - "reference": "408105dff4c104454100730bdfd1a9cdd993f04d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/cc168be6fbdcdf3401f50ae863ee3818ed4338f5", + "reference": "cc168be6fbdcdf3401f50ae863ee3818ed4338f5", "shasum": "" }, "require": { "php": ">=8.2", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8" + "symfony/polyfill-mbstring": "~1.8", + "symfony/process": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -5630,7 +6285,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.0.6" + "source": "https://github.com/symfony/filesystem/tree/v7.0.7" }, "funding": [ { @@ -5646,20 +6301,20 @@ "type": "tidelift" } ], - "time": "2024-03-21T19:37:36+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/finder", - "version": "v7.0.0", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56" + "reference": "4d58f0f4fe95a30d7b538d71197135483560b97c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", - "reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56", + "url": "https://api.github.com/repos/symfony/finder/zipball/4d58f0f4fe95a30d7b538d71197135483560b97c", + "reference": "4d58f0f4fe95a30d7b538d71197135483560b97c", "shasum": "" }, "require": { @@ -5694,7 +6349,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.0.0" + "source": "https://github.com/symfony/finder/tree/v7.0.7" }, "funding": [ { @@ -5710,20 +6365,20 @@ "type": "tidelift" } ], - "time": "2023-10-31T17:59:56+00:00" + "time": "2024-04-28T11:44:19+00:00" }, { "name": "symfony/options-resolver", - "version": "v7.0.0", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "700ff4096e346f54cb628ea650767c8130f1001f" + "reference": "23cc173858776ad451e31f053b1c9f47840b2cfa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/700ff4096e346f54cb628ea650767c8130f1001f", - "reference": "700ff4096e346f54cb628ea650767c8130f1001f", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/23cc173858776ad451e31f053b1c9f47840b2cfa", + "reference": "23cc173858776ad451e31f053b1c9f47840b2cfa", "shasum": "" }, "require": { @@ -5761,7 +6416,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v7.0.0" + "source": "https://github.com/symfony/options-resolver/tree/v7.0.7" }, "funding": [ { @@ -5777,7 +6432,7 @@ "type": "tidelift" } ], - "time": "2023-08-08T10:20:21+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/polyfill-php81", @@ -5857,16 +6512,16 @@ }, { "name": "symfony/process", - "version": "v7.0.4", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0e7727191c3b71ebec6d529fa0e50a01ca5679e9" + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0e7727191c3b71ebec6d529fa0e50a01ca5679e9", - "reference": "0e7727191c3b71ebec6d529fa0e50a01ca5679e9", + "url": "https://api.github.com/repos/symfony/process/zipball/3839e56b94dd1dbd13235d27504e66baf23faba0", + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0", "shasum": "" }, "require": { @@ -5898,7 +6553,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v7.0.4" + "source": "https://github.com/symfony/process/tree/v7.0.7" }, "funding": [ { @@ -5914,20 +6569,20 @@ "type": "tidelift" } ], - "time": "2024-02-22T20:27:20+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/stopwatch", - "version": "v7.0.3", + "version": "v7.0.7", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "983900d6fddf2b0cbaacacbbad07610854bd8112" + "reference": "41a7a24aa1dc82adf46a06bc292d1923acfe6b84" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/983900d6fddf2b0cbaacacbbad07610854bd8112", - "reference": "983900d6fddf2b0cbaacacbbad07610854bd8112", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/41a7a24aa1dc82adf46a06bc292d1923acfe6b84", + "reference": "41a7a24aa1dc82adf46a06bc292d1923acfe6b84", "shasum": "" }, "require": { @@ -5960,7 +6615,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v7.0.3" + "source": "https://github.com/symfony/stopwatch/tree/v7.0.7" }, "funding": [ { @@ -5976,7 +6631,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T15:02:46+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "theseer/tokenizer", @@ -6030,16 +6685,16 @@ }, { "name": "vimeo/psalm", - "version": "5.23.1", + "version": "5.24.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4" + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/8471a896ccea3526b26d082f4461eeea467f10a4", - "reference": "8471a896ccea3526b26d082f4461eeea467f10a4", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/462c80e31c34e58cc4f750c656be3927e80e550e", + "reference": "462c80e31c34e58cc4f750c656be3927e80e550e", "shasum": "" }, "require": { @@ -6136,7 +6791,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-03-11T20:33:46+00:00" + "time": "2024-05-01T19:32:08+00:00" }, { "name": "webmozart/assert", diff --git a/domain/Batch/SelfReferee.php b/domain/Batch/SelfReferee.php index aafdf0b..e2da037 100644 --- a/domain/Batch/SelfReferee.php +++ b/domain/Batch/SelfReferee.php @@ -5,11 +5,12 @@ use SportsPlanning\Batch; use SportsPlanning\Batch\SelfReferee\OtherPoule as SelfRefereeOtherPoule; use SportsPlanning\Batch\SelfReferee\SamePoule as SelfRefereeSamePoule; +use SportsPlanning\Counters\GamePlacesCounterForPoule; +use SportsPlanning\Counters\PouleCounter; use SportsPlanning\Game\Against as AgainstGame; use SportsPlanning\Game\Together as TogetherGame; use SportsPlanning\Place; use SportsPlanning\Poule; -use SportsPlanning\Poule\PouleCounter; abstract class SelfReferee { @@ -20,7 +21,7 @@ abstract class SelfReferee */ protected array $placesAsRefereeMap = []; /** - * @var array + * @var array */ protected array $previousTotalPouleCounterMap = []; /** @@ -28,7 +29,7 @@ abstract class SelfReferee */ protected array $previousTotalNrOfForcedRefereePlacesMap = []; /** - * @var array + * @var array */ protected array $pouleCounterMap = []; @@ -105,18 +106,18 @@ public function isParticipatingAsReferee(Place $placeReferee): bool } /** - * @param array $previousTotalPouleCounterMap + * @param array $previousTotalPouleCounterMap * @param array $previousPreviousTotalNrOfForcedRefereePlacesMap */ public function getCopyPreviousTotals(array &$previousTotalPouleCounterMap, array &$previousPreviousTotalNrOfForcedRefereePlacesMap): void { - foreach ($this->previousTotalPouleCounterMap as $key => $pouleCounterMap) { - $copiedPouleCounterMap = new PouleCounter( - $pouleCounterMap->getPoule(), - $pouleCounterMap->getNrOfPlacesAssigned() + foreach ($this->previousTotalPouleCounterMap as $key => $gamePlacesCounterForPoule) { + $copiedGamePlacesCounterForPoule = new GamePlacesCounterForPoule( + $gamePlacesCounterForPoule->getPoule(), + $gamePlacesCounterForPoule->getNrOfPlacesAssigned(), + $gamePlacesCounterForPoule->getNrOfGames() ); - $copiedPouleCounterMap->addNrOfGames($pouleCounterMap->getNrOfGames()); - $previousTotalPouleCounterMap[$key] = $copiedPouleCounterMap; + $previousTotalPouleCounterMap[$key] = $gamePlacesCounterForPoule; } foreach ($this->previousTotalNrOfForcedRefereePlacesMap as $key => $nrOfForcedRefereePlace) { $previousPreviousTotalNrOfForcedRefereePlacesMap[$key] = $nrOfForcedRefereePlace; @@ -124,7 +125,7 @@ public function getCopyPreviousTotals(array &$previousTotalPouleCounterMap, arra } /** - * @param array $previousPreviousTotalPouleCounterMap + * @param array $previousPreviousTotalPouleCounterMap * @param array $previousPreviousTotalNrOfForcedRefereePlacesMap * @param self $previousBatch * @return void @@ -173,27 +174,33 @@ protected function addForcedRefereePlacesMaps( } /** - * @return array + * @return array */ public function getTotalPouleCounters(): array { $previousTotalPouleCounterMap = []; foreach ($this->previousTotalPouleCounterMap as $key => $it) { - $previousTotalPouleCounterMap[$key] = new PouleCounter($it->getPoule(), $it->getNrOfPlacesAssigned()); - $previousTotalPouleCounterMap[$key]->addNrOfGames($it->getNrOfGames()); + $previousTotalPouleCounterMap[$key] = new GamePlacesCounterForPoule( + $it->getPoule(), + $it->getNrOfPlacesAssigned(), + $it->getNrOfGames() + ); } $pouleCounterMap = []; foreach ($this->pouleCounterMap as $key => $it) { - $pouleCounterMap[$key] = new PouleCounter($it->getPoule(), $it->getNrOfPlacesAssigned()); - $pouleCounterMap[$key]->addNrOfGames($it->getNrOfGames()); + $pouleCounterMap[$key] = new GamePlacesCounterForPoule( + $it->getPoule(), + $it->getNrOfPlacesAssigned(), + $it->getNrOfGames() + ); } return $this->addPouleCounters($previousTotalPouleCounterMap, $pouleCounterMap); } /** - * @param array $previousPreviousTotalPouleCounterMap - * @param array $previousBatchPouleCounterMap - * @return array + * @param array $previousPreviousTotalPouleCounterMap + * @param array $previousBatchPouleCounterMap + * @return array */ protected function addPouleCounters( array $previousPreviousTotalPouleCounterMap, @@ -204,12 +211,11 @@ protected function addPouleCounters( if (!array_key_exists($previousPouleNr, $previousPreviousTotalPouleCounterMap)) { $previousPreviousTotalPouleCounterMap[$previousPouleNr] = $previousBatchPouleCounter; } else { - $previousPreviousTotalPouleCounterMap[$previousPouleNr]->addNrOfGames( - $previousBatchPouleCounter->getNrOfGames() - ); - $previousPreviousTotalPouleCounterMap[$previousPouleNr]->addNrOfAssignedPlaces( - $previousBatchPouleCounter->getNrOfPlacesAssigned() - ); + $previousPreviousTotalPouleCounterMap[$previousPouleNr] = + $previousPreviousTotalPouleCounterMap[$previousPouleNr]->add( + $previousBatchPouleCounter->getNrOfPlacesAssigned(), + $previousBatchPouleCounter->getNrOfGames() + ); } } return $previousPreviousTotalPouleCounterMap; @@ -240,7 +246,7 @@ function (Place $place): bool { } /** - * @return array + * @return array */ public function getPouleCounters(): array { @@ -265,7 +271,7 @@ public function add(TogetherGame|AgainstGame $game): void $poule = $game->getPoule(); if (!array_key_exists($poule->getNumber(), $this->pouleCounterMap)) { - $this->pouleCounterMap[$poule->getNumber()] = new PouleCounter($poule); + $this->pouleCounterMap[$poule->getNumber()] = new GamePlacesCounterForPoule($poule); } $this->pouleCounterMap[$poule->getNumber()]->add($game->getPlaces()->count()); } diff --git a/domain/Combinations/Mapper.php b/domain/Combinations/Mapper.php index b4ba032..38369fc 100644 --- a/domain/Combinations/Mapper.php +++ b/domain/Combinations/Mapper.php @@ -2,18 +2,19 @@ namespace SportsPlanning\Combinations; -use SportsPlanning\PlaceCounter; -use SportsPlanning\Poule; -use SportsPlanning\Place; -use SportsHelpers\Sport\Variant\Against\H2h as AgainstH2h; use SportsHelpers\Sport\Variant\Against\GamesPerPlace as AgainstGpp; +use SportsHelpers\Sport\Variant\Against\H2h as AgainstH2h; +use SportsPlanning\Counters\CounterForPlace; +use SportsPlanning\Counters\CounterForPlaceCombination; +use SportsPlanning\Place; +use SportsPlanning\Poule; class Mapper { /** * @param Poule $poule - * @param list $againstVariants - * @return array + * @param list $againstVariants + * @return array */ public function getWithMap(Poule $poule, array $againstVariants): array { @@ -26,7 +27,7 @@ public function getWithMap(Poule $poule, array $againstVariants): array /** * @param Poule $poule - * @return array + * @return array */ public function getAgainstMap(Poule $poule): array { @@ -37,7 +38,7 @@ public function getAgainstMap(Poule $poule): array /** - * @param list $againstVariants + * @param list $againstVariants * @return list */ protected function getNrOfSidePlaces(array $againstVariants): array { @@ -52,7 +53,7 @@ protected function getNrOfSidePlaces(array $againstVariants): array { /** * @param Poule $poule * @param int $nrOfSidePlaces - * @return array + * @return array */ public function getPlaceCombinationMap(Poule $poule, int $nrOfSidePlaces): array { @@ -62,7 +63,7 @@ public function getPlaceCombinationMap(Poule $poule, int $nrOfSidePlaces): array } /** - * @param array $map + * @param array $map * @param Poule $poule * @param int $nrOfSidePlaces */ @@ -86,25 +87,25 @@ protected function addToPlaceCombinationMap(array &$map, Poule $poule, int $nrOf /** - * @param array $map + * @param array $map * @param list $places */ protected function addPlacesToPlaceCombinationMap(array &$map, array $places): void { $placeCombination = new PlaceCombination($places); - $map[$placeCombination->getIndex()] = new PlaceCombinationCounter($placeCombination); + $map[$placeCombination->getIndex()] = new CounterForPlaceCombination($placeCombination); } /** * @param Poule $poule - * @return array + * @return array */ - public function getPlaceMap(Poule $poule): array + public function getPlaceCounterMap(Poule $poule): array { $map = []; foreach ($poule->getPlaces() as $place) { - $map[$place->getPlaceNr()] = new PlaceCounter($place); + $map[$place->getPlaceNr()] = new CounterForPlace($place); } return $map; } diff --git a/domain/Combinations/PlaceCombination.php b/domain/Combinations/PlaceCombination.php index 791c040..1cf18b5 100644 --- a/domain/Combinations/PlaceCombination.php +++ b/domain/Combinations/PlaceCombination.php @@ -6,30 +6,30 @@ use SportsPlanning\Place; -class PlaceCombination implements \Stringable +readonly class PlaceCombination implements \Stringable { - private string|null $index = null; /** * @var list $places */ private array $places; + private string $index; /** * @param list $places */ public function __construct(array $places) { - uasort($places, function(Place $place1, Place $place2): int { + $uniquePlaces = array_unique($places); + uasort($uniquePlaces, function(Place $place1, Place $place2): int { return $place1->getPlaceNr() - $place2->getPlaceNr(); }); - $this->places = array_values($places); + $this->places = array_values($uniquePlaces); + + $this->index = (string)$this; } public function getIndex(): string { - if( $this->index === null) { - $this->index = (string)$this; - } return $this->index; } diff --git a/domain/Combinations/PlaceCombinationCounterMap.php b/domain/Combinations/PlaceCombinationCounterMap.php deleted file mode 100644 index 031ccd5..0000000 --- a/domain/Combinations/PlaceCombinationCounterMap.php +++ /dev/null @@ -1,209 +0,0 @@ - - */ - private array $map; - private bool|null $canBeBalanced = null; - private AmountRange|null $range = null; - /** - * @var array|null - */ - private array|null $amounts = null; - /** - * @var array> - */ - private array|null $perAmount = null; - - /** - * @param array $placeCombinationCounters - */ - public function __construct(array $placeCombinationCounters) - { - $this->map = $placeCombinationCounters; - } - - public function getPlaceCombination(string $index): PlaceCombination - { - return $this->map[$index]->getPlaceCombination(); - } - - public function count(PlaceCombination $placeCombination): int - { - if( !array_key_exists($placeCombination->getIndex(), $this->map) ) { - return 0; - } - return $this->map[$placeCombination->getIndex()]->count(); - } - - /** - * @return list - */ - public function getPlaceCombinationCounters(): array - { - return array_values($this->map); - } - - public function addPlaceCombination(PlaceCombination $placeCombination): self { - - $newCounter = $this->map[$placeCombination->getIndex()]->increment2(); - $map = $this->map; - $map[$placeCombination->getIndex()] = $newCounter; - - return new self($map); - } - - public function removePlaceCombination(PlaceCombination $placeCombination): self { - - $newCounter = $this->map[$placeCombination->getIndex()]->decrement(); - $map = $this->map; - $map[$placeCombination->getIndex()] = $newCounter; - - return new self($map); - } - - /** - * @return list - */ - public function getList(): array - { - return array_values($this->map); - } - -// /** -// * @return array -// */ -// public function getMap(): array -// { -// return $this->map; -// } - - public function getAmountRange(): SportRange|null { - $range = $this->getRange(); - return $range !== null ? new SportRange($range->getMin()->amount, $range->getMax()->amount) : null; - } - - public function getRange(): AmountRange|null { - if( $this->range === null) { - $amounts = $this->getAmountMap(); - $min = array_shift($amounts); - $max = array_pop($amounts); - if( $min === null || $max === null) { - $this->range = null; - } else { - $this->range = new AmountRange($min, $max); - } - } - return $this->range; - } - - - public function getAmountDifference(): int { - return $this->getAmountRange()?->difference() ?? 0; - } - - public function getMin(): Amount|null { - return $this->getRange()?->getMin(); - } - - public function getMinAmount(): int { - return $this->getMin()?->amount ?? 0; - } - - public function getCountOfMinAmount(): int { - return $this->getMin()?->count ?? 0; - } - - public function getMax(): Amount|null { - return $this->getRange()?->getMax(); - } - - public function getMaxAmount(): int { - return $this->getMax()?->amount ?? 0; - } - - public function getCountOfMaxAmount(): int { - return $this->getMax()?->count ?? 0; - } - - - protected function canBeBalanced(): bool { - if( $this->canBeBalanced === null) { - $totalCount = 0; - foreach( $this->map as $placeCombinationCounter) { - $totalCount += $placeCombinationCounter->count(); - } - $this->canBeBalanced = ($totalCount % count($this->map)) === 0; - } - return $this->canBeBalanced; - - } - - /** - * @return array - */ - public function getAmountMap(): array { - if( $this->amounts === null) { - $this->amounts = []; - $perAmount = $this->getPerAmount(); - foreach ($perAmount as $amount => $combinationCounters) { - $this->amounts[$amount] = new Amount($amount, count($combinationCounters)); - } - } - return $this->amounts; - } - - /** - * @return array> - */ - public function getPerAmount(): array { - if( $this->perAmount === null) { - $this->perAmount = []; - foreach ($this->map as $combinationCounter) { - $count = $combinationCounter->count(); - if (!array_key_exists($count, $this->perAmount)) { - $this->perAmount[$count] = []; - } - $this->perAmount[$count][] = $combinationCounter; - } - ksort($this->perAmount); - } - return $this->perAmount; - } - - public function output(LoggerInterface $logger, string $prefix, string $header): void { - $logger->info($prefix . $header); - $prefix = $prefix . ' '; - $amountPerLine = 4; $counter = 0; $line = ''; - foreach( $this->getPlaceCombinationCounters() as $counterIt ) { - $line .= $counterIt->getPlaceCombination() . ' ' . $counterIt->count() . 'x, '; - if( ++$counter === $amountPerLine ) { - $logger->info($prefix . $line); - $counter = 0; - $line = ''; - } - } - if( strlen($line) > 0 ) { - $logger->info($prefix . $line); - } - } - - function __clone() - { - $map = []; - foreach( $this->map as $index => $placeCombinationCounter) { - $map[$index] = clone $placeCombinationCounter; - } - $this->map = $map; - } -} diff --git a/domain/Combinations/PlaceCounterMap.php b/domain/Combinations/PlaceCounterMap.php deleted file mode 100644 index 4f3d1a7..0000000 --- a/domain/Combinations/PlaceCounterMap.php +++ /dev/null @@ -1,209 +0,0 @@ - - */ - private array $map; - private bool|null $canBeBalanced = null; - private AmountRange|null|false $range = false; - /** - * @var array|null - */ - private array|null $amounts = null; - /** - * @var array> - */ - private array|null $perAmount = null; - - /** - * @param array $placeCounters - */ - public function __construct(array $placeCounters) - { - $this->map = $placeCounters; - } - - public function getPlace(int $number): Place - { - return $this->map[$number]->getPlace(); - } - - public function count(Place|null $place = null): int - { - if( $place === null ) { - return count($this->map); - } - if( !array_key_exists($place->getPlaceNr(), $this->map) ) { - return 0; - } - return $this->map[$place->getPlaceNr()]->count(); - } - - /** - * @return list - */ - protected function getPlaceCounters(): array - { - return array_values($this->map); - } - - public function addPlace(Place $place): self { - - $newCounter = $this->map[$place->getPlaceNr()]->increment2(); - $map = $this->map; - $map[$place->getPlaceNr()] = $newCounter; - return new self($map); - } - - public function removePlace(Place $place): self { - - $newCounter = $this->map[$place->getPlaceNr()]->decrement(); - $map = $this->map; - $map[$place->getPlaceNr()] = $newCounter; - - return new self($map); - } - - public function getAmountDifference(): int { - return $this->getAmountRange()?->difference() ?? 0; - } - - public function getMin(): Amount|null { - return $this->getRange()?->getMin(); - } - - public function getMinAmount(): int { - return $this->getMin()?->amount ?? 0; - } - - public function getCountOfMinAmount(): int { - return $this->getMin()?->count ?? 0; - } - - public function getMax(): Amount|null { - return $this->getRange()?->getMax(); - } - - public function getMaxAmount(): int { - return $this->getMax()?->amount ?? 0; - } - - public function getCountOfMaxAmount(): int { - return $this->getMax()?->count ?? 0; - } - - public function getAmountRange(): SportRange|null { - $range = $this->getRange(); - return $range ? new SportRange($range->getMin()->amount, $range->getMax()->amount) : null; - } - - public function getRange(): AmountRange|null { - if( $this->range === false) { - $amounts = $this->getAmountMap(); - $min = array_shift($amounts); - $max = array_pop($amounts); - if( $min === null || $max === null) { - $this->range = null; - } else { - $this->range = new AmountRange($min, $max); - } - } - return $this->range; - } - - protected function canBeBalanced(): bool { - if( $this->canBeBalanced === null) { - $totalCount = 0; - foreach( $this->map as $placeCounter) { - $totalCount += $placeCounter->count(); - } - $this->canBeBalanced = ($totalCount % count($this->map)) === 0; - } - return $this->canBeBalanced; - - } - - /** - * @return array - */ - public function getAmountMap(): array { - if( $this->amounts === null) { - $this->amounts = []; - $perAmount = $this->getPerAmount(); - foreach ($perAmount as $amount => $combinationCounters) { - $this->amounts[$amount] = new Amount($amount, count($combinationCounters)); - } - } - return $this->amounts; - } - - /** - * @return array> - */ - public function getPerAmount(): array { - if( $this->perAmount === null) { - $this->perAmount = []; - foreach ($this->map as $combinationCounter) { - $count = $combinationCounter->count(); - if (!array_key_exists($count, $this->perAmount)) { - $this->perAmount[$count] = []; - } - $this->perAmount[$count][] = $combinationCounter; - } - ksort($this->perAmount); - } - return $this->perAmount; - } - - public function output(LoggerInterface $logger, string $prefix, string $header): void { - $logger->info($prefix . $header); - $prefix = $prefix . ' '; - - $amountPerLine = 4; $counter = 0; $line = ''; - foreach( $this->getPlaceCounters() as $counterIt ) { - $line .= $counterIt->getPlace() . ' ' . $counterIt->count() . 'x, '; - if( ++$counter === $amountPerLine ) { - $logger->info($prefix . $line); - $counter = 0; - $line = ''; - } - } - if( strlen($line) > 0 ) { - $logger->info( $prefix . $line); - } - } - - function __clone() - { - $map = []; - foreach( $this->map as $number => $placeCounter) { - $map[$number] = clone $placeCounter; - } - $this->map = $map; - } - -// /** -// * @param array $map -// * @return array -// */ -// protected function copyPlaceCombinationCounterMap(array $map): array { -// $newMap = []; -// foreach( $map as $idx => $counter ) { -// $newMap[$idx] = new PlaceCombinationCounter($counter->getPlaceCombination(), $counter->count()); -// } -// return $newMap; -// } - -} diff --git a/domain/Combinations/AssignedCounter.php b/domain/Counters/AssignedCounter.php similarity index 52% rename from domain/Combinations/AssignedCounter.php rename to domain/Counters/AssignedCounter.php index f67517b..d18c810 100644 --- a/domain/Combinations/AssignedCounter.php +++ b/domain/Counters/AssignedCounter.php @@ -2,17 +2,18 @@ declare(strict_types=1); -namespace SportsPlanning\Combinations; +namespace SportsPlanning\Counters; use Countable; -use SportsHelpers\Counter; use SportsHelpers\Sport\Variant\Against\GamesPerPlace as AgainstGpp; use SportsHelpers\Sport\Variant\Against\H2h as AgainstH2h; use SportsHelpers\Sport\Variant\AllInOneGame; use SportsHelpers\Sport\Variant\Single; -use SportsHelpers\Sport\Variant\WithPoule\Against\EquallyAssignCalculator; -use SportsPlanning\Place; -use SportsPlanning\PlaceCounter; +use SportsPlanning\Combinations\HomeAway; +use SportsPlanning\Combinations\Mapper; +use SportsPlanning\Combinations\PlaceCombination; +use SportsPlanning\Counters\Maps\PlaceCombinationCounterMap; +use SportsPlanning\Counters\Maps\PlaceCounterMap; use SportsPlanning\Poule; class AssignedCounter @@ -22,10 +23,10 @@ class AssignedCounter protected PlaceCombinationCounterMap $assignedWithMap; protected PlaceCombinationCounterMap $assignedHomeMap; /** - * @var array> + * @var array> */ - protected array $assignedTogetherMap = []; - protected bool $hasAgainstSportWithMultipleSidePlaces; + // protected array $assignedTogetherMap = []; + // protected bool $hasAgainstSportWithMultipleSidePlaces; /** * @param Poule $poule @@ -34,29 +35,29 @@ class AssignedCounter public function __construct(Poule $poule, array $sportVariants) { $combinationMapper = new Mapper(); - $this->assignedMap = new PlaceCounterMap( $combinationMapper->getPlaceMap($poule) ); + $this->assignedMap = new PlaceCounterMap( $combinationMapper->getPlaceCounterMap($poule) ); $this->assignedAgainstMap = new PlaceCombinationCounterMap( $combinationMapper->getAgainstMap($poule) ); $againstVariants = array_values(array_filter($sportVariants, function(Single|AllInOneGame|AgainstGpp|AgainstH2h $sportVariant): bool { return (($sportVariant instanceof AgainstGpp) || ($sportVariant instanceof AgainstH2h)); })); - $this->hasAgainstSportWithMultipleSidePlaces = count(array_filter($againstVariants, - function(AgainstGpp|AgainstH2h $againstVariant): bool { - return $againstVariant->hasMultipleSidePlaces(); - })) > 0; +// $this->hasAgainstSportWithMultipleSidePlaces = count(array_filter($againstVariants, +// function(AgainstGpp|AgainstH2h $againstVariant): bool { +// return $againstVariant->hasMultipleSidePlaces(); +// })) > 0; $withCounters = $combinationMapper->getWithMap($poule, $againstVariants); $this->assignedWithMap = new PlaceCombinationCounterMap( $withCounters ); $this->assignedHomeMap = new PlaceCombinationCounterMap( $withCounters ); - foreach ($poule->getPlaces() as $place) { - $this->assignedTogetherMap[(string)$place] = []; - foreach ($poule->getPlaces() as $coPlace) { - if ($coPlace === $place) { - continue; - } - $this->assignedTogetherMap[(string)$place][(string)$coPlace] = new PlaceCounter($coPlace); - } - } +// foreach ($poule->getPlaces() as $place) { +// $this->assignedTogetherMap[(string)$place] = []; +// foreach ($poule->getPlaces() as $coPlace) { +// if ($coPlace === $place) { +// continue; +// } +// $this->assignedTogetherMap[(string)$place][(string)$coPlace] = new CounterForPlace($coPlace); +// } +// } } public function getAssignedMap(): PlaceCounterMap @@ -88,26 +89,26 @@ public function getAssignedAwayMap(): PlaceCombinationCounterMap if( $nrOfAgainst < 0) { $nrOfAgainst = 0; } - $counters[$withCombination->getIndex()] = new PlaceCombinationCounter($withCombination, $nrOfAgainst); + $counters[$withCombination->getIndex()] = new CounterForPlaceCombination($withCombination, $nrOfAgainst); } return new PlaceCombinationCounterMap($counters); } /** - * @return array> + * @return array> */ - public function getAssignedTogetherMap(): array - { - return $this->assignedTogetherMap; - } +// public function getAssignedTogetherMap(): array +// { +// return $this->assignedTogetherMap; +// } /** - * @param array> $assignedTogetherMap + * @param array> $assignedTogetherMap */ - public function setAssignedTogetherMap(array $assignedTogetherMap): void - { - $this->assignedTogetherMap = $assignedTogetherMap; - } +// public function setAssignedTogetherMap(array $assignedTogetherMap): void +// { +// $this->assignedTogetherMap = $assignedTogetherMap; +// } /** * @param list $homeAways @@ -138,8 +139,8 @@ protected function assignHomeAway(HomeAway $homeAway): void $this->assignedHomeMap = $this->assignedHomeMap->addPlaceCombination($homeAway->getHome()); - $this->assignToTogetherMap($homeAway->getHome()); - $this->assignToTogetherMap($homeAway->getAway()); +// $this->assignToTogetherMap($homeAway->getHome()); +// $this->assignToTogetherMap($homeAway->getAway()); } // public function getAssignedPlaceCounter(Place $place): PlaceCounter|null @@ -151,33 +152,33 @@ protected function assignHomeAway(HomeAway $homeAway): void // return $this->assignedMap[$place->getNumber()]; // } - public function getTogetherPlaceCounter(Place $place, Place $coPlace): PlaceCounter|null - { - if (!isset($this->assignedTogetherMap[(string)$place]) - || !isset($this->assignedTogetherMap[(string)$place][(string)$coPlace])) { - return null; - } - return $this->assignedTogetherMap[(string)$place][(string)$coPlace]; - } +// public function getTogetherPlaceCounter(Place $place, Place $coPlace): CounterForPlace|null +// { +// if (!isset($this->assignedTogetherMap[(string)$place]) +// || !isset($this->assignedTogetherMap[(string)$place][(string)$coPlace])) { +// return null; +// } +// return $this->assignedTogetherMap[(string)$place][(string)$coPlace]; +// } /** - * @param list $placeCombinations + * @param PlaceCombination $placeCombinations * @param bool $withAssigned */ - public function assignTogether(array $placeCombinations, bool $withAssigned): void - { - foreach ($placeCombinations as $placeCombination) { - $this->assignToTogetherMap($placeCombination); - if( $this->hasAgainstSportWithMultipleSidePlaces ) { - $this->assignedWithMap = $this->assignedWithMap->addPlaceCombination($placeCombination); - } - if( $withAssigned ) { - foreach( $placeCombination->getPlaces() as $place ) { - $this->assignedMap = $this->assignedMap->addPlace($place); - } - } - } - } +// public function assignTogether(array $placeCombinations, bool $withAssigned): void +// { +// foreach ($placeCombinations as $placeCombination) { +// $this->assignToTogetherMap($placeCombination); +// if( $this->hasAgainstSportWithMultipleSidePlaces ) { +// $this->assignedWithMap = $this->assignedWithMap->addPlaceCombination($placeCombination); +// } +// if( $withAssigned ) { +// foreach( $placeCombination->getPlaces() as $place ) { +// $this->assignedMap = $this->assignedMap->addPlace($place); +// } +// } +// } +// } // /** // * @param PlaceCombination $placeCombination @@ -192,47 +193,47 @@ public function assignTogether(array $placeCombinations, bool $withAssigned): vo /** * @param PlaceCombination $placeCombination */ - protected function assignToTogetherMap(PlaceCombination $placeCombination): void - { - $places = $placeCombination->getPlaces(); - foreach ($places as $placeIt) { - foreach ($places as $coPlace) { - if ($coPlace === $placeIt) { - continue; - } - $this->assignedTogetherMap[(string)$placeIt][(string)$coPlace]->increment(); - } - } - } +// protected function assignToTogetherMap(PlaceCombination $placeCombination): void +// { +// $places = $placeCombination->getPlaces(); +// foreach ($places as $placeIt) { +// foreach ($places as $coPlace) { +// if ($coPlace === $placeIt) { +// continue; +// } +// $this->assignedTogetherMap[(string)$placeIt][(string)$coPlace]->increment(); +// } +// } +// } public function getAmountDifference(): int { - return $this->assignedMap->getAmountDifference(); + return $this->assignedMap->getReport()->getAmountDifference(); } public function getAgainstAmountDifference(): int { - return $this->assignedAgainstMap->getAmountDifference(); + return $this->assignedAgainstMap->getReport()->getAmountDifference(); } public function getWithAmountDifference(): int { - return $this->assignedWithMap->getAmountDifference(); + return $this->assignedWithMap->getReport()->getAmountDifference(); } public function getHomeAmountDifference(): int { - return $this->assignedHomeMap->getAmountDifference(); + return $this->assignedHomeMap->getReport()->getAmountDifference(); } /** - * @param list $counters + * @param Countable $counters * @return int */ - protected function getMapDifference(array $counters): int { - $counts = array_map( function(Countable $counter): int { - return $counter->count(); - }, $counters ); - if( count($counts) === 0 ) { - return 0; - } - return max($counts) - min($counts); - } +// protected function getMapDifference(array $counters): int { +// $counts = array_map( function(Countable $counter): int { +// return $counter->count(); +// }, $counters ); +// if( count($counts) === 0 ) { +// return 0; +// } +// return max($counts) - min($counts); +// } } diff --git a/domain/PlaceCounter.php b/domain/Counters/CounterForPlace.php similarity index 60% rename from domain/PlaceCounter.php rename to domain/Counters/CounterForPlace.php index 2ba008b..ea797ed 100644 --- a/domain/PlaceCounter.php +++ b/domain/Counters/CounterForPlace.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace SportsPlanning; +namespace SportsPlanning\Counters; use SportsHelpers\Counter; +use SportsPlanning\Place; /** * @template-extends Counter */ -class PlaceCounter extends Counter +readonly class CounterForPlace extends Counter { public function __construct(Place $place, int $count = 0) { @@ -26,14 +27,14 @@ public function getPlace(): Place return $this->countedObject; } - public function decrement(): self + public function increment(): CounterForPlace { - return new self($this->getPlace(), $this->count - 1 ); + return new CounterForPlace($this->countedObject, $this->count + 1 ); } - public function increment2(): self + public function decrement(): CounterForPlace { - return new self($this->getPlace(), $this->count() + 1 ); + return new CounterForPlace($this->countedObject, $this->count - 1 ); } public function __toString(): string diff --git a/domain/Combinations/PlaceCombinationCounter.php b/domain/Counters/CounterForPlaceCombination.php similarity index 79% rename from domain/Combinations/PlaceCombinationCounter.php rename to domain/Counters/CounterForPlaceCombination.php index c2ec5a0..895aba3 100644 --- a/domain/Combinations/PlaceCombinationCounter.php +++ b/domain/Counters/CounterForPlaceCombination.php @@ -2,14 +2,15 @@ declare(strict_types=1); -namespace SportsPlanning\Combinations; +namespace SportsPlanning\Counters; use SportsHelpers\Counter; +use SportsPlanning\Combinations\PlaceCombination; /** * @template-extends Counter */ -class PlaceCombinationCounter extends Counter implements \Stringable +readonly class CounterForPlaceCombination extends Counter implements \Stringable { public function __construct(PlaceCombination $placeCombination, int $count = 0) { @@ -23,10 +24,10 @@ public function getPlaceCombination(): PlaceCombination public function decrement(): self { - return new self($this->getPlaceCombination(), $this->count - 1 ); + return new self($this->getPlaceCombination(), $this->count() - 1 ); } - public function increment2(): self + public function increment(): self { return new self($this->getPlaceCombination(), $this->count() + 1 ); } diff --git a/domain/Counters/GamePlacesCounterForPoule.php b/domain/Counters/GamePlacesCounterForPoule.php new file mode 100644 index 0000000..2863b04 --- /dev/null +++ b/domain/Counters/GamePlacesCounterForPoule.php @@ -0,0 +1,64 @@ + + */ + protected Counter $gameCounter; + + public function __construct(protected Poule $poule, protected int $nrOfPlacesAssigned = 0, int $count = 0) + { + $this->gameCounter = new Counter($poule, $count); + } + + private function create( int $nrOfGames, int $nrOfPlacesAssigned): self { + return new self($this->poule, $nrOfPlacesAssigned, $nrOfGames); + } + + public function getPoule(): Poule + { + return $this->poule; + } + + public function reset(): self + { + return $this->create( 0, 0 ); + } + + public function add(int $nrOfPlacesToAssign, int $nrOfGames = 1): self + { + return $this->create( + $this->gameCounter->count() + $nrOfGames, + $this->nrOfPlacesAssigned + $nrOfPlacesToAssign + ); + } + + public function remove(int $nrOfPlacesToUnassign, int $nrOfGamesToRemove = 1): self + { + return $this->create( + $this->gameCounter->count() + $nrOfGamesToRemove, + $this->nrOfPlacesAssigned - $nrOfPlacesToUnassign + ); + } + + public function getNrOfPlacesAssigned(bool|null $addRefereePlace = null): int + { + if ($addRefereePlace === true) { + return $this->nrOfPlacesAssigned + $this->gameCounter->count(); + } + return $this->nrOfPlacesAssigned; + } + + public function getNrOfGames(): int + { + return $this->gameCounter->count(); + } +} diff --git a/domain/Counters/Maps/PlaceCombinationCounterMap.php b/domain/Counters/Maps/PlaceCombinationCounterMap.php new file mode 100644 index 0000000..8959ebd --- /dev/null +++ b/domain/Counters/Maps/PlaceCombinationCounterMap.php @@ -0,0 +1,110 @@ + + */ + private array $map; + private PlaceCombinationCountersReport $report; + + /** + * @param array $placeCombinationCounters + */ + public function __construct(array $placeCombinationCounters) + { + $this->map = $placeCombinationCounters; + $this->report = new PlaceCombinationCountersReport($placeCombinationCounters); + } + + public function getReport(): PlaceCombinationCountersReport + { + return $this->report; + } + + public function getPlaceCombination(string $index): PlaceCombination + { + return $this->map[$index]->getPlaceCombination(); + } + + public function count(PlaceCombination|null $placeCombination = null): int + { + if( $placeCombination === null ) { + return count($this->map); + } + + if( !array_key_exists($placeCombination->getIndex(), $this->map) ) { + return 0; + } + return $this->map[$placeCombination->getIndex()]->count(); + } + + /** + * @return list + */ + public function getPlaceCombinationCounters(): array + { + return array_values($this->map); + } + + public function addPlaceCombination(PlaceCombination $placeCombination): self { + + $newCounter = $this->map[$placeCombination->getIndex()]->increment(); + $map = $this->map; + $map[$placeCombination->getIndex()] = $newCounter; + + return new self($map); + } + + public function removePlaceCombination(PlaceCombination $placeCombination): self { + + $newCounter = $this->map[$placeCombination->getIndex()]->decrement(); + $map = $this->map; + $map[$placeCombination->getIndex()] = $newCounter; + + return new PlaceCombinationCounterMap($map); + } + + /** + * @return list + */ + public function getList(): array + { + return array_values($this->map); + } + + public function output(LoggerInterface $logger, string $prefix, string $header): void { + $logger->info($prefix . $header); + $prefix = $prefix . ' '; + $amountPerLine = 4; $counter = 0; $line = ''; + foreach( $this->getPlaceCombinationCounters() as $counterIt ) { + $line .= $counterIt->getPlaceCombination() . ' ' . $counterIt->count() . 'x, '; + if( ++$counter === $amountPerLine ) { + $logger->info($prefix . $line); + $counter = 0; + $line = ''; + } + } + if( strlen($line) > 0 ) { + $logger->info($prefix . $line); + } + } + + function __clone() + { + $map = []; + foreach( $this->map as $index => $placeCombinationCounter) { + $map[$index] = clone $placeCombinationCounter; + } + $this->map = $map; + } +} diff --git a/domain/Counters/Maps/PlaceCounterMap.php b/domain/Counters/Maps/PlaceCounterMap.php new file mode 100644 index 0000000..e279843 --- /dev/null +++ b/domain/Counters/Maps/PlaceCounterMap.php @@ -0,0 +1,114 @@ + + */ + private array $map; + private PlaceCountersReport $report; + + /** + * @param array $placeCounters + */ + public function __construct(array $placeCounters) + { + $this->map = $placeCounters; + $this->report = new PlaceCountersReport($placeCounters); + } + + public function getPlace(int $number): Place + { + return $this->map[$number]->getPlace(); + } + + public function getReport(): PlaceCountersReport + { + return $this->report; + } + + public function count(Place|null $place = null): int + { + if( $place === null ) { + return count($this->map); + } + if( !array_key_exists($place->getPlaceNr(), $this->map) ) { + return 0; + } + return $this->map[$place->getPlaceNr()]->count(); + } + + /** + * @return list + */ + protected function getPlaceCounters(): array + { + return array_values($this->map); + } + + public function addPlace(Place $place): self { + + $newCounter = $this->map[$place->getPlaceNr()]->increment(); + $map = $this->map; + $map[$place->getPlaceNr()] = $newCounter; + return new PlaceCounterMap($map); + } + + public function removePlace(Place $place): self { + + $newCounter = $this->map[$place->getPlaceNr()]->decrement(); + $map = $this->map; + $map[$place->getPlaceNr()] = $newCounter; + + return new PlaceCounterMap($map); + } + + public function output(LoggerInterface $logger, string $prefix, string $header): void { + $logger->info($prefix . $header); + $prefix = $prefix . ' '; + + $amountPerLine = 4; $counter = 0; $line = ''; + foreach( $this->getPlaceCounters() as $counterIt ) { + $line .= $counterIt->getPlace() . ' ' . $counterIt->count() . 'x, '; + if( ++$counter === $amountPerLine ) { + $logger->info($prefix . $line); + $counter = 0; + $line = ''; + } + } + if( strlen($line) > 0 ) { + $logger->info( $prefix . $line); + } + } + + function __clone() + { + $map = []; + foreach( $this->map as $number => $placeCounter) { + $map[$number] = clone $placeCounter; + } + $this->map = $map; + } + +// /** +// * @param array $map +// * @return array +// */ +// protected function copyPlaceCombinationCounterMap(array $map): array { +// $newMap = []; +// foreach( $map as $idx => $counter ) { +// $newMap[$idx] = new PlaceCombinationCounter($counter->getPlaceCombination(), $counter->count()); +// } +// return $newMap; +// } + +} diff --git a/domain/Counters/Maps/RangedPlaceCombinationCounterMap.php b/domain/Counters/Maps/RangedPlaceCombinationCounterMap.php new file mode 100644 index 0000000..34a0614 --- /dev/null +++ b/domain/Counters/Maps/RangedPlaceCombinationCounterMap.php @@ -0,0 +1,98 @@ +map = $map; + $this->allowedRange = $allowedRange; + $this->report = new RangedPlaceCombinationCountersReport($map, $allowedRange); + } + + public function getAllowedRange(): AmountRange { + return $this->allowedRange; + } + +// protected function getMap(): PlaceCombinationCounterMap { +// return $this->map; +// } + + public function addPlaceCombination(PlaceCombination $placeCombination): self { + + return new self($this->map->addPlaceCombination($placeCombination), $this->allowedRange ); + } + + public function removePlaceCombination(PlaceCombination $placeCombination): self { + + return new self($this->map->removePlaceCombination($placeCombination), $this->allowedRange); + } + + + public function count(PlaceCombination $placeCombination): int + { + return $this->map->count($placeCombination); + } + + public function countAmount(int $amount): int { + $amountMap = $this->map->getReport()->getAmountMap(); + return array_key_exists($amount, $amountMap) ? $amountMap[$amount]->count : 0; + } + + public function getAmountDifference(): int + { + return $this->map->getReport()->getAmountDifference(); + } + + public function getRange(): AmountRange|null + { + return $this->map->getReport()->getRange(); + } + + public function getMinAmount(): int + { + return $this->map->getReport()->getMinAmount(); + } + + + public function getCountOfMinAmount(): int + { + return $this->map->getReport()->getCountOfMinAmount(); + } + + public function getMaxAmount(): int + { + return $this->map->getReport()->getMaxAmount(); + } + + public function getCountOfMaxAmount(): int + { + return $this->map->getReport()->getCountOfMaxAmount(); + } + + public function withinRange(int $nrOfCombinationsToGo): bool + { + return $this->minimumCanBeReached($nrOfCombinationsToGo) && !$this->report->aboveMaximum($nrOfCombinationsToGo); + } + + public function minimumCanBeReached(int $nrOfCombinationsToGo): bool + { + return $this->report->minimumCanBeReached($nrOfCombinationsToGo); + } + + +} \ No newline at end of file diff --git a/domain/Combinations/PlaceCounterMap/Ranged.php b/domain/Counters/Maps/RangedPlaceCounterMap.php similarity index 63% rename from domain/Combinations/PlaceCounterMap/Ranged.php rename to domain/Counters/Maps/RangedPlaceCounterMap.php index 2dea67e..b1675ba 100644 --- a/domain/Combinations/PlaceCounterMap/Ranged.php +++ b/domain/Counters/Maps/RangedPlaceCounterMap.php @@ -1,25 +1,24 @@ map = $map; $this->allowedRange = $allowedRange; + $this->report = new RangedPlaceCountersReport($map, $allowedRange); } public function getAllowedRange(): AmountRange { @@ -42,63 +41,55 @@ public function removePlace(Place $place): self { public function getNrOfPlacesBelowMinimum(): int { - if( $this->nrOfPlacesBelowMinimum === null) { - $calculator = new AmountCalculator($this->getMap()->count(), $this->allowedRange); - $this->nrOfPlacesBelowMinimum = $calculator->countBeneathMinimum( $this->map->getAmountMap() ); - } - return $this->nrOfPlacesBelowMinimum; + return $this->report->getNrOfPlacesBelowMinimum(); } public function getNrOfPlacesAboveMaximum(): int { - if( $this->nrOfPlacesAboveMaximum === null) { - $calculator = new AmountCalculator($this->getMap()->count(), $this->allowedRange); - $this->nrOfPlacesAboveMaximum = $calculator->countAboveMaximum( $this->map->getAmountMap() ); - } - return $this->nrOfPlacesAboveMaximum; + return $this->report->getNrOfPlacesAboveMaximum(); } - public function count(Place $place): int - { - return $this->map->count($place); - } +// public function count(Place $place): int +// { +// return $this->map->count($place); +// } public function countAmount(int $amount): int { - $amountMap = $this->map->getAmountMap(); + $amountMap = $this->map->getReport()->getAmountMap(); return array_key_exists($amount, $amountMap) ? $amountMap[$amount]->count : 0; } public function getAmountDifference(): int { - return $this->map->getAmountDifference(); + return $this->report->getAmountDifference(); } public function getRange(): AmountRange|null { - return $this->map->getRange(); + return $this->report->getRange(); } public function getMinAmount(): int { - return $this->map->getMinAmount(); + return $this->report->getMinAmount(); } public function getCountOfMinAmount(): int { - return $this->map->getCountOfMinAmount(); + return $this->report->getCountOfMinAmount(); } public function getMaxAmount(): int { - return $this->map->getMaxAmount(); + return $this->report->getMaxAmount(); } public function getCountOfMaxAmount(): int { - return $this->map->getCountOfMaxAmount(); + return $this->report->getCountOfMaxAmount(); } public function withinRange(int $nrOfCombinationsToGo): bool diff --git a/domain/Counters/Reports/PlaceCombinationCountersReport.php b/domain/Counters/Reports/PlaceCombinationCountersReport.php new file mode 100644 index 0000000..efa8f63 --- /dev/null +++ b/domain/Counters/Reports/PlaceCombinationCountersReport.php @@ -0,0 +1,143 @@ + + */ + private array $amounts; + /** + * @var array> + */ + private array $perAmount; + + /** + * @param array $placeCombinationCounters + */ + final public function __construct(array $placeCombinationCounters) + { + $this->perAmount = $this->calculatePerAmount($placeCombinationCounters); + $this->amounts = $this->calculateAmountMap($this->perAmount); + $this->range = $this->calculateRange($this->amounts); + $this->canBeBalanced = $this->calculateCanBeBalanced($placeCombinationCounters); + } + + + /** + * @param array $placeCombinationCounters + * @return array> + */ + private function calculatePerAmount(array $placeCombinationCounters): array { + $perAmount = []; + foreach ($placeCombinationCounters as $combinationCounter) { + $count = $combinationCounter->count(); + if (!array_key_exists($count, $perAmount)) { + $perAmount[$count] = []; + } + $perAmount[$count][] = $combinationCounter; + } + ksort($perAmount); + return $perAmount; + } + + /** + * @param array> $perAmount + * @return array + */ + private function calculateAmountMap(array $perAmount): array { + + $amounts = []; + foreach ($perAmount as $amount => $combinationCounters) { + $amounts[$amount] = new Amount($amount, count($combinationCounters)); + } + return $amounts; + } + + /** + * @param array $amountMap + * @return AmountRange|null + */ + private function calculateRange(array $amountMap): AmountRange|null { + $min = array_shift($amountMap); + $max = array_pop($amountMap); + if( $min === null || $max === null) { + return null; + } + return new AmountRange($min, $max); + } + + /** + * @param array $placeCombinationCounters + * @return bool + */ + private function calculateCanBeBalanced(array $placeCombinationCounters): bool { + $totalCount = 0; + foreach( $placeCombinationCounters as $placeCombinationCounter) { + $totalCount += $placeCombinationCounter->count(); + } + return (($totalCount % count($placeCombinationCounters)) === 0); + } + + public function getAmountRange(): SportRange|null { + $range = $this->getRange(); + return $range !== null ? new SportRange($range->getMin()->amount, $range->getMax()->amount) : null; + } + + public function getRange(): AmountRange|null { + return $this->range; + } + + + public function getAmountDifference(): int { + return $this->getAmountRange()?->difference() ?? 0; + } + + public function getMin(): Amount|null { + return $this->getRange()?->getMin(); + } + + public function getMinAmount(): int { + return $this->getMin()?->amount ?? 0; + } + + public function getCountOfMinAmount(): int { + return $this->getMin()?->count ?? 0; + } + + public function getMax(): Amount|null { + return $this->getRange()?->getMax(); + } + + public function getMaxAmount(): int { + return $this->getMax()?->amount ?? 0; + } + + public function getCountOfMaxAmount(): int { + return $this->getMax()?->count ?? 0; + } + + /** + * @return array + */ + public function getAmountMap(): array { + return $this->amounts; + } + + /** + * @return array> + */ + public function getPerAmount(): array { + return $this->perAmount; + } +} diff --git a/domain/Counters/Reports/PlaceCountersReport.php b/domain/Counters/Reports/PlaceCountersReport.php new file mode 100644 index 0000000..fb05402 --- /dev/null +++ b/domain/Counters/Reports/PlaceCountersReport.php @@ -0,0 +1,158 @@ + + */ + private array $amounts; + /** + * @var array> + */ + private array $perAmount; + + /** + * @param array $placeCounters + */ + public function __construct(array $placeCounters) + { + $this->perAmount = $this->calculatePerAmount($placeCounters); + $this->amounts = $this->calculateAmountMap($this->perAmount); + $this->range = $this->calculateRange($this->amounts); + $this->canBeBalanced = $this->calculateCanBeBalanced($placeCounters); + } + + /** + * @param array $placeCounters + * @return array> + */ + private function calculatePerAmount(array $placeCounters): array { + $perAmount = []; + foreach ($placeCounters as $placeCounter) { + $count = $placeCounter->count(); + if (!array_key_exists($count, $perAmount)) { + $perAmount[$count] = []; + } + $perAmount[$count][] = $placeCounter; + } + ksort($perAmount); + return $perAmount; + } + + /** + * @param array> $perAmount + * @return array + */ + private function calculateAmountMap(array $perAmount): array { + + $amounts = []; + foreach ($perAmount as $amount => $combinationCounters) { + $amounts[$amount] = new Amount($amount, count($combinationCounters)); + } + return $amounts; + } + + /** + * @param array $amountMap + * @return AmountRange|null + */ + private function calculateRange(array $amountMap): AmountRange|null { + $min = array_shift($amountMap); + $max = array_pop($amountMap); + if( $min === null || $max === null) { + return null; + } + return new AmountRange($min, $max); + } + + /** + * @param array $placeCounters + * @return bool + */ + private function calculateCanBeBalanced(array $placeCounters): bool { + $totalCount = 0; + foreach( $placeCounters as $placeCounter) { + $totalCount += $placeCounter->count(); + } + return (($totalCount % count($placeCounters)) === 0); + } + + public function getAmountDifference(): int { + return $this->getAmountRange()?->difference() ?? 0; + } + + public function getMin(): Amount|null { + return $this->getRange()?->getMin(); + } + + public function getMinAmount(): int { + return $this->getMin()?->amount ?? 0; + } + + public function getCountOfMinAmount(): int { + return $this->getMin()?->count ?? 0; + } + + public function getMax(): Amount|null { + return $this->getRange()?->getMax(); + } + + public function getMaxAmount(): int { + return $this->getMax()?->amount ?? 0; + } + + public function getCountOfMaxAmount(): int { + return $this->getMax()?->count ?? 0; + } + + public function getAmountRange(): SportRange|null { + $range = $this->getRange(); + return $range ? new SportRange($range->getMin()->amount, $range->getMax()->amount) : null; + } + + public function getRange(): AmountRange|null { + return $this->range; + } + + protected function canBeBalanced(): bool { + return $this->canBeBalanced; + } + + /** + * @return array + */ + public function getAmountMap(): array { + return $this->amounts; + } + + /** + * @return array> + */ + public function getPerAmount(): array { + return $this->perAmount; + } + +// /** +// * @param array $map +// * @return array +// */ +// protected function copyPlaceCombinationCounterMap(array $map): array { +// $newMap = []; +// foreach( $map as $idx => $counter ) { +// $newMap[$idx] = new PlaceCombinationCounter($counter->getPlaceCombination(), $counter->count()); +// } +// return $newMap; +// } + +} diff --git a/domain/Combinations/PlaceCombinationCounterMap/Ranged.php b/domain/Counters/Reports/RangedPlaceCombinationCountersReport.php similarity index 50% rename from domain/Combinations/PlaceCombinationCounterMap/Ranged.php rename to domain/Counters/Reports/RangedPlaceCombinationCountersReport.php index efd7ce1..c5128c7 100644 --- a/domain/Combinations/PlaceCombinationCounterMap/Ranged.php +++ b/domain/Counters/Reports/RangedPlaceCombinationCountersReport.php @@ -1,105 +1,85 @@ map = $map; + public function __construct(PlaceCombinationCounterMap $map, AmountRange $allowedRange) { + $this->report = $map->getReport(); $this->allowedRange = $allowedRange; - } - public function getAllowedRange(): AmountRange { - return $this->allowedRange; - } + $calculator = new AmountCalculator($map->count(), $this->allowedRange); + $this->nrOfPlaceCombinationsBelowMinimum = $calculator->countBeneathMinimum( $this->report->getAmountMap() ); + $this->nrOfPlaceCombinationsAboveMaximum = $calculator->countAboveMaximum( $this->report->getAmountMap() ); - public function getMap(): PlaceCombinationCounterMap { - return $this->map; + $this->nrOfPossibleCombinations = $map->count(); } - public function addPlaceCombination(PlaceCombination $placeCombination): self { - - return new self($this->map->addPlaceCombination($placeCombination), $this->allowedRange ); + public function getAllowedRange(): AmountRange { + return $this->allowedRange; } - public function removePlaceCombination(PlaceCombination $placeCombination): self { - - return new self($this->map->removePlaceCombination($placeCombination), $this->allowedRange); - } +// public function getMap(): PlaceCombinationCounterMap { +// return $this->map; +// } public function getNrOfPlaceCombinationsBelowMinimum(): int { - if( $this->nrOfPlaceCombinationsBelowMinimum === null) { - $calculator = new AmountCalculator(count($this->getMap()->getList()), $this->allowedRange); - $this->nrOfPlaceCombinationsBelowMinimum = $calculator->countBeneathMinimum( $this->map->getAmountMap() ); - } return $this->nrOfPlaceCombinationsBelowMinimum; } public function getNrOfPlaceCombinationsAboveMaximum(): int { - if( $this->nrOfPlaceCombinationsAboveMaximum === null) { - $calculator = new AmountCalculator(count($this->getMap()->getList()), $this->allowedRange); - $this->nrOfPlaceCombinationsAboveMaximum = $calculator->countAboveMaximum( $this->map->getAmountMap() ); - } return $this->nrOfPlaceCombinationsAboveMaximum; } - - - public function count(PlaceCombination $placeCombination): int - { - return $this->map->count($placeCombination); - } - public function countAmount(int $amount): int { - $amountMap = $this->map->getAmountMap(); + $amountMap = $this->report->getAmountMap(); return array_key_exists($amount, $amountMap) ? $amountMap[$amount]->count : 0; } public function getAmountDifference(): int { - return $this->map->getAmountDifference(); + return $this->report->getAmountDifference(); } public function getRange(): AmountRange|null { - return $this->map->getRange(); + return $this->report->getRange(); } public function getMinAmount(): int { - return $this->map->getMinAmount(); + return $this->report->getMinAmount(); } public function getCountOfMinAmount(): int { - return $this->map->getCountOfMinAmount(); + return $this->report->getCountOfMinAmount(); } public function getMaxAmount(): int { - return $this->map->getMaxAmount(); + return $this->report->getMaxAmount(); } public function getCountOfMaxAmount(): int { - return $this->map->getCountOfMaxAmount(); + return $this->report->getCountOfMaxAmount(); } public function withinRange(int $nrOfCombinationsToGo): bool @@ -114,10 +94,9 @@ public function minimumCanBeReached(int $nrOfCombinationsToGo): bool }; $allowedMin = $this->allowedRange->getMin(); - $nrOfPossibleCombinations = count( $this->getMap()->getList() ); if ( $this->getMinAmount() === $allowedMin->amount - && $this->getCountOfMinAmount() + $nrOfCombinationsToGo <= $nrOfPossibleCombinations + && $this->getCountOfMinAmount() + $nrOfCombinationsToGo <= $this->nrOfPossibleCombinations ) { return true; } @@ -131,12 +110,11 @@ public function aboveMaximum(int $nrOfCombinationsToGo): bool } $allowedMax = $this->allowedRange->getMax(); - $nrOfPossibleCombinations = count( $this->getMap()->getList() ); if ( $this->getMaxAmount() === $allowedMax->amount && ( - $this->getCountOfMaxAmount() + $nrOfCombinationsToGo <= $nrOfPossibleCombinations + $this->getCountOfMaxAmount() + $nrOfCombinationsToGo <= $this->nrOfPossibleCombinations ) ) { return false; diff --git a/domain/Counters/Reports/RangedPlaceCountersReport.php b/domain/Counters/Reports/RangedPlaceCountersReport.php new file mode 100644 index 0000000..2909675 --- /dev/null +++ b/domain/Counters/Reports/RangedPlaceCountersReport.php @@ -0,0 +1,126 @@ +report = $map->getReport(); + $this->allowedRange = $allowedRange; + + $calculator = new AmountCalculator($map->count(), $this->allowedRange); + $this->nrOfPlacesBelowMinimum = $calculator->countBeneathMinimum( $this->report->getAmountMap() ); + $this->nrOfPlacesAboveMaximum = $calculator->countAboveMaximum( $this->report->getAmountMap() ); + + $this->nrOfPossibleCombinations = $map->count(); + } + + public function getAllowedRange(): AmountRange { + return $this->allowedRange; + } + + public function getNrOfPlacesBelowMinimum(): int + { + return $this->nrOfPlacesBelowMinimum; + } + + public function getNrOfPlacesAboveMaximum(): int + { + return $this->nrOfPlacesAboveMaximum; + } + +// public function count(Place $place): int +// { +// return $this->map->count($place); +// } + + public function countAmount(int $amount): int { + $amountMap = $this->report->getAmountMap(); + return array_key_exists($amount, $amountMap) ? $amountMap[$amount]->count : 0; + } + + public function getAmountDifference(): int + { + return $this->report->getAmountDifference(); + } + + public function getRange(): AmountRange|null + { + return $this->report->getRange(); + } + + public function getMinAmount(): int + { + return $this->report->getMinAmount(); + } + + + public function getCountOfMinAmount(): int + { + return $this->report->getCountOfMinAmount(); + } + + public function getMaxAmount(): int + { + return $this->report->getMaxAmount(); + } + + public function getCountOfMaxAmount(): int + { + return $this->report->getCountOfMaxAmount(); + } + + public function withinRange(int $nrOfCombinationsToGo): bool + { + return $this->minimumCanBeReached($nrOfCombinationsToGo) && !$this->aboveMaximum($nrOfCombinationsToGo); + } + + public function minimumCanBeReached(int $nrOfCombinationsToGo): bool + { + if( $this->getNrOfPlacesBelowMinimum() <= $nrOfCombinationsToGo ) { + return true; + }; + + $allowedMin = $this->allowedRange->getMin(); + + if ( $this->getMinAmount() === $allowedMin->amount + && $this->getCountOfMinAmount() + $nrOfCombinationsToGo <= $this->nrOfPossibleCombinations + ) { + return true; + } + return false; + } + + public function aboveMaximum(int $nrOfCombinationsToGo): bool + { + if( $this->getNrOfPlacesAboveMaximum() === 0 ) { + return false; + } + + $allowedMax = $this->allowedRange->getMax(); + + if ( $this->getMaxAmount() === $allowedMax->amount + && + ( + $this->getCountOfMaxAmount() + $nrOfCombinationsToGo <= $this->nrOfPossibleCombinations + ) + ) { + return false; + } + return true; + } + +} \ No newline at end of file diff --git a/domain/Game.php b/domain/Game.php index dcb9a5c..5b4086f 100644 --- a/domain/Game.php +++ b/domain/Game.php @@ -17,7 +17,7 @@ abstract class Game extends Identifiable */ protected Collection|null $poulePlaces = null; - public const ORDER_BY_BATCH = 1; + public const int ORDER_BY_BATCH = 1; // public const ORDER_BY_GAMENUMBER = 2; public function __construct(protected Planning $planning, protected Poule $poule, protected Field $field) diff --git a/domain/GameRound/Against.php b/domain/GameRound/Against.php index acd1511..b800445 100644 --- a/domain/GameRound/Against.php +++ b/domain/GameRound/Against.php @@ -6,7 +6,6 @@ use SportsPlanning\Combinations\HomeAway; use SportsPlanning\GameRound; -use SportsPlanning\GameRound\Against as AgainstGameRound; use SportsPlanning\Planning\ListNode; /** diff --git a/domain/Output/Combinations/GameRoundOutput.php b/domain/Output/Combinations/GameRoundOutput.php index 82e55f3..6d1ca81 100644 --- a/domain/Output/Combinations/GameRoundOutput.php +++ b/domain/Output/Combinations/GameRoundOutput.php @@ -7,8 +7,8 @@ use Psr\Log\LoggerInterface; use SportsHelpers\Output as OutputHelper; use SportsPlanning\Combinations\HomeAway as HomeAwayBase; -use SportsPlanning\Output\Combinations\HomeAwayOutput as HomeAwayOutput; use SportsPlanning\GameRound\Against as AgainstGameRound; +use SportsPlanning\Output\Combinations\HomeAwayOutput as HomeAwayOutput; class GameRoundOutput extends OutputHelper { diff --git a/domain/Output/Combinations/HomeAwayOutput.php b/domain/Output/Combinations/HomeAwayOutput.php index 1500b17..8d53f1d 100644 --- a/domain/Output/Combinations/HomeAwayOutput.php +++ b/domain/Output/Combinations/HomeAwayOutput.php @@ -10,6 +10,7 @@ use SportsPlanning\Combinations\HomeAway as HomeAwayBase; use SportsPlanning\Combinations\PlaceCombination; use SportsPlanning\Combinations\PlaceCombinationCounter; +use SportsPlanning\Counters\CounterForPlaceCombination; use SportsPlanning\GameRound\Against as AgainstGameRound; use SportsPlanning\Place; @@ -65,14 +66,14 @@ public function outputAgainstTotals(array $homeAways): void { /** * @param list $homeAways - * @return array $map + * @return array $map */ protected function convertToAgainstPlaceCombinationMap(array $homeAways): array { $map = []; foreach ($homeAways as $homeAway) { foreach( $homeAway->getAgainstPlaceCombinations() as $withPlaceCombincation ) { if( !array_key_exists($withPlaceCombincation->getIndex(), $map)) { - $map[$withPlaceCombincation->getIndex()] = new PlaceCombinationCounter($withPlaceCombincation); + $map[$withPlaceCombincation->getIndex()] = new CounterForPlaceCombination($withPlaceCombincation); } $map[$withPlaceCombincation->getIndex()]->increment(); } @@ -97,14 +98,14 @@ public function outputWithTotals(array $homeAways): void { /** * @param list $homeAways - * @return array $map + * @return array $map */ protected function convertToWithPlaceCombinationMap(array $homeAways): array { $map = []; foreach ($homeAways as $homeAway) { foreach( $homeAway->getWithPlaceCombinations() as $withPlaceCombincation ) { if( !array_key_exists($withPlaceCombincation->getIndex(), $map)) { - $map[$withPlaceCombincation->getIndex()] = new PlaceCombinationCounter($withPlaceCombincation); + $map[$withPlaceCombincation->getIndex()] = new CounterForPlaceCombination($withPlaceCombincation); } $map[$withPlaceCombincation->getIndex()]->increment(); } @@ -113,7 +114,7 @@ protected function convertToWithPlaceCombinationMap(array $homeAways): array { } /** - * @param array $map + * @param array $map * @return void */ public function outputTotalsHelpers(array $map): void { diff --git a/domain/Output/ScheduleOutput.php b/domain/Output/ScheduleOutput.php index 75d118a..d74dabd 100644 --- a/domain/Output/ScheduleOutput.php +++ b/domain/Output/ScheduleOutput.php @@ -5,6 +5,7 @@ namespace SportsPlanning\Output; use Psr\Log\LoggerInterface; +use SportsHelpers\Against\Side as AgainstSide; use SportsHelpers\Counter; use SportsHelpers\Output as OutputHelper; use SportsHelpers\PouleStructure; @@ -12,18 +13,14 @@ use SportsHelpers\Sport\Variant\Against\H2h as AgainstH2h; use SportsHelpers\Sport\Variant\Creator as VariantCreator; use SportsHelpers\Sport\Variant\WithPoule\Against\GamesPerPlace as AgainstGppWithPoule; -use SportsPlanning\Combinations\AssignedCounter; use SportsPlanning\Combinations\HomeAway; use SportsPlanning\Combinations\PlaceCombination; -use SportsPlanning\Combinations\PlaceCombinationCounter; +use SportsPlanning\Counters\AssignedCounter; +use SportsPlanning\Counters\CounterForPlaceCombination; use SportsPlanning\Input; use SportsPlanning\Poule; use SportsPlanning\Referee\Info; use SportsPlanning\Schedule as ScheduleBase; -use SportsPlanning\Output\GameOutput as GameOutput; -use SportsPlanning\Game\Together as TogetherGame; -use SportsPlanning\Game\Against as AgainstGame; -use SportsHelpers\Against\Side as AgainstSide; use SportsPlanning\Schedule\Name; class ScheduleOutput extends OutputHelper @@ -190,7 +187,7 @@ public function outputAssignedNrOfGames(array $assignedNrOfGames, string $prefix } /** - * @param list $assignedAgainstMap + * @param list $assignedAgainstMap * @param string $prefix * @return void */ diff --git a/domain/Planning/TimeoutConfig.php b/domain/Planning/TimeoutConfig.php index 2027635..c03b728 100644 --- a/domain/Planning/TimeoutConfig.php +++ b/domain/Planning/TimeoutConfig.php @@ -10,8 +10,8 @@ class TimeoutConfig { - public const MINIMUM_TIMEOUTSECONDS = 5; - public const MAXIMUM_TIMEOUTSECONDS = 15; + public const int MINIMUM_TIMEOUTSECONDS = 5; + public const int MAXIMUM_TIMEOUTSECONDS = 15; public function getTimeoutSeconds(Input $input, TimeoutState|null $timeoutState): int { diff --git a/domain/Planning/Validity.php b/domain/Planning/Validity.php index cbcc475..ec188d8 100644 --- a/domain/Planning/Validity.php +++ b/domain/Planning/Validity.php @@ -4,27 +4,27 @@ class Validity { - public const NOT_VALIDATED = -1; - public const VALID = 0; - public const NO_GAMES = 1; - public const EMPTY_PLACE = 2; - public const EMPTY_REFEREE = 8; - public const EMPTY_REFEREEPLACE = 16; - public const UNEQUAL_GAME_HOME_AWAY = 32; - public const UNEQUAL_GAME_AGAINST = 64; - public const NOT_EQUALLY_ASSIGNED_PLACES = 128; - public const TOO_MANY_GAMES_IN_A_ROW = 256; - public const MULTIPLE_ASSIGNED_FIELDS_IN_BATCH = 512; - public const MULTIPLE_ASSIGNED_REFEREES_IN_BATCH = 1024; - public const MULTIPLE_ASSIGNED_PLACES_IN_BATCH = 2048; - public const UNEQUALLY_ASSIGNED_FIELDS = 4096; - public const UNEQUALLY_ASSIGNED_REFEREES = 8192; - public const UNEQUALLY_ASSIGNED_REFEREEPLACES = 16384; - public const INVALID_ASSIGNED_REFEREEPLACE = 32768; - public const UNEQUAL_PLACE_NROFHOMESIDES = 65536; - public const INVALID_REFEREESELF_AND_REFEREES = 131072; - public const INVALID_NROFBATCHES = 262144; - public const UNEQUAL_GAME_WITH = 524288; + public const int NOT_VALIDATED = -1; + public const int VALID = 0; + public const int NO_GAMES = 1; + public const int EMPTY_PLACE = 2; + public const int EMPTY_REFEREE = 8; + public const int EMPTY_REFEREEPLACE = 16; + public const int UNEQUAL_GAME_HOME_AWAY = 32; + public const int UNEQUAL_GAME_AGAINST = 64; + public const int NOT_EQUALLY_ASSIGNED_PLACES = 128; + public const int TOO_MANY_GAMES_IN_A_ROW = 256; + public const int MULTIPLE_ASSIGNED_FIELDS_IN_BATCH = 512; + public const int MULTIPLE_ASSIGNED_REFEREES_IN_BATCH = 1024; + public const int MULTIPLE_ASSIGNED_PLACES_IN_BATCH = 2048; + public const int UNEQUALLY_ASSIGNED_FIELDS = 4096; + public const int UNEQUALLY_ASSIGNED_REFEREES = 8192; + public const int UNEQUALLY_ASSIGNED_REFEREEPLACES = 16384; + public const int INVALID_ASSIGNED_REFEREEPLACE = 32768; + public const int UNEQUAL_PLACE_NROFHOMESIDES = 65536; + public const int INVALID_REFEREESELF_AND_REFEREES = 131072; + public const int INVALID_NROFBATCHES = 262144; + public const int UNEQUAL_GAME_WITH = 524288; - public const ALL_INVALID = 1048575; + public const int ALL_INVALID = 1048575; } \ No newline at end of file diff --git a/domain/Poule/GameCounter.php b/domain/Poule/GameCounter.php deleted file mode 100644 index 3dcf3d6..0000000 --- a/domain/Poule/GameCounter.php +++ /dev/null @@ -1,34 +0,0 @@ - - */ -class GameCounter extends Counter -{ - public function __construct(Poule $poule, int $nrOfGames = 0) - { - parent::__construct($poule, $nrOfGames); - } - - public function getPoule(): Poule - { - return $this->countedObject; - } - - public function addNrOfGames(int $nrOfGames): void - { - $this->increase($nrOfGames); - } - - public function getNrOfGames(): int - { - return $this->count(); - } -} diff --git a/domain/Poule/PouleCounter.php b/domain/Poule/PouleCounter.php deleted file mode 100644 index 3ea9f0f..0000000 --- a/domain/Poule/PouleCounter.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ - protected Counter $gameCounter; - - public function __construct(protected Poule $poule, protected int $nrOfPlacesAssigned = 0) - { - $this->gameCounter = new Counter($poule); - } - - public function getPoule(): Poule - { - return $this->poule; - } - - public function reset(): void - { - $this->gameCounter = new Counter($this->poule); - $this->nrOfPlacesAssigned = 0; - } - - public function add(int $nrOfPlacesToAssign): void - { - $this->addNrOfGames(1); - $this->addNrOfAssignedPlaces($nrOfPlacesToAssign); - } - - public function addNrOfGames(int $nrOfGames): void - { - $this->gameCounter->increase($nrOfGames); - } - - public function addNrOfAssignedPlaces(int $nrOfAssignedPlaces): void - { - $this->nrOfPlacesAssigned += $nrOfAssignedPlaces; - } - - public function remove(int $nrOfPlacesToUnassign): void - { - $this->gameCounter = $this->gameCounter->decrement2(); - $this->nrOfPlacesAssigned -= $nrOfPlacesToUnassign; - } - - public function getNrOfPlacesAssigned(bool|null $addRefereePlace = null): int - { - if ($addRefereePlace === true) { - return $this->nrOfPlacesAssigned + $this->gameCounter->count(); - } - return $this->nrOfPlacesAssigned; - } - - public function getNrOfGames(): int - { - return $this->gameCounter->count(); - } -} diff --git a/domain/Resource/GameCounter.php b/domain/Resource/GameCounter.php index e6600d7..c2fdb3b 100644 --- a/domain/Resource/GameCounter.php +++ b/domain/Resource/GameCounter.php @@ -8,7 +8,7 @@ /** * @template-extends Counter */ -class GameCounter extends Counter implements \Stringable +readonly class GameCounter extends Counter implements \Stringable { public function __construct(PlanningResource $resource, int $nrOfGames = 0) { @@ -20,6 +20,11 @@ public function getResource(): PlanningResource return $this->countedObject; } + public function increment(): GameCounter + { + return new GameCounter($this->countedObject, $this->count + 1 ); + } + public function getIndex(): string { return $this->countedObject->getUniqueIndex(); diff --git a/domain/Resource/GameCounter/Place.php b/domain/Resource/GameCounter/Place.php index 507ee89..ad95668 100644 --- a/domain/Resource/GameCounter/Place.php +++ b/domain/Resource/GameCounter/Place.php @@ -7,7 +7,7 @@ use SportsPlanning\Place as PlaceBase; use SportsPlanning\Resource\GameCounter; -class Place extends GameCounter +readonly class Place extends GameCounter { public function __construct(protected PlaceBase $place, int $nrOfGames = 0) { diff --git a/domain/Schedule/Game.php b/domain/Schedule/Game.php index 7707e60..2a6b804 100644 --- a/domain/Schedule/Game.php +++ b/domain/Schedule/Game.php @@ -8,10 +8,6 @@ use Doctrine\Common\Collections\Collection; use SportsHelpers\Against\Side as AgainstSide; use SportsPlanning\Identifiable; -use SportsPlanning\Combinations\HomeAway; -use SportsPlanning\Combinations\PlaceCombination; -use SportsPlanning\Place; -use SportsPlanning\Poule; use SportsPlanning\Schedule\Sport as SportSchedule; class Game extends Identifiable diff --git a/domain/Schedule/Sport.php b/domain/Schedule/Sport.php index d748160..76dcefe 100644 --- a/domain/Schedule/Sport.php +++ b/domain/Schedule/Sport.php @@ -7,9 +7,6 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use SportsHelpers\Sport\PersistVariant; -use SportsHelpers\Sport\Variant\Creator as VariantCreator; -use SportsHelpers\Sport\Variant\WithPoule\Against\GamesPerPlace as AgainstGppWithPoule; -use SportsPlanning\Combinations\HomeAway; use SportsPlanning\Schedule; class Sport extends PersistVariant diff --git a/tests/cases/PlaceCounterTest.php b/tests/cases/PlaceCounterTest.php index 2e53abc..cb5ecc4 100644 --- a/tests/cases/PlaceCounterTest.php +++ b/tests/cases/PlaceCounterTest.php @@ -5,7 +5,7 @@ namespace SportsPlanning\Tests; use PHPUnit\Framework\TestCase; -use SportsPlanning\PlaceCounter; +use SportsPlanning\Counters\CounterForPlace; use SportsPlanning\TestHelper\PlanningCreator; class PlaceCounterTest extends TestCase @@ -16,7 +16,7 @@ public function testSimple(): void { $input = $this->createInput([5]); $place = $input->getPoule(1)->getPlace(1); - $placeCounter = new PlaceCounter($place); + $placeCounter = new CounterForPlace($place); self::assertSame(1, $placeCounter->getPlaceNr()); } @@ -24,10 +24,7 @@ public function testCounter(): void { $input = $this->createInput([5]); $place = $input->getPoule(1)->getPlace(1); - $placeCounter = new PlaceCounter($place); - $placeCounter->increment(); - $placeCounter->increment(); - $placeCounter->increment(); - self::assertCount(3, $placeCounter); + $placeCounter = new CounterForPlace($place); + self::assertCount(3, $placeCounter->increment()->increment()->increment()); } } diff --git a/tests/cases/Poule/PouleCounterTest.php b/tests/cases/Poule/PouleCounterTest.php index 316b032..08e6f3a 100644 --- a/tests/cases/Poule/PouleCounterTest.php +++ b/tests/cases/Poule/PouleCounterTest.php @@ -4,7 +4,7 @@ namespace SportsPlanning\Tests\Poule; -use SportsPlanning\Poule\PouleCounter; +use SportsPlanning\Counters\GamePlacesCounterForPoule; use SportsPlanning\TestHelper\PlanningCreator; class PouleCounterTest extends \PHPUnit\Framework\TestCase @@ -16,18 +16,18 @@ public function testCalculations(): void $input = $this->createInput([3]); $pouleOne = $input->getPoule(1); - $pouleCounter = new PouleCounter($pouleOne); + $gamePlacesCounter = new GamePlacesCounterForPoule($pouleOne); $nrOfPlacesAssigned = 3; - $pouleCounter->add($nrOfPlacesAssigned); + $gamePlacesCounter = $gamePlacesCounter->add($nrOfPlacesAssigned); - self::assertSame($nrOfPlacesAssigned, $pouleCounter->getNrOfPlacesAssigned()); - self::assertSame(1, $pouleCounter->getNrOfGames()); + self::assertSame($nrOfPlacesAssigned, $gamePlacesCounter->getNrOfPlacesAssigned()); + self::assertSame(1, $gamePlacesCounter->getNrOfGames()); - $pouleCounter->reset(); - self::assertSame(0, $pouleCounter->getNrOfPlacesAssigned()); - self::assertSame(0, $pouleCounter->getNrOfGames()); + $gamePlacesCounter = $gamePlacesCounter->reset(); + self::assertSame(0, $gamePlacesCounter->getNrOfPlacesAssigned()); + self::assertSame(0, $gamePlacesCounter->getNrOfGames()); - self::assertSame($pouleOne, $pouleCounter->getPoule()); + self::assertSame($pouleOne, $gamePlacesCounter->getPoule()); } } diff --git a/tests/cases/Resource/GameCounter/PlaceTest.php b/tests/cases/Resource/GameCounter/PlaceTest.php index 3753229..22a2460 100644 --- a/tests/cases/Resource/GameCounter/PlaceTest.php +++ b/tests/cases/Resource/GameCounter/PlaceTest.php @@ -5,7 +5,7 @@ namespace SportsPlanning\Tests\Resource\GameCounter; use PHPUnit\Framework\TestCase; -use SportsPlanning\PlaceCounter; +use SportsPlanning\Counters\CounterForPlace; use SportsPlanning\TestHelper\PlanningCreator; class PlaceTest extends TestCase @@ -17,7 +17,7 @@ public function testCalculations(): void $input = $this->createInput([3]); $placeOne = $input->getPoule(1)->getPlace(1); - $gameCounter = new PlaceCounter($placeOne); + $gameCounter = new CounterForPlace($placeOne); self::assertSame($placeOne, $gameCounter->getPlace()); } diff --git a/tests/cases/Resource/GameCounterTest.php b/tests/cases/Resource/GameCounterTest.php index 59a666e..5a2589e 100644 --- a/tests/cases/Resource/GameCounterTest.php +++ b/tests/cases/Resource/GameCounterTest.php @@ -20,7 +20,7 @@ public function testCalculations(): void self::assertSame("1", $gameCounter->getIndex()); self::assertSame(0, $gameCounter->getNrOfGames()); - $gameCounter->increment(); + $gameCounter = $gameCounter->increment(); self::assertSame(1, $gameCounter->getNrOfGames()); self::assertSame($referee, $gameCounter->getResource());