Form
4 years ago
Frontend
4 years ago
Gateways
4 years ago
ArrayDataSet.php
4 years ago
Call.php
4 years ago
Hooks.php
4 years ago
Html.php
4 years ago
Table.php
4 years ago
Utils.php
4 years ago
Call.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Helpers; |
| 4 | |
| 5 | use Give\Framework\Exceptions\Primitives\InvalidArgumentException; |
| 6 | |
| 7 | class Call |
| 8 | { |
| 9 | /** |
| 10 | * Call an invokable class. |
| 11 | * |
| 12 | * @since 2.17.0 |
| 13 | * |
| 14 | * @param string $class |
| 15 | * @param mixed $args |
| 16 | * |
| 17 | * @return mixed |
| 18 | */ |
| 19 | public static function invoke($class, ...$args) |
| 20 | { |
| 21 | if ( ! method_exists($class, '__invoke')) { |
| 22 | throw new InvalidArgumentException("This class is not invokable"); |
| 23 | } |
| 24 | |
| 25 | /** @var callable $instance */ |
| 26 | $instance = give($class); |
| 27 | |
| 28 | return $instance(...$args); |
| 29 | } |
| 30 | } |
| 31 |