mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Refactors HigherOrderMessage
This commit is contained in:
@ -70,8 +70,9 @@ final class HigherOrderMessage
|
|||||||
*/
|
*/
|
||||||
public function call(object $target)
|
public function call(object $target)
|
||||||
{
|
{
|
||||||
if (($value = $this->retrieveHigherOrderCallable($target)) !== null) {
|
if ($this->hasHigherOrderCallable()) {
|
||||||
return $value;
|
/* @phpstan-ignore-next-line */
|
||||||
|
return (new HigherOrderCallables($target))->{$this->methodName}(...$this->arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -93,18 +94,13 @@ final class HigherOrderMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to call one of the available Higher Order callables if it exists.
|
* Determines whether or not there exists a higher order callable with the message name.
|
||||||
*
|
*
|
||||||
* @return mixed|null
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function retrieveHigherOrderCallable(object $target)
|
private function hasHigherOrderCallable()
|
||||||
{
|
{
|
||||||
if (in_array($this->methodName, get_class_methods(HigherOrderCallables::class), true)) {
|
return in_array($this->methodName, get_class_methods(HigherOrderCallables::class), true);
|
||||||
/* @phpstan-ignore-next-line */
|
|
||||||
return (new HigherOrderCallables($target))->{$this->methodName}(...$this->arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getUndefinedMethodMessage(object $target, string $methodName): string
|
private static function getUndefinedMethodMessage(object $target, string $methodName): string
|
||||||
|
|||||||
Reference in New Issue
Block a user