repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.stopWorkers
protected function stopWorkers($n = 1) { Daemon::log('--' . $n . '-- ' . Debug::backtrace() . '-----'); $n = (int)$n; $i = 0; foreach ($this->workers->threads as &$w) { if ($i >= $n) { break; } if ($w->shutdown) { continue; } if ($w->reloaded) { continue; } $w->stop(); ++$i; } $this->lastMpmActionTs = microtime(true); return true; }
php
protected function stopWorkers($n = 1) { Daemon::log('--' . $n . '-- ' . Debug::backtrace() . '-----'); $n = (int)$n; $i = 0; foreach ($this->workers->threads as &$w) { if ($i >= $n) { break; } if ($w->shutdown) { continue; } if ($w->reloaded) { continue; } $w->stop(); ++$i; } $this->lastMpmActionTs = microtime(true); return true; }
[ "protected", "function", "stopWorkers", "(", "$", "n", "=", "1", ")", "{", "Daemon", "::", "log", "(", "'--'", ".", "$", "n", ".", "'-- '", ".", "Debug", "::", "backtrace", "(", ")", ".", "'-----'", ")", ";", "$", "n", "=", "(", "int", ")", "$"...
Stop the workers @param $n - integer - number of workers to stop @return boolean - success
[ "Stop", "the", "workers" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L299-L325
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.shutdown
protected function shutdown($signo = false) { $this->shutdown = true; $this->waitAll(true); Daemon::$shm_wstate->delete(); file_put_contents(Daemon::$config->pidfile->value, ''); posix_kill(getmypid(), SIGKILL); exit(0); }
php
protected function shutdown($signo = false) { $this->shutdown = true; $this->waitAll(true); Daemon::$shm_wstate->delete(); file_put_contents(Daemon::$config->pidfile->value, ''); posix_kill(getmypid(), SIGKILL); exit(0); }
[ "protected", "function", "shutdown", "(", "$", "signo", "=", "false", ")", "{", "$", "this", "->", "shutdown", "=", "true", ";", "$", "this", "->", "waitAll", "(", "true", ")", ";", "Daemon", "::", "$", "shm_wstate", "->", "delete", "(", ")", ";", ...
Called when master is going to shutdown @param integer System singal's number @return void
[ "Called", "when", "master", "is", "going", "to", "shutdown" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L332-L340
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigint
protected function sigint() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGINT.'); } $this->signalToChildren(SIGINT); $this->shutdown(SIGINT); }
php
protected function sigint() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGINT.'); } $this->signalToChildren(SIGINT); $this->shutdown(SIGINT); }
[ "protected", "function", "sigint", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGINT.'", ")", ";", "}", "$", "this", "->", "signalToChildren", "(", "SIGI...
Handler for the SIGINT (shutdown) signal in master process. Shutdown. @return void
[ "Handler", "for", "the", "SIGINT", "(", "shutdown", ")", "signal", "in", "master", "process", ".", "Shutdown", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L359-L367
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigterm
protected function sigterm() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGTERM.'); } $this->signalToChildren(SIGTERM); $this->shutdown(SIGTERM); }
php
protected function sigterm() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGTERM.'); } $this->signalToChildren(SIGTERM); $this->shutdown(SIGTERM); }
[ "protected", "function", "sigterm", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGTERM.'", ")", ";", "}", "$", "this", "->", "signalToChildren", "(", "SI...
Handler for the SIGTERM (shutdown) signal in master process @return void
[ "Handler", "for", "the", "SIGTERM", "(", "shutdown", ")", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L383-L391
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigquit
protected function sigquit() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGQUIT.'); } $this->signalToChildren(SIGQUIT); $this->shutdown(SIGQUIT); }
php
protected function sigquit() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGQUIT.'); } $this->signalToChildren(SIGQUIT); $this->shutdown(SIGQUIT); }
[ "protected", "function", "sigquit", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGQUIT.'", ")", ";", "}", "$", "this", "->", "signalToChildren", "(", "SI...
Handler for the SIGQUIT signal in master process @return void
[ "Handler", "for", "the", "SIGQUIT", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L397-L405
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigtstp
protected function sigtstp() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGTSTP (graceful stop all workers).'); } $this->signalToChildren(SIGTSTP); $this->shutdown(SIGTSTP); }
php
protected function sigtstp() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGTSTP (graceful stop all workers).'); } $this->signalToChildren(SIGTSTP); $this->shutdown(SIGTSTP); }
[ "protected", "function", "sigtstp", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGTSTP (graceful stop all workers).'", ")", ";", "}", "$", "this", "->", "sig...
Handler for the SIGTSTP (graceful stop all workers) signal in master process @return void
[ "Handler", "for", "the", "SIGTSTP", "(", "graceful", "stop", "all", "workers", ")", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L411-L419
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sighup
protected function sighup() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGHUP (reload config).'); } if (isset(Daemon::$config->configfile)) { Daemon::loadConfig(Daemon::$config->configfile->value); } $this->signalToChildren(SIGHUP); }
php
protected function sighup() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGHUP (reload config).'); } if (isset(Daemon::$config->configfile)) { Daemon::loadConfig(Daemon::$config->configfile->value); } $this->signalToChildren(SIGHUP); }
[ "protected", "function", "sighup", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGHUP (reload config).'", ")", ";", "}", "if", "(", "isset", "(", "Daemon", ...
Handler for the SIGHUP (reload config) signal in master process @return void
[ "Handler", "for", "the", "SIGHUP", "(", "reload", "config", ")", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L425-L436
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigusr1
protected function sigusr1() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGUSR1 (re-open log-file).'); } Daemon::openLogs(); $this->signalToChildren(SIGUSR1); }
php
protected function sigusr1() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGUSR1 (re-open log-file).'); } Daemon::openLogs(); $this->signalToChildren(SIGUSR1); }
[ "protected", "function", "sigusr1", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGUSR1 (re-open log-file).'", ")", ";", "}", "Daemon", "::", "openLogs", "(",...
Handler for the SIGUSR1 (re-open log-file) signal in master process @return void
[ "Handler", "for", "the", "SIGUSR1", "(", "re", "-", "open", "log", "-", "file", ")", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L442-L450
kakserpom/phpdaemon
PHPDaemon/Thread/Master.php
Master.sigusr2
protected function sigusr2() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGUSR2 (graceful restart all workers).'); } $this->signalToChildren(SIGUSR2); }
php
protected function sigusr2() { if (Daemon::$config->logsignals->value) { $this->log('Caught SIGUSR2 (graceful restart all workers).'); } $this->signalToChildren(SIGUSR2); }
[ "protected", "function", "sigusr2", "(", ")", "{", "if", "(", "Daemon", "::", "$", "config", "->", "logsignals", "->", "value", ")", "{", "$", "this", "->", "log", "(", "'Caught SIGUSR2 (graceful restart all workers).'", ")", ";", "}", "$", "this", "->", "...
Handler for the SIGUSR2 (graceful restart all workers) signal in master process @return void
[ "Handler", "for", "the", "SIGUSR2", "(", "graceful", "restart", "all", "workers", ")", "signal", "in", "master", "process" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L456-L462
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicCancelOkFrame.php
BasicCancelOkFrame.create
public static function create( $consumerTag = null ) { $frame = new self(); if (null !== $consumerTag) { $frame->consumerTag = $consumerTag; } return $frame; }
php
public static function create( $consumerTag = null ) { $frame = new self(); if (null !== $consumerTag) { $frame->consumerTag = $consumerTag; } return $frame; }
[ "public", "static", "function", "create", "(", "$", "consumerTag", "=", "null", ")", "{", "$", "frame", "=", "new", "self", "(", ")", ";", "if", "(", "null", "!==", "$", "consumerTag", ")", "{", "$", "frame", "->", "consumerTag", "=", "$", "consumerT...
shortstr
[ "shortstr" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicCancelOkFrame.php#L20-L31
kakserpom/phpdaemon
PHPDaemon/Servers/WebSocket/Protocols/VE.php
VE.sendHandshakeReply
public function sendHandshakeReply($extraHeaders = '') { if (!isset($this->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) { $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = ''; } $this->write( "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: WebSocket\r\n" . "Connection: Upgrade\r\n" . "Sec-WebSocket-Origin: " . $this->server['HTTP_ORIGIN'] . "\r\n" . "Sec-WebSocket-Location: ws://" . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI'] . "\r\n" ); if ($this->pool->config->expose->value) { $this->writeln('X-Powered-By: phpDaemon/' . Daemon::$version); } if (isset($this->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) { $this->writeln("Sec-WebSocket-Protocol: " . $this->server['HTTP_SEC_WEBSOCKET_PROTOCOL']); } $this->writeln($extraHeaders); return true; }
php
public function sendHandshakeReply($extraHeaders = '') { if (!isset($this->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) { $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = ''; } $this->write( "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: WebSocket\r\n" . "Connection: Upgrade\r\n" . "Sec-WebSocket-Origin: " . $this->server['HTTP_ORIGIN'] . "\r\n" . "Sec-WebSocket-Location: ws://" . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI'] . "\r\n" ); if ($this->pool->config->expose->value) { $this->writeln('X-Powered-By: phpDaemon/' . Daemon::$version); } if (isset($this->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) { $this->writeln("Sec-WebSocket-Protocol: " . $this->server['HTTP_SEC_WEBSOCKET_PROTOCOL']); } $this->writeln($extraHeaders); return true; }
[ "public", "function", "sendHandshakeReply", "(", "$", "extraHeaders", "=", "''", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "server", "[", "'HTTP_SEC_WEBSOCKET_ORIGIN'", "]", ")", ")", "{", "$", "this", "->", "server", "[", "'HTTP_SEC_WEBSO...
Sends a handshake message reply @param string Received data (no use in this class) @return boolean OK?
[ "Sends", "a", "handshake", "message", "reply" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Protocols/VE.php#L22-L43
kakserpom/phpdaemon
PHPDaemon/Servers/WebSocket/Protocols/VE.php
VE.sendFrame
public function sendFrame($data, $type = null, $cb = null) { if (!$this->handshaked) { return false; } if ($this->finished && $type !== 'CONNCLOSE') { return false; } if ($type === 'CONNCLOSE') { if ($cb !== null) { $cb($this); return true; } } // Binary $type = $this->getFrameType($type); if (($type & self::BINARY) === self::BINARY) { $n = mb_orig_strlen($data); $len = ''; $pos = 0; char: ++$pos; $c = $n >> 0 & 0x7F; $n >>= 7; if ($pos !== 1) { $c += 0x80; } if ($c !== 0x80) { $len = chr($c) . $len; goto char; }; $this->write(chr(self::BINARY) . $len . $data); } // String else { $this->write(chr(self::STRING) . $data . "\xFF"); } if ($cb !== null) { $this->onWriteOnce($cb); } return true; }
php
public function sendFrame($data, $type = null, $cb = null) { if (!$this->handshaked) { return false; } if ($this->finished && $type !== 'CONNCLOSE') { return false; } if ($type === 'CONNCLOSE') { if ($cb !== null) { $cb($this); return true; } } // Binary $type = $this->getFrameType($type); if (($type & self::BINARY) === self::BINARY) { $n = mb_orig_strlen($data); $len = ''; $pos = 0; char: ++$pos; $c = $n >> 0 & 0x7F; $n >>= 7; if ($pos !== 1) { $c += 0x80; } if ($c !== 0x80) { $len = chr($c) . $len; goto char; }; $this->write(chr(self::BINARY) . $len . $data); } // String else { $this->write(chr(self::STRING) . $data . "\xFF"); } if ($cb !== null) { $this->onWriteOnce($cb); } return true; }
[ "public", "function", "sendFrame", "(", "$", "data", ",", "$", "type", "=", "null", ",", "$", "cb", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "handshaked", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "fi...
Sends a frame. @param string $data Frame's data. @param string $type Frame's type. ("STRING" OR "BINARY") @param callable $cb Optional. Callback called when the frame is received by client. @callback $cb ( ) @return boolean Success.
[ "Sends", "a", "frame", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Protocols/VE.php#L53-L101
kakserpom/phpdaemon
PHPDaemon/Servers/WebSocket/Protocols/VE.php
VE.onRead
public function onRead() { while (($buflen = $this->getInputLength()) >= 2) { $hdr = $this->look(10); $frametype = ord(mb_orig_substr($hdr, 0, 1)); if (($frametype & 0x80) === 0x80) { $len = 0; $i = 0; do { if ($buflen < $i + 1) { return; } $b = ord(mb_orig_substr($hdr, ++$i, 1)); $n = $b & 0x7F; $len *= 0x80; $len += $n; } while ($b > 0x80); if ($this->pool->maxAllowedPacket <= $len) { // Too big packet $this->finish(); return; } if ($buflen < $len + $i + 1) { // not enough data yet return; } $this->drain($i + 1); $this->onFrame($this->read($len), $frametype); } else { if (($p = $this->search("\xFF")) !== false) { if ($this->pool->maxAllowedPacket <= $p - 1) { // Too big packet $this->finish(); return; } $this->drain(1); $data = $this->read($p); $this->drain(1); $this->onFrame($data, 'STRING'); } else { if ($this->pool->maxAllowedPacket < $buflen - 1) { // Too big packet $this->finish(); return; } } } } }
php
public function onRead() { while (($buflen = $this->getInputLength()) >= 2) { $hdr = $this->look(10); $frametype = ord(mb_orig_substr($hdr, 0, 1)); if (($frametype & 0x80) === 0x80) { $len = 0; $i = 0; do { if ($buflen < $i + 1) { return; } $b = ord(mb_orig_substr($hdr, ++$i, 1)); $n = $b & 0x7F; $len *= 0x80; $len += $n; } while ($b > 0x80); if ($this->pool->maxAllowedPacket <= $len) { // Too big packet $this->finish(); return; } if ($buflen < $len + $i + 1) { // not enough data yet return; } $this->drain($i + 1); $this->onFrame($this->read($len), $frametype); } else { if (($p = $this->search("\xFF")) !== false) { if ($this->pool->maxAllowedPacket <= $p - 1) { // Too big packet $this->finish(); return; } $this->drain(1); $data = $this->read($p); $this->drain(1); $this->onFrame($data, 'STRING'); } else { if ($this->pool->maxAllowedPacket < $buflen - 1) { // Too big packet $this->finish(); return; } } } } }
[ "public", "function", "onRead", "(", ")", "{", "while", "(", "(", "$", "buflen", "=", "$", "this", "->", "getInputLength", "(", ")", ")", ">=", "2", ")", "{", "$", "hdr", "=", "$", "this", "->", "look", "(", "10", ")", ";", "$", "frametype", "=...
Called when new data received @return void
[ "Called", "when", "new", "data", "received" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Protocols/VE.php#L107-L158
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.onConfigUpdated
public function onConfigUpdated() { if (Daemon::$process instanceof Thread\Worker) { if ($this->config === null) { $this->disable(); } else { $this->enable(); } } if ($defaults = $this->getConfigDefaults()) { $this->config->imposeDefault($defaults); } $this->applyConfig(); }
php
public function onConfigUpdated() { if (Daemon::$process instanceof Thread\Worker) { if ($this->config === null) { $this->disable(); } else { $this->enable(); } } if ($defaults = $this->getConfigDefaults()) { $this->config->imposeDefault($defaults); } $this->applyConfig(); }
[ "public", "function", "onConfigUpdated", "(", ")", "{", "if", "(", "Daemon", "::", "$", "process", "instanceof", "Thread", "\\", "Worker", ")", "{", "if", "(", "$", "this", "->", "config", "===", "null", ")", "{", "$", "this", "->", "disable", "(", "...
Called when worker is going to update configuration @return void
[ "Called", "when", "worker", "is", "going", "to", "update", "configuration" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L119-L132
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.applyConfig
protected function applyConfig() { foreach ($this->config as $k => $v) { if (is_object($v) && $v instanceof Config\Entry\Generic) { $v = $v->getValue(); } $k = strtolower($k); if ($k === 'connectionclass') { $this->connectionClass = $v; } elseif ($k === 'name') { $this->name = $v; } elseif ($k === 'maxallowedpacket') { $this->maxAllowedPacket = (int)$v; } elseif ($k === 'maxconcurrency') { $this->maxConcurrency = (int)$v; } } }
php
protected function applyConfig() { foreach ($this->config as $k => $v) { if (is_object($v) && $v instanceof Config\Entry\Generic) { $v = $v->getValue(); } $k = strtolower($k); if ($k === 'connectionclass') { $this->connectionClass = $v; } elseif ($k === 'name') { $this->name = $v; } elseif ($k === 'maxallowedpacket') { $this->maxAllowedPacket = (int)$v; } elseif ($k === 'maxconcurrency') { $this->maxConcurrency = (int)$v; } } }
[ "protected", "function", "applyConfig", "(", ")", "{", "foreach", "(", "$", "this", "->", "config", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_object", "(", "$", "v", ")", "&&", "$", "v", "instanceof", "Config", "\\", "Entry", "\\", ...
Applies config @return void
[ "Applies", "config" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L138-L155
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.getInstance
public static function getInstance($arg = '', $spawn = true) { if ($arg === 'default') { $arg = ''; } $class = static::class; if (is_string($arg)) { $key = $class . ':' . $arg; if (isset(self::$instances[$key])) { return self::$instances[$key]; } elseif (!$spawn) { return false; } $k = '\PHPDaemon\Core\Pool:\\' . $class . ($arg !== '' ? ':' . $arg : ''); $config = (isset(Daemon::$config->{$k}) && Daemon::$config->{$k} instanceof Config\Section) ? Daemon::$config->{$k} : new Config\Section; $obj = self::$instances[$key] = new $class($config); $obj->name = $arg; } elseif ($arg instanceof Config\Section) { $obj = new static($arg); } else { $obj = new static(new Config\Section($arg)); } $obj->eventLoop = EventLoop::$instance; return $obj; }
php
public static function getInstance($arg = '', $spawn = true) { if ($arg === 'default') { $arg = ''; } $class = static::class; if (is_string($arg)) { $key = $class . ':' . $arg; if (isset(self::$instances[$key])) { return self::$instances[$key]; } elseif (!$spawn) { return false; } $k = '\PHPDaemon\Core\Pool:\\' . $class . ($arg !== '' ? ':' . $arg : ''); $config = (isset(Daemon::$config->{$k}) && Daemon::$config->{$k} instanceof Config\Section) ? Daemon::$config->{$k} : new Config\Section; $obj = self::$instances[$key] = new $class($config); $obj->name = $arg; } elseif ($arg instanceof Config\Section) { $obj = new static($arg); } else { $obj = new static(new Config\Section($arg)); } $obj->eventLoop = EventLoop::$instance; return $obj; }
[ "public", "static", "function", "getInstance", "(", "$", "arg", "=", "''", ",", "$", "spawn", "=", "true", ")", "{", "if", "(", "$", "arg", "===", "'default'", ")", "{", "$", "arg", "=", "''", ";", "}", "$", "class", "=", "static", "::", "class",...
Returns instance object @param string $arg name / array config / ConfigSection @param boolean $spawn Spawn? Default is true @return this
[ "Returns", "instance", "object" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L172-L196
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.finish
public function finish($graceful = false) { $this->disable(); if (!$this->finished) { $this->finished = true; $this->onFinish(); } $result = true; foreach ($this as $conn) { if ($graceful) { if (!$conn->gracefulShutdown()) { $result = false; } } else { $conn->finish(); } } return $result; }
php
public function finish($graceful = false) { $this->disable(); if (!$this->finished) { $this->finished = true; $this->onFinish(); } $result = true; foreach ($this as $conn) { if ($graceful) { if (!$conn->gracefulShutdown()) { $result = false; } } else { $conn->finish(); } } return $result; }
[ "public", "function", "finish", "(", "$", "graceful", "=", "false", ")", "{", "$", "this", "->", "disable", "(", ")", ";", "if", "(", "!", "$", "this", "->", "finished", ")", "{", "$", "this", "->", "finished", "=", "true", ";", "$", "this", "->"...
Finishes ConnectionPool @return boolean Success
[ "Finishes", "ConnectionPool" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L272-L294
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.attach
public function attach($conn, $inf = null) { parent::attach($conn, $inf); if ($this->maxConcurrency && !$this->overload) { if ($this->count() >= $this->maxConcurrency) { $this->overload = true; $this->disable(); return; } } }
php
public function attach($conn, $inf = null) { parent::attach($conn, $inf); if ($this->maxConcurrency && !$this->overload) { if ($this->count() >= $this->maxConcurrency) { $this->overload = true; $this->disable(); return; } } }
[ "public", "function", "attach", "(", "$", "conn", ",", "$", "inf", "=", "null", ")", "{", "parent", "::", "attach", "(", "$", "conn", ",", "$", "inf", ")", ";", "if", "(", "$", "this", "->", "maxConcurrency", "&&", "!", "$", "this", "->", "overlo...
Attach Connection @param object $conn Connection @param mixed $inf Info @return void
[ "Attach", "Connection" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L302-L312
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.detach
public function detach($conn) { parent::detach($conn); if ($this->overload) { if (!$this->maxConcurrency || ($this->count() < $this->maxConcurrency)) { $this->overload = false; $this->enable(); } } }
php
public function detach($conn) { parent::detach($conn); if ($this->overload) { if (!$this->maxConcurrency || ($this->count() < $this->maxConcurrency)) { $this->overload = false; $this->enable(); } } }
[ "public", "function", "detach", "(", "$", "conn", ")", "{", "parent", "::", "detach", "(", "$", "conn", ")", ";", "if", "(", "$", "this", "->", "overload", ")", "{", "if", "(", "!", "$", "this", "->", "maxConcurrency", "||", "(", "$", "this", "->...
Detach Connection @param object $conn Connection @return void
[ "Detach", "Connection" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L319-L328
kakserpom/phpdaemon
PHPDaemon/Network/Pool.php
Pool.connect
public function connect($url, $cb, $class = null) { if ($class === null) { $class = $this->connectionClass; } $conn = new $class(null, $this); $conn->connect($url, $cb); return $conn; }
php
public function connect($url, $cb, $class = null) { if ($class === null) { $class = $this->connectionClass; } $conn = new $class(null, $this); $conn->connect($url, $cb); return $conn; }
[ "public", "function", "connect", "(", "$", "url", ",", "$", "cb", ",", "$", "class", "=", "null", ")", "{", "if", "(", "$", "class", "===", "null", ")", "{", "$", "class", "=", "$", "this", "->", "connectionClass", ";", "}", "$", "conn", "=", "...
Establish a connection with remote peer @param string $url URL @param callback $cb Callback @param string $class Optional. Connection class name @return integer Connection's ID. Boolean false when failed
[ "Establish", "a", "connection", "with", "remote", "peer" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/Pool.php#L337-L345
kakserpom/phpdaemon
PHPDaemon/Core/DeferredEvent.php
DeferredEvent.setResult
public function setResult($result = null) { $this->result = $result; $this->state = self::STATE_DONE; if ($this->listeners) { $this->listeners->executeAll($this->result); } }
php
public function setResult($result = null) { $this->result = $result; $this->state = self::STATE_DONE; if ($this->listeners) { $this->listeners->executeAll($this->result); } }
[ "public", "function", "setResult", "(", "$", "result", "=", "null", ")", "{", "$", "this", "->", "result", "=", "$", "result", ";", "$", "this", "->", "state", "=", "self", "::", "STATE_DONE", ";", "if", "(", "$", "this", "->", "listeners", ")", "{...
Set result @param mixed $result Result @return void
[ "Set", "result" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/DeferredEvent.php#L84-L91
kakserpom/phpdaemon
PHPDaemon/Core/DeferredEvent.php
DeferredEvent.cleanup
public function cleanup() { $this->listeners = null; $this->producer = null; $this->args = []; $this->parent = null; }
php
public function cleanup() { $this->listeners = null; $this->producer = null; $this->args = []; $this->parent = null; }
[ "public", "function", "cleanup", "(", ")", "{", "$", "this", "->", "listeners", "=", "null", ";", "$", "this", "->", "producer", "=", "null", ";", "$", "this", "->", "args", "=", "[", "]", ";", "$", "this", "->", "parent", "=", "null", ";", "}" ]
Clean up @return void
[ "Clean", "up" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/DeferredEvent.php#L97-L103
kakserpom/phpdaemon
PHPDaemon/Core/DeferredEvent.php
DeferredEvent.reset
public function reset() { $this->state = self::STATE_WAITING; $this->result = null; $this->args = []; return $this; }
php
public function reset() { $this->state = self::STATE_WAITING; $this->result = null; $this->args = []; return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "state", "=", "self", "::", "STATE_WAITING", ";", "$", "this", "->", "result", "=", "null", ";", "$", "this", "->", "args", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Reset @return this
[ "Reset" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/DeferredEvent.php#L109-L115
kakserpom/phpdaemon
PHPDaemon/Core/DeferredEvent.php
DeferredEvent.addListener
public function addListener($cb) { if ($this->state === self::STATE_DONE) { if ($cb !== null) { $cb($this); } return; } if ($cb !== null) { $this->listeners->push($cb); } if ($this->state === self::STATE_WAITING) { $i = 1; $n = func_num_args(); while ($i < $n) { $this->args[] = func_get_arg($i); ++$i; } $this->state = self::STATE_RUNNING; $func = $this->producer; $func($this); } }
php
public function addListener($cb) { if ($this->state === self::STATE_DONE) { if ($cb !== null) { $cb($this); } return; } if ($cb !== null) { $this->listeners->push($cb); } if ($this->state === self::STATE_WAITING) { $i = 1; $n = func_num_args(); while ($i < $n) { $this->args[] = func_get_arg($i); ++$i; } $this->state = self::STATE_RUNNING; $func = $this->producer; $func($this); } }
[ "public", "function", "addListener", "(", "$", "cb", ")", "{", "if", "(", "$", "this", "->", "state", "===", "self", "::", "STATE_DONE", ")", "{", "if", "(", "$", "cb", "!==", "null", ")", "{", "$", "cb", "(", "$", "this", ")", ";", "}", "retur...
Add listener @param callable $cb Callback @param mixed ...$args Arguments @return void
[ "Add", "listener" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/DeferredEvent.php#L133-L155
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.dispatch
public function dispatch(IncomingFrame $incomingFrame) { switch (true) { case $incomingFrame instanceof Basic\BasicDeliverFrame: case $incomingFrame instanceof Basic\BasicGetOkFrame: $message = new Message(); $message->setRoutingKey($incomingFrame->routingKey) ->setExchange($incomingFrame->exchange) ->setTag($incomingFrame->deliveryTag) ->setChannel($this); $object = new \stdClass(); if ($incomingFrame instanceof Basic\BasicDeliverFrame) { $object->consumerTag = $incomingFrame->consumerTag; } $object->message = $message; $this->stack->attach($object); $this->stack->rewind(); break; case $incomingFrame instanceof Basic\BasicHeaderFrame: $object = $this->stack->current(); /** @var Message $message */ $message = $object->message; $message->setContentLength($incomingFrame->contentLength) ->setContentType($incomingFrame->contentType) ->setContentEncoding($incomingFrame->contentEncoding) ->setHeaders($incomingFrame->headers) ->setMessageId($incomingFrame->messageId) ->setDeliveryMode($incomingFrame->deliveryMode) ->setCorrelationId($incomingFrame->correlationId) ->setReplyTo($incomingFrame->replyTo) ->setExpiration($incomingFrame->expiration) ->setTimestamp($incomingFrame->timestamp) ->setType($incomingFrame->type) ->setUserId($incomingFrame->userId) ->setAppId($incomingFrame->appId) ->setClusterId($incomingFrame->clusterId); $object->totalPayloadSize = $incomingFrame->contentLength; break; case $incomingFrame instanceof BodyFrame: $object = $this->stack->current(); /** * Use only php strlen because wee need string length in bytes */ $currentContentLength = strlen($incomingFrame->content); /** @var Message $message */ $message = $object->message; $message->setContent($message->getContent() . $incomingFrame->content); $object->totalPayloadSize -= $currentContentLength; if ($object->totalPayloadSize === 0) { if (isset($object->consumerTag)) { $this->trigger(self::EVENT_DISPATCH_CONSUMER_MESSAGE, $object->consumerTag, $message); } else { $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, $message); } $this->stack->detach($object); } break; case $incomingFrame instanceof Basic\BasicGetEmptyFrame: $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, false); break; case $incomingFrame instanceof Basic\BasicCancelOkFrame: unset($this->consumers[$incomingFrame->consumerTag]); break; case $incomingFrame instanceof ProtocolChannel\ChannelOpenOkFrame: $this->isConnected = true; $this->id = $incomingFrame->frameChannelId; //write QoS $outputFrame = Basic\BasicQosFrame::create( self::QOS_PREFECTH_SIZE, self::QOS_PREFETCH_COUNT ); $outputFrame->frameChannelId = $incomingFrame->frameChannelId; $this->connection->command($outputFrame); break; case $incomingFrame instanceof ProtocolChannel\ChannelCloseFrame: $this->trigger(self::EVENT_ON_CHANNEL_CLOSE_CALLBACK); Daemon::log(sprintf('[AMQP] Channel closed by broker. Reason: %s[%d]', $incomingFrame->replyText, $incomingFrame->replyCode)); $this->isConnected = false; break; case $incomingFrame instanceof Basic\BasicQosOkFrame: $this->trigger(self::EVENT_ON_CHANNEL_OPEN_CALLBACK, $this); break; case $incomingFrame instanceof Basic\BasicConsumeOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, $incomingFrame); break; case $incomingFrame instanceof ProtocolChannel\ChannelCloseOkFrame: $this->isConnected = false; break; case $incomingFrame instanceof Queue\QueueDeclareOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueDeleteOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueuePurgeOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_PURGE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueBindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueUnbindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_QUEUE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeDeclareOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeDeleteOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeBindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeUnbindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK); break; } }
php
public function dispatch(IncomingFrame $incomingFrame) { switch (true) { case $incomingFrame instanceof Basic\BasicDeliverFrame: case $incomingFrame instanceof Basic\BasicGetOkFrame: $message = new Message(); $message->setRoutingKey($incomingFrame->routingKey) ->setExchange($incomingFrame->exchange) ->setTag($incomingFrame->deliveryTag) ->setChannel($this); $object = new \stdClass(); if ($incomingFrame instanceof Basic\BasicDeliverFrame) { $object->consumerTag = $incomingFrame->consumerTag; } $object->message = $message; $this->stack->attach($object); $this->stack->rewind(); break; case $incomingFrame instanceof Basic\BasicHeaderFrame: $object = $this->stack->current(); /** @var Message $message */ $message = $object->message; $message->setContentLength($incomingFrame->contentLength) ->setContentType($incomingFrame->contentType) ->setContentEncoding($incomingFrame->contentEncoding) ->setHeaders($incomingFrame->headers) ->setMessageId($incomingFrame->messageId) ->setDeliveryMode($incomingFrame->deliveryMode) ->setCorrelationId($incomingFrame->correlationId) ->setReplyTo($incomingFrame->replyTo) ->setExpiration($incomingFrame->expiration) ->setTimestamp($incomingFrame->timestamp) ->setType($incomingFrame->type) ->setUserId($incomingFrame->userId) ->setAppId($incomingFrame->appId) ->setClusterId($incomingFrame->clusterId); $object->totalPayloadSize = $incomingFrame->contentLength; break; case $incomingFrame instanceof BodyFrame: $object = $this->stack->current(); /** * Use only php strlen because wee need string length in bytes */ $currentContentLength = strlen($incomingFrame->content); /** @var Message $message */ $message = $object->message; $message->setContent($message->getContent() . $incomingFrame->content); $object->totalPayloadSize -= $currentContentLength; if ($object->totalPayloadSize === 0) { if (isset($object->consumerTag)) { $this->trigger(self::EVENT_DISPATCH_CONSUMER_MESSAGE, $object->consumerTag, $message); } else { $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, $message); } $this->stack->detach($object); } break; case $incomingFrame instanceof Basic\BasicGetEmptyFrame: $this->triggerOneAndUnbind(self::EVENT_DISPATCH_MESSAGE, false); break; case $incomingFrame instanceof Basic\BasicCancelOkFrame: unset($this->consumers[$incomingFrame->consumerTag]); break; case $incomingFrame instanceof ProtocolChannel\ChannelOpenOkFrame: $this->isConnected = true; $this->id = $incomingFrame->frameChannelId; //write QoS $outputFrame = Basic\BasicQosFrame::create( self::QOS_PREFECTH_SIZE, self::QOS_PREFETCH_COUNT ); $outputFrame->frameChannelId = $incomingFrame->frameChannelId; $this->connection->command($outputFrame); break; case $incomingFrame instanceof ProtocolChannel\ChannelCloseFrame: $this->trigger(self::EVENT_ON_CHANNEL_CLOSE_CALLBACK); Daemon::log(sprintf('[AMQP] Channel closed by broker. Reason: %s[%d]', $incomingFrame->replyText, $incomingFrame->replyCode)); $this->isConnected = false; break; case $incomingFrame instanceof Basic\BasicQosOkFrame: $this->trigger(self::EVENT_ON_CHANNEL_OPEN_CALLBACK, $this); break; case $incomingFrame instanceof Basic\BasicConsumeOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, $incomingFrame); break; case $incomingFrame instanceof ProtocolChannel\ChannelCloseOkFrame: $this->isConnected = false; break; case $incomingFrame instanceof Queue\QueueDeclareOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueDeleteOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueuePurgeOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_PURGE_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueBindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_QUEUE_CALLBACK); break; case $incomingFrame instanceof Queue\QueueUnbindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_QUEUE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeDeclareOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DECLARE_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeDeleteOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_DELETE_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeBindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK); break; case $incomingFrame instanceof Exchange\ExchangeUnbindOkFrame: $this->triggerOneAndUnbind(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK); break; } }
[ "public", "function", "dispatch", "(", "IncomingFrame", "$", "incomingFrame", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "incomingFrame", "instanceof", "Basic", "\\", "BasicDeliverFrame", ":", "case", "$", "incomingFrame", "instanceof", "Basic", "\\...
Dispatch incoming frame @param IncomingFrame $incomingFrame @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Dispatch", "incoming", "frame" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L196-L316
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.close
public function close() { $outputFrame = ProtocolChannel\ChannelCloseFrame::create( 0,//@todo replyCode 'Channel closed by client' ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function close() { $outputFrame = ProtocolChannel\ChannelCloseFrame::create( 0,//@todo replyCode 'Channel closed by client' ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "close", "(", ")", "{", "$", "outputFrame", "=", "ProtocolChannel", "\\", "ChannelCloseFrame", "::", "create", "(", "0", ",", "//@todo replyCode", "'Channel closed by client'", ")", ";", "$", "outputFrame", "->", "frameChannelId", "=", "$", ...
Close the channel. @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Close", "the", "channel", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L324-L332
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.declareQueue
public function declareQueue($name, array $options = [], callable $callback = null) { $passive = array_key_exists('passive', $options) ? (bool)$options['passive'] : null; $durable = array_key_exists('durable', $options) ? (bool)$options['durable'] : null; $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null; $autoDelete = array_key_exists('autoDelete', $options) ? (bool)$options['autoDelete'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Queue\QueueDeclareFrame::create( $name, $passive, $durable, $exclusive, $autoDelete, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DECLARE_QUEUE_CALLBACK, $callback); } }
php
public function declareQueue($name, array $options = [], callable $callback = null) { $passive = array_key_exists('passive', $options) ? (bool)$options['passive'] : null; $durable = array_key_exists('durable', $options) ? (bool)$options['durable'] : null; $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null; $autoDelete = array_key_exists('autoDelete', $options) ? (bool)$options['autoDelete'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Queue\QueueDeclareFrame::create( $name, $passive, $durable, $exclusive, $autoDelete, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DECLARE_QUEUE_CALLBACK, $callback); } }
[ "public", "function", "declareQueue", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "passive", "=", "array_key_exists", "(", "'passive'", ",", "$", "options", ")", "?", "(",...
DeclareQueue @param string $name a quque name @param array $options a queue options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "DeclareQueue" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L355-L379
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.deleteQueue
public function deleteQueue($name, array $options = [], callable $callback = null) { $ifUnused = array_key_exists('ifUnused', $options) ? (bool)$options['ifUnused'] : null; $ifEmpty = array_key_exists('ifEmpty', $options) ? (bool)$options['ifEmpty'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Queue\QueueDeleteFrame::create($name, $ifUnused, $ifEmpty, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DELETE_QUEUE_CALLBACK, $callback); } }
php
public function deleteQueue($name, array $options = [], callable $callback = null) { $ifUnused = array_key_exists('ifUnused', $options) ? (bool)$options['ifUnused'] : null; $ifEmpty = array_key_exists('ifEmpty', $options) ? (bool)$options['ifEmpty'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Queue\QueueDeleteFrame::create($name, $ifUnused, $ifEmpty, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DELETE_QUEUE_CALLBACK, $callback); } }
[ "public", "function", "deleteQueue", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "ifUnused", "=", "array_key_exists", "(", "'ifUnused'", ",", "$", "options", ")", "?", "("...
Delete Queue @param string $name a queue name @param array $options a options array @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Delete", "Queue" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L390-L403
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.purgeQueue
public function purgeQueue($name, array $options = [], callable $callback = null) { $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Queue\QueuePurgeFrame::create($name, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_PURGE_QUEUE_CALLBACK, $callback); } }
php
public function purgeQueue($name, array $options = [], callable $callback = null) { $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Queue\QueuePurgeFrame::create($name, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_PURGE_QUEUE_CALLBACK, $callback); } }
[ "public", "function", "purgeQueue", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "noWait", "=", "array_key_exists", "(", "'noWait'", ",", "$", "options", ")", "?", "(", "...
Purge queue messages @param string $name a queue name @param array $options a options array @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Purge", "queue", "messages" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L414-L425
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.bindQueue
public function bindQueue($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Queue\QueueBindFrame::create( $name, $exchangeName, $routingKey, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_BIND_QUEUE_CALLBACK, $callback); } }
php
public function bindQueue($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Queue\QueueBindFrame::create( $name, $exchangeName, $routingKey, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_BIND_QUEUE_CALLBACK, $callback); } }
[ "public", "function", "bindQueue", "(", "$", "name", ",", "$", "exchangeName", ",", "$", "routingKey", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "noWait", "=", "array_key_exists", "(", "'...
Bind queue to exchange @param string $name a queue name @param string $exchangeName a exchange name @param string $routingKey a routing key @param array $options additional options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Bind", "queue", "to", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L438-L456
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.unbindQueue
public function unbindQueue($name, $exchangeName, $routingKey, callable $callback = null) { $outputFrame = Queue\QueueUnbindFrame::create( $name, $exchangeName, $routingKey ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_UNBIND_QUEUE_CALLBACK, $callback); } }
php
public function unbindQueue($name, $exchangeName, $routingKey, callable $callback = null) { $outputFrame = Queue\QueueUnbindFrame::create( $name, $exchangeName, $routingKey ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_UNBIND_QUEUE_CALLBACK, $callback); } }
[ "public", "function", "unbindQueue", "(", "$", "name", ",", "$", "exchangeName", ",", "$", "routingKey", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "outputFrame", "=", "Queue", "\\", "QueueUnbindFrame", "::", "create", "(", "$", "name", ...
Unbind queue from exchange @param string $name a queue name @param string $exchangeName a exchange name @param string $routingKey a routing key @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Unbind", "queue", "from", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L468-L481
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.declareExchange
public function declareExchange($name, array $options = [], callable $callback = null) { $type = array_key_exists('type', $options) ? $options['type'] : null; $passive = array_key_exists('passive', $options) ? (bool)$options['passive'] : null; $durable = array_key_exists('durable', $options) ? (bool)$options['durable'] : null; $internal = array_key_exists('internal', $options) ? (bool)$options['internal'] : null; $autoDelete = array_key_exists('autoDelete', $options) ? (bool)$options['autoDelete'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Exchange\ExchangeDeclareFrame::create( $name, $type, $passive, $durable, $autoDelete, $internal, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DECLARE_EXCHANGE_CALLBACK, $callback); } }
php
public function declareExchange($name, array $options = [], callable $callback = null) { $type = array_key_exists('type', $options) ? $options['type'] : null; $passive = array_key_exists('passive', $options) ? (bool)$options['passive'] : null; $durable = array_key_exists('durable', $options) ? (bool)$options['durable'] : null; $internal = array_key_exists('internal', $options) ? (bool)$options['internal'] : null; $autoDelete = array_key_exists('autoDelete', $options) ? (bool)$options['autoDelete'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Exchange\ExchangeDeclareFrame::create( $name, $type, $passive, $durable, $autoDelete, $internal, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DECLARE_EXCHANGE_CALLBACK, $callback); } }
[ "public", "function", "declareExchange", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "type", "=", "array_key_exists", "(", "'type'", ",", "$", "options", ")", "?", "$", ...
Declare exchange @param string $name a name of exchange @param array $options exchange options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Declare", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L492-L518
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.deleteExchange
public function deleteExchange($name, array $options = [], callable $callback = null) { $ifUnused = array_key_exists('ifUnused', $options) ? (bool)$options['ifUnused'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Exchange\ExchangeDeleteFrame::create($name, $ifUnused, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DELETE_EXCHANGE_CALLBACK, $callback); } }
php
public function deleteExchange($name, array $options = [], callable $callback = null) { $ifUnused = array_key_exists('ifUnused', $options) ? (bool)$options['ifUnused'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $outputFrame = Exchange\ExchangeDeleteFrame::create($name, $ifUnused, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_DELETE_EXCHANGE_CALLBACK, $callback); } }
[ "public", "function", "deleteExchange", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "ifUnused", "=", "array_key_exists", "(", "'ifUnused'", ",", "$", "options", ")", "?", ...
Delete Exchange @param string $name a exchange name @param array $options a exchange options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Delete", "Exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L529-L541
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.bindExchange
public function bindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); } if ($exchangeName === $name) { throw new AMQPChannelException('Exchange cannot bind to itself'); } $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; $outputFrame = Exchange\ExchangeBindFrame::create( $name, $exchangeName, $routingKey, $noWait, $options ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK, $callback); } }
php
public function bindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); } if ($exchangeName === $name) { throw new AMQPChannelException('Exchange cannot bind to itself'); } $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; $outputFrame = Exchange\ExchangeBindFrame::create( $name, $exchangeName, $routingKey, $noWait, $options ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_BIND_EXCHANGE_CALLBACK, $callback); } }
[ "public", "function", "bindExchange", "(", "$", "name", ",", "$", "exchangeName", ",", "$", "routingKey", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "connec...
Bind exchange @param string $name a source exchange name @param string $exchangeName a destination exchange name @param string $routingKey a routing key @param array $options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPChannelException
[ "Bind", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L555-L580
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.unbindExchange
public function unbindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); } if ($exchangeName === $name) { throw new AMQPChannelException('Exchange cannot unbind itself'); } $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; $outputFrame = Exchange\ExchangeUnbindFrame::create( $name, $exchangeName, $routingKey, $noWait, $options ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK, $callback); } }
php
public function unbindExchange($name, $exchangeName, $routingKey, array $options = [], callable $callback = null) { if (!$this->connection->getFeatures()->exchangeToExchangeBindings) { throw new AMQPChannelException('Broker does not support exchange to exchange bindings'); } if ($exchangeName === $name) { throw new AMQPChannelException('Exchange cannot unbind itself'); } $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : false; $outputFrame = Exchange\ExchangeUnbindFrame::create( $name, $exchangeName, $routingKey, $noWait, $options ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_UNBIND_EXCHANGE_CALLBACK, $callback); } }
[ "public", "function", "unbindExchange", "(", "$", "name", ",", "$", "exchangeName", ",", "$", "routingKey", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "conn...
Unbind exchange @param string $name a source exchange name @param string $exchangeName a destination exchange name @param string $routingKey a routing key @param array $options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPChannelException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Unbind", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L594-L619
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.publish
public function publish($content, $exchangeName, $routingKey, array $options = []) { /** * Нам нужно собрать докучи три фрейма * 1. BasicPublishFrame сообщает брокеру , что будет чтото передавать. * 2. BasicHeaderFrame сообщает брокеру заголовки отправляемого сообщения * 3. BodyFrame содержит контент сообщения . Отправляется этот фрейм пачками по $this->channel->getConnection()->getMaximumFrameSize() */ $outputBasicPublishFrame = Basic\BasicPublishFrame::create( $exchangeName, $routingKey ); $outputBasicPublishFrame->frameChannelId = $this->id; $this->connection->command($outputBasicPublishFrame); $outputBasicHeaderFrame = new Basic\BasicHeaderFrame(); $outputBasicHeaderFrame->frameChannelId = $this->id; $outputBasicHeaderFrame->contentLength = array_key_exists('contentLength', $options) ? $options['contentLength'] : null; $outputBasicHeaderFrame->contentType = array_key_exists('contentType', $options) ? $options['contentType'] : null; $outputBasicHeaderFrame->contentEncoding = array_key_exists('contentEncoding', $options) ? $options['contentEncoding'] : null; $outputBasicHeaderFrame->headers = array_key_exists('headers', $options) ? $options['headers'] : null; $outputBasicHeaderFrame->messageId = array_key_exists('messageId', $options) ? $options['messageId'] : null; $outputBasicHeaderFrame->deliveryMode = array_key_exists('deliveryMode', $options) ? $options['deliveryMode'] : null; $outputBasicHeaderFrame->correlationId = array_key_exists('correlationId', $options) ? $options['correlationId'] : null; $outputBasicHeaderFrame->replyTo = array_key_exists('replyTo', $options) ? $options['replyTo'] : null; $outputBasicHeaderFrame->expiration = array_key_exists('expiration', $options) ? $options['expiration'] : null; $outputBasicHeaderFrame->timestamp = array_key_exists('timestamp', $options) ? $options['timestamp'] : null; $outputBasicHeaderFrame->type = array_key_exists('type', $options) ? $options['type'] : null; $outputBasicHeaderFrame->userId = array_key_exists('userId', $options) ? $options['userId'] : null; $outputBasicHeaderFrame->appId = array_key_exists('appId', $options) ? $options['appId'] : null; $outputBasicHeaderFrame->clusterId = array_key_exists('clusterId', $options) ? $options['clusterId'] : null; $fInfo = new \finfo(); if (null === $outputBasicHeaderFrame->contentType) { $outputBasicHeaderFrame->contentType = $fInfo->buffer($content, FILEINFO_MIME_TYPE); } if (null === $outputBasicHeaderFrame->contentEncoding) { $outputBasicHeaderFrame->contentEncoding = $fInfo->buffer($content, FILEINFO_MIME_ENCODING); } unset($fInfo); if (null === $outputBasicHeaderFrame->contentLength) { $outputBasicHeaderFrame->contentLength = strlen($content); } $this->connection->command($outputBasicHeaderFrame); $maxFrameSize = $this->connection->getMaximumFrameSize(); $length = $outputBasicHeaderFrame->contentLength; $contentBuffer = $content; while ($length) { $outputBodyFrame = new BodyFrame(); $outputBodyFrame->frameChannelId = $this->id; if ($length <= $maxFrameSize) { $outputBodyFrame->content = $contentBuffer; $contentBuffer = ''; $length = 0; } else { $outputBodyFrame->content = substr($contentBuffer, 0, $maxFrameSize); $contentBuffer = substr($contentBuffer, $maxFrameSize); $length -= $maxFrameSize; } $this->connection->command($outputBodyFrame); } }
php
public function publish($content, $exchangeName, $routingKey, array $options = []) { /** * Нам нужно собрать докучи три фрейма * 1. BasicPublishFrame сообщает брокеру , что будет чтото передавать. * 2. BasicHeaderFrame сообщает брокеру заголовки отправляемого сообщения * 3. BodyFrame содержит контент сообщения . Отправляется этот фрейм пачками по $this->channel->getConnection()->getMaximumFrameSize() */ $outputBasicPublishFrame = Basic\BasicPublishFrame::create( $exchangeName, $routingKey ); $outputBasicPublishFrame->frameChannelId = $this->id; $this->connection->command($outputBasicPublishFrame); $outputBasicHeaderFrame = new Basic\BasicHeaderFrame(); $outputBasicHeaderFrame->frameChannelId = $this->id; $outputBasicHeaderFrame->contentLength = array_key_exists('contentLength', $options) ? $options['contentLength'] : null; $outputBasicHeaderFrame->contentType = array_key_exists('contentType', $options) ? $options['contentType'] : null; $outputBasicHeaderFrame->contentEncoding = array_key_exists('contentEncoding', $options) ? $options['contentEncoding'] : null; $outputBasicHeaderFrame->headers = array_key_exists('headers', $options) ? $options['headers'] : null; $outputBasicHeaderFrame->messageId = array_key_exists('messageId', $options) ? $options['messageId'] : null; $outputBasicHeaderFrame->deliveryMode = array_key_exists('deliveryMode', $options) ? $options['deliveryMode'] : null; $outputBasicHeaderFrame->correlationId = array_key_exists('correlationId', $options) ? $options['correlationId'] : null; $outputBasicHeaderFrame->replyTo = array_key_exists('replyTo', $options) ? $options['replyTo'] : null; $outputBasicHeaderFrame->expiration = array_key_exists('expiration', $options) ? $options['expiration'] : null; $outputBasicHeaderFrame->timestamp = array_key_exists('timestamp', $options) ? $options['timestamp'] : null; $outputBasicHeaderFrame->type = array_key_exists('type', $options) ? $options['type'] : null; $outputBasicHeaderFrame->userId = array_key_exists('userId', $options) ? $options['userId'] : null; $outputBasicHeaderFrame->appId = array_key_exists('appId', $options) ? $options['appId'] : null; $outputBasicHeaderFrame->clusterId = array_key_exists('clusterId', $options) ? $options['clusterId'] : null; $fInfo = new \finfo(); if (null === $outputBasicHeaderFrame->contentType) { $outputBasicHeaderFrame->contentType = $fInfo->buffer($content, FILEINFO_MIME_TYPE); } if (null === $outputBasicHeaderFrame->contentEncoding) { $outputBasicHeaderFrame->contentEncoding = $fInfo->buffer($content, FILEINFO_MIME_ENCODING); } unset($fInfo); if (null === $outputBasicHeaderFrame->contentLength) { $outputBasicHeaderFrame->contentLength = strlen($content); } $this->connection->command($outputBasicHeaderFrame); $maxFrameSize = $this->connection->getMaximumFrameSize(); $length = $outputBasicHeaderFrame->contentLength; $contentBuffer = $content; while ($length) { $outputBodyFrame = new BodyFrame(); $outputBodyFrame->frameChannelId = $this->id; if ($length <= $maxFrameSize) { $outputBodyFrame->content = $contentBuffer; $contentBuffer = ''; $length = 0; } else { $outputBodyFrame->content = substr($contentBuffer, 0, $maxFrameSize); $contentBuffer = substr($contentBuffer, $maxFrameSize); $length -= $maxFrameSize; } $this->connection->command($outputBodyFrame); } }
[ "public", "function", "publish", "(", "$", "content", ",", "$", "exchangeName", ",", "$", "routingKey", ",", "array", "$", "options", "=", "[", "]", ")", "{", "/**\n * Нам нужно собрать докучи три фрейма\n * 1. BasicPublishFrame сообщает брокеру , что будет ...
Publish message to exchange @param string $content The message content @param string $exchangeName exchange name @param string $routingKey routing key @param array $options @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Publish", "message", "to", "exchange" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L631-L695
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.consume
public function consume($queueName, array $options = [], callable $callback) { $consumerTag = array_key_exists('consumerTag', $options) ? $options['consumerTag'] : null; $noLocal = array_key_exists('noLocal', $options) ? (bool)$options['noLocal'] : null; $noAck = array_key_exists('noAck', $options) ? (bool)$options['noAck'] : null; $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Basic\BasicConsumeFrame::create( $queueName, $consumerTag, $noLocal, $noAck, $exclusive, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, function (Basic\BasicConsumeOkFrame $incomingFrame) use ($callback) { $this->consumers[$incomingFrame->consumerTag] = $callback; }); } }
php
public function consume($queueName, array $options = [], callable $callback) { $consumerTag = array_key_exists('consumerTag', $options) ? $options['consumerTag'] : null; $noLocal = array_key_exists('noLocal', $options) ? (bool)$options['noLocal'] : null; $noAck = array_key_exists('noAck', $options) ? (bool)$options['noAck'] : null; $exclusive = array_key_exists('exclusive', $options) ? (bool)$options['exclusive'] : null; $noWait = array_key_exists('noWait', $options) ? (bool)$options['noWait'] : null; $arguments = array_key_exists('arguments', $options) ? $options['arguments'] : null; $outputFrame = Basic\BasicConsumeFrame::create( $queueName, $consumerTag, $noLocal, $noAck, $exclusive, $noWait, $arguments ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_ON_CHANNEL_CONSUMEOK_CALLBACK, function (Basic\BasicConsumeOkFrame $incomingFrame) use ($callback) { $this->consumers[$incomingFrame->consumerTag] = $callback; }); } }
[ "public", "function", "consume", "(", "$", "queueName", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", ")", "{", "$", "consumerTag", "=", "array_key_exists", "(", "'consumerTag'", ",", "$", "options", ")", "?", "$", "optio...
Bind a consumer to consume on message receive @param string $queueName a queue name @param array $options @param callable $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Bind", "a", "consumer", "to", "consume", "on", "message", "receive" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L720-L746
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.cancel
public function cancel($consumerTag, array $options = []) { $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : null; $outputFrame = Basic\BasicCancelFrame::create($consumerTag, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function cancel($consumerTag, array $options = []) { $noWait = array_key_exists('noWait', $options) ? $options['noWait'] : null; $outputFrame = Basic\BasicCancelFrame::create($consumerTag, $noWait); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "cancel", "(", "$", "consumerTag", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "noWait", "=", "array_key_exists", "(", "'noWait'", ",", "$", "options", ")", "?", "$", "options", "[", "'noWait'", "]", ":", "null", ...
Unbind consumer @param string $consumerTag @param array $options @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Unbind", "consumer" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L756-L763
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.get
public function get($queueName, array $options = [], callable $callback = null) { $noAck = array_key_exists('noAck', $options) ? $options['noAck'] : null; $outputFrame = Basic\BasicGetFrame::create( $queueName, $noAck ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_DISPATCH_MESSAGE, $callback); } }
php
public function get($queueName, array $options = [], callable $callback = null) { $noAck = array_key_exists('noAck', $options) ? $options['noAck'] : null; $outputFrame = Basic\BasicGetFrame::create( $queueName, $noAck ); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); if (is_callable($callback)) { $this->on(self::EVENT_DISPATCH_MESSAGE, $callback); } }
[ "public", "function", "get", "(", "$", "queueName", ",", "array", "$", "options", "=", "[", "]", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "noAck", "=", "array_key_exists", "(", "'noAck'", ",", "$", "options", ")", "?", "$", "opti...
get message from queue @param string $queueName a queue name @param array $options @param callable|null $callback @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "get", "message", "from", "queue" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L774-L788
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.ack
public function ack($deliveryTag, array $options = []) { $multiple = array_key_exists('multiple', $options) ? (int)$options['multiple'] : null; $outputFrame = Basic\BasicAckFrame::create($deliveryTag, $multiple); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function ack($deliveryTag, array $options = []) { $multiple = array_key_exists('multiple', $options) ? (int)$options['multiple'] : null; $outputFrame = Basic\BasicAckFrame::create($deliveryTag, $multiple); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "ack", "(", "$", "deliveryTag", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "multiple", "=", "array_key_exists", "(", "'multiple'", ",", "$", "options", ")", "?", "(", "int", ")", "$", "options", "[", "'multiple'",...
Ack message by delivery tag @param int $deliveryTag @param array $options @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Ack", "message", "by", "delivery", "tag" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L798-L805
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.nack
public function nack($deliveryTag, array $options = []) { $multiple = array_key_exists('multiple', $options) ? (int)$options['multiple'] : null; $requeue = array_key_exists('requeue', $options) ? (bool)$options['requeue'] : null; $outputFrame = Basic\BasicNackFrame::create($deliveryTag, $multiple, $requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function nack($deliveryTag, array $options = []) { $multiple = array_key_exists('multiple', $options) ? (int)$options['multiple'] : null; $requeue = array_key_exists('requeue', $options) ? (bool)$options['requeue'] : null; $outputFrame = Basic\BasicNackFrame::create($deliveryTag, $multiple, $requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "nack", "(", "$", "deliveryTag", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "multiple", "=", "array_key_exists", "(", "'multiple'", ",", "$", "options", ")", "?", "(", "int", ")", "$", "options", "[", "'multiple'"...
Nack message @param $deliveryTag @param array $options @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Nack", "message" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L815-L823
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.reject
public function reject($deliveryTag, array $options = []) { $requeue = array_key_exists('requeue', $options) ? $options['requeue'] : null; $outputFrame = Basic\BasicRejectFrame::create($deliveryTag, $requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function reject($deliveryTag, array $options = []) { $requeue = array_key_exists('requeue', $options) ? $options['requeue'] : null; $outputFrame = Basic\BasicRejectFrame::create($deliveryTag, $requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "reject", "(", "$", "deliveryTag", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "requeue", "=", "array_key_exists", "(", "'requeue'", ",", "$", "options", ")", "?", "$", "options", "[", "'requeue'", "]", ":", "null"...
Reject a message @param $deliveryTag @param array $options @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Reject", "a", "message" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L833-L840
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Channel.php
Channel.recover
public function recover($requeue = true) { $outputFrame = Basic\BasicRecoverFrame::create($requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
php
public function recover($requeue = true) { $outputFrame = Basic\BasicRecoverFrame::create($requeue); $outputFrame->frameChannelId = $this->id; $this->connection->command($outputFrame); }
[ "public", "function", "recover", "(", "$", "requeue", "=", "true", ")", "{", "$", "outputFrame", "=", "Basic", "\\", "BasicRecoverFrame", "::", "create", "(", "$", "requeue", ")", ";", "$", "outputFrame", "->", "frameChannelId", "=", "$", "this", "->", "...
Redeliver unacknowledged messages. @param bool $requeue @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Redeliver", "unacknowledged", "messages", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Channel.php#L849-L854
kakserpom/phpdaemon
PHPDaemon/Servers/HTTP/Pool.php
Pool.onConfigUpdated
public function onConfigUpdated() { parent::onConfigUpdated(); if (($order = ini_get('request_order')) || ($order = ini_get('variables_order'))) { $this->variablesOrder = $order; } else { $this->variablesOrder = null; } }
php
public function onConfigUpdated() { parent::onConfigUpdated(); if (($order = ini_get('request_order')) || ($order = ini_get('variables_order'))) { $this->variablesOrder = $order; } else { $this->variablesOrder = null; } }
[ "public", "function", "onConfigUpdated", "(", ")", "{", "parent", "::", "onConfigUpdated", "(", ")", ";", "if", "(", "(", "$", "order", "=", "ini_get", "(", "'request_order'", ")", ")", "||", "(", "$", "order", "=", "ini_get", "(", "'variables_order'", "...
Called when worker is going to update configuration. @return void
[ "Called", "when", "worker", "is", "going", "to", "update", "configuration", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/HTTP/Pool.php#L28-L37
kakserpom/phpdaemon
PHPDaemon/Servers/HTTP/Pool.php
Pool.onReady
public function onReady() { parent::onReady(); $this->WS = \PHPDaemon\Servers\WebSocket\Pool::getInstance($this->config->wssname->value, false); }
php
public function onReady() { parent::onReady(); $this->WS = \PHPDaemon\Servers\WebSocket\Pool::getInstance($this->config->wssname->value, false); }
[ "public", "function", "onReady", "(", ")", "{", "parent", "::", "onReady", "(", ")", ";", "$", "this", "->", "WS", "=", "\\", "PHPDaemon", "\\", "Servers", "\\", "WebSocket", "\\", "Pool", "::", "getInstance", "(", "$", "this", "->", "config", "->", ...
Called when the worker is ready to go. @return void
[ "Called", "when", "the", "worker", "is", "ready", "to", "go", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/HTTP/Pool.php#L43-L47
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Queue/QueueUnbindFrame.php
QueueUnbindFrame.create
public static function create( $queue = null, $exchange = null, $routingKey = null, $arguments = null ) { $frame = new self(); if (null !== $queue) { $frame->queue = $queue; } if (null !== $exchange) { $frame->exchange = $exchange; } if (null !== $routingKey) { $frame->routingKey = $routingKey; } if (null !== $arguments) { $frame->arguments = $arguments; } return $frame; }
php
public static function create( $queue = null, $exchange = null, $routingKey = null, $arguments = null ) { $frame = new self(); if (null !== $queue) { $frame->queue = $queue; } if (null !== $exchange) { $frame->exchange = $exchange; } if (null !== $routingKey) { $frame->routingKey = $routingKey; } if (null !== $arguments) { $frame->arguments = $arguments; } return $frame; }
[ "public", "static", "function", "create", "(", "$", "queue", "=", "null", ",", "$", "exchange", "=", "null", ",", "$", "routingKey", "=", "null", ",", "$", "arguments", "=", "null", ")", "{", "$", "frame", "=", "new", "self", "(", ")", ";", "if", ...
table
[ "table" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Queue/QueueUnbindFrame.php#L24-L44
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Message.php
Message.ack
public function ack() { $this->checkChannel(); $outputFrame = BasicAckFrame::create($this->tag); $outputFrame->frameChannelId = $this->channel->getId(); $this->channel->getConnection()->command($outputFrame); }
php
public function ack() { $this->checkChannel(); $outputFrame = BasicAckFrame::create($this->tag); $outputFrame->frameChannelId = $this->channel->getId(); $this->channel->getConnection()->command($outputFrame); }
[ "public", "function", "ack", "(", ")", "{", "$", "this", "->", "checkChannel", "(", ")", ";", "$", "outputFrame", "=", "BasicAckFrame", "::", "create", "(", "$", "this", "->", "tag", ")", ";", "$", "outputFrame", "->", "frameChannelId", "=", "$", "this...
Acknowledge the message. @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPMessageException
[ "Acknowledge", "the", "message", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Message.php#L137-L145
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Message.php
Message.nack
public function nack($multiple = null, $requeue = null) { $this->checkChannel(); $outputFrame = BasicNackFrame::create($this->tag, $multiple, $requeue); $outputFrame->frameChannelId = $this->channel->getId(); $this->channel->getConnection()->command($outputFrame); }
php
public function nack($multiple = null, $requeue = null) { $this->checkChannel(); $outputFrame = BasicNackFrame::create($this->tag, $multiple, $requeue); $outputFrame->frameChannelId = $this->channel->getId(); $this->channel->getConnection()->command($outputFrame); }
[ "public", "function", "nack", "(", "$", "multiple", "=", "null", ",", "$", "requeue", "=", "null", ")", "{", "$", "this", "->", "checkChannel", "(", ")", ";", "$", "outputFrame", "=", "BasicNackFrame", "::", "create", "(", "$", "this", "->", "tag", "...
Not Acknowledge the message. @param null $multiple @param null $requeue @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
[ "Not", "Acknowledge", "the", "message", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Message.php#L155-L162
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Message.php
Message.reject
public function reject($requeue = true) { $this->checkChannel(); $outputFrame = BasicRejectFrame::create($this->tag, $requeue); $outputFrame->frameChannelId = $this->channel->getId(); if (null !== $requeue) { $outputFrame->requeue = $requeue; } $this->channel->getConnection()->command($outputFrame); }
php
public function reject($requeue = true) { $this->checkChannel(); $outputFrame = BasicRejectFrame::create($this->tag, $requeue); $outputFrame->frameChannelId = $this->channel->getId(); if (null !== $requeue) { $outputFrame->requeue = $requeue; } $this->channel->getConnection()->command($outputFrame); }
[ "public", "function", "reject", "(", "$", "requeue", "=", "true", ")", "{", "$", "this", "->", "checkChannel", "(", ")", ";", "$", "outputFrame", "=", "BasicRejectFrame", "::", "create", "(", "$", "this", "->", "tag", ",", "$", "requeue", ")", ";", "...
Reject the message and requeue it. @see ConsumerOptionsInterface::$noAck to consume messages without requiring excplicit acknowledgement by the consumer. @param bool $requeue @throws \InvalidArgumentException @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPMessageException
[ "Reject", "the", "message", "and", "requeue", "it", "." ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Message.php#L175-L185
kakserpom/phpdaemon
PHPDaemon/Clients/AMQP/Message.php
Message.checkChannel
private function checkChannel() { if (!$this->channel->isConnected()) { throw new AMQPMessageException('Channel is closed'); } if (null === $this->channel->getId()) { throw new AMQPMessageException('AMQPChannel id not found'); } return true; }
php
private function checkChannel() { if (!$this->channel->isConnected()) { throw new AMQPMessageException('Channel is closed'); } if (null === $this->channel->getId()) { throw new AMQPMessageException('AMQPChannel id not found'); } return true; }
[ "private", "function", "checkChannel", "(", ")", "{", "if", "(", "!", "$", "this", "->", "channel", "->", "isConnected", "(", ")", ")", "{", "throw", "new", "AMQPMessageException", "(", "'Channel is closed'", ")", ";", "}", "if", "(", "null", "===", "$",...
Проеряет, что канал еще жив @throws AMQPMessageException
[ "Проеряет", "что", "канал", "еще", "жив" ]
train
https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Message.php#L372-L383
squareboat/sneaker
src/SneakerServiceProvider.php
SneakerServiceProvider.boot
public function boot() { $this->loadViewsFrom(__DIR__ . '/../resources/views', 'sneaker'); $this->publishes([ __DIR__ . '/../resources/views/email' => resource_path('views/vendor/sneaker/email') ], 'views'); $this->publishes([ __DIR__.'/../config/sneaker.php' => config_path('sneaker.php'), ], 'config'); if ($this->app->runningInConsole()) { $this->commands([ \SquareBoat\Sneaker\Commands\Sneak::class, ]); } }
php
public function boot() { $this->loadViewsFrom(__DIR__ . '/../resources/views', 'sneaker'); $this->publishes([ __DIR__ . '/../resources/views/email' => resource_path('views/vendor/sneaker/email') ], 'views'); $this->publishes([ __DIR__.'/../config/sneaker.php' => config_path('sneaker.php'), ], 'config'); if ($this->app->runningInConsole()) { $this->commands([ \SquareBoat\Sneaker\Commands\Sneak::class, ]); } }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/../resources/views'", ",", "'sneaker'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../resources/views/email'", "=>", "resource_...
Bootstrap the application services. @return void
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/SneakerServiceProvider.php#L21-L38
squareboat/sneaker
src/SneakerServiceProvider.php
SneakerServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__.'/../config/sneaker.php', 'sneaker' ); $this->app->singleton('sneaker', function () { return $this->app->make(Sneaker::class); }); }
php
public function register() { $this->mergeConfigFrom( __DIR__.'/../config/sneaker.php', 'sneaker' ); $this->app->singleton('sneaker', function () { return $this->app->make(Sneaker::class); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../config/sneaker.php'", ",", "'sneaker'", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'sneaker'", ",", "function", "(", ")", "{...
Register the application services. @return void
[ "Register", "the", "application", "services", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/SneakerServiceProvider.php#L45-L54
squareboat/sneaker
src/Commands/Sneak.php
Sneak.handle
public function handle() { $this->overrideConfig(); try { app('sneaker')->captureException(new DummyException, true); $this->info('Sneaker is working fine ✅'); } catch (Exception $e) { (new ConsoleApplication)->renderException($e, $this->output); } }
php
public function handle() { $this->overrideConfig(); try { app('sneaker')->captureException(new DummyException, true); $this->info('Sneaker is working fine ✅'); } catch (Exception $e) { (new ConsoleApplication)->renderException($e, $this->output); } }
[ "public", "function", "handle", "(", ")", "{", "$", "this", "->", "overrideConfig", "(", ")", ";", "try", "{", "app", "(", "'sneaker'", ")", "->", "captureException", "(", "new", "DummyException", ",", "true", ")", ";", "$", "this", "->", "info", "(", ...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/Commands/Sneak.php#L52-L63
squareboat/sneaker
src/ExceptionHandler.php
ExceptionHandler.convertExceptionToHtml
public function convertExceptionToHtml($exception) { $flat = $this->getFlattenedException($exception); $handler = new SymfonyExceptionHandler(); return $this->decorate($handler->getContent($flat), $handler->getStylesheet($flat), $flat); }
php
public function convertExceptionToHtml($exception) { $flat = $this->getFlattenedException($exception); $handler = new SymfonyExceptionHandler(); return $this->decorate($handler->getContent($flat), $handler->getStylesheet($flat), $flat); }
[ "public", "function", "convertExceptionToHtml", "(", "$", "exception", ")", "{", "$", "flat", "=", "$", "this", "->", "getFlattenedException", "(", "$", "exception", ")", ";", "$", "handler", "=", "new", "SymfonyExceptionHandler", "(", ")", ";", "return", "$...
Create a html for the given exception. @param \Exception $exception @return string
[ "Create", "a", "html", "for", "the", "given", "exception", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/ExceptionHandler.php#L46-L53
squareboat/sneaker
src/ExceptionHandler.php
ExceptionHandler.decorate
private function decorate($content, $css, $exception) { $content = $this->removeTitle($content); return $this->view->make('sneaker::email.body', compact('content', 'css', 'exception'))->render(); }
php
private function decorate($content, $css, $exception) { $content = $this->removeTitle($content); return $this->view->make('sneaker::email.body', compact('content', 'css', 'exception'))->render(); }
[ "private", "function", "decorate", "(", "$", "content", ",", "$", "css", ",", "$", "exception", ")", "{", "$", "content", "=", "$", "this", "->", "removeTitle", "(", "$", "content", ")", ";", "return", "$", "this", "->", "view", "->", "make", "(", ...
Get the html response content. @param string $content @param string $css @return string
[ "Get", "the", "html", "response", "content", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/ExceptionHandler.php#L77-L82
squareboat/sneaker
src/ExceptionHandler.php
ExceptionHandler.removeTitle
private function removeTitle($content) { $titles = [ 'Whoops, looks like something went wrong.', 'Sorry, the page you are looking for could not be found.', ]; foreach ($titles as $title) { $content = str_replace("<h1>{$title}</h1>", '', $content); } return $content; }
php
private function removeTitle($content) { $titles = [ 'Whoops, looks like something went wrong.', 'Sorry, the page you are looking for could not be found.', ]; foreach ($titles as $title) { $content = str_replace("<h1>{$title}</h1>", '', $content); } return $content; }
[ "private", "function", "removeTitle", "(", "$", "content", ")", "{", "$", "titles", "=", "[", "'Whoops, looks like something went wrong.'", ",", "'Sorry, the page you are looking for could not be found.'", ",", "]", ";", "foreach", "(", "$", "titles", "as", "$", "titl...
Removes title from content as it is same for all exceptions and has no real value. @param string $content @return string
[ "Removes", "title", "from", "content", "as", "it", "is", "same", "for", "all", "exceptions", "and", "has", "no", "real", "value", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/ExceptionHandler.php#L90-L102
squareboat/sneaker
src/Sneaker.php
Sneaker.captureException
public function captureException(Exception $exception, $sneaking = false) { try { if ($this->isSilent()) { return; } if ($this->isExceptionFromBot()) { return; } if ($this->shouldCapture($exception)) { $this->capture($exception); } } catch (Exception $e) { $this->logger->error(sprintf( 'Exception thrown in Sneaker when capturing an exception (%s: %s)', get_class($e), $e->getMessage() )); $this->logger->error($e); if ($sneaking) { throw $e; } } }
php
public function captureException(Exception $exception, $sneaking = false) { try { if ($this->isSilent()) { return; } if ($this->isExceptionFromBot()) { return; } if ($this->shouldCapture($exception)) { $this->capture($exception); } } catch (Exception $e) { $this->logger->error(sprintf( 'Exception thrown in Sneaker when capturing an exception (%s: %s)', get_class($e), $e->getMessage() )); $this->logger->error($e); if ($sneaking) { throw $e; } } }
[ "public", "function", "captureException", "(", "Exception", "$", "exception", ",", "$", "sneaking", "=", "false", ")", "{", "try", "{", "if", "(", "$", "this", "->", "isSilent", "(", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", ...
Checks an exception which should be tracked and captures it if applicable. @param \Exception $exception @return void
[ "Checks", "an", "exception", "which", "should", "be", "tracked", "and", "captures", "it", "if", "applicable", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/Sneaker.php#L69-L95
squareboat/sneaker
src/Sneaker.php
Sneaker.capture
private function capture($exception) { $recipients = $this->config->get('sneaker.to'); $subject = $this->handler->convertExceptionToString($exception); $body = $this->handler->convertExceptionToHtml($exception); $this->mailer->to($recipients)->send(new ExceptionMailer($subject, $body)); }
php
private function capture($exception) { $recipients = $this->config->get('sneaker.to'); $subject = $this->handler->convertExceptionToString($exception); $body = $this->handler->convertExceptionToHtml($exception); $this->mailer->to($recipients)->send(new ExceptionMailer($subject, $body)); }
[ "private", "function", "capture", "(", "$", "exception", ")", "{", "$", "recipients", "=", "$", "this", "->", "config", "->", "get", "(", "'sneaker.to'", ")", ";", "$", "subject", "=", "$", "this", "->", "handler", "->", "convertExceptionToString", "(", ...
Capture an exception. @param \Exception $exception @return void
[ "Capture", "an", "exception", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/Sneaker.php#L103-L112
squareboat/sneaker
src/Sneaker.php
Sneaker.shouldCapture
private function shouldCapture(Exception $exception) { $capture = $this->config->get('sneaker.capture'); if (! is_array($capture)) { return false; } if (in_array('*', $capture)) { return true; } foreach ($capture as $type) { if ($exception instanceof $type) { return true; } } return false; }
php
private function shouldCapture(Exception $exception) { $capture = $this->config->get('sneaker.capture'); if (! is_array($capture)) { return false; } if (in_array('*', $capture)) { return true; } foreach ($capture as $type) { if ($exception instanceof $type) { return true; } } return false; }
[ "private", "function", "shouldCapture", "(", "Exception", "$", "exception", ")", "{", "$", "capture", "=", "$", "this", "->", "config", "->", "get", "(", "'sneaker.capture'", ")", ";", "if", "(", "!", "is_array", "(", "$", "capture", ")", ")", "{", "re...
Determine if the exception is in the "capture" list. @param Exception $exception @return boolean
[ "Determine", "if", "the", "exception", "is", "in", "the", "capture", "list", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/Sneaker.php#L130-L149
squareboat/sneaker
src/Sneaker.php
Sneaker.isExceptionFromBot
private function isExceptionFromBot() { $ignored_bots = $this->config->get('sneaker.ignored_bots'); $agent = array_key_exists('HTTP_USER_AGENT', $_SERVER) ? strtolower($_SERVER['HTTP_USER_AGENT']) : null; if (is_null($agent)) { return false; } foreach ($ignored_bots as $bot) { if ((strpos($agent, $bot) !== false)) { return true; } } return false; }
php
private function isExceptionFromBot() { $ignored_bots = $this->config->get('sneaker.ignored_bots'); $agent = array_key_exists('HTTP_USER_AGENT', $_SERVER) ? strtolower($_SERVER['HTTP_USER_AGENT']) : null; if (is_null($agent)) { return false; } foreach ($ignored_bots as $bot) { if ((strpos($agent, $bot) !== false)) { return true; } } return false; }
[ "private", "function", "isExceptionFromBot", "(", ")", "{", "$", "ignored_bots", "=", "$", "this", "->", "config", "->", "get", "(", "'sneaker.ignored_bots'", ")", ";", "$", "agent", "=", "array_key_exists", "(", "'HTTP_USER_AGENT'", ",", "$", "_SERVER", ")", ...
Determine if the exception is from the bot. @return boolean
[ "Determine", "if", "the", "exception", "is", "from", "the", "bot", "." ]
train
https://github.com/squareboat/sneaker/blob/618a8c5dfc7852a83b523b65c5485e21acfdf03d/src/Sneaker.php#L156-L175
TheNetworg/oauth2-azure
src/Provider/AzureResourceOwner.php
AzureResourceOwner.claim
public function claim($name) { return isset($this->data[$name]) ? $this->data[$name] : null; }
php
public function claim($name) { return isset($this->data[$name]) ? $this->data[$name] : null; }
[ "public", "function", "claim", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "data", "[", "$", "name", "]", ")", "?", "$", "this", "->", "data", "[", "$", "name", "]", ":", "null", ";", "}" ]
Returns a field from the parsed JWT data. @param string $name @return mixed|null
[ "Returns", "a", "field", "from", "the", "parsed", "JWT", "data", "." ]
train
https://github.com/TheNetworg/oauth2-azure/blob/1bd78900f8048c9493b6f27a2e4409ee62a5718a/src/Provider/AzureResourceOwner.php#L83-L86
TheNetworg/oauth2-azure
src/Provider/Azure.php
Azure.validateAccessToken
public function validateAccessToken($accessToken) { $keys = $this->getJwtVerificationKeys(); $tokenClaims = (array)JWT::decode($accessToken, $keys, ['RS256']); if ($this->getClientId() != $tokenClaims['aud'] && $this->getClientId() != $tokenClaims['appid']) { throw new \RuntimeException('The client_id / audience is invalid!'); } if ($tokenClaims['nbf'] > time() || $tokenClaims['exp'] < time()) { // Additional validation is being performed in firebase/JWT itself throw new \RuntimeException('The id_token is invalid!'); } if ('common' == $this->tenant) { $this->tenant = $tokenClaims['tid']; $tenant = $this->getTenantDetails($this->tenant); if ($tokenClaims['iss'] != $tenant['issuer']) { throw new \RuntimeException('Invalid token issuer!'); } } else { $tenant = $this->getTenantDetails($this->tenant); if ($tokenClaims['iss'] != $tenant['issuer']) { throw new \RuntimeException('Invalid token issuer!'); } } return $tokenClaims; }
php
public function validateAccessToken($accessToken) { $keys = $this->getJwtVerificationKeys(); $tokenClaims = (array)JWT::decode($accessToken, $keys, ['RS256']); if ($this->getClientId() != $tokenClaims['aud'] && $this->getClientId() != $tokenClaims['appid']) { throw new \RuntimeException('The client_id / audience is invalid!'); } if ($tokenClaims['nbf'] > time() || $tokenClaims['exp'] < time()) { // Additional validation is being performed in firebase/JWT itself throw new \RuntimeException('The id_token is invalid!'); } if ('common' == $this->tenant) { $this->tenant = $tokenClaims['tid']; $tenant = $this->getTenantDetails($this->tenant); if ($tokenClaims['iss'] != $tenant['issuer']) { throw new \RuntimeException('Invalid token issuer!'); } } else { $tenant = $this->getTenantDetails($this->tenant); if ($tokenClaims['iss'] != $tenant['issuer']) { throw new \RuntimeException('Invalid token issuer!'); } } return $tokenClaims; }
[ "public", "function", "validateAccessToken", "(", "$", "accessToken", ")", "{", "$", "keys", "=", "$", "this", "->", "getJwtVerificationKeys", "(", ")", ";", "$", "tokenClaims", "=", "(", "array", ")", "JWT", "::", "decode", "(", "$", "accessToken", ",", ...
Validate the access token you received in your application. @param $accessToken string The access token you received in the authorization header. @return array
[ "Validate", "the", "access", "token", "you", "received", "in", "your", "application", "." ]
train
https://github.com/TheNetworg/oauth2-azure/blob/1bd78900f8048c9493b6f27a2e4409ee62a5718a/src/Provider/Azure.php#L202-L230
TheNetworg/oauth2-azure
src/Provider/Azure.php
Azure.getJwtVerificationKeys
public function getJwtVerificationKeys() { $factory = $this->getRequestFactory(); $request = $factory->getRequestWithOptions('get', 'https://login.windows.net/common/discovery/keys', []); $response = $this->getParsedResponse($request); $keys = []; foreach ($response['keys'] as $i => $keyinfo) { if (isset($keyinfo['x5c']) && is_array($keyinfo['x5c'])) { foreach ($keyinfo['x5c'] as $encodedkey) { $cert = '-----BEGIN CERTIFICATE-----' . PHP_EOL . chunk_split($encodedkey, 64, PHP_EOL) . '-----END CERTIFICATE-----' . PHP_EOL; $cert_object = openssl_x509_read($cert); if ($cert_object === false) { throw new \RuntimeException('An attempt to read ' . $encodedkey . ' as a certificate failed.'); } $pkey_object = openssl_pkey_get_public($cert_object); if ($pkey_object === false) { throw new \RuntimeException('An attempt to read a public key from a ' . $encodedkey . ' certificate failed.'); } $pkey_array = openssl_pkey_get_details($pkey_object); if ($pkey_array === false) { throw new \RuntimeException('An attempt to get a public key as an array from a ' . $encodedkey . ' certificate failed.'); } $publicKey = $pkey_array ['key']; $keys[$keyinfo['kid']] = $publicKey; } } } return $keys; }
php
public function getJwtVerificationKeys() { $factory = $this->getRequestFactory(); $request = $factory->getRequestWithOptions('get', 'https://login.windows.net/common/discovery/keys', []); $response = $this->getParsedResponse($request); $keys = []; foreach ($response['keys'] as $i => $keyinfo) { if (isset($keyinfo['x5c']) && is_array($keyinfo['x5c'])) { foreach ($keyinfo['x5c'] as $encodedkey) { $cert = '-----BEGIN CERTIFICATE-----' . PHP_EOL . chunk_split($encodedkey, 64, PHP_EOL) . '-----END CERTIFICATE-----' . PHP_EOL; $cert_object = openssl_x509_read($cert); if ($cert_object === false) { throw new \RuntimeException('An attempt to read ' . $encodedkey . ' as a certificate failed.'); } $pkey_object = openssl_pkey_get_public($cert_object); if ($pkey_object === false) { throw new \RuntimeException('An attempt to read a public key from a ' . $encodedkey . ' certificate failed.'); } $pkey_array = openssl_pkey_get_details($pkey_object); if ($pkey_array === false) { throw new \RuntimeException('An attempt to get a public key as an array from a ' . $encodedkey . ' certificate failed.'); } $publicKey = $pkey_array ['key']; $keys[$keyinfo['kid']] = $publicKey; } } } return $keys; }
[ "public", "function", "getJwtVerificationKeys", "(", ")", "{", "$", "factory", "=", "$", "this", "->", "getRequestFactory", "(", ")", ";", "$", "request", "=", "$", "factory", "->", "getRequestWithOptions", "(", "'get'", ",", "'https://login.windows.net/common/dis...
Get JWT verification keys from Azure Active Directory. @return array
[ "Get", "JWT", "verification", "keys", "from", "Azure", "Active", "Directory", "." ]
train
https://github.com/TheNetworg/oauth2-azure/blob/1bd78900f8048c9493b6f27a2e4409ee62a5718a/src/Provider/Azure.php#L237-L279
TheNetworg/oauth2-azure
src/Provider/Azure.php
Azure.getTenantDetails
public function getTenantDetails($tenant) { $factory = $this->getRequestFactory(); $request = $factory->getRequestWithOptions( 'get', 'https://login.windows.net/' . $tenant . '/.well-known/openid-configuration', [] ); $response = $this->getParsedResponse($request); return $response; }
php
public function getTenantDetails($tenant) { $factory = $this->getRequestFactory(); $request = $factory->getRequestWithOptions( 'get', 'https://login.windows.net/' . $tenant . '/.well-known/openid-configuration', [] ); $response = $this->getParsedResponse($request); return $response; }
[ "public", "function", "getTenantDetails", "(", "$", "tenant", ")", "{", "$", "factory", "=", "$", "this", "->", "getRequestFactory", "(", ")", ";", "$", "request", "=", "$", "factory", "->", "getRequestWithOptions", "(", "'get'", ",", "'https://login.windows.n...
Get the specified tenant's details. @param string $tenant @return array
[ "Get", "the", "specified", "tenant", "s", "details", "." ]
train
https://github.com/TheNetworg/oauth2-azure/blob/1bd78900f8048c9493b6f27a2e4409ee62a5718a/src/Provider/Azure.php#L288-L300
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.inheritFromParent
protected function inheritFromParent(BaseQuery $parent) { parent::inheritFromParent($parent); if ($parent instanceof Select) { $parent->copyTo($this); } }
php
protected function inheritFromParent(BaseQuery $parent) { parent::inheritFromParent($parent); if ($parent instanceof Select) { $parent->copyTo($this); } }
[ "protected", "function", "inheritFromParent", "(", "BaseQuery", "$", "parent", ")", "{", "parent", "::", "inheritFromParent", "(", "$", "parent", ")", ";", "if", "(", "$", "parent", "instanceof", "Select", ")", "{", "$", "parent", "->", "copyTo", "(", "$",...
Inherit property values from parent query @param BaseQuery $parent @return void
[ "Inherit", "property", "values", "from", "parent", "query" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L73-L80
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.copyTo
public function copyTo(Select $query) { $query->fields = $this->fields; $query->distinct = $this->distinct; $query->orders = $this->orders; $query->groups = $this->groups; $query->joins = $this->joins; $query->groupResults = $this->groupResults; $query->forwardKey = $this->forwardKey; }
php
public function copyTo(Select $query) { $query->fields = $this->fields; $query->distinct = $this->distinct; $query->orders = $this->orders; $query->groups = $this->groups; $query->joins = $this->joins; $query->groupResults = $this->groupResults; $query->forwardKey = $this->forwardKey; }
[ "public", "function", "copyTo", "(", "Select", "$", "query", ")", "{", "$", "query", "->", "fields", "=", "$", "this", "->", "fields", ";", "$", "query", "->", "distinct", "=", "$", "this", "->", "distinct", ";", "$", "query", "->", "orders", "=", ...
Copy current queries select attributes to the given one @param Select $query
[ "Copy", "current", "queries", "select", "attributes", "to", "the", "given", "one" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L87-L96
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.fields
public function fields($fields) { // we always have to reset the fields $this->fields = array(); // when a string is given if (is_string($fields)) { $fields = $this->stringArgumentToArray($fields); } // it also could be an object elseif (is_object($fields)) { return $this->addField($fields); } // do nothing if we get nothing if (empty($fields) || $fields === array('*') || $fields === array('')) { return $this; } // add the fields foreach($fields as $key => $field) { // when we have a string as key we have an alias definition if (is_string($key)) { $this->addField($key, $field); } else { $this->addField($field); } } return $this; }
php
public function fields($fields) { // we always have to reset the fields $this->fields = array(); // when a string is given if (is_string($fields)) { $fields = $this->stringArgumentToArray($fields); } // it also could be an object elseif (is_object($fields)) { return $this->addField($fields); } // do nothing if we get nothing if (empty($fields) || $fields === array('*') || $fields === array('')) { return $this; } // add the fields foreach($fields as $key => $field) { // when we have a string as key we have an alias definition if (is_string($key)) { $this->addField($key, $field); } else { $this->addField($field); } } return $this; }
[ "public", "function", "fields", "(", "$", "fields", ")", "{", "// we always have to reset the fields", "$", "this", "->", "fields", "=", "array", "(", ")", ";", "// when a string is given", "if", "(", "is_string", "(", "$", "fields", ")", ")", "{", "$", "fie...
Set the selected fields fields ->fields('title') ->fields(['id', 'name']) ->fields('id, name, created_at as created') @param array $values @return self The current query builder.
[ "Set", "the", "selected", "fields", "fields" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L121-L153
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldCount
public function addFieldCount($field, $alias = null) { $this->addField(new Func('count', $field), $alias); return $this; }
php
public function addFieldCount($field, $alias = null) { $this->addField(new Func('count', $field), $alias); return $this; }
[ "public", "function", "addFieldCount", "(", "$", "field", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'count'", ",", "$", "field", ")", ",", "$", "alias", ")", ";", "return", "$", "this", ";", ...
Shortcut to add a count function ->addFieldCount('id') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "count", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L178-L181
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldMax
public function addFieldMax($field, $alias = null) { $this->addField(new Func('max', $field), $alias); return $this; }
php
public function addFieldMax($field, $alias = null) { $this->addField(new Func('max', $field), $alias); return $this; }
[ "public", "function", "addFieldMax", "(", "$", "field", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'max'", ",", "$", "field", ")", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}...
Shortcut to add a max function ->addFieldMax('views') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "max", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L192-L195
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldMin
public function addFieldMin($field, $alias = null) { $this->addField(new Func('min', $field), $alias); return $this; }
php
public function addFieldMin($field, $alias = null) { $this->addField(new Func('min', $field), $alias); return $this; }
[ "public", "function", "addFieldMin", "(", "$", "field", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'min'", ",", "$", "field", ")", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}...
Shortcut to add a min function ->addFieldMin('views') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "min", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L206-L209
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldSum
public function addFieldSum($field, $alias = null) { $this->addField(new Func('sum', $field), $alias); return $this; }
php
public function addFieldSum($field, $alias = null) { $this->addField(new Func('sum', $field), $alias); return $this; }
[ "public", "function", "addFieldSum", "(", "$", "field", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'sum'", ",", "$", "field", ")", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}...
Shortcut to add a sum function ->addFieldSum('views') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "sum", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L220-L223
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldAvg
public function addFieldAvg($field, $alias = null) { $this->addField(new Func('avg', $field), $alias); return $this; }
php
public function addFieldAvg($field, $alias = null) { $this->addField(new Func('avg', $field), $alias); return $this; }
[ "public", "function", "addFieldAvg", "(", "$", "field", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'avg'", ",", "$", "field", ")", ",", "$", "alias", ")", ";", "return", "$", "this", ";", "}...
Shortcut to add a avg function ->addFieldAvg('views') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "avg", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L234-L237
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.addFieldRound
public function addFieldRound($field, $decimals = 0, $alias = null) { $this->addField(new Func('round', $field, new Expression((int)$decimals)), $alias); return $this; }
php
public function addFieldRound($field, $decimals = 0, $alias = null) { $this->addField(new Func('round', $field, new Expression((int)$decimals)), $alias); return $this; }
[ "public", "function", "addFieldRound", "(", "$", "field", ",", "$", "decimals", "=", "0", ",", "$", "alias", "=", "null", ")", "{", "$", "this", "->", "addField", "(", "new", "Func", "(", "'round'", ",", "$", "field", ",", "new", "Expression", "(", ...
Shortcut to add a price function ->addFieldRound('price') @param string $field @param string $alias @return self The current query builder.
[ "Shortcut", "to", "add", "a", "price", "function" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L248-L251
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.orderBy
public function orderBy($columns, $direction = 'asc') { if (is_string($columns)) { $columns = $this->stringArgumentToArray($columns); } elseif ($columns instanceof Expression) { $this->orders[] = array($columns, $direction); return $this; } foreach ($columns as $key => $column) { if (is_numeric($key)) { if ($column instanceof Expression) { $this->orders[] = array($column, $direction); } else { $this->orders[$column] = $direction; } } else { $this->orders[$key] = $column; } } return $this; }
php
public function orderBy($columns, $direction = 'asc') { if (is_string($columns)) { $columns = $this->stringArgumentToArray($columns); } elseif ($columns instanceof Expression) { $this->orders[] = array($columns, $direction); return $this; } foreach ($columns as $key => $column) { if (is_numeric($key)) { if ($column instanceof Expression) { $this->orders[] = array($column, $direction); } else { $this->orders[$column] = $direction; } } else { $this->orders[$key] = $column; } } return $this; }
[ "public", "function", "orderBy", "(", "$", "columns", ",", "$", "direction", "=", "'asc'", ")", "{", "if", "(", "is_string", "(", "$", "columns", ")", ")", "{", "$", "columns", "=", "$", "this", "->", "stringArgumentToArray", "(", "$", "columns", ")", ...
Add an order by statement to the current query ->orderBy('created_at') ->orderBy('modified_at', 'desc') // multiple order statements ->orderBy(['firstname', 'lastname'], 'desc') // muliple order statements with diffrent directions ->orderBy(['firstname' => 'asc', 'lastname' => 'desc']) @param array|string $cols @param string $order @return self The current query builder.
[ "Add", "an", "order", "by", "statement", "to", "the", "current", "query" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L269-L296
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.groupBy
public function groupBy($groupKeys) { if (is_string($groupKeys)) { $groupKeys = $this->stringArgumentToArray($groupKeys); } foreach ($groupKeys as $groupKey) { $this->groups[] = $groupKey; } return $this; }
php
public function groupBy($groupKeys) { if (is_string($groupKeys)) { $groupKeys = $this->stringArgumentToArray($groupKeys); } foreach ($groupKeys as $groupKey) { $this->groups[] = $groupKey; } return $this; }
[ "public", "function", "groupBy", "(", "$", "groupKeys", ")", "{", "if", "(", "is_string", "(", "$", "groupKeys", ")", ")", "{", "$", "groupKeys", "=", "$", "this", "->", "stringArgumentToArray", "(", "$", "groupKeys", ")", ";", "}", "foreach", "(", "$"...
Add a group by statement to the current query ->groupBy('category') ->gorupBy(['category', 'price']) @param array|string $keys @return self The current query builder.
[ "Add", "a", "group", "by", "statement", "to", "the", "current", "query" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L307-L320
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.join
public function join($table, $localKey, $operator = null, $referenceKey = null, $type = 'left') { // validate the join type if (!in_array($type, array('inner', 'left', 'right', 'outer'))) { throw new Exception('Invalid join type "'.$type.'" given. Available type: inner, left, right, outer'); } // to make nested joins possible you can pass an closure // wich will create a new query where you can add your nested wheres if (is_object($localKey) && ($localKey instanceof \Closure)) { // create new query object $subquery = new SelectJoin; // run the closure callback on the sub query call_user_func_array($localKey, array(&$subquery)); // add the join $this->joins[] = array($type, $table, $subquery); return $this; } $this->joins[] = array($type, $table, $localKey, $operator, $referenceKey); return $this; }
php
public function join($table, $localKey, $operator = null, $referenceKey = null, $type = 'left') { // validate the join type if (!in_array($type, array('inner', 'left', 'right', 'outer'))) { throw new Exception('Invalid join type "'.$type.'" given. Available type: inner, left, right, outer'); } // to make nested joins possible you can pass an closure // wich will create a new query where you can add your nested wheres if (is_object($localKey) && ($localKey instanceof \Closure)) { // create new query object $subquery = new SelectJoin; // run the closure callback on the sub query call_user_func_array($localKey, array(&$subquery)); // add the join $this->joins[] = array($type, $table, $subquery); return $this; } $this->joins[] = array($type, $table, $localKey, $operator, $referenceKey); return $this; }
[ "public", "function", "join", "(", "$", "table", ",", "$", "localKey", ",", "$", "operator", "=", "null", ",", "$", "referenceKey", "=", "null", ",", "$", "type", "=", "'left'", ")", "{", "// validate the join type", "if", "(", "!", "in_array", "(", "$...
Add a join statement to the current query ->join('avatars', 'users.id', '=', 'avatars.user_id') @param array|string $table The table to join. (can contain an alias definition.) @param string $localKey @param string $operator The operator (=, !=, <, > etc.) @param string $referenceKey @param string $type The join type (inner, left, right, outer) @return self The current query builder.
[ "Add", "a", "join", "statement", "to", "the", "current", "query" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L335-L358
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.leftJoin
public function leftJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'left'); }
php
public function leftJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'left'); }
[ "public", "function", "leftJoin", "(", "$", "table", ",", "$", "localKey", ",", "$", "operator", "=", "null", ",", "$", "referenceKey", "=", "null", ")", "{", "return", "$", "this", "->", "join", "(", "$", "table", ",", "$", "localKey", ",", "$", "...
Left join same as join with special type @param array|string $table The table to join. (can contain an alias definition.) @param string $localKey @param string $operator The operator (=, !=, <, > etc.) @param string $referenceKey @return self The current query builder.
[ "Left", "join", "same", "as", "join", "with", "special", "type" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L370-L373
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.rightJoin
public function rightJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'right'); }
php
public function rightJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'right'); }
[ "public", "function", "rightJoin", "(", "$", "table", ",", "$", "localKey", ",", "$", "operator", "=", "null", ",", "$", "referenceKey", "=", "null", ")", "{", "return", "$", "this", "->", "join", "(", "$", "table", ",", "$", "localKey", ",", "$", ...
Alias of the `join` method with join type right. @param array|string $table The table to join. (can contain an alias definition.) @param string $localKey @param string $operator The operator (=, !=, <, > etc.) @param string $referenceKey @return self The current query builder.
[ "Alias", "of", "the", "join", "method", "with", "join", "type", "right", "." ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L385-L388
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.innerJoin
public function innerJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'inner'); }
php
public function innerJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'inner'); }
[ "public", "function", "innerJoin", "(", "$", "table", ",", "$", "localKey", ",", "$", "operator", "=", "null", ",", "$", "referenceKey", "=", "null", ")", "{", "return", "$", "this", "->", "join", "(", "$", "table", ",", "$", "localKey", ",", "$", ...
Alias of the `join` method with join type inner. @param array|string $table The table to join. (can contain an alias definition.) @param string $localKey @param string $operator The operator (=, !=, <, > etc.) @param string $referenceKey @return self The current query builder.
[ "Alias", "of", "the", "join", "method", "with", "join", "type", "inner", "." ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L400-L403
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.outerJoin
public function outerJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'outer'); }
php
public function outerJoin($table, $localKey, $operator = null, $referenceKey = null) { return $this->join($table, $localKey, $operator, $referenceKey, 'outer'); }
[ "public", "function", "outerJoin", "(", "$", "table", ",", "$", "localKey", ",", "$", "operator", "=", "null", ",", "$", "referenceKey", "=", "null", ")", "{", "return", "$", "this", "->", "join", "(", "$", "table", ",", "$", "localKey", ",", "$", ...
Alias of the `join` method with join type outer. @param array|string $table The table to join. (can contain an alias definition.) @param string $localKey @param string $operator The operator (=, !=, <, > etc.) @param string $referenceKey @return self The current query builder.
[ "Alias", "of", "the", "join", "method", "with", "join", "type", "outer", "." ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L415-L418
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.forwardKey
public function forwardKey($key = true) { if ($key === false) { $this->forwardKey = false; } elseif ($key === true) { $this->forwardKey = \ClanCats::$config->get('database.default_primary_key', 'id'); } else { $this->forwardKey = $key; } return $this; }
php
public function forwardKey($key = true) { if ($key === false) { $this->forwardKey = false; } elseif ($key === true) { $this->forwardKey = \ClanCats::$config->get('database.default_primary_key', 'id'); } else { $this->forwardKey = $key; } return $this; }
[ "public", "function", "forwardKey", "(", "$", "key", "=", "true", ")", "{", "if", "(", "$", "key", "===", "false", ")", "{", "$", "this", "->", "forwardKey", "=", "false", ";", "}", "elseif", "(", "$", "key", "===", "true", ")", "{", "$", "this",...
Forward a result value as array key @param string|bool $key @return self The current query builder.
[ "Forward", "a", "result", "value", "as", "array", "key" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L426-L437
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.groupResults
public function groupResults($key) { if ($key === false) { $this->groupResults = false; } else { $this->groupResults = $key; } return $this; }
php
public function groupResults($key) { if ($key === false) { $this->groupResults = false; } else { $this->groupResults = $key; } return $this; }
[ "public", "function", "groupResults", "(", "$", "key", ")", "{", "if", "(", "$", "key", "===", "false", ")", "{", "$", "this", "->", "groupResults", "=", "false", ";", "}", "else", "{", "$", "this", "->", "groupResults", "=", "$", "key", ";", "}", ...
Group results by a column example: array( 'name' => 'John', 'age' => 18, ), array( 'name' => 'Jeff', 'age' => 32, ), array( 'name' => 'Jenny', 'age' => 18, ), To: '18' => array( array( 'name' => 'John', 'age' => 18 ), array( 'name' => 'Jenny', 'age' => 18 ), ), '32' => array( array( 'name' => 'Jeff', 'age' => 32 ), ), @param string|bool $key @return self The current query builder.
[ "Group", "results", "by", "a", "column" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L458-L467
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.get
public function get() { // run the callbacks to retirve the results $results = $this->executeResultFetcher(); // we always exprect an array here! if (!is_array($results) || empty($results)) { $results = array(); } // In case we should forward a key means using a value // from every result as array key. if ((!empty($results)) && $this->forwardKey !== false && is_string($this->forwardKey)) { $rawResults = $results; $results = array(); // check if the collection is beeing fetched // as an associated array if (!is_array(reset($rawResults))) { throw new Exception('Cannot forward key, the result is no associated array.'); } foreach ($rawResults as $result) { $results[$result[$this->forwardKey]] = $result; } } // Group the resuls by a items value if ((!empty($results)) && $this->groupResults !== false && is_string($this->groupResults)) { $rawResults = $results; $results = array(); // check if the collection is beeing fetched // as an associated array if (!is_array(reset($rawResults))) { throw new Exception('Cannot forward key, the result is no associated array.'); } foreach ($rawResults as $key => $result) { $results[$result[$this->groupResults]][$key] = $result; } } // when the limit is specified to exactly one result we // return directly that one result instead of the entire array if ($this->limit === 1) { $results = reset($results); } return $results; }
php
public function get() { // run the callbacks to retirve the results $results = $this->executeResultFetcher(); // we always exprect an array here! if (!is_array($results) || empty($results)) { $results = array(); } // In case we should forward a key means using a value // from every result as array key. if ((!empty($results)) && $this->forwardKey !== false && is_string($this->forwardKey)) { $rawResults = $results; $results = array(); // check if the collection is beeing fetched // as an associated array if (!is_array(reset($rawResults))) { throw new Exception('Cannot forward key, the result is no associated array.'); } foreach ($rawResults as $result) { $results[$result[$this->forwardKey]] = $result; } } // Group the resuls by a items value if ((!empty($results)) && $this->groupResults !== false && is_string($this->groupResults)) { $rawResults = $results; $results = array(); // check if the collection is beeing fetched // as an associated array if (!is_array(reset($rawResults))) { throw new Exception('Cannot forward key, the result is no associated array.'); } foreach ($rawResults as $key => $result) { $results[$result[$this->groupResults]][$key] = $result; } } // when the limit is specified to exactly one result we // return directly that one result instead of the entire array if ($this->limit === 1) { $results = reset($results); } return $results; }
[ "public", "function", "get", "(", ")", "{", "// run the callbacks to retirve the results", "$", "results", "=", "$", "this", "->", "executeResultFetcher", "(", ")", ";", "// we always exprect an array here!", "if", "(", "!", "is_array", "(", "$", "results", ")", "...
Executes the `executeResultFetcher` callback and handles the results. @return mixed The fetched result.
[ "Executes", "the", "executeResultFetcher", "callback", "and", "handles", "the", "results", "." ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L474-L532
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.column
public function column($column) { $result = $this->fields($column)->one(); // only return something if something is found if (is_array($result)) { return reset($result); } }
php
public function column($column) { $result = $this->fields($column)->one(); // only return something if something is found if (is_array($result)) { return reset($result); } }
[ "public", "function", "column", "(", "$", "column", ")", "{", "$", "result", "=", "$", "this", "->", "fields", "(", "$", "column", ")", "->", "one", "(", ")", ";", "// only return something if something is found", "if", "(", "is_array", "(", "$", "result",...
Just get a single value from the result @param string $column The name of the column. @return mixed The columns value
[ "Just", "get", "a", "single", "value", "from", "the", "result" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L601-L610
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.count
public function count($field = null) { // when no field is given we use * if (is_null($field)) { $field = new Expression('*'); } // return the column return (int) $this->column(new Func('count', $field)); }
php
public function count($field = null) { // when no field is given we use * if (is_null($field)) { $field = new Expression('*'); } // return the column return (int) $this->column(new Func('count', $field)); }
[ "public", "function", "count", "(", "$", "field", "=", "null", ")", "{", "// when no field is given we use *", "if", "(", "is_null", "(", "$", "field", ")", ")", "{", "$", "field", "=", "new", "Expression", "(", "'*'", ")", ";", "}", "// return the column"...
Just return the number of results @param string $field @return int
[ "Just", "return", "the", "number", "of", "results" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L618-L628
ClanCats/Hydrahon
src/Query/Sql/Select.php
Select.exists
public function exists() { $existsQuery = new Exists($this); // set the current select for the exists query $existsQuery->setSelect($this); // run the callbacks to retirve the results $result = $existsQuery->executeResultFetcher(); if (isset($result[0]['exists'])) { return (bool) $result[0]['exists']; } return false; }
php
public function exists() { $existsQuery = new Exists($this); // set the current select for the exists query $existsQuery->setSelect($this); // run the callbacks to retirve the results $result = $existsQuery->executeResultFetcher(); if (isset($result[0]['exists'])) { return (bool) $result[0]['exists']; } return false; }
[ "public", "function", "exists", "(", ")", "{", "$", "existsQuery", "=", "new", "Exists", "(", "$", "this", ")", ";", "// set the current select for the exists query", "$", "existsQuery", "->", "setSelect", "(", "$", "this", ")", ";", "// run the callbacks to retir...
Do any results of this query exist? @return bool
[ "Do", "any", "results", "of", "this", "query", "exist?" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/Select.php#L679-L695
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translate
public function translate(BaseQuery $query) { // retrive the query attributes $this->attributes = $query->attributes(); // handle SQL SELECT queries if ($query instanceof Select) { $queryString = $this->translateSelect(); } // handle SQL INSERT queries elseif ($query instanceof Replace) { $queryString = $this->translateInsert('replace'); } // handle SQL INSERT queries elseif ($query instanceof Insert) { $queryString = $this->translateInsert('insert'); } // handle SQL UPDATE queries elseif ($query instanceof Update) { $queryString = $this->translateUpdate(); } // handle SQL UPDATE queries elseif ($query instanceof Delete) { $queryString = $this->translateDelete(); } // handle SQL DROP queries elseif ($query instanceof Drop) { $queryString = $this->translateDrop(); } // handle SQL TRUNCATE queries elseif ($query instanceof Truncate) { $queryString = $this->translateTruncate(); } elseif ($query instanceof Exists) { $queryString = $this->translateExists(); } // everything else is wrong else { throw new Exception('Unknown query type. Cannot translate: '.get_class($query)); } // get the query parameters and reset $queryParameters = $this->parameters; $this->clearParameters(); return array($queryString, $queryParameters); }
php
public function translate(BaseQuery $query) { // retrive the query attributes $this->attributes = $query->attributes(); // handle SQL SELECT queries if ($query instanceof Select) { $queryString = $this->translateSelect(); } // handle SQL INSERT queries elseif ($query instanceof Replace) { $queryString = $this->translateInsert('replace'); } // handle SQL INSERT queries elseif ($query instanceof Insert) { $queryString = $this->translateInsert('insert'); } // handle SQL UPDATE queries elseif ($query instanceof Update) { $queryString = $this->translateUpdate(); } // handle SQL UPDATE queries elseif ($query instanceof Delete) { $queryString = $this->translateDelete(); } // handle SQL DROP queries elseif ($query instanceof Drop) { $queryString = $this->translateDrop(); } // handle SQL TRUNCATE queries elseif ($query instanceof Truncate) { $queryString = $this->translateTruncate(); } elseif ($query instanceof Exists) { $queryString = $this->translateExists(); } // everything else is wrong else { throw new Exception('Unknown query type. Cannot translate: '.get_class($query)); } // get the query parameters and reset $queryParameters = $this->parameters; $this->clearParameters(); return array($queryString, $queryParameters); }
[ "public", "function", "translate", "(", "BaseQuery", "$", "query", ")", "{", "// retrive the query attributes", "$", "this", "->", "attributes", "=", "$", "query", "->", "attributes", "(", ")", ";", "// handle SQL SELECT queries", "if", "(", "$", "query", "insta...
Translate the given query object and return the results as argument array @param ClanCats\Hydrahon\BaseQuery $query @return array
[ "Translate", "the", "given", "query", "object", "and", "return", "the", "results", "as", "argument", "array" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L56-L110
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.escape
protected function escape($string) { if (is_object($string)) { if ($this->isExpression($string)) { return $string->value(); } elseif ($this->isFunction($string)) { return $this->escapeFunction($string); } else { throw new Exception('Cannot translate object of class: ' . get_class($string)); } } // the string might contain an 'as' statement that we wil have to split. if (strpos($string, ' as ') !== false) { $string = explode(' as ', $string); return $this->escape(trim($string[0])) . ' as ' . $this->escape(trim($string[1])); } // it also might contain dott seperations we have to split if (strpos($string, '.') !== false) { $string = explode('.', $string); foreach ($string as $key => $item) { $string[$key] = $this->escapeString($item); } return implode('.', $string); } return $this->escapeString($string); }
php
protected function escape($string) { if (is_object($string)) { if ($this->isExpression($string)) { return $string->value(); } elseif ($this->isFunction($string)) { return $this->escapeFunction($string); } else { throw new Exception('Cannot translate object of class: ' . get_class($string)); } } // the string might contain an 'as' statement that we wil have to split. if (strpos($string, ' as ') !== false) { $string = explode(' as ', $string); return $this->escape(trim($string[0])) . ' as ' . $this->escape(trim($string[1])); } // it also might contain dott seperations we have to split if (strpos($string, '.') !== false) { $string = explode('.', $string); foreach ($string as $key => $item) { $string[$key] = $this->escapeString($item); } return implode('.', $string); } return $this->escapeString($string); }
[ "protected", "function", "escape", "(", "$", "string", ")", "{", "if", "(", "is_object", "(", "$", "string", ")", ")", "{", "if", "(", "$", "this", "->", "isExpression", "(", "$", "string", ")", ")", "{", "return", "$", "string", "->", "value", "("...
Escape / wrap an string for sql @param string|object $string
[ "Escape", "/", "wrap", "an", "string", "for", "sql" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L200-L240
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.escapeFunction
protected function escapeFunction($function) { $buffer = $function->name() . '('; $arguments = $function->arguments(); foreach($arguments as &$argument) { $argument = $this->escape($argument); } return $buffer . implode(', ', $arguments) . ')'; }
php
protected function escapeFunction($function) { $buffer = $function->name() . '('; $arguments = $function->arguments(); foreach($arguments as &$argument) { $argument = $this->escape($argument); } return $buffer . implode(', ', $arguments) . ')'; }
[ "protected", "function", "escapeFunction", "(", "$", "function", ")", "{", "$", "buffer", "=", "$", "function", "->", "name", "(", ")", ".", "'('", ";", "$", "arguments", "=", "$", "function", "->", "arguments", "(", ")", ";", "foreach", "(", "$", "a...
Escapes an sql function object @param Func $function @return string
[ "Escapes", "an", "sql", "function", "object" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L248-L260
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.escapeTable
protected function escapeTable($allowAlias = true) { $table = $this->attr('table'); $database = $this->attr('database'); $buffer = ''; if (!is_null($database)) { $buffer .= $this->escape($database) . '.'; } // when the table is an array we have a table with alias if (is_array($table)) { reset($table); // the table might be a subselect so check that // first and compile the select if it is one if ($table[key($table)] instanceof Select) { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($table[key($table)]); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return '(' . $subQuery . ') as ' . $this->escape(key($table)); } // otherwise continue with normal table if ($allowAlias) { $table = key($table) . ' as ' . $table[key($table)]; } else { $table = key($table); } } return $buffer . $this->escape($table); }
php
protected function escapeTable($allowAlias = true) { $table = $this->attr('table'); $database = $this->attr('database'); $buffer = ''; if (!is_null($database)) { $buffer .= $this->escape($database) . '.'; } // when the table is an array we have a table with alias if (is_array($table)) { reset($table); // the table might be a subselect so check that // first and compile the select if it is one if ($table[key($table)] instanceof Select) { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($table[key($table)]); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return '(' . $subQuery . ') as ' . $this->escape(key($table)); } // otherwise continue with normal table if ($allowAlias) { $table = key($table) . ' as ' . $table[key($table)]; } else { $table = key($table); } } return $buffer . $this->escape($table); }
[ "protected", "function", "escapeTable", "(", "$", "allowAlias", "=", "true", ")", "{", "$", "table", "=", "$", "this", "->", "attr", "(", "'table'", ")", ";", "$", "database", "=", "$", "this", "->", "attr", "(", "'database'", ")", ";", "$", "buffer"...
get and escape the table name @return string
[ "get", "and", "escape", "the", "table", "name" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L294-L338
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateInsert
protected function translateInsert($key) { $build = ($this->attr('ignore') ? $key . ' ignore' : $key); $build .= ' into ' . $this->escapeTable(false) . ' '; if (!$valueCollection = $this->attr('values')) { throw new Exception('Cannot build insert query without values.'); } // Get the array keys from the first array in the collection. // We use them as insert keys. If you pass an array collection with // missing keys or a diffrent structure well... f*ck $build .= '(' . $this->escapeList(array_keys(reset($valueCollection))) . ') values '; // add the array values. foreach ($valueCollection as $values) { $build .= '(' . $this->parameterize($values) . '), '; } // cut the last comma away return substr($build, 0, -2); }
php
protected function translateInsert($key) { $build = ($this->attr('ignore') ? $key . ' ignore' : $key); $build .= ' into ' . $this->escapeTable(false) . ' '; if (!$valueCollection = $this->attr('values')) { throw new Exception('Cannot build insert query without values.'); } // Get the array keys from the first array in the collection. // We use them as insert keys. If you pass an array collection with // missing keys or a diffrent structure well... f*ck $build .= '(' . $this->escapeList(array_keys(reset($valueCollection))) . ') values '; // add the array values. foreach ($valueCollection as $values) { $build .= '(' . $this->parameterize($values) . '), '; } // cut the last comma away return substr($build, 0, -2); }
[ "protected", "function", "translateInsert", "(", "$", "key", ")", "{", "$", "build", "=", "(", "$", "this", "->", "attr", "(", "'ignore'", ")", "?", "$", "key", ".", "' ignore'", ":", "$", "key", ")", ";", "$", "build", ".=", "' into '", ".", "$", ...
Translate the current query to an SQL insert statement @return string
[ "Translate", "the", "current", "query", "to", "an", "SQL", "insert", "statement" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L365-L389
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateUpdate
protected function translateUpdate() { $build = 'update ' . $this->escapeTable() . ' set '; // add the array values. foreach ($this->attr('values') as $key => $value) { $build .= $this->escape($key) . ' = ' . $this->param($value) . ', '; } // cut away the last comma and space $build = substr($build, 0, -2); // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build offset and limit if ($this->attr('limit')) { $build .= $this->translateLimit(); } return $build; }
php
protected function translateUpdate() { $build = 'update ' . $this->escapeTable() . ' set '; // add the array values. foreach ($this->attr('values') as $key => $value) { $build .= $this->escape($key) . ' = ' . $this->param($value) . ', '; } // cut away the last comma and space $build = substr($build, 0, -2); // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build offset and limit if ($this->attr('limit')) { $build .= $this->translateLimit(); } return $build; }
[ "protected", "function", "translateUpdate", "(", ")", "{", "$", "build", "=", "'update '", ".", "$", "this", "->", "escapeTable", "(", ")", ".", "' set '", ";", "// add the array values.", "foreach", "(", "$", "this", "->", "attr", "(", "'values'", ")", "a...
Translate the current query to an SQL update statement @return string
[ "Translate", "the", "current", "query", "to", "an", "SQL", "update", "statement" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L396-L421
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateDelete
protected function translateDelete() { $build = 'delete from ' . $this->escapeTable(false); // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build offset and limit if ($this->attr('limit')) { $build .= $this->translateLimit(); } return $build; }
php
protected function translateDelete() { $build = 'delete from ' . $this->escapeTable(false); // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build offset and limit if ($this->attr('limit')) { $build .= $this->translateLimit(); } return $build; }
[ "protected", "function", "translateDelete", "(", ")", "{", "$", "build", "=", "'delete from '", ".", "$", "this", "->", "escapeTable", "(", "false", ")", ";", "// build the where statements", "if", "(", "$", "wheres", "=", "$", "this", "->", "attr", "(", "...
Translate the current query to an SQL delete statement @return string
[ "Translate", "the", "current", "query", "to", "an", "SQL", "delete", "statement" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L428-L445
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateSelect
protected function translateSelect() { // normal or distinct selection? $build = ($this->attr('distinct') ? 'select distinct' : 'select') . ' '; // build the selected fields $fields = $this->attr('fields'); if (!empty($fields)) { foreach ($fields as $key => $field) { list($column, $alias) = $field; if (!is_null($alias)) { $build .= $this->escape($column) . ' as ' . $this->escape($alias); } else { $build .= $this->escape($column); } $build .= ', '; } $build = substr($build, 0, -2); } else { $build .= '*'; } // append the table $build .= ' from ' . $this->escapeTable(); // build the join statements if ($this->attr('joins')) { $build .= $this->translateJoins(); } // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build the groups if ($this->attr('groups')) { $build .= $this->translateGroupBy(); } // build the order statement if ($this->attr('orders')) { $build .= $this->translateOrderBy(); } // build offset and limit if ($this->attr('limit') || $this->attr('offset')) { $build .= $this->translateLimitWithOffset(); } return $build; }
php
protected function translateSelect() { // normal or distinct selection? $build = ($this->attr('distinct') ? 'select distinct' : 'select') . ' '; // build the selected fields $fields = $this->attr('fields'); if (!empty($fields)) { foreach ($fields as $key => $field) { list($column, $alias) = $field; if (!is_null($alias)) { $build .= $this->escape($column) . ' as ' . $this->escape($alias); } else { $build .= $this->escape($column); } $build .= ', '; } $build = substr($build, 0, -2); } else { $build .= '*'; } // append the table $build .= ' from ' . $this->escapeTable(); // build the join statements if ($this->attr('joins')) { $build .= $this->translateJoins(); } // build the where statements if ($wheres = $this->attr('wheres')) { $build .= $this->translateWhere($wheres); } // build the groups if ($this->attr('groups')) { $build .= $this->translateGroupBy(); } // build the order statement if ($this->attr('orders')) { $build .= $this->translateOrderBy(); } // build offset and limit if ($this->attr('limit') || $this->attr('offset')) { $build .= $this->translateLimitWithOffset(); } return $build; }
[ "protected", "function", "translateSelect", "(", ")", "{", "// normal or distinct selection?", "$", "build", "=", "(", "$", "this", "->", "attr", "(", "'distinct'", ")", "?", "'select distinct'", ":", "'select'", ")", ".", "' '", ";", "// build the selected fields...
Translate the current query to an SQL select statement @return string
[ "Translate", "the", "current", "query", "to", "an", "SQL", "select", "statement" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L452-L519
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateWhere
protected function translateWhere($wheres) { $build = ''; foreach ($wheres as $where) { // to make nested wheres possible you can pass an closure // wich will create a new query where you can add your nested wheres if (!isset($where[2]) && isset( $where[1] ) && $where[1] instanceof BaseQuery ) { $subAttributes = $where[1]->attributes(); // The parameters get added by the call of compile where $build .= ' ' . $where[0] . ' ( ' . substr($this->translateWhere($subAttributes['wheres']), 7) . ' )'; continue; } // when we have an array as where values we have // to parameterize them if (is_array($where[3])) { $where[3] = '(' . $this->parameterize($where[3]) . ')'; } else { $where[3] = $this->param($where[3]); } // we always need to escepe where 1 wich referrs to the key $where[1] = $this->escape($where[1]); // implode the beauty $build .= ' ' . implode(' ', $where); } return $build; }
php
protected function translateWhere($wheres) { $build = ''; foreach ($wheres as $where) { // to make nested wheres possible you can pass an closure // wich will create a new query where you can add your nested wheres if (!isset($where[2]) && isset( $where[1] ) && $where[1] instanceof BaseQuery ) { $subAttributes = $where[1]->attributes(); // The parameters get added by the call of compile where $build .= ' ' . $where[0] . ' ( ' . substr($this->translateWhere($subAttributes['wheres']), 7) . ' )'; continue; } // when we have an array as where values we have // to parameterize them if (is_array($where[3])) { $where[3] = '(' . $this->parameterize($where[3]) . ')'; } else { $where[3] = $this->param($where[3]); } // we always need to escepe where 1 wich referrs to the key $where[1] = $this->escape($where[1]); // implode the beauty $build .= ' ' . implode(' ', $where); } return $build; }
[ "protected", "function", "translateWhere", "(", "$", "wheres", ")", "{", "$", "build", "=", "''", ";", "foreach", "(", "$", "wheres", "as", "$", "where", ")", "{", "// to make nested wheres possible you can pass an closure", "// wich will create a new query where you ca...
Translate the where statements into sql @param array $wheres @return string
[ "Translate", "the", "where", "statements", "into", "sql" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L527-L562
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateJoins
protected function translateJoins() { $build = ''; foreach ($this->attr('joins') as $join) { // get the type and table $type = $join[0]; $table = $join[1]; // table if (is_array($table)) { reset($table); // the table might be a subselect so check that // first and compile the select if it is one if ($table[key($table)] instanceof Select) { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($table[key($table)]); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return '(' . $subQuery . ') as ' . $this->escape(key($table)); } } // start the join $build .= ' ' . $type . ' join ' . $this->escape($table) . ' on '; // to make nested join conditions possible you can pass an closure // wich will create a new query where you can add your nested ons and wheres if (!isset($join[3]) && isset($join[2]) && $join[2] instanceof BaseQuery) { $subAttributes = $join[2]->attributes(); $joinConditions = ''; // remove the first type from the ons reset($subAttributes['ons']); $subAttributes['ons'][key($subAttributes['ons'])][0] = ''; foreach($subAttributes['ons'] as $on) { list($type, $localKey, $operator, $referenceKey) = $on; $joinConditions .= ' ' . $type . ' ' . $this->escape($localKey) . ' ' . $operator . ' ' . $this->escape($referenceKey); } $build .= trim($joinConditions); // compile the where if set if (!empty($subAttributes['wheres'])) { $build .= ' and ' . substr($this->translateWhere($subAttributes['wheres']), 7); } } else { // othewise default join list($type, $table, $localKey, $operator, $referenceKey) = $join; $build .= $this->escape($localKey) . ' ' . $operator . ' ' . $this->escape($referenceKey); } } return $build; }
php
protected function translateJoins() { $build = ''; foreach ($this->attr('joins') as $join) { // get the type and table $type = $join[0]; $table = $join[1]; // table if (is_array($table)) { reset($table); // the table might be a subselect so check that // first and compile the select if it is one if ($table[key($table)] instanceof Select) { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($table[key($table)]); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return '(' . $subQuery . ') as ' . $this->escape(key($table)); } } // start the join $build .= ' ' . $type . ' join ' . $this->escape($table) . ' on '; // to make nested join conditions possible you can pass an closure // wich will create a new query where you can add your nested ons and wheres if (!isset($join[3]) && isset($join[2]) && $join[2] instanceof BaseQuery) { $subAttributes = $join[2]->attributes(); $joinConditions = ''; // remove the first type from the ons reset($subAttributes['ons']); $subAttributes['ons'][key($subAttributes['ons'])][0] = ''; foreach($subAttributes['ons'] as $on) { list($type, $localKey, $operator, $referenceKey) = $on; $joinConditions .= ' ' . $type . ' ' . $this->escape($localKey) . ' ' . $operator . ' ' . $this->escape($referenceKey); } $build .= trim($joinConditions); // compile the where if set if (!empty($subAttributes['wheres'])) { $build .= ' and ' . substr($this->translateWhere($subAttributes['wheres']), 7); } } else { // othewise default join list($type, $table, $localKey, $operator, $referenceKey) = $join; $build .= $this->escape($localKey) . ' ' . $operator . ' ' . $this->escape($referenceKey); } } return $build; }
[ "protected", "function", "translateJoins", "(", ")", "{", "$", "build", "=", "''", ";", "foreach", "(", "$", "this", "->", "attr", "(", "'joins'", ")", "as", "$", "join", ")", "{", "// get the type and table", "$", "type", "=", "$", "join", "[", "0", ...
Build the sql join statements @return string
[ "Build", "the", "sql", "join", "statements" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L569-L640
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateOrderBy
protected function translateOrderBy() { $build = " order by "; foreach ($this->attr('orders') as $column => $direction) { // in case a raw value is given we had to // put the column / raw value an direction inside another // array because we cannot make objects to array keys. if (is_array($direction)) { // This only works in php 7 the php 5 fix is below //list($column, $direction) = $direction; $column = $direction[0]; $direction = $direction[1]; } $build .= $this->escape($column) . ' ' . $direction . ', '; } return substr($build, 0, -2); }
php
protected function translateOrderBy() { $build = " order by "; foreach ($this->attr('orders') as $column => $direction) { // in case a raw value is given we had to // put the column / raw value an direction inside another // array because we cannot make objects to array keys. if (is_array($direction)) { // This only works in php 7 the php 5 fix is below //list($column, $direction) = $direction; $column = $direction[0]; $direction = $direction[1]; } $build .= $this->escape($column) . ' ' . $direction . ', '; } return substr($build, 0, -2); }
[ "protected", "function", "translateOrderBy", "(", ")", "{", "$", "build", "=", "\" order by \"", ";", "foreach", "(", "$", "this", "->", "attr", "(", "'orders'", ")", "as", "$", "column", "=>", "$", "direction", ")", "{", "// in case a raw value is given we ha...
Build the order by statement @return string
[ "Build", "the", "order", "by", "statement" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L647-L668
ClanCats/Hydrahon
src/Translator/Mysql.php
Mysql.translateExists
protected function translateExists() { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($this->attr('select')); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return 'select exists(' . $subQuery .') as `exists`'; }
php
protected function translateExists() { $translator = new static; // translate the subselect list($subQuery, $subQueryParameters) = $translator->translate($this->attr('select')); // merge the parameters foreach($subQueryParameters as $parameter) { $this->addParameter($parameter); } return 'select exists(' . $subQuery .') as `exists`'; }
[ "protected", "function", "translateExists", "(", ")", "{", "$", "translator", "=", "new", "static", ";", "// translate the subselect", "list", "(", "$", "subQuery", ",", "$", "subQueryParameters", ")", "=", "$", "translator", "->", "translate", "(", "$", "this...
Translate the exists querry @return string
[ "Translate", "the", "exists", "querry" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Translator/Mysql.php#L727-L741
ClanCats/Hydrahon
src/Query/Sql/SelectJoin.php
SelectJoin.on
public function on($localKey, $operator, $referenceKey, $type = 'and') { $this->ons[] = array($type, $localKey, $operator, $referenceKey); return $this; }
php
public function on($localKey, $operator, $referenceKey, $type = 'and') { $this->ons[] = array($type, $localKey, $operator, $referenceKey); return $this; }
[ "public", "function", "on", "(", "$", "localKey", ",", "$", "operator", ",", "$", "referenceKey", ",", "$", "type", "=", "'and'", ")", "{", "$", "this", "->", "ons", "[", "]", "=", "array", "(", "$", "type", ",", "$", "localKey", ",", "$", "opera...
Add an on condition to the join object @param string $localKey @param string $operator @param string $referenceKey @return self
[ "Add", "an", "on", "condition", "to", "the", "join", "object" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/SelectJoin.php#L39-L42
ClanCats/Hydrahon
src/Query/Sql/SelectJoin.php
SelectJoin.orOn
public function orOn($localKey, $operator, $referenceKey) { $this->on($localKey, $operator, $referenceKey, 'or'); return $this; }
php
public function orOn($localKey, $operator, $referenceKey) { $this->on($localKey, $operator, $referenceKey, 'or'); return $this; }
[ "public", "function", "orOn", "(", "$", "localKey", ",", "$", "operator", ",", "$", "referenceKey", ")", "{", "$", "this", "->", "on", "(", "$", "localKey", ",", "$", "operator", ",", "$", "referenceKey", ",", "'or'", ")", ";", "return", "$", "this",...
Add an or on condition to the join object @param string $localKey @param string $operator @param string $referenceKey @return self
[ "Add", "an", "or", "on", "condition", "to", "the", "join", "object" ]
train
https://github.com/ClanCats/Hydrahon/blob/e2790279bfdb1faa9155504267db1f57d4dabe00/src/Query/Sql/SelectJoin.php#L53-L56