Skip to content

Commit

Permalink
Update HooksTrait.php
Browse files Browse the repository at this point in the history
  • Loading branch information
evasyakin committed Aug 18, 2021
1 parent 03f38ff commit 7f7ed16
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Help/HooksTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
trait HooksTrait
{
/**
* Вызов метода при наличии. Для хуков событий.
* Вызов метода при наличии.
* @param string имя метода
* @param mixed аргумент метода
*/
Expand All @@ -22,4 +22,19 @@ protected function hook(string $methodName, ...$methodArgs)
call_user_func_array([$this, $methodName], $methodArgs);
}
}

/**
* Вызов статического метода при наличии.
* @param string имя метода
* @param mixed аргумент метода
*/
protected static function staticHook(string $methodName, ...$methodArgs)
{
if (defined('EVAS_DEBUG') && true == EVAS_DEBUG) {
echo $methodName . ('cli' == PHP_SAPI ? "\n" : '<br>');
}
if (method_exists(static::class, $methodName)) {
call_user_func_array([static::class, $methodName], $methodArgs);
}
}
}

0 comments on commit 7f7ed16

Please sign in to comment.