llms_get_callable_name( mixed $callable )
Retrieve a string representing a PHP callable
Description Description
This can be used to log callables regardless of the callable format.
Parameters Parameters
- $callable
-
(mixed) (Required) PHP callable.
Return Return
(string)
Source Source
File: includes/functions/llms.functions.log.php
function llms_get_callable_name( $callable ) {
// Function name or static class -> method: 'function' or 'class::method'.
if ( is_string( $callable ) ) {
return $callable;
}
if ( is_array( $callable ) && ! empty( $callable ) ) {
// Class and class method: [ $class, 'method' ]. (phpcs:ignore Squiz.PHP.CommentedOutCode.Found).
if ( is_object( $callable[0] ) ) {
return get_class( $callable[0] ) . '->' . $callable[1];
}
// Static class + method: [ 'class', 'method' ]. (phpcs:ignore Squiz.PHP.CommentedOutCode.Found).
return implode( '::', $callable );
}
// Invokable class: $class. (phpcs:ignore Squiz.PHP.CommentedOutCode.Found).
if ( is_object( $callable ) ) {
return get_class( $callable );
}
return 'Unknown';
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |