diff --git a/src/Analyzer/ClassDescription.php b/src/Analyzer/ClassDescription.php index 0a2719f2..01edd26a 100644 --- a/src/Analyzer/ClassDescription.php +++ b/src/Analyzer/ClassDescription.php @@ -94,6 +94,11 @@ public function namespaceMatches(string $pattern): bool } public function namespaceMatchesOneOfTheseNamespaces(array $classesToBeExcluded): bool + { + return $this->namespaceMatchesOneOfTheseNamespacesSplat(...$classesToBeExcluded); + } + + public function namespaceMatchesOneOfTheseNamespacesSplat(string ...$classesToBeExcluded): bool { foreach ($classesToBeExcluded as $classToBeExcluded) { if ($this->namespaceMatches($classToBeExcluded)) { diff --git a/src/Rules/ArchRule.php b/src/Rules/ArchRule.php index 2909d417..198fa16b 100644 --- a/src/Rules/ArchRule.php +++ b/src/Rules/ArchRule.php @@ -38,7 +38,7 @@ public function __construct( public function check(ClassDescription $classDescription, Violations $violations): void { - if ($classDescription->namespaceMatchesOneOfTheseNamespaces($this->classesToBeExcluded)) { + if ($classDescription->namespaceMatchesOneOfTheseNamespacesSplat(...$this->classesToBeExcluded)) { return; } diff --git a/tests/Unit/Analyzer/ClassDescriptionTest.php b/tests/Unit/Analyzer/ClassDescriptionTest.php index 4726d027..7dc06266 100644 --- a/tests/Unit/Analyzer/ClassDescriptionTest.php +++ b/tests/Unit/Analyzer/ClassDescriptionTest.php @@ -39,6 +39,13 @@ public function test_should_return_true_if_there_class_is_in_namespace_array(): $this->assertTrue($cd->namespaceMatchesOneOfTheseNamespaces(['Fruit'])); } + public function test_should_return_true_if_there_class_is_in_namespace_list(): void + { + $cd = $this->builder->build(); + + $this->assertTrue($cd->namespaceMatchesOneOfTheseNamespacesSplat('Fruit', 'Banana')); + } + public function test_should_return_true_if_is_annotated_with(): void { $cd = $this->builder