InvocationException.php
1 month ago
NotCallableException.php
1 month ago
NotEnoughParametersException.php
1 month ago
NotCallableException.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace FacebookFeed\Vendor\Invoker\Exception; |
| 5 | |
| 6 | /** |
| 7 | * The given callable is not actually callable. |
| 8 | */ |
| 9 | class NotCallableException extends InvocationException |
| 10 | { |
| 11 | /** |
| 12 | * @param mixed $value |
| 13 | */ |
| 14 | public static function fromInvalidCallable($value, bool $containerEntry = \false): self |
| 15 | { |
| 16 | if (is_object($value)) { |
| 17 | $message = sprintf('Instance of %s is not a callable', get_class($value)); |
| 18 | } elseif (is_array($value) && isset($value[0], $value[1])) { |
| 19 | $class = is_object($value[0]) ? get_class($value[0]) : $value[0]; |
| 20 | $extra = method_exists($class, '__call') || method_exists($class, '__callStatic') ? ' A __call() or __callStatic() method exists but magic methods are not supported.' : ''; |
| 21 | $message = sprintf('%s::%s() is not a callable.%s', $class, $value[1], $extra); |
| 22 | } elseif ($containerEntry) { |
| 23 | $message = var_export($value, \true) . ' is neither a callable nor a valid container entry'; |
| 24 | } else { |
| 25 | $message = var_export($value, \true) . ' is not a callable'; |
| 26 | } |
| 27 | return new self($message); |
| 28 | } |
| 29 | } |
| 30 |