From 19647986d413b0ec751a9424bb4e32b6dc84b43f Mon Sep 17 00:00:00 2001 From: Edie Lemoine Date: Fri, 27 Sep 2024 11:46:54 +0200 Subject: [PATCH] refactor: fix phpmd warnings --- tests/Mock/MockPsCountry.php | 19 ++++++++++++------- tests/Mock/MockPsOrder.php | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/Mock/MockPsCountry.php b/tests/Mock/MockPsCountry.php index b90a1466..64edf474 100644 --- a/tests/Mock/MockPsCountry.php +++ b/tests/Mock/MockPsCountry.php @@ -23,7 +23,13 @@ abstract class MockPsCountry extends ObjectModel */ public static function getByIso(string $isoCode, bool $active = false) { - $found = self::firstWhere(['iso_code' => $isoCode]); + $wheres = ['iso_code' => $isoCode]; + + if ($active) { + $wheres[] = ['active' => true]; + } + + $found = self::firstWhere($wheres); if (! $found) { return false; @@ -33,17 +39,16 @@ public static function getByIso(string $isoCode, bool $active = false) } /** - * @param int $id_zone - * @param int $id_lang + * @param int $zoneId + * @param int $langId * * @return array[] - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException * @see \CountryCore::getCountriesByZoneId() + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public static function getCountriesByZoneId(int $id_zone, int $id_lang): array + public static function getCountriesByZoneId(int $zoneId, int $langId): array { - $ids = MockPsCountries::getCountriesByZoneId($id_zone); + $ids = MockPsCountries::getCountriesByZoneId($zoneId); return array_map(static function (int $id) { return (new static($id))->toArray(); diff --git a/tests/Mock/MockPsOrder.php b/tests/Mock/MockPsOrder.php index 92e6f8a3..410337f6 100644 --- a/tests/Mock/MockPsOrder.php +++ b/tests/Mock/MockPsOrder.php @@ -12,7 +12,7 @@ */ abstract class MockPsOrder extends ObjectModel { - protected $hasCustomIdKey = true; + protected bool $hasCustomIdKey = true; protected static function getTable(): string { @@ -35,8 +35,7 @@ public function getCurrentOrderState(): ?OrderState * @param int|null $idEmployee * * @return bool - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function setCurrentState(int $state, int $idEmployee = null): bool {