Added "toBeInvokable" arch expectation.

This commit is contained in:
Ash Allen
2023-08-01 12:09:18 +01:00
parent 4de70da0a0
commit 011bd3ba82
9 changed files with 127 additions and 0 deletions

View File

@ -693,4 +693,17 @@ final class Expectation
{
return ToBeUsedInNothing::make($this);
}
/**
* Asserts that the given expectation dependency is an invokable class.
*/
public function toBeInvokable(): ArchExpectation
{
return Targeted::make(
$this,
fn(ObjectDescription $object): bool => $object->reflectionClass->hasMethod('__invoke'),
'to be invokable',
FileLineFinder::where(fn (string $line): bool => str_contains($line, 'class'))
);
}
}