Functional\Exceptions\InvalidArgumentException::assertMethodName PHP Метод

assertMethodName() публичный статический Метод

public static assertMethodName ( $methodName, $callee, $parameterPosition )
    public static function assertMethodName($methodName, $callee, $parameterPosition)
    {
        if (!is_string($methodName)) {
            throw new static(sprintf('%s() expects parameter %d to be string, %s given', $callee, $parameterPosition, gettype($methodName)));
        }
    }

Usage Example

Пример #1
0
/**
 * Returns a function that invokes method `$method` with arguments `$methodArguments` on the object
 *
 * @param string $methodName
 * @param array $arguments
 * @return callable
 */
function invoker($methodName, array $arguments = [])
{
    InvalidArgumentException::assertMethodName($methodName, __FUNCTION__, 1);
    return static function ($object) use($methodName, $arguments) {
        return $object->{$methodName}(...$arguments);
    };
}
All Usage Examples Of Functional\Exceptions\InvalidArgumentException::assertMethodName