diff --git a/src/Expectation.php b/src/Expectation.php index 7a8090f0..d237b567 100644 --- a/src/Expectation.php +++ b/src/Expectation.php @@ -479,6 +479,27 @@ final class Expectation return $this->toBeEnum(); } + /** + * Asserts that the given expectation targets is an class. + */ + public function toBeClass(): ArchExpectation + { + return Targeted::make( + $this, + fn (ObjectDescription $object): bool => class_exists($object->name), + 'to be class', + FileLineFinder::where(fn (string $line): bool => true), + ); + } + + /** + * Asserts that the given expectation targets are classes. + */ + public function toBeClasses(): ArchExpectation + { + return $this->toBeClass(); + } + /** * Asserts that the given expectation target is interface. */ diff --git a/tests/Arch.php b/tests/Arch.php index eb47a06e..a46c37b2 100644 --- a/tests/Arch.php +++ b/tests/Arch.php @@ -30,4 +30,4 @@ test('contracts') 'NunoMaduro\Collision\Contracts', 'Pest\Factories\TestCaseMethodFactory', 'Symfony\Component\Console', - ]); + ])->toBeInterfaces();