From ab11663fb2d43b29ee11dcfa1c6769e529f6b7d6 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 20 May 2024 01:15:01 +0900 Subject: [PATCH] Allow d in short names (#116) --- src/ObjectCalisthenics/Rules/NoShortNameRule.php | 5 ++++- .../Rules/NoShortNameRule/Fixture/AllowD.php | 8 ++++++++ .../Rules/NoShortNameRule/NoShortNameRuleTest.php | 6 ++++-- .../Rules/NoShortNameRule/config/configured_rule.neon | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php diff --git a/src/ObjectCalisthenics/Rules/NoShortNameRule.php b/src/ObjectCalisthenics/Rules/NoShortNameRule.php index 505ad4af..7c83cda3 100644 --- a/src/ObjectCalisthenics/Rules/NoShortNameRule.php +++ b/src/ObjectCalisthenics/Rules/NoShortNameRule.php @@ -36,7 +36,7 @@ final class NoShortNameRule extends AbstractSymplifyRule implements Configurable */ public function __construct( private readonly int $minNameLength, - private readonly array $allowedShortNames = ['i', 'j', 'y', 'z'] + private readonly array $allowedShortNames = ['i', 'j', 'y', 'z', 'd', 'dd'] ) { } @@ -130,6 +130,9 @@ private function isNameValid(string $name): bool return true; } + dump($name); + dump(in_array($name, $this->allowedShortNames, true)); + return in_array($name, $this->allowedShortNames, true); } } diff --git a/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php b/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php new file mode 100644 index 00000000..1ad227fd --- /dev/null +++ b/tests/ObjectCalisthenics/Rules/NoShortNameRule/Fixture/AllowD.php @@ -0,0 +1,8 @@ +