Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Analyzer/ClassDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/ArchRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/Unit/Analyzer/ClassDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down