commands[$cmd])) { $this->commands[$cmd] = [$callback, $source]; $this->count++; return true; } return false; } /** * Detach existing command. * * @param string $cmd Command ID * @param mixed $source Provider * * @return bool * * @since 1.0.0 */ public function detach(string $cmd, $source) : bool { if (array_key_exists($cmd, $this->commands)) { unset($this->commands[$cmd]); $this->count--; return true; } return false; } /** * Trigger command. * * @param string $cmd Command ID * @param mixed $para Parameters to pass * * @return mixed|bool * * @since 1.0.0 */ public function trigger(string $cmd, $para) { if (array_key_exists($cmd, $this->commands)) { return $this->commands[$cmd][0]($para); } return false; } /** * Count commands. * * @return int * * @since 1.0.0 */ public function count() : int { return $this->count; } }