for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ajax\common\html\traits;
trait BaseHooksTrait {
protected $_hooks=[];
/**
* @param string $hookKey
* @return boolean
*/
public function hookExists($hookKey){
return isset($this->_hooks[$hookKey]);
}
* @return callable|NULL
public function getHook($hookKey){
if(isset($this->_hooks[$hookKey])){
return $this->_hooks[$hookKey];
return null;
* Adds a new Hook
* @param String $hookKey
* @param callable $callable
public function addHook($hookKey,$callable){
$this->_hooks[$hookKey]=$callable;
* Executes the hook with key $hookKey
* @param mixed|null $variable
* @return void|mixed
public function execHook($hookKey,$variable=null){
if(($hook=$this->getHook($hookKey))!=null){
return $hook($variable);
return;