id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
22,100
codezero-be/curl
src/OptionParser.php
OptionParser.parseUrl
public function parseUrl($url, array $data) { return (empty($data)) ? $url : $url . '?' . $this->parseData($data); }
php
public function parseUrl($url, array $data) { return (empty($data)) ? $url : $url . '?' . $this->parseData($data); }
[ "public", "function", "parseUrl", "(", "$", "url", ",", "array", "$", "data", ")", "{", "return", "(", "empty", "(", "$", "data", ")", ")", "?", "$", "url", ":", "$", "url", ".", "'?'", ".", "$", "this", "->", "parseData", "(", "$", "data", ")", ";", "}" ]
Build URL with query string @param string $url @param array $data @return string
[ "Build", "URL", "with", "query", "string" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/OptionParser.php#L13-L16
22,101
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Filter/ClassFactory.php
ClassFactory.getChainFor
public function getChainFor($fqcn) { if (!isset($this->chains[$fqcn])) { $this->chains[$fqcn] = new FilterChain(); } return $this->chains[$fqcn]; }
php
public function getChainFor($fqcn) { if (!isset($this->chains[$fqcn])) { $this->chains[$fqcn] = new FilterChain(); } return $this->chains[$fqcn]; }
[ "public", "function", "getChainFor", "(", "$", "fqcn", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "chains", "[", "$", "fqcn", "]", ")", ")", "{", "$", "this", "->", "chains", "[", "$", "fqcn", "]", "=", "new", "FilterChain", "(", ")", ";", "}", "return", "$", "this", "->", "chains", "[", "$", "fqcn", "]", ";", "}" ]
Retrieves the filters for a class with a given FQCN. @param string $fqcn @return FilterChain
[ "Retrieves", "the", "filters", "for", "a", "class", "with", "a", "given", "FQCN", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Filter/ClassFactory.php#L31-L38
22,102
mothership-ec/composer
src/Composer/Repository/Vcs/GitHubDriver.php
GitHubDriver.getRateLimit
protected function getRateLimit(array $headers) { $rateLimit = array( 'limit' => '?', 'reset' => '?', ); foreach ($headers as $header) { $header = trim($header); if (false === strpos($header, 'X-RateLimit-')) { continue; } list($type, $value) = explode(':', $header, 2); switch ($type) { case 'X-RateLimit-Limit': $rateLimit['limit'] = (int) trim($value); break; case 'X-RateLimit-Reset': $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value)); break; } } return $rateLimit; }
php
protected function getRateLimit(array $headers) { $rateLimit = array( 'limit' => '?', 'reset' => '?', ); foreach ($headers as $header) { $header = trim($header); if (false === strpos($header, 'X-RateLimit-')) { continue; } list($type, $value) = explode(':', $header, 2); switch ($type) { case 'X-RateLimit-Limit': $rateLimit['limit'] = (int) trim($value); break; case 'X-RateLimit-Reset': $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value)); break; } } return $rateLimit; }
[ "protected", "function", "getRateLimit", "(", "array", "$", "headers", ")", "{", "$", "rateLimit", "=", "array", "(", "'limit'", "=>", "'?'", ",", "'reset'", "=>", "'?'", ",", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "header", "=", "trim", "(", "$", "header", ")", ";", "if", "(", "false", "===", "strpos", "(", "$", "header", ",", "'X-RateLimit-'", ")", ")", "{", "continue", ";", "}", "list", "(", "$", "type", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "header", ",", "2", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'X-RateLimit-Limit'", ":", "$", "rateLimit", "[", "'limit'", "]", "=", "(", "int", ")", "trim", "(", "$", "value", ")", ";", "break", ";", "case", "'X-RateLimit-Reset'", ":", "$", "rateLimit", "[", "'reset'", "]", "=", "date", "(", "'Y-m-d H:i:s'", ",", "(", "int", ")", "trim", "(", "$", "value", ")", ")", ";", "break", ";", "}", "}", "return", "$", "rateLimit", ";", "}" ]
Extract ratelimit from response. @param array $headers Headers from Composer\Downloader\TransportException. @return array Associative array with the keys limit and reset.
[ "Extract", "ratelimit", "from", "response", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/GitHubDriver.php#L369-L393
22,103
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.connect
public function connect() { //if port is not set, try and determine based on transport if(!is_numeric($this->port)){ if(substr($this->host, 0, 3) == 'ssl'){ $this->port = 5223; $this->log("Connecting with SSL"); } else { $this->port = 5222; } } parent::__construct($this->host.':'.$this->port, $this->timeout); $this->open(); //begin stream $this->write("<stream:stream to='$this->host' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en' version='1.0'>"); $this->read(); $this->read(); $this->connected = true; }
php
public function connect() { //if port is not set, try and determine based on transport if(!is_numeric($this->port)){ if(substr($this->host, 0, 3) == 'ssl'){ $this->port = 5223; $this->log("Connecting with SSL"); } else { $this->port = 5222; } } parent::__construct($this->host.':'.$this->port, $this->timeout); $this->open(); //begin stream $this->write("<stream:stream to='$this->host' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en' version='1.0'>"); $this->read(); $this->read(); $this->connected = true; }
[ "public", "function", "connect", "(", ")", "{", "//if port is not set, try and determine based on transport", "if", "(", "!", "is_numeric", "(", "$", "this", "->", "port", ")", ")", "{", "if", "(", "substr", "(", "$", "this", "->", "host", ",", "0", ",", "3", ")", "==", "'ssl'", ")", "{", "$", "this", "->", "port", "=", "5223", ";", "$", "this", "->", "log", "(", "\"Connecting with SSL\"", ")", ";", "}", "else", "{", "$", "this", "->", "port", "=", "5222", ";", "}", "}", "parent", "::", "__construct", "(", "$", "this", "->", "host", ".", "':'", ".", "$", "this", "->", "port", ",", "$", "this", "->", "timeout", ")", ";", "$", "this", "->", "open", "(", ")", ";", "//begin stream", "$", "this", "->", "write", "(", "\"<stream:stream to='$this->host' xmlns='jabber:client'\nxmlns:stream='http://etherx.jabber.org/streams' xml:lang='en' version='1.0'>\"", ")", ";", "$", "this", "->", "read", "(", ")", ";", "$", "this", "->", "read", "(", ")", ";", "$", "this", "->", "connected", "=", "true", ";", "}" ]
Connects to the XMPP server
[ "Connects", "to", "the", "XMPP", "server" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L97-L124
22,104
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.login
public function login() { //connect if not connected if(!$this->connected){ $this->reconnect(); } //calc the jid from uname+host $this->jid = $this->uname.'@'.substr($this->host, strpos($this->host, '//')+2); if($this->pass){ $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->uname . "\x00" . $this->pass) . "</auth>"); } else { $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />"); } $buffer = $this->read(); if(substr($buffer, 0, 5) == '<fail'){ $this->onError(0, 'Cound not log in'); return false; } $this->client_name = empty($this->client_name) ? __CLASS__ : $this->client_name; if(!$this->sendClientName()){ return false; } $this->setStatus($this->status); $this->onAfterLogin(); return true; }
php
public function login() { //connect if not connected if(!$this->connected){ $this->reconnect(); } //calc the jid from uname+host $this->jid = $this->uname.'@'.substr($this->host, strpos($this->host, '//')+2); if($this->pass){ $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->uname . "\x00" . $this->pass) . "</auth>"); } else { $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />"); } $buffer = $this->read(); if(substr($buffer, 0, 5) == '<fail'){ $this->onError(0, 'Cound not log in'); return false; } $this->client_name = empty($this->client_name) ? __CLASS__ : $this->client_name; if(!$this->sendClientName()){ return false; } $this->setStatus($this->status); $this->onAfterLogin(); return true; }
[ "public", "function", "login", "(", ")", "{", "//connect if not connected", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "this", "->", "reconnect", "(", ")", ";", "}", "//calc the jid from uname+host", "$", "this", "->", "jid", "=", "$", "this", "->", "uname", ".", "'@'", ".", "substr", "(", "$", "this", "->", "host", ",", "strpos", "(", "$", "this", "->", "host", ",", "'//'", ")", "+", "2", ")", ";", "if", "(", "$", "this", "->", "pass", ")", "{", "$", "this", "->", "write", "(", "\"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>\"", ".", "base64_encode", "(", "\"\\x00\"", ".", "$", "this", "->", "uname", ".", "\"\\x00\"", ".", "$", "this", "->", "pass", ")", ".", "\"</auth>\"", ")", ";", "}", "else", "{", "$", "this", "->", "write", "(", "\"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />\"", ")", ";", "}", "$", "buffer", "=", "$", "this", "->", "read", "(", ")", ";", "if", "(", "substr", "(", "$", "buffer", ",", "0", ",", "5", ")", "==", "'<fail'", ")", "{", "$", "this", "->", "onError", "(", "0", ",", "'Cound not log in'", ")", ";", "return", "false", ";", "}", "$", "this", "->", "client_name", "=", "empty", "(", "$", "this", "->", "client_name", ")", "?", "__CLASS__", ":", "$", "this", "->", "client_name", ";", "if", "(", "!", "$", "this", "->", "sendClientName", "(", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "setStatus", "(", "$", "this", "->", "status", ")", ";", "$", "this", "->", "onAfterLogin", "(", ")", ";", "return", "true", ";", "}" ]
Login to the XMPP server as a user and set their precence to avaiable @return boolean
[ "Login", "to", "the", "XMPP", "server", "as", "a", "user", "and", "set", "their", "precence", "to", "avaiable" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L141-L178
22,105
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.sendPresence
public function sendPresence(\sb\XMPP\Presence $presence) { $presence->setFrom($this->jid); return $this->write($presence); }
php
public function sendPresence(\sb\XMPP\Presence $presence) { $presence->setFrom($this->jid); return $this->write($presence); }
[ "public", "function", "sendPresence", "(", "\\", "sb", "\\", "XMPP", "\\", "Presence", "$", "presence", ")", "{", "$", "presence", "->", "setFrom", "(", "$", "this", "->", "jid", ")", ";", "return", "$", "this", "->", "write", "(", "$", "presence", ")", ";", "}" ]
Converts a presense request instance to XML and sends it. It sets the from to the bots jid for you @param \sb\XMPP\Presence $presence The presence instance to send @return boolean
[ "Converts", "a", "presense", "request", "instance", "to", "XML", "and", "sends", "it", ".", "It", "sets", "the", "from", "to", "the", "bots", "jid", "for", "you" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L187-L192
22,106
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.setStatus
public function setStatus($status=null) { $presence = new \sb\XMPP\Presence(); $presence->setStatus(is_string($status) ? $status : $this->status); $this->sendPresence($presence); }
php
public function setStatus($status=null) { $presence = new \sb\XMPP\Presence(); $presence->setStatus(is_string($status) ? $status : $this->status); $this->sendPresence($presence); }
[ "public", "function", "setStatus", "(", "$", "status", "=", "null", ")", "{", "$", "presence", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Presence", "(", ")", ";", "$", "presence", "->", "setStatus", "(", "is_string", "(", "$", "status", ")", "?", "$", "status", ":", "$", "this", "->", "status", ")", ";", "$", "this", "->", "sendPresence", "(", "$", "presence", ")", ";", "}" ]
Sets status message @param string $status The status message to send
[ "Sets", "status", "message" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L198-L205
22,107
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.sendSimpleMessage
public function sendSimpleMessage($to, $body) { $message = new \sb\XMPP\Message(); $message->setTo($to); $message->setBody($body); $this->sendMessage($message); }
php
public function sendSimpleMessage($to, $body) { $message = new \sb\XMPP\Message(); $message->setTo($to); $message->setBody($body); $this->sendMessage($message); }
[ "public", "function", "sendSimpleMessage", "(", "$", "to", ",", "$", "body", ")", "{", "$", "message", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Message", "(", ")", ";", "$", "message", "->", "setTo", "(", "$", "to", ")", ";", "$", "message", "->", "setBody", "(", "$", "body", ")", ";", "$", "this", "->", "sendMessage", "(", "$", "message", ")", ";", "}" ]
Sends simple string based text message @param string $to The jid to send the message to @param string $body The text to send
[ "Sends", "simple", "string", "based", "text", "message" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L213-L221
22,108
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.sendAcceptSubscriptionRequest
public function sendAcceptSubscriptionRequest($to) { $presence = new \sb\XMPP\Presence(); $presence->setType('subscribed'); $presence->setTo($to); return $this->sendPresence($presence); }
php
public function sendAcceptSubscriptionRequest($to) { $presence = new \sb\XMPP\Presence(); $presence->setType('subscribed'); $presence->setTo($to); return $this->sendPresence($presence); }
[ "public", "function", "sendAcceptSubscriptionRequest", "(", "$", "to", ")", "{", "$", "presence", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Presence", "(", ")", ";", "$", "presence", "->", "setType", "(", "'subscribed'", ")", ";", "$", "presence", "->", "setTo", "(", "$", "to", ")", ";", "return", "$", "this", "->", "sendPresence", "(", "$", "presence", ")", ";", "}" ]
Send a presence message accepting subscription request to a jid @param string $to The jid of the person to send the acceptance request to @return boolean
[ "Send", "a", "presence", "message", "accepting", "subscription", "request", "to", "a", "jid" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L228-L234
22,109
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.sendSubscriptionRequest
public function sendSubscriptionRequest($to) { $presence = new \sb\XMPP\Presence(); $presence->setTo($to); $presence->setType('subscribe'); $presence->setFrom($this->jid); return $this->sendPresence($presence); }
php
public function sendSubscriptionRequest($to) { $presence = new \sb\XMPP\Presence(); $presence->setTo($to); $presence->setType('subscribe'); $presence->setFrom($this->jid); return $this->sendPresence($presence); }
[ "public", "function", "sendSubscriptionRequest", "(", "$", "to", ")", "{", "$", "presence", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Presence", "(", ")", ";", "$", "presence", "->", "setTo", "(", "$", "to", ")", ";", "$", "presence", "->", "setType", "(", "'subscribe'", ")", ";", "$", "presence", "->", "setFrom", "(", "$", "this", "->", "jid", ")", ";", "return", "$", "this", "->", "sendPresence", "(", "$", "presence", ")", ";", "}" ]
Sends a subscription request to a jid @param string $to The hid to send the subscription request to @return boolean
[ "Sends", "a", "subscription", "request", "to", "a", "jid" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L241-L250
22,110
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.sleep
public function sleep($secs) { $str = 'Going to sleep for '.$secs.'secs'; $this->log('NOTICE: '.$str); $this->setStatus($str); sleep($secs); $this->setStatus($this->status ? $this->status : 'awake'); }
php
public function sleep($secs) { $str = 'Going to sleep for '.$secs.'secs'; $this->log('NOTICE: '.$str); $this->setStatus($str); sleep($secs); $this->setStatus($this->status ? $this->status : 'awake'); }
[ "public", "function", "sleep", "(", "$", "secs", ")", "{", "$", "str", "=", "'Going to sleep for '", ".", "$", "secs", ".", "'secs'", ";", "$", "this", "->", "log", "(", "'NOTICE: '", ".", "$", "str", ")", ";", "$", "this", "->", "setStatus", "(", "$", "str", ")", ";", "sleep", "(", "$", "secs", ")", ";", "$", "this", "->", "setStatus", "(", "$", "this", "->", "status", "?", "$", "this", "->", "status", ":", "'awake'", ")", ";", "}" ]
Puts the bot to sleep for a while @param integer $secs
[ "Puts", "the", "bot", "to", "sleep", "for", "a", "while" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L310-L317
22,111
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.composingStart
public function composingStart($to) { $message = new \sb\XMPP\Message(); $message->setTo($to); $message->setFrom($this->jid); $message->setType('chat'); $node = $message->createElement('composing'); $attr = $message->createAttribute('xmlns'); $node->appendChild($attr); $attr->appendChild($message->createTextNode('http://jabber.org/protocol/chatstates')); $message->doc->appendChild($node); $this->sendMessage($message); }
php
public function composingStart($to) { $message = new \sb\XMPP\Message(); $message->setTo($to); $message->setFrom($this->jid); $message->setType('chat'); $node = $message->createElement('composing'); $attr = $message->createAttribute('xmlns'); $node->appendChild($attr); $attr->appendChild($message->createTextNode('http://jabber.org/protocol/chatstates')); $message->doc->appendChild($node); $this->sendMessage($message); }
[ "public", "function", "composingStart", "(", "$", "to", ")", "{", "$", "message", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Message", "(", ")", ";", "$", "message", "->", "setTo", "(", "$", "to", ")", ";", "$", "message", "->", "setFrom", "(", "$", "this", "->", "jid", ")", ";", "$", "message", "->", "setType", "(", "'chat'", ")", ";", "$", "node", "=", "$", "message", "->", "createElement", "(", "'composing'", ")", ";", "$", "attr", "=", "$", "message", "->", "createAttribute", "(", "'xmlns'", ")", ";", "$", "node", "->", "appendChild", "(", "$", "attr", ")", ";", "$", "attr", "->", "appendChild", "(", "$", "message", "->", "createTextNode", "(", "'http://jabber.org/protocol/chatstates'", ")", ")", ";", "$", "message", "->", "doc", "->", "appendChild", "(", "$", "node", ")", ";", "$", "this", "->", "sendMessage", "(", "$", "message", ")", ";", "}" ]
Send an indication that the bot is composing text. @param string $to The jid to send to
[ "Send", "an", "indication", "that", "the", "bot", "is", "composing", "text", "." ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L323-L338
22,112
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.read
final public function read($byte_count=null) { $buffer = ''; $read = array($this->socket); $updated = @stream_select($read, $write, $except, 1); if ($updated > 0) { $data = fread($this->socket, 4096); if($data) { $buffer = $data; } } if(!empty($buffer)){ $this->log('RECEIVED: '.$buffer); } return $buffer; }
php
final public function read($byte_count=null) { $buffer = ''; $read = array($this->socket); $updated = @stream_select($read, $write, $except, 1); if ($updated > 0) { $data = fread($this->socket, 4096); if($data) { $buffer = $data; } } if(!empty($buffer)){ $this->log('RECEIVED: '.$buffer); } return $buffer; }
[ "final", "public", "function", "read", "(", "$", "byte_count", "=", "null", ")", "{", "$", "buffer", "=", "''", ";", "$", "read", "=", "array", "(", "$", "this", "->", "socket", ")", ";", "$", "updated", "=", "@", "stream_select", "(", "$", "read", ",", "$", "write", ",", "$", "except", ",", "1", ")", ";", "if", "(", "$", "updated", ">", "0", ")", "{", "$", "data", "=", "fread", "(", "$", "this", "->", "socket", ",", "4096", ")", ";", "if", "(", "$", "data", ")", "{", "$", "buffer", "=", "$", "data", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "buffer", ")", ")", "{", "$", "this", "->", "log", "(", "'RECEIVED: '", ".", "$", "buffer", ")", ";", "}", "return", "$", "buffer", ";", "}" ]
Reads from the socket, should be protected but can't because this is inherited as public @return string The buffer data read from the socket
[ "Reads", "from", "the", "socket", "should", "be", "protected", "but", "can", "t", "because", "this", "is", "inherited", "as", "public" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L366-L387
22,113
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.listen
final public function listen() { $this->log("Listening..."); $x = 1; while($x){ $x++; $xml = $this->read(1024); if(!empty($xml)){ if($this->onRead($xml) === false){ return false; } } if(substr($xml, 0, 8 ) == '<message'){ $message = new \sb\XMPP\Message($xml); $message->client = $this; $this->onMessage($message); } elseif(substr($xml, 0, 9 ) == '<presence'){ $presence = new \sb\XMPP\Presence($xml); $from = $presence->getFrom(); $type = $presence->getType(); if(is_array($this->buddies_online)){ $status = $presence->getStatus(); if($from && $type == 'unavailable'){ unset($this->buddies_online[$from]); $this->log('NOTICE: '.$from.' is unavailable'); } elseif($from){ $this->buddies_online[$from] = $status; $this->log('NOTICE: '.$from.' is '.$status); } } if(strstr($type, 'subscribe') && $this->onSubscriptionRequest($presence)){ $this->sendAcceptSubscriptionRequest($from); $this->log('NOTICE: Auto accepting subscription request from '.$from); } $this->onPresence($presence); } if($x % 100 == 0){ $presence = new \sb\XMPP\Presence(); $presence->setStatus($this->status); $this->sendPresence($presence); $x = 1; } //extra little sleep reduces CPU usleep(100000); } }
php
final public function listen() { $this->log("Listening..."); $x = 1; while($x){ $x++; $xml = $this->read(1024); if(!empty($xml)){ if($this->onRead($xml) === false){ return false; } } if(substr($xml, 0, 8 ) == '<message'){ $message = new \sb\XMPP\Message($xml); $message->client = $this; $this->onMessage($message); } elseif(substr($xml, 0, 9 ) == '<presence'){ $presence = new \sb\XMPP\Presence($xml); $from = $presence->getFrom(); $type = $presence->getType(); if(is_array($this->buddies_online)){ $status = $presence->getStatus(); if($from && $type == 'unavailable'){ unset($this->buddies_online[$from]); $this->log('NOTICE: '.$from.' is unavailable'); } elseif($from){ $this->buddies_online[$from] = $status; $this->log('NOTICE: '.$from.' is '.$status); } } if(strstr($type, 'subscribe') && $this->onSubscriptionRequest($presence)){ $this->sendAcceptSubscriptionRequest($from); $this->log('NOTICE: Auto accepting subscription request from '.$from); } $this->onPresence($presence); } if($x % 100 == 0){ $presence = new \sb\XMPP\Presence(); $presence->setStatus($this->status); $this->sendPresence($presence); $x = 1; } //extra little sleep reduces CPU usleep(100000); } }
[ "final", "public", "function", "listen", "(", ")", "{", "$", "this", "->", "log", "(", "\"Listening...\"", ")", ";", "$", "x", "=", "1", ";", "while", "(", "$", "x", ")", "{", "$", "x", "++", ";", "$", "xml", "=", "$", "this", "->", "read", "(", "1024", ")", ";", "if", "(", "!", "empty", "(", "$", "xml", ")", ")", "{", "if", "(", "$", "this", "->", "onRead", "(", "$", "xml", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "if", "(", "substr", "(", "$", "xml", ",", "0", ",", "8", ")", "==", "'<message'", ")", "{", "$", "message", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Message", "(", "$", "xml", ")", ";", "$", "message", "->", "client", "=", "$", "this", ";", "$", "this", "->", "onMessage", "(", "$", "message", ")", ";", "}", "elseif", "(", "substr", "(", "$", "xml", ",", "0", ",", "9", ")", "==", "'<presence'", ")", "{", "$", "presence", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Presence", "(", "$", "xml", ")", ";", "$", "from", "=", "$", "presence", "->", "getFrom", "(", ")", ";", "$", "type", "=", "$", "presence", "->", "getType", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "buddies_online", ")", ")", "{", "$", "status", "=", "$", "presence", "->", "getStatus", "(", ")", ";", "if", "(", "$", "from", "&&", "$", "type", "==", "'unavailable'", ")", "{", "unset", "(", "$", "this", "->", "buddies_online", "[", "$", "from", "]", ")", ";", "$", "this", "->", "log", "(", "'NOTICE: '", ".", "$", "from", ".", "' is unavailable'", ")", ";", "}", "elseif", "(", "$", "from", ")", "{", "$", "this", "->", "buddies_online", "[", "$", "from", "]", "=", "$", "status", ";", "$", "this", "->", "log", "(", "'NOTICE: '", ".", "$", "from", ".", "' is '", ".", "$", "status", ")", ";", "}", "}", "if", "(", "strstr", "(", "$", "type", ",", "'subscribe'", ")", "&&", "$", "this", "->", "onSubscriptionRequest", "(", "$", "presence", ")", ")", "{", "$", "this", "->", "sendAcceptSubscriptionRequest", "(", "$", "from", ")", ";", "$", "this", "->", "log", "(", "'NOTICE: Auto accepting subscription request from '", ".", "$", "from", ")", ";", "}", "$", "this", "->", "onPresence", "(", "$", "presence", ")", ";", "}", "if", "(", "$", "x", "%", "100", "==", "0", ")", "{", "$", "presence", "=", "new", "\\", "sb", "\\", "XMPP", "\\", "Presence", "(", ")", ";", "$", "presence", "->", "setStatus", "(", "$", "this", "->", "status", ")", ";", "$", "this", "->", "sendPresence", "(", "$", "presence", ")", ";", "$", "x", "=", "1", ";", "}", "//extra little sleep reduces CPU", "usleep", "(", "100000", ")", ";", "}", "}" ]
Listens for incoming chat on the socket
[ "Listens", "for", "incoming", "chat", "on", "the", "socket" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L392-L456
22,114
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.write
final public function write($xml) { if($xml instanceof \SimpleXMLElement){ $xml = $xml->asXML(); } elseif($xml instanceof \DOMDocument){ $xml = $xml->saveXML(); } $this->log("SENT: ".$xml); return parent::write($xml); }
php
final public function write($xml) { if($xml instanceof \SimpleXMLElement){ $xml = $xml->asXML(); } elseif($xml instanceof \DOMDocument){ $xml = $xml->saveXML(); } $this->log("SENT: ".$xml); return parent::write($xml); }
[ "final", "public", "function", "write", "(", "$", "xml", ")", "{", "if", "(", "$", "xml", "instanceof", "\\", "SimpleXMLElement", ")", "{", "$", "xml", "=", "$", "xml", "->", "asXML", "(", ")", ";", "}", "elseif", "(", "$", "xml", "instanceof", "\\", "DOMDocument", ")", "{", "$", "xml", "=", "$", "xml", "->", "saveXML", "(", ")", ";", "}", "$", "this", "->", "log", "(", "\"SENT: \"", ".", "$", "xml", ")", ";", "return", "parent", "::", "write", "(", "$", "xml", ")", ";", "}" ]
Writes XML to the socket client @param mixed $xml Can be DOMDocument, SimpleXMLElement or string of XML @return <type>
[ "Writes", "XML", "to", "the", "socket", "client" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L463-L475
22,115
surebert/surebert-framework
src/sb/XMPP/Client.php
Client.close
final public function close() { $this->onCloseConnection(); if($this->socket){ $this->write("</stream:stream>"); parent::close(); $this->connected = false; } }
php
final public function close() { $this->onCloseConnection(); if($this->socket){ $this->write("</stream:stream>"); parent::close(); $this->connected = false; } }
[ "final", "public", "function", "close", "(", ")", "{", "$", "this", "->", "onCloseConnection", "(", ")", ";", "if", "(", "$", "this", "->", "socket", ")", "{", "$", "this", "->", "write", "(", "\"</stream:stream>\"", ")", ";", "parent", "::", "close", "(", ")", ";", "$", "this", "->", "connected", "=", "false", ";", "}", "}" ]
Ends the stream and closes the connection
[ "Ends", "the", "stream", "and", "closes", "the", "connection" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Client.php#L505-L516
22,116
GrupaZero/api
src/Gzero/Api/Controller/Admin/ContentController.php
ContentController.indexTree
public function indexTree($id = null) { $this->authorize('readList', Content::class); $input = $this->validator->validate('tree'); $params = $this->processor->process($input)->getProcessedFields(); $this->getSerializer()->parseIncludes('children'); // We need to enable children include to return tree from api if ($id) { // Single tree $content = $this->repository->getById($id); if (!empty($content)) { return $this->respondWithSuccess( $this->repository->getTree( $content, $params['filter'], $params['orderBy'] ), new ContentTransformer ); } else { return $this->respondNotFound(); } } // All trees //$params['filter'] = array_merge(['type' => ['value' => 'category', 'relation' => null]], $params['filter']); $nodes = $this->repository->getContentsByLevel( $params['filter'], $params['orderBy'], null ); $trees = $this->repository->buildTree($nodes); // We need to guarantee LaravelCollection here because buildTree will return single root // if we have only one if (!empty($trees) && !$trees instanceof LaravelCollection) { $trees = new LaravelCollection([$trees]); } return $this->respondWithSuccess($trees, new ContentTransformer); }
php
public function indexTree($id = null) { $this->authorize('readList', Content::class); $input = $this->validator->validate('tree'); $params = $this->processor->process($input)->getProcessedFields(); $this->getSerializer()->parseIncludes('children'); // We need to enable children include to return tree from api if ($id) { // Single tree $content = $this->repository->getById($id); if (!empty($content)) { return $this->respondWithSuccess( $this->repository->getTree( $content, $params['filter'], $params['orderBy'] ), new ContentTransformer ); } else { return $this->respondNotFound(); } } // All trees //$params['filter'] = array_merge(['type' => ['value' => 'category', 'relation' => null]], $params['filter']); $nodes = $this->repository->getContentsByLevel( $params['filter'], $params['orderBy'], null ); $trees = $this->repository->buildTree($nodes); // We need to guarantee LaravelCollection here because buildTree will return single root // if we have only one if (!empty($trees) && !$trees instanceof LaravelCollection) { $trees = new LaravelCollection([$trees]); } return $this->respondWithSuccess($trees, new ContentTransformer); }
[ "public", "function", "indexTree", "(", "$", "id", "=", "null", ")", "{", "$", "this", "->", "authorize", "(", "'readList'", ",", "Content", "::", "class", ")", ";", "$", "input", "=", "$", "this", "->", "validator", "->", "validate", "(", "'tree'", ")", ";", "$", "params", "=", "$", "this", "->", "processor", "->", "process", "(", "$", "input", ")", "->", "getProcessedFields", "(", ")", ";", "$", "this", "->", "getSerializer", "(", ")", "->", "parseIncludes", "(", "'children'", ")", ";", "// We need to enable children include to return tree from api", "if", "(", "$", "id", ")", "{", "// Single tree", "$", "content", "=", "$", "this", "->", "repository", "->", "getById", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "return", "$", "this", "->", "respondWithSuccess", "(", "$", "this", "->", "repository", "->", "getTree", "(", "$", "content", ",", "$", "params", "[", "'filter'", "]", ",", "$", "params", "[", "'orderBy'", "]", ")", ",", "new", "ContentTransformer", ")", ";", "}", "else", "{", "return", "$", "this", "->", "respondNotFound", "(", ")", ";", "}", "}", "// All trees", "//$params['filter'] = array_merge(['type' => ['value' => 'category', 'relation' => null]], $params['filter']);", "$", "nodes", "=", "$", "this", "->", "repository", "->", "getContentsByLevel", "(", "$", "params", "[", "'filter'", "]", ",", "$", "params", "[", "'orderBy'", "]", ",", "null", ")", ";", "$", "trees", "=", "$", "this", "->", "repository", "->", "buildTree", "(", "$", "nodes", ")", ";", "// We need to guarantee LaravelCollection here because buildTree will return single root", "// if we have only one", "if", "(", "!", "empty", "(", "$", "trees", ")", "&&", "!", "$", "trees", "instanceof", "LaravelCollection", ")", "{", "$", "trees", "=", "new", "LaravelCollection", "(", "[", "$", "trees", "]", ")", ";", "}", "return", "$", "this", "->", "respondWithSuccess", "(", "$", "trees", ",", "new", "ContentTransformer", ")", ";", "}" ]
Display a listing of the resource as nested tree. @param int|null $id Id used for nested resources @return \Illuminate\Http\JsonResponse
[ "Display", "a", "listing", "of", "the", "resource", "as", "nested", "tree", "." ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/ContentController.php#L132-L168
22,117
GrupaZero/api
src/Gzero/Api/Controller/Admin/ContentController.php
ContentController.buildSyncData
protected function buildSyncData(array $input) { $syncData = []; foreach ($input['data'] as $item) { $syncData[$item['id']] = ['weight' => isset($item['weight']) ? $item['weight'] : 0]; } return $syncData; }
php
protected function buildSyncData(array $input) { $syncData = []; foreach ($input['data'] as $item) { $syncData[$item['id']] = ['weight' => isset($item['weight']) ? $item['weight'] : 0]; } return $syncData; }
[ "protected", "function", "buildSyncData", "(", "array", "$", "input", ")", "{", "$", "syncData", "=", "[", "]", ";", "foreach", "(", "$", "input", "[", "'data'", "]", "as", "$", "item", ")", "{", "$", "syncData", "[", "$", "item", "[", "'id'", "]", "]", "=", "[", "'weight'", "=>", "isset", "(", "$", "item", "[", "'weight'", "]", ")", "?", "$", "item", "[", "'weight'", "]", ":", "0", "]", ";", "}", "return", "$", "syncData", ";", "}" ]
It builds syncData @param array $input Validated input @return mixed
[ "It", "builds", "syncData" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/ContentController.php#L316-L323
22,118
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.getRemainingLifetime
public function getRemainingLifetime( $id, $attributes = array() ) { if ( count( $found = $this->search( $id, $attributes ) ) > 0 ) { $identifier = $found[0][2]; return $this->calcLifetime( $identifier ); } return 0; }
php
public function getRemainingLifetime( $id, $attributes = array() ) { if ( count( $found = $this->search( $id, $attributes ) ) > 0 ) { $identifier = $found[0][2]; return $this->calcLifetime( $identifier ); } return 0; }
[ "public", "function", "getRemainingLifetime", "(", "$", "id", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "if", "(", "count", "(", "$", "found", "=", "$", "this", "->", "search", "(", "$", "id", ",", "$", "attributes", ")", ")", ">", "0", ")", "{", "$", "identifier", "=", "$", "found", "[", "0", "]", "[", "2", "]", ";", "return", "$", "this", "->", "calcLifetime", "(", "$", "identifier", ")", ";", "}", "return", "0", ";", "}" ]
Returns the time in seconds which remains for a cache object, before it gets outdated. In case the cache object is already outdated or does not exists, this method returns 0. @param string $id The item ID @param array(string=>string) $attributes Attributes describing the data @return int The remaining lifetime (0 if it does not exist or outdated)
[ "Returns", "the", "time", "in", "seconds", "which", "remains", "for", "a", "cache", "object", "before", "it", "gets", "outdated", ".", "In", "case", "the", "cache", "object", "is", "already", "outdated", "or", "does", "not", "exists", "this", "method", "returns", "0", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L291-L299
22,119
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.generateIdentifier
public function generateIdentifier( $id, $attributes = null ) { $identifier = strtolower( $this->backendName ) . $this->properties['location'] . $id . ( ( $attributes !== null && !empty( $attributes ) ) ? md5( serialize( $attributes ) ) : '' ); return urlencode( $identifier ); }
php
public function generateIdentifier( $id, $attributes = null ) { $identifier = strtolower( $this->backendName ) . $this->properties['location'] . $id . ( ( $attributes !== null && !empty( $attributes ) ) ? md5( serialize( $attributes ) ) : '' ); return urlencode( $identifier ); }
[ "public", "function", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", "=", "null", ")", "{", "$", "identifier", "=", "strtolower", "(", "$", "this", "->", "backendName", ")", ".", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "id", ".", "(", "(", "$", "attributes", "!==", "null", "&&", "!", "empty", "(", "$", "attributes", ")", ")", "?", "md5", "(", "serialize", "(", "$", "attributes", ")", ")", ":", "''", ")", ";", "return", "urlencode", "(", "$", "identifier", ")", ";", "}" ]
Generates the storage internal identifier from ID and attributes. @param string $id The ID @param array(string=>string) $attributes Attributes describing the data @return string The generated identifier
[ "Generates", "the", "storage", "internal", "identifier", "from", "ID", "and", "attributes", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L308-L319
22,120
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.purge
public function purge( $limit = null ) { $this->fetchSearchRegistry( true ); $purgedIds = array(); $ttl = $this->properties['options']->ttl; foreach ( $this->searchRegistry[$this->properties['location']] as $id => $identifiers ) { $deleted = false; foreach( $identifiers as $identifier => $data ) { if ( $ttl !== false && $this->calcLifetime( $identifier ) == 0 ) { // Since ID <-> identifier mapping is ambigious, this does // not ensure that all data for an ID is deleted. However, // this should work if used properly $this->backend->delete( $identifier ); $this->unRegisterIdentifier( null, null, $identifiers, true ); // Avoid adding an ID twice to the returned array $deleted = true; } } if ( $deleted === true ) { $purgedIds[] = $id; } if ( $limit !== null && count( $purgedIds ) >= $limit ) { break; } } $this->storeSearchRegistry(); return $purgedIds; }
php
public function purge( $limit = null ) { $this->fetchSearchRegistry( true ); $purgedIds = array(); $ttl = $this->properties['options']->ttl; foreach ( $this->searchRegistry[$this->properties['location']] as $id => $identifiers ) { $deleted = false; foreach( $identifiers as $identifier => $data ) { if ( $ttl !== false && $this->calcLifetime( $identifier ) == 0 ) { // Since ID <-> identifier mapping is ambigious, this does // not ensure that all data for an ID is deleted. However, // this should work if used properly $this->backend->delete( $identifier ); $this->unRegisterIdentifier( null, null, $identifiers, true ); // Avoid adding an ID twice to the returned array $deleted = true; } } if ( $deleted === true ) { $purgedIds[] = $id; } if ( $limit !== null && count( $purgedIds ) >= $limit ) { break; } } $this->storeSearchRegistry(); return $purgedIds; }
[ "public", "function", "purge", "(", "$", "limit", "=", "null", ")", "{", "$", "this", "->", "fetchSearchRegistry", "(", "true", ")", ";", "$", "purgedIds", "=", "array", "(", ")", ";", "$", "ttl", "=", "$", "this", "->", "properties", "[", "'options'", "]", "->", "ttl", ";", "foreach", "(", "$", "this", "->", "searchRegistry", "[", "$", "this", "->", "properties", "[", "'location'", "]", "]", "as", "$", "id", "=>", "$", "identifiers", ")", "{", "$", "deleted", "=", "false", ";", "foreach", "(", "$", "identifiers", "as", "$", "identifier", "=>", "$", "data", ")", "{", "if", "(", "$", "ttl", "!==", "false", "&&", "$", "this", "->", "calcLifetime", "(", "$", "identifier", ")", "==", "0", ")", "{", "// Since ID <-> identifier mapping is ambigious, this does", "// not ensure that all data for an ID is deleted. However,", "// this should work if used properly", "$", "this", "->", "backend", "->", "delete", "(", "$", "identifier", ")", ";", "$", "this", "->", "unRegisterIdentifier", "(", "null", ",", "null", ",", "$", "identifiers", ",", "true", ")", ";", "// Avoid adding an ID twice to the returned array", "$", "deleted", "=", "true", ";", "}", "}", "if", "(", "$", "deleted", "===", "true", ")", "{", "$", "purgedIds", "[", "]", "=", "$", "id", ";", "}", "if", "(", "$", "limit", "!==", "null", "&&", "count", "(", "$", "purgedIds", ")", ">=", "$", "limit", ")", "{", "break", ";", "}", "}", "$", "this", "->", "storeSearchRegistry", "(", ")", ";", "return", "$", "purgedIds", ";", "}" ]
Purge outdated data from the storage. This method purges outdated data from the cache. If $limit is given, a maximum of $limit items is purged. Otherwise all outdated items are purged. The method returns an array containing the IDs of all cache items that have been purged. @param int $limit @return array(string)
[ "Purge", "outdated", "data", "from", "the", "storage", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L332-L366
22,121
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.reset
public function reset() { $this->backend->reset(); $this->registry = array(); $this->searchRegistry = array( $this->properties['location'] => null ); $this->storeSearchRegistry(); }
php
public function reset() { $this->backend->reset(); $this->registry = array(); $this->searchRegistry = array( $this->properties['location'] => null ); $this->storeSearchRegistry(); }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "backend", "->", "reset", "(", ")", ";", "$", "this", "->", "registry", "=", "array", "(", ")", ";", "$", "this", "->", "searchRegistry", "=", "array", "(", "$", "this", "->", "properties", "[", "'location'", "]", "=>", "null", ")", ";", "$", "this", "->", "storeSearchRegistry", "(", ")", ";", "}" ]
Reset the complete storage. This method resets the complete cache storage. All content (including content stored with the {@link ezcCacheStackMetaDataStorage} interfacer) must be deleted and the cache storage must appear as if it has just newly been created. @return void
[ "Reset", "the", "complete", "storage", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L378-L384
22,122
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.registerIdentifier
protected function registerIdentifier( $id = null, $attributes = array(), $identifier = null ) { $identifier = ( $identifier !== null ) ? $identifier : $this->generateIdentifier( $id, $attributes ); $location = $this->properties['location']; $this->fetchSearchRegistry(); // Makes sure the identifier exists if ( !isset( $this->searchRegistry[$location][$id][$identifier] ) ) { // Makes sure the id exists if ( !isset( $this->searchRegistry[$location][$id] ) || !is_array( $this->searchRegistry[$location][$id] ) ) { $this->searchRegistry[$location][$id] = array(); } $this->searchRegistry[$location][$id][$identifier] = new ezcCacheStorageMemoryRegisterStruct( $id, $attributes, $identifier, $location ); $this->storeSearchRegistry(); } }
php
protected function registerIdentifier( $id = null, $attributes = array(), $identifier = null ) { $identifier = ( $identifier !== null ) ? $identifier : $this->generateIdentifier( $id, $attributes ); $location = $this->properties['location']; $this->fetchSearchRegistry(); // Makes sure the identifier exists if ( !isset( $this->searchRegistry[$location][$id][$identifier] ) ) { // Makes sure the id exists if ( !isset( $this->searchRegistry[$location][$id] ) || !is_array( $this->searchRegistry[$location][$id] ) ) { $this->searchRegistry[$location][$id] = array(); } $this->searchRegistry[$location][$id][$identifier] = new ezcCacheStorageMemoryRegisterStruct( $id, $attributes, $identifier, $location ); $this->storeSearchRegistry(); } }
[ "protected", "function", "registerIdentifier", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "identifier", "=", "null", ")", "{", "$", "identifier", "=", "(", "$", "identifier", "!==", "null", ")", "?", "$", "identifier", ":", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "$", "location", "=", "$", "this", "->", "properties", "[", "'location'", "]", ";", "$", "this", "->", "fetchSearchRegistry", "(", ")", ";", "// Makes sure the identifier exists", "if", "(", "!", "isset", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", "[", "$", "identifier", "]", ")", ")", "{", "// Makes sure the id exists", "if", "(", "!", "isset", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", ")", ")", "{", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", "[", "$", "identifier", "]", "=", "new", "ezcCacheStorageMemoryRegisterStruct", "(", "$", "id", ",", "$", "attributes", ",", "$", "identifier", ",", "$", "location", ")", ";", "$", "this", "->", "storeSearchRegistry", "(", ")", ";", "}", "}" ]
Registers an identifier to facilitate searching. @param string $id ID for the cache item @param array $attributes Attributes for the cache item @param string $identifier Identifier generated for the cache item
[ "Registers", "an", "identifier", "to", "facilitate", "searching", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L513-L533
22,123
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.unRegisterIdentifier
protected function unRegisterIdentifier( $id = null, $attributes = array(), $identifier = null, $delayStore = false ) { $identifier = ( $identifier !== null ) ? $identifier : $this->generateIdentifier( $id, $attributes ); $location = $this->properties['location']; $this->fetchSearchRegistry( !$delayStore ); if ( $this->searchRegistry === false ) { $this->searchRegistry = array(); } if ( isset( $this->searchRegistry[$location][$id][$identifier] ) ) { unset( $this->searchRegistry[$location][$id][$identifier], $this->registry[$location][$id][$identifier] ); if ( $delayStore === false ) { $this->storeSearchRegistry(); } } }
php
protected function unRegisterIdentifier( $id = null, $attributes = array(), $identifier = null, $delayStore = false ) { $identifier = ( $identifier !== null ) ? $identifier : $this->generateIdentifier( $id, $attributes ); $location = $this->properties['location']; $this->fetchSearchRegistry( !$delayStore ); if ( $this->searchRegistry === false ) { $this->searchRegistry = array(); } if ( isset( $this->searchRegistry[$location][$id][$identifier] ) ) { unset( $this->searchRegistry[$location][$id][$identifier], $this->registry[$location][$id][$identifier] ); if ( $delayStore === false ) { $this->storeSearchRegistry(); } } }
[ "protected", "function", "unRegisterIdentifier", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "identifier", "=", "null", ",", "$", "delayStore", "=", "false", ")", "{", "$", "identifier", "=", "(", "$", "identifier", "!==", "null", ")", "?", "$", "identifier", ":", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "$", "location", "=", "$", "this", "->", "properties", "[", "'location'", "]", ";", "$", "this", "->", "fetchSearchRegistry", "(", "!", "$", "delayStore", ")", ";", "if", "(", "$", "this", "->", "searchRegistry", "===", "false", ")", "{", "$", "this", "->", "searchRegistry", "=", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", "[", "$", "identifier", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "[", "$", "id", "]", "[", "$", "identifier", "]", ",", "$", "this", "->", "registry", "[", "$", "location", "]", "[", "$", "id", "]", "[", "$", "identifier", "]", ")", ";", "if", "(", "$", "delayStore", "===", "false", ")", "{", "$", "this", "->", "storeSearchRegistry", "(", ")", ";", "}", "}", "}" ]
Un-registers a previously registered identifier. @param string $id ID for the cache item @param array $attributes Attributes for the cache item @param string $identifier Identifier generated for the cache item @param bool $delayStore Delays the storing of the updated search registry
[ "Un", "-", "registers", "a", "previously", "registered", "identifier", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L543-L563
22,124
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.fetchSearchRegistry
protected function fetchSearchRegistry( $requireFresh = false ) { $location = $this->properties['location']; if ( !is_array( $this->searchRegistry ) ) { $this->searchRegistry = array(); } if ( !isset( $this->searchRegistry[$location] ) || !is_array( $this->searchRegistry[$location] ) ) { $this->searchRegistry[$location] = array(); } // Makes sure the registry exists if ( empty( $this->searchRegistry[$location] ) || $requireFresh === true ) { $this->searchRegistry[$location] = $this->backend->fetch( $this->registryName . '_' . urlencode( $location ) ); } }
php
protected function fetchSearchRegistry( $requireFresh = false ) { $location = $this->properties['location']; if ( !is_array( $this->searchRegistry ) ) { $this->searchRegistry = array(); } if ( !isset( $this->searchRegistry[$location] ) || !is_array( $this->searchRegistry[$location] ) ) { $this->searchRegistry[$location] = array(); } // Makes sure the registry exists if ( empty( $this->searchRegistry[$location] ) || $requireFresh === true ) { $this->searchRegistry[$location] = $this->backend->fetch( $this->registryName . '_' . urlencode( $location ) ); } }
[ "protected", "function", "fetchSearchRegistry", "(", "$", "requireFresh", "=", "false", ")", "{", "$", "location", "=", "$", "this", "->", "properties", "[", "'location'", "]", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "searchRegistry", ")", ")", "{", "$", "this", "->", "searchRegistry", "=", "array", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", ")", ")", "{", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "=", "array", "(", ")", ";", "}", "// Makes sure the registry exists", "if", "(", "empty", "(", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", ")", "||", "$", "requireFresh", "===", "true", ")", "{", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "=", "$", "this", "->", "backend", "->", "fetch", "(", "$", "this", "->", "registryName", ".", "'_'", ".", "urlencode", "(", "$", "location", ")", ")", ";", "}", "}" ]
Fetches the search registry from the backend or creates it if empty. @param bool $requireFresh To create a new search registry or not
[ "Fetches", "the", "search", "registry", "from", "the", "backend", "or", "creates", "it", "if", "empty", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L570-L589
22,125
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php
ezcCacheStorageMemory.storeSearchRegistry
protected function storeSearchRegistry() { $location = $this->properties['location']; $this->backend->store( $this->registryName . '_' . urlencode( $location ), $this->searchRegistry[$location] ); $this->searchRegistry[$location] = null; $this->fetchSearchRegistry( true ); }
php
protected function storeSearchRegistry() { $location = $this->properties['location']; $this->backend->store( $this->registryName . '_' . urlencode( $location ), $this->searchRegistry[$location] ); $this->searchRegistry[$location] = null; $this->fetchSearchRegistry( true ); }
[ "protected", "function", "storeSearchRegistry", "(", ")", "{", "$", "location", "=", "$", "this", "->", "properties", "[", "'location'", "]", ";", "$", "this", "->", "backend", "->", "store", "(", "$", "this", "->", "registryName", ".", "'_'", ".", "urlencode", "(", "$", "location", ")", ",", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", ")", ";", "$", "this", "->", "searchRegistry", "[", "$", "location", "]", "=", "null", ";", "$", "this", "->", "fetchSearchRegistry", "(", "true", ")", ";", "}" ]
Stores the search registry in the backend.
[ "Stores", "the", "search", "registry", "in", "the", "backend", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/memory.php#L594-L602
22,126
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.apiStore
public function apiStore() { DB::beginTransaction(); try { $record = $this->__apiStore(); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0002' . $e->getCode(), $e->getMessage()); } DB::commit(); return response($record); }
php
public function apiStore() { DB::beginTransaction(); try { $record = $this->__apiStore(); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0002' . $e->getCode(), $e->getMessage()); } DB::commit(); return response($record); }
[ "public", "function", "apiStore", "(", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "$", "record", "=", "$", "this", "->", "__apiStore", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "HCLog", "::", "error", "(", "'CORE-0002'", ".", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "DB", "::", "commit", "(", ")", ";", "return", "response", "(", "$", "record", ")", ";", "}" ]
Function which will store new record @return mixed
[ "Function", "which", "will", "store", "new", "record" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L100-L115
22,127
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.apiUpdate
public function apiUpdate(string $id) { DB::beginTransaction(); try { $record = $this->__apiUpdate($id); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0003' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
php
public function apiUpdate(string $id) { DB::beginTransaction(); try { $record = $this->__apiUpdate($id); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0003' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
[ "public", "function", "apiUpdate", "(", "string", "$", "id", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "$", "record", "=", "$", "this", "->", "__apiUpdate", "(", "$", "id", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "HCLog", "::", "error", "(", "'CORE-0003'", ".", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "DB", "::", "commit", "(", ")", ";", "return", "$", "record", ";", "}" ]
Function which will update record @param $id @return mixed
[ "Function", "which", "will", "update", "record" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L138-L153
22,128
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.apiUpdateStrict
public function apiUpdateStrict(string $id) { DB::beginTransaction(); try { $record = $this->__apiUpdateStrict($id); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0003' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
php
public function apiUpdateStrict(string $id) { DB::beginTransaction(); try { $record = $this->__apiUpdateStrict($id); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0003' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
[ "public", "function", "apiUpdateStrict", "(", "string", "$", "id", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "$", "record", "=", "$", "this", "->", "__apiUpdateStrict", "(", "$", "id", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "HCLog", "::", "error", "(", "'CORE-0003'", ".", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "DB", "::", "commit", "(", ")", ";", "return", "$", "record", ";", "}" ]
Function which will update specific values of the record @param $id @return mixed
[ "Function", "which", "will", "update", "specific", "values", "of", "the", "record" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L177-L192
22,129
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.initializeDelete
private function initializeDelete(string $id = null, bool $soft) { if ($id) $list = [$id]; else $list = request()->input('list'); if (sizeOf($list) <= 0) return HCLog::info('CORE-0004', trans('HCTranslations::core.nothing_to_delete')); DB::beginTransaction(); try { if ($soft) $response = $this->__apiDestroy($list); else $response = $this->__apiForceDelete($list); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0005' . $e->getCode(), $e->getMessage()); } DB::commit(); if (isset($response)) return $response; return ['success' => true, 'list' => $list]; }
php
private function initializeDelete(string $id = null, bool $soft) { if ($id) $list = [$id]; else $list = request()->input('list'); if (sizeOf($list) <= 0) return HCLog::info('CORE-0004', trans('HCTranslations::core.nothing_to_delete')); DB::beginTransaction(); try { if ($soft) $response = $this->__apiDestroy($list); else $response = $this->__apiForceDelete($list); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0005' . $e->getCode(), $e->getMessage()); } DB::commit(); if (isset($response)) return $response; return ['success' => true, 'list' => $list]; }
[ "private", "function", "initializeDelete", "(", "string", "$", "id", "=", "null", ",", "bool", "$", "soft", ")", "{", "if", "(", "$", "id", ")", "$", "list", "=", "[", "$", "id", "]", ";", "else", "$", "list", "=", "request", "(", ")", "->", "input", "(", "'list'", ")", ";", "if", "(", "sizeOf", "(", "$", "list", ")", "<=", "0", ")", "return", "HCLog", "::", "info", "(", "'CORE-0004'", ",", "trans", "(", "'HCTranslations::core.nothing_to_delete'", ")", ")", ";", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "if", "(", "$", "soft", ")", "$", "response", "=", "$", "this", "->", "__apiDestroy", "(", "$", "list", ")", ";", "else", "$", "response", "=", "$", "this", "->", "__apiForceDelete", "(", "$", "list", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "HCLog", "::", "error", "(", "'CORE-0005'", ".", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "DB", "::", "commit", "(", ")", ";", "if", "(", "isset", "(", "$", "response", ")", ")", "return", "$", "response", ";", "return", "[", "'success'", "=>", "true", ",", "'list'", "=>", "$", "list", "]", ";", "}" ]
Function which will actually call deletion function @param string $id @param bool $soft @return array @internal param $callback
[ "Function", "which", "will", "actually", "call", "deletion", "function" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L245-L274
22,130
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.apiRestore
public function apiRestore() { $toRestore = request()->input('list'); if (sizeOf($toRestore) <= 0) return HCLog::info('CORE-0006', trans('HCTranslations::core.nothing_to_restore')); $response = $this->__apiRestore($toRestore); if (isset($response)) return $response; return ['success' => true, 'list' => $toRestore]; }
php
public function apiRestore() { $toRestore = request()->input('list'); if (sizeOf($toRestore) <= 0) return HCLog::info('CORE-0006', trans('HCTranslations::core.nothing_to_restore')); $response = $this->__apiRestore($toRestore); if (isset($response)) return $response; return ['success' => true, 'list' => $toRestore]; }
[ "public", "function", "apiRestore", "(", ")", "{", "$", "toRestore", "=", "request", "(", ")", "->", "input", "(", "'list'", ")", ";", "if", "(", "sizeOf", "(", "$", "toRestore", ")", "<=", "0", ")", "return", "HCLog", "::", "info", "(", "'CORE-0006'", ",", "trans", "(", "'HCTranslations::core.nothing_to_restore'", ")", ")", ";", "$", "response", "=", "$", "this", "->", "__apiRestore", "(", "$", "toRestore", ")", ";", "if", "(", "isset", "(", "$", "response", ")", ")", "return", "$", "response", ";", "return", "[", "'success'", "=>", "true", ",", "'list'", "=>", "$", "toRestore", "]", ";", "}" ]
Recovers items from database by given id's Just need to set wanted Model name with list parameter @return mixed
[ "Recovers", "items", "from", "database", "by", "given", "id", "s", "Just", "need", "to", "set", "wanted", "Model", "name", "with", "list", "parameter" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L313-L326
22,131
interactivesolutions/honeycomb-core
src/http/controllers/HCBaseController.php
HCBaseController.apiMerge
public function apiMerge() { DB::beginTransaction(); try { $record = $this->__apiMerge(); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0007' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
php
public function apiMerge() { DB::beginTransaction(); try { $record = $this->__apiMerge(); } catch (\Exception $e) { DB::rollback(); return HCLog::error('CORE-0007' . $e->getCode(), $e->getMessage()); } DB::commit(); return $record; }
[ "public", "function", "apiMerge", "(", ")", "{", "DB", "::", "beginTransaction", "(", ")", ";", "try", "{", "$", "record", "=", "$", "this", "->", "__apiMerge", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "DB", "::", "rollback", "(", ")", ";", "return", "HCLog", "::", "error", "(", "'CORE-0007'", ".", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "DB", "::", "commit", "(", ")", ";", "return", "$", "record", ";", "}" ]
Function will can be used to merge multiple records into one @return mixed
[ "Function", "will", "can", "be", "used", "to", "merge", "multiple", "records", "into", "one" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/HCBaseController.php#L359-L374
22,132
WellCommerce/AppBundle
Service/Currency/Importer/EcbRatesImporter.php
EcbRatesImporter.downloadExchangeRatesTable
protected function downloadExchangeRatesTable() { try { $this->table[$this->baseCurrency] = 1; $xml = simplexml_load_file($this->url, 'SimpleXMLElement', LIBXML_NOWARNING); if ($xml instanceof \SimpleXMLElement) { $data = $xml->xpath('//gesmes:Envelope/*[3]/*'); foreach ($data[0]->children() as $child) { $currency = (string)$child->attributes()->currency; $exchangeRate = (string)$child->attributes()->rate; $this->table[$currency] = $exchangeRate; } } } catch (\Exception $e) { throw new \RuntimeException('Cannot download rates from ECB.'); } }
php
protected function downloadExchangeRatesTable() { try { $this->table[$this->baseCurrency] = 1; $xml = simplexml_load_file($this->url, 'SimpleXMLElement', LIBXML_NOWARNING); if ($xml instanceof \SimpleXMLElement) { $data = $xml->xpath('//gesmes:Envelope/*[3]/*'); foreach ($data[0]->children() as $child) { $currency = (string)$child->attributes()->currency; $exchangeRate = (string)$child->attributes()->rate; $this->table[$currency] = $exchangeRate; } } } catch (\Exception $e) { throw new \RuntimeException('Cannot download rates from ECB.'); } }
[ "protected", "function", "downloadExchangeRatesTable", "(", ")", "{", "try", "{", "$", "this", "->", "table", "[", "$", "this", "->", "baseCurrency", "]", "=", "1", ";", "$", "xml", "=", "simplexml_load_file", "(", "$", "this", "->", "url", ",", "'SimpleXMLElement'", ",", "LIBXML_NOWARNING", ")", ";", "if", "(", "$", "xml", "instanceof", "\\", "SimpleXMLElement", ")", "{", "$", "data", "=", "$", "xml", "->", "xpath", "(", "'//gesmes:Envelope/*[3]/*'", ")", ";", "foreach", "(", "$", "data", "[", "0", "]", "->", "children", "(", ")", "as", "$", "child", ")", "{", "$", "currency", "=", "(", "string", ")", "$", "child", "->", "attributes", "(", ")", "->", "currency", ";", "$", "exchangeRate", "=", "(", "string", ")", "$", "child", "->", "attributes", "(", ")", "->", "rate", ";", "$", "this", "->", "table", "[", "$", "currency", "]", "=", "$", "exchangeRate", ";", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot download rates from ECB.'", ")", ";", "}", "}" ]
Downloads exchange rates table from ECB
[ "Downloads", "exchange", "rates", "table", "from", "ECB" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Service/Currency/Importer/EcbRatesImporter.php#L43-L63
22,133
WellCommerce/AppBundle
Service/Currency/Importer/EcbRatesImporter.php
EcbRatesImporter.updateCurrencyRates
protected function updateCurrencyRates(Currency $currency) { $baseExchangeRate = $this->table[$currency->getCode()]; foreach ($this->table as $currencySymbol => $exchangeRate) { $rate = $this->calculateExchangeRate($baseExchangeRate, $currencySymbol); $this->addUpdateExchangeRate($currency->getCode(), $currencySymbol, $rate); } $this->helper->getEntityManager()->flush(); }
php
protected function updateCurrencyRates(Currency $currency) { $baseExchangeRate = $this->table[$currency->getCode()]; foreach ($this->table as $currencySymbol => $exchangeRate) { $rate = $this->calculateExchangeRate($baseExchangeRate, $currencySymbol); $this->addUpdateExchangeRate($currency->getCode(), $currencySymbol, $rate); } $this->helper->getEntityManager()->flush(); }
[ "protected", "function", "updateCurrencyRates", "(", "Currency", "$", "currency", ")", "{", "$", "baseExchangeRate", "=", "$", "this", "->", "table", "[", "$", "currency", "->", "getCode", "(", ")", "]", ";", "foreach", "(", "$", "this", "->", "table", "as", "$", "currencySymbol", "=>", "$", "exchangeRate", ")", "{", "$", "rate", "=", "$", "this", "->", "calculateExchangeRate", "(", "$", "baseExchangeRate", ",", "$", "currencySymbol", ")", ";", "$", "this", "->", "addUpdateExchangeRate", "(", "$", "currency", "->", "getCode", "(", ")", ",", "$", "currencySymbol", ",", "$", "rate", ")", ";", "}", "$", "this", "->", "helper", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "}" ]
Updates managed currency with exchange rates @param Currency $currency
[ "Updates", "managed", "currency", "with", "exchange", "rates" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Service/Currency/Importer/EcbRatesImporter.php#L70-L80
22,134
motivatedsloth/noaa
noaa/NOAA.php
NOAA.point
protected function point(){ if(!$this->point->isLoaded()){ $url = str_replace("{point}", $this->point->getLat() . "," . $this->point->getLon(), self::POINT); $res = $this->load($url, Point::TTL); $this->point->setProperties($res); } return $this->point; }
php
protected function point(){ if(!$this->point->isLoaded()){ $url = str_replace("{point}", $this->point->getLat() . "," . $this->point->getLon(), self::POINT); $res = $this->load($url, Point::TTL); $this->point->setProperties($res); } return $this->point; }
[ "protected", "function", "point", "(", ")", "{", "if", "(", "!", "$", "this", "->", "point", "->", "isLoaded", "(", ")", ")", "{", "$", "url", "=", "str_replace", "(", "\"{point}\"", ",", "$", "this", "->", "point", "->", "getLat", "(", ")", ".", "\",\"", ".", "$", "this", "->", "point", "->", "getLon", "(", ")", ",", "self", "::", "POINT", ")", ";", "$", "res", "=", "$", "this", "->", "load", "(", "$", "url", ",", "Point", "::", "TTL", ")", ";", "$", "this", "->", "point", "->", "setProperties", "(", "$", "res", ")", ";", "}", "return", "$", "this", "->", "point", ";", "}" ]
ensure point has data loaded
[ "ensure", "point", "has", "data", "loaded" ]
621c8dab1d774ec2810a508941f568b716ce779a
https://github.com/motivatedsloth/noaa/blob/621c8dab1d774ec2810a508941f568b716ce779a/noaa/NOAA.php#L97-L104
22,135
thelia-modules/CustomerGroup
Handler/CustomerGroupHandler.php
CustomerGroupHandler.getGroup
public function getGroup() { /** @var Request $request */ $request = $this->container->get('request'); $groupInfo = $request->getSession()->get(CustomerGroup::getModuleCode()); return $groupInfo; }
php
public function getGroup() { /** @var Request $request */ $request = $this->container->get('request'); $groupInfo = $request->getSession()->get(CustomerGroup::getModuleCode()); return $groupInfo; }
[ "public", "function", "getGroup", "(", ")", "{", "/** @var Request $request */", "$", "request", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", ";", "$", "groupInfo", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "CustomerGroup", "::", "getModuleCode", "(", ")", ")", ";", "return", "$", "groupInfo", ";", "}" ]
Get CustomerGroup of the current customer @return array|null
[ "Get", "CustomerGroup", "of", "the", "current", "customer" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Handler/CustomerGroupHandler.php#L33-L41
22,136
thelia-modules/CustomerGroup
Handler/CustomerGroupHandler.php
CustomerGroupHandler.checkGroup
public function checkGroup($groupCode) { /** @var SecurityContext $securityContext */ $securityContext = $this->container->get('thelia.securityContext'); return $securityContext->hasCustomerUser() && $this->getGroupCode() === $groupCode; }
php
public function checkGroup($groupCode) { /** @var SecurityContext $securityContext */ $securityContext = $this->container->get('thelia.securityContext'); return $securityContext->hasCustomerUser() && $this->getGroupCode() === $groupCode; }
[ "public", "function", "checkGroup", "(", "$", "groupCode", ")", "{", "/** @var SecurityContext $securityContext */", "$", "securityContext", "=", "$", "this", "->", "container", "->", "get", "(", "'thelia.securityContext'", ")", ";", "return", "$", "securityContext", "->", "hasCustomerUser", "(", ")", "&&", "$", "this", "->", "getGroupCode", "(", ")", "===", "$", "groupCode", ";", "}" ]
Check if the current customer is in the asked group @param string $groupCode Code for the group to check @return boolean @uses getGroupCode()
[ "Check", "if", "the", "current", "customer", "is", "in", "the", "asked", "group" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Handler/CustomerGroupHandler.php#L66-L72
22,137
thelia-modules/CustomerGroup
Handler/CustomerGroupHandler.php
CustomerGroupHandler.checkCustomerHasGroup
public function checkCustomerHasGroup(Customer $customer, $groupCode) { $group = CustomerCustomerGroupQuery::create() ->filterByCustomer($customer) ->useCustomerGroupQuery() ->filterByCode($groupCode) ->endUse() ->findOne(); return $group !== null; }
php
public function checkCustomerHasGroup(Customer $customer, $groupCode) { $group = CustomerCustomerGroupQuery::create() ->filterByCustomer($customer) ->useCustomerGroupQuery() ->filterByCode($groupCode) ->endUse() ->findOne(); return $group !== null; }
[ "public", "function", "checkCustomerHasGroup", "(", "Customer", "$", "customer", ",", "$", "groupCode", ")", "{", "$", "group", "=", "CustomerCustomerGroupQuery", "::", "create", "(", ")", "->", "filterByCustomer", "(", "$", "customer", ")", "->", "useCustomerGroupQuery", "(", ")", "->", "filterByCode", "(", "$", "groupCode", ")", "->", "endUse", "(", ")", "->", "findOne", "(", ")", ";", "return", "$", "group", "!==", "null", ";", "}" ]
Check that a customer belongs to a group. @param Customer $customer @param string $groupCode @return bool
[ "Check", "that", "a", "customer", "belongs", "to", "a", "group", "." ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Handler/CustomerGroupHandler.php#L82-L92
22,138
kenphp/ken
src/Application.php
Application.init
protected function init() { $this->container->set('logger', function($c) { $configuration = $c->get('configuration'); $logger = new Logger($configuration['logger']); return $logger; }); $this->container->set(MiddlewareFactory::class, function($c) { return new MiddlewareFactory(); }); $this->container->set('request', function($c) { $psr17Factory = new Psr17Factory(); $creator = new ServerRequestCreator( $psr17Factory, // ServerRequestFactory $psr17Factory, // UriFactory $psr17Factory, // UploadedFileFactory $psr17Factory // StreamFactory ); return $creator->fromGlobals(); }); $this->container->set('router', function($c) { return new Router(); }); $this->container->set('response', function($c) { return new Response(); }); $this->container->set('view', function($c) { $configuration = $c->get('configuration')['view']; $viewFunctions = isset($configuration['viewFunctions']) ? $configuration['viewFunctions'] : []; return new Plates($configuration['viewPath'], $viewFunctions); }); $this->registerErrorHandler(); }
php
protected function init() { $this->container->set('logger', function($c) { $configuration = $c->get('configuration'); $logger = new Logger($configuration['logger']); return $logger; }); $this->container->set(MiddlewareFactory::class, function($c) { return new MiddlewareFactory(); }); $this->container->set('request', function($c) { $psr17Factory = new Psr17Factory(); $creator = new ServerRequestCreator( $psr17Factory, // ServerRequestFactory $psr17Factory, // UriFactory $psr17Factory, // UploadedFileFactory $psr17Factory // StreamFactory ); return $creator->fromGlobals(); }); $this->container->set('router', function($c) { return new Router(); }); $this->container->set('response', function($c) { return new Response(); }); $this->container->set('view', function($c) { $configuration = $c->get('configuration')['view']; $viewFunctions = isset($configuration['viewFunctions']) ? $configuration['viewFunctions'] : []; return new Plates($configuration['viewPath'], $viewFunctions); }); $this->registerErrorHandler(); }
[ "protected", "function", "init", "(", ")", "{", "$", "this", "->", "container", "->", "set", "(", "'logger'", ",", "function", "(", "$", "c", ")", "{", "$", "configuration", "=", "$", "c", "->", "get", "(", "'configuration'", ")", ";", "$", "logger", "=", "new", "Logger", "(", "$", "configuration", "[", "'logger'", "]", ")", ";", "return", "$", "logger", ";", "}", ")", ";", "$", "this", "->", "container", "->", "set", "(", "MiddlewareFactory", "::", "class", ",", "function", "(", "$", "c", ")", "{", "return", "new", "MiddlewareFactory", "(", ")", ";", "}", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'request'", ",", "function", "(", "$", "c", ")", "{", "$", "psr17Factory", "=", "new", "Psr17Factory", "(", ")", ";", "$", "creator", "=", "new", "ServerRequestCreator", "(", "$", "psr17Factory", ",", "// ServerRequestFactory", "$", "psr17Factory", ",", "// UriFactory", "$", "psr17Factory", ",", "// UploadedFileFactory", "$", "psr17Factory", "// StreamFactory", ")", ";", "return", "$", "creator", "->", "fromGlobals", "(", ")", ";", "}", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'router'", ",", "function", "(", "$", "c", ")", "{", "return", "new", "Router", "(", ")", ";", "}", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'response'", ",", "function", "(", "$", "c", ")", "{", "return", "new", "Response", "(", ")", ";", "}", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'view'", ",", "function", "(", "$", "c", ")", "{", "$", "configuration", "=", "$", "c", "->", "get", "(", "'configuration'", ")", "[", "'view'", "]", ";", "$", "viewFunctions", "=", "isset", "(", "$", "configuration", "[", "'viewFunctions'", "]", ")", "?", "$", "configuration", "[", "'viewFunctions'", "]", ":", "[", "]", ";", "return", "new", "Plates", "(", "$", "configuration", "[", "'viewPath'", "]", ",", "$", "viewFunctions", ")", ";", "}", ")", ";", "$", "this", "->", "registerErrorHandler", "(", ")", ";", "}" ]
Initializes application's components
[ "Initializes", "application", "s", "components" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Application.php#L62-L103
22,139
kenphp/ken
src/Application.php
Application.registerErrorHandler
public function registerErrorHandler() { $whoops = new \Whoops\Run(); $configuration = $this->getConfiguration(); if (isset($configuration['debug']) && $configuration['debug']) { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\CallbackHandler(function ($exception) { $this->logger->error($exception->getMessage(), compact('exception')); $request = $this->container->get('request'); $response = $this->container->get('response'); $view = $this->container->get('view'); $errorInfo = ['message' => $exception->getMessage()]; if (is_a($exception, HttpException::class)) { $errorInfo['code'] = $exception->getCode(); } else { $errorInfo['code'] = 500; } $headerAccept = $request->getHeader('Accept'); if (in_array('application/json', $headerAccept)) { $response = $response->withStatus($errorInfo['code']); $response->getBody()->write(json_encode($errorInfo)); $response = $response->withHeader('Content-Type', 'application/json'); } else { $response = $view->render($response, 'error', $errorInfo); } $this->emitResponse($response); return \Whoops\Handler\Handler::DONE; })); } $whoops->register(); }
php
public function registerErrorHandler() { $whoops = new \Whoops\Run(); $configuration = $this->getConfiguration(); if (isset($configuration['debug']) && $configuration['debug']) { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\CallbackHandler(function ($exception) { $this->logger->error($exception->getMessage(), compact('exception')); $request = $this->container->get('request'); $response = $this->container->get('response'); $view = $this->container->get('view'); $errorInfo = ['message' => $exception->getMessage()]; if (is_a($exception, HttpException::class)) { $errorInfo['code'] = $exception->getCode(); } else { $errorInfo['code'] = 500; } $headerAccept = $request->getHeader('Accept'); if (in_array('application/json', $headerAccept)) { $response = $response->withStatus($errorInfo['code']); $response->getBody()->write(json_encode($errorInfo)); $response = $response->withHeader('Content-Type', 'application/json'); } else { $response = $view->render($response, 'error', $errorInfo); } $this->emitResponse($response); return \Whoops\Handler\Handler::DONE; })); } $whoops->register(); }
[ "public", "function", "registerErrorHandler", "(", ")", "{", "$", "whoops", "=", "new", "\\", "Whoops", "\\", "Run", "(", ")", ";", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", ")", ";", "if", "(", "isset", "(", "$", "configuration", "[", "'debug'", "]", ")", "&&", "$", "configuration", "[", "'debug'", "]", ")", "{", "$", "whoops", "->", "pushHandler", "(", "new", "\\", "Whoops", "\\", "Handler", "\\", "PrettyPageHandler", "(", ")", ")", ";", "}", "else", "{", "$", "whoops", "->", "pushHandler", "(", "new", "\\", "Whoops", "\\", "Handler", "\\", "CallbackHandler", "(", "function", "(", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "compact", "(", "'exception'", ")", ")", ";", "$", "request", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", ";", "$", "response", "=", "$", "this", "->", "container", "->", "get", "(", "'response'", ")", ";", "$", "view", "=", "$", "this", "->", "container", "->", "get", "(", "'view'", ")", ";", "$", "errorInfo", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ";", "if", "(", "is_a", "(", "$", "exception", ",", "HttpException", "::", "class", ")", ")", "{", "$", "errorInfo", "[", "'code'", "]", "=", "$", "exception", "->", "getCode", "(", ")", ";", "}", "else", "{", "$", "errorInfo", "[", "'code'", "]", "=", "500", ";", "}", "$", "headerAccept", "=", "$", "request", "->", "getHeader", "(", "'Accept'", ")", ";", "if", "(", "in_array", "(", "'application/json'", ",", "$", "headerAccept", ")", ")", "{", "$", "response", "=", "$", "response", "->", "withStatus", "(", "$", "errorInfo", "[", "'code'", "]", ")", ";", "$", "response", "->", "getBody", "(", ")", "->", "write", "(", "json_encode", "(", "$", "errorInfo", ")", ")", ";", "$", "response", "=", "$", "response", "->", "withHeader", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "}", "else", "{", "$", "response", "=", "$", "view", "->", "render", "(", "$", "response", ",", "'error'", ",", "$", "errorInfo", ")", ";", "}", "$", "this", "->", "emitResponse", "(", "$", "response", ")", ";", "return", "\\", "Whoops", "\\", "Handler", "\\", "Handler", "::", "DONE", ";", "}", ")", ")", ";", "}", "$", "whoops", "->", "register", "(", ")", ";", "}" ]
Registers error handler for this application
[ "Registers", "error", "handler", "for", "this", "application" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Application.php#L108-L147
22,140
kenphp/ken
src/Application.php
Application.run
public function run() { $request = $this->request; $response = $this->response; $config = $this->configuration; $httpMethod = $request->getMethod(); $pathInfo = $request->getUri()->getPath(); if (empty($pathInfo)) { $pathInfo = '/'; } $routeObject = $this->router->resolve($pathInfo, $httpMethod); if($routeObject) { $middlewareList = []; if (isset($routeObject['middleware'])) { $middlewareConfig = $config->get('middlewares'); $middlewareCount = count($routeObject['middleware']); $middlewareNext = null; $middlewareFactory = $this->container->get(MiddlewareFactory::class); for ($i=$middlewareCount-1; $i >= 0; $i--) { $middlewareName = $routeObject['middleware'][$i]; $middlewareClass = $middlewareConfig[$middlewareName]; $middlewareList[$i] = $middlewareFactory->createObject($middlewareClass, [ 'response' => $response, 'next' => $middlewareNext, ]); $middlewareNext = $middlewareList[$i]; } } $baseNamespace = $config->get('controllersNamespace'); $handler = $this->convertCallbackToClosure($routeObject['handler'], $baseNamespace); $params = isset($routeObject['params']) ? $routeObject['params'] : []; $requestHandler = new ServerRequestHandler($response, $handler, $routeObject['params']); if (isset($middlewareList[0])) { $response = $middlewareList[0]->process($request, $requestHandler); } else { $response = $requestHandler->handle($request); } } else { throw new HttpException(404, "Route '{$pathInfo}' not found"); } $this->emitResponse($response); }
php
public function run() { $request = $this->request; $response = $this->response; $config = $this->configuration; $httpMethod = $request->getMethod(); $pathInfo = $request->getUri()->getPath(); if (empty($pathInfo)) { $pathInfo = '/'; } $routeObject = $this->router->resolve($pathInfo, $httpMethod); if($routeObject) { $middlewareList = []; if (isset($routeObject['middleware'])) { $middlewareConfig = $config->get('middlewares'); $middlewareCount = count($routeObject['middleware']); $middlewareNext = null; $middlewareFactory = $this->container->get(MiddlewareFactory::class); for ($i=$middlewareCount-1; $i >= 0; $i--) { $middlewareName = $routeObject['middleware'][$i]; $middlewareClass = $middlewareConfig[$middlewareName]; $middlewareList[$i] = $middlewareFactory->createObject($middlewareClass, [ 'response' => $response, 'next' => $middlewareNext, ]); $middlewareNext = $middlewareList[$i]; } } $baseNamespace = $config->get('controllersNamespace'); $handler = $this->convertCallbackToClosure($routeObject['handler'], $baseNamespace); $params = isset($routeObject['params']) ? $routeObject['params'] : []; $requestHandler = new ServerRequestHandler($response, $handler, $routeObject['params']); if (isset($middlewareList[0])) { $response = $middlewareList[0]->process($request, $requestHandler); } else { $response = $requestHandler->handle($request); } } else { throw new HttpException(404, "Route '{$pathInfo}' not found"); } $this->emitResponse($response); }
[ "public", "function", "run", "(", ")", "{", "$", "request", "=", "$", "this", "->", "request", ";", "$", "response", "=", "$", "this", "->", "response", ";", "$", "config", "=", "$", "this", "->", "configuration", ";", "$", "httpMethod", "=", "$", "request", "->", "getMethod", "(", ")", ";", "$", "pathInfo", "=", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", "if", "(", "empty", "(", "$", "pathInfo", ")", ")", "{", "$", "pathInfo", "=", "'/'", ";", "}", "$", "routeObject", "=", "$", "this", "->", "router", "->", "resolve", "(", "$", "pathInfo", ",", "$", "httpMethod", ")", ";", "if", "(", "$", "routeObject", ")", "{", "$", "middlewareList", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "routeObject", "[", "'middleware'", "]", ")", ")", "{", "$", "middlewareConfig", "=", "$", "config", "->", "get", "(", "'middlewares'", ")", ";", "$", "middlewareCount", "=", "count", "(", "$", "routeObject", "[", "'middleware'", "]", ")", ";", "$", "middlewareNext", "=", "null", ";", "$", "middlewareFactory", "=", "$", "this", "->", "container", "->", "get", "(", "MiddlewareFactory", "::", "class", ")", ";", "for", "(", "$", "i", "=", "$", "middlewareCount", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "middlewareName", "=", "$", "routeObject", "[", "'middleware'", "]", "[", "$", "i", "]", ";", "$", "middlewareClass", "=", "$", "middlewareConfig", "[", "$", "middlewareName", "]", ";", "$", "middlewareList", "[", "$", "i", "]", "=", "$", "middlewareFactory", "->", "createObject", "(", "$", "middlewareClass", ",", "[", "'response'", "=>", "$", "response", ",", "'next'", "=>", "$", "middlewareNext", ",", "]", ")", ";", "$", "middlewareNext", "=", "$", "middlewareList", "[", "$", "i", "]", ";", "}", "}", "$", "baseNamespace", "=", "$", "config", "->", "get", "(", "'controllersNamespace'", ")", ";", "$", "handler", "=", "$", "this", "->", "convertCallbackToClosure", "(", "$", "routeObject", "[", "'handler'", "]", ",", "$", "baseNamespace", ")", ";", "$", "params", "=", "isset", "(", "$", "routeObject", "[", "'params'", "]", ")", "?", "$", "routeObject", "[", "'params'", "]", ":", "[", "]", ";", "$", "requestHandler", "=", "new", "ServerRequestHandler", "(", "$", "response", ",", "$", "handler", ",", "$", "routeObject", "[", "'params'", "]", ")", ";", "if", "(", "isset", "(", "$", "middlewareList", "[", "0", "]", ")", ")", "{", "$", "response", "=", "$", "middlewareList", "[", "0", "]", "->", "process", "(", "$", "request", ",", "$", "requestHandler", ")", ";", "}", "else", "{", "$", "response", "=", "$", "requestHandler", "->", "handle", "(", "$", "request", ")", ";", "}", "}", "else", "{", "throw", "new", "HttpException", "(", "404", ",", "\"Route '{$pathInfo}' not found\"", ")", ";", "}", "$", "this", "->", "emitResponse", "(", "$", "response", ")", ";", "}" ]
Runs application to handle request.
[ "Runs", "application", "to", "handle", "request", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Application.php#L196-L244
22,141
kenphp/ken
src/Application.php
Application.emitResponse
protected function emitResponse(ResponseInterface $response) { $this->logger->flush(); (new \Zend\HttpHandlerRunner\Emitter\SapiEmitter())->emit($response); }
php
protected function emitResponse(ResponseInterface $response) { $this->logger->flush(); (new \Zend\HttpHandlerRunner\Emitter\SapiEmitter())->emit($response); }
[ "protected", "function", "emitResponse", "(", "ResponseInterface", "$", "response", ")", "{", "$", "this", "->", "logger", "->", "flush", "(", ")", ";", "(", "new", "\\", "Zend", "\\", "HttpHandlerRunner", "\\", "Emitter", "\\", "SapiEmitter", "(", ")", ")", "->", "emit", "(", "$", "response", ")", ";", "}" ]
Emits response to client @param ResponseInterface $response
[ "Emits", "response", "to", "client" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Application.php#L250-L253
22,142
kenphp/ken
src/Application.php
Application.convertCallbackToClosure
protected function convertCallbackToClosure($callback, $namespace) { if ($callback instanceof Closure || is_callable($callback)) { return $callback; } elseif (is_string($callback)) { $namespace = rtrim($namespace, '\\').'\\'; $arrCallback = explode('::', $callback); $isStaticCall = count($arrCallback) == 2; if ($isStaticCall) { $className = $namespace.$arrCallback[0]; return [$className, $arrCallback[1]]; } else { $arrCallback = explode(':', $callback); $className = $namespace.$arrCallback[0]; // Must be replaced with a safer way to instantiate an object $obj = $this->container->get($className); return [$obj, $arrCallback[1]]; } } }
php
protected function convertCallbackToClosure($callback, $namespace) { if ($callback instanceof Closure || is_callable($callback)) { return $callback; } elseif (is_string($callback)) { $namespace = rtrim($namespace, '\\').'\\'; $arrCallback = explode('::', $callback); $isStaticCall = count($arrCallback) == 2; if ($isStaticCall) { $className = $namespace.$arrCallback[0]; return [$className, $arrCallback[1]]; } else { $arrCallback = explode(':', $callback); $className = $namespace.$arrCallback[0]; // Must be replaced with a safer way to instantiate an object $obj = $this->container->get($className); return [$obj, $arrCallback[1]]; } } }
[ "protected", "function", "convertCallbackToClosure", "(", "$", "callback", ",", "$", "namespace", ")", "{", "if", "(", "$", "callback", "instanceof", "Closure", "||", "is_callable", "(", "$", "callback", ")", ")", "{", "return", "$", "callback", ";", "}", "elseif", "(", "is_string", "(", "$", "callback", ")", ")", "{", "$", "namespace", "=", "rtrim", "(", "$", "namespace", ",", "'\\\\'", ")", ".", "'\\\\'", ";", "$", "arrCallback", "=", "explode", "(", "'::'", ",", "$", "callback", ")", ";", "$", "isStaticCall", "=", "count", "(", "$", "arrCallback", ")", "==", "2", ";", "if", "(", "$", "isStaticCall", ")", "{", "$", "className", "=", "$", "namespace", ".", "$", "arrCallback", "[", "0", "]", ";", "return", "[", "$", "className", ",", "$", "arrCallback", "[", "1", "]", "]", ";", "}", "else", "{", "$", "arrCallback", "=", "explode", "(", "':'", ",", "$", "callback", ")", ";", "$", "className", "=", "$", "namespace", ".", "$", "arrCallback", "[", "0", "]", ";", "// Must be replaced with a safer way to instantiate an object", "$", "obj", "=", "$", "this", "->", "container", "->", "get", "(", "$", "className", ")", ";", "return", "[", "$", "obj", ",", "$", "arrCallback", "[", "1", "]", "]", ";", "}", "}", "}" ]
Converts callback to Closure. @param string|Closure $callback @param string $namespace @return Closure
[ "Converts", "callback", "to", "Closure", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Application.php#L263-L282
22,143
DesignPond/newsletter
src/Newsletter/Worker/CampagneWorker.php
CampagneWorker.arretsToHide
public function arretsToHide($newsletter_id = null) { $campagnes = $this->campagne->getAll($newsletter_id)->where('status','brouillon'); return $campagnes->flatMap(function ($campagne) { return $campagne->content; })->map(function ($content, $key) { if($content->arret_id) return $content->arret_id ; if($content->groupe_id > 0) return $content->groupe->arrets->pluck('id')->all(); })->filter(function ($value, $key) { return !empty($value); })->flatten()->toArray(); }
php
public function arretsToHide($newsletter_id = null) { $campagnes = $this->campagne->getAll($newsletter_id)->where('status','brouillon'); return $campagnes->flatMap(function ($campagne) { return $campagne->content; })->map(function ($content, $key) { if($content->arret_id) return $content->arret_id ; if($content->groupe_id > 0) return $content->groupe->arrets->pluck('id')->all(); })->filter(function ($value, $key) { return !empty($value); })->flatten()->toArray(); }
[ "public", "function", "arretsToHide", "(", "$", "newsletter_id", "=", "null", ")", "{", "$", "campagnes", "=", "$", "this", "->", "campagne", "->", "getAll", "(", "$", "newsletter_id", ")", "->", "where", "(", "'status'", ",", "'brouillon'", ")", ";", "return", "$", "campagnes", "->", "flatMap", "(", "function", "(", "$", "campagne", ")", "{", "return", "$", "campagne", "->", "content", ";", "}", ")", "->", "map", "(", "function", "(", "$", "content", ",", "$", "key", ")", "{", "if", "(", "$", "content", "->", "arret_id", ")", "return", "$", "content", "->", "arret_id", ";", "if", "(", "$", "content", "->", "groupe_id", ">", "0", ")", "return", "$", "content", "->", "groupe", "->", "arrets", "->", "pluck", "(", "'id'", ")", "->", "all", "(", ")", ";", "}", ")", "->", "filter", "(", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "!", "empty", "(", "$", "value", ")", ";", "}", ")", "->", "flatten", "(", ")", "->", "toArray", "(", ")", ";", "}" ]
Interaction with site controllers List of arrets in non sent campagne to hide on frontend
[ "Interaction", "with", "site", "controllers", "List", "of", "arrets", "in", "non", "sent", "campagne", "to", "hide", "on", "frontend" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Worker/CampagneWorker.php#L28-L45
22,144
DesignPond/newsletter
src/Newsletter/Worker/CampagneWorker.php
CampagneWorker.siteCampagnes
public function siteCampagnes($site_id) { if(config('newsletter.multi')) { $newsletters = $this->newsletter->getSite($site_id); return $newsletters->map(function ($newsletter, $key) { return $newsletter->campagnes; })->flatten(1); } return null; }
php
public function siteCampagnes($site_id) { if(config('newsletter.multi')) { $newsletters = $this->newsletter->getSite($site_id); return $newsletters->map(function ($newsletter, $key) { return $newsletter->campagnes; })->flatten(1); } return null; }
[ "public", "function", "siteCampagnes", "(", "$", "site_id", ")", "{", "if", "(", "config", "(", "'newsletter.multi'", ")", ")", "{", "$", "newsletters", "=", "$", "this", "->", "newsletter", "->", "getSite", "(", "$", "site_id", ")", ";", "return", "$", "newsletters", "->", "map", "(", "function", "(", "$", "newsletter", ",", "$", "key", ")", "{", "return", "$", "newsletter", "->", "campagnes", ";", "}", ")", "->", "flatten", "(", "1", ")", ";", "}", "return", "null", ";", "}" ]
All campagnes for site
[ "All", "campagnes", "for", "site" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Worker/CampagneWorker.php#L88-L98
22,145
DesignPond/newsletter
src/Newsletter/Worker/CampagneWorker.php
CampagneWorker.html
public function html($id) { libxml_use_internal_errors(true); $htmldoc = new InlineStyle(file_get_contents( url('campagne/'.$id))); $htmldoc->applyStylesheet($htmldoc->extractStylesheets()); $html = $htmldoc->getHTML(); $html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html); return $html; }
php
public function html($id) { libxml_use_internal_errors(true); $htmldoc = new InlineStyle(file_get_contents( url('campagne/'.$id))); $htmldoc->applyStylesheet($htmldoc->extractStylesheets()); $html = $htmldoc->getHTML(); $html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html); return $html; }
[ "public", "function", "html", "(", "$", "id", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "htmldoc", "=", "new", "InlineStyle", "(", "file_get_contents", "(", "url", "(", "'campagne/'", ".", "$", "id", ")", ")", ")", ";", "$", "htmldoc", "->", "applyStylesheet", "(", "$", "htmldoc", "->", "extractStylesheets", "(", ")", ")", ";", "$", "html", "=", "$", "htmldoc", "->", "getHTML", "(", ")", ";", "$", "html", "=", "preg_replace", "(", "'#<script(.*?)>(.*?)</script>#is'", ",", "''", ",", "$", "html", ")", ";", "return", "$", "html", ";", "}" ]
Put styles inline for campagne Used when sending cammpagne or test
[ "Put", "styles", "inline", "for", "campagne", "Used", "when", "sending", "cammpagne", "or", "test" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Newsletter/Worker/CampagneWorker.php#L114-L125
22,146
nabab/bbn
src/bbn/appui/mapperv2.php
mapperv2.save_config
public function save_config(array $cfg, $description, $class = 'grid') { if ( isset($cfg['elements']) ){ $copy = $cfg; unset($copy['elements']); $obj_param = [ 'id_project' => 1, 'class' => $class, 'description' => $description, 'configuration' => json_encode($copy) ]; if ( isset($cfg['table']) ){ $obj_param['table'] = $cfg['table']; } $this->db->insert($this->admin_db.'.'.$this->prefix.'objects', $obj_param); $id = $this->db->last_id(); $i = 1; foreach ( $cfg['elements'] as $name => $ele ){ $table = $column = false; if ( !empty($ele['appui']['table']) ){ $table = $ele['appui']['table']; } else if ( !empty($ele['table']) ){ $table = $ele['table']; } else if ( !empty($cfg['table']) ){ $table = $cfg['table']; } if ( $table && isset($ele['attr']['name']) ){ $column = $this->db->tfn($table).'.'.$this->db->csn($ele['attr']['name']); } $this->db->insert($this->admin_db.'.'.$this->prefix.'fields',[ 'id_obj' => $id, 'column' => ( $column ?: null ), 'title' => isset($ele['label']) ? $ele['label'] : null, 'position' => $i, 'configuration' => json_encode($ele) ]); $i++; } return $id; } }
php
public function save_config(array $cfg, $description, $class = 'grid') { if ( isset($cfg['elements']) ){ $copy = $cfg; unset($copy['elements']); $obj_param = [ 'id_project' => 1, 'class' => $class, 'description' => $description, 'configuration' => json_encode($copy) ]; if ( isset($cfg['table']) ){ $obj_param['table'] = $cfg['table']; } $this->db->insert($this->admin_db.'.'.$this->prefix.'objects', $obj_param); $id = $this->db->last_id(); $i = 1; foreach ( $cfg['elements'] as $name => $ele ){ $table = $column = false; if ( !empty($ele['appui']['table']) ){ $table = $ele['appui']['table']; } else if ( !empty($ele['table']) ){ $table = $ele['table']; } else if ( !empty($cfg['table']) ){ $table = $cfg['table']; } if ( $table && isset($ele['attr']['name']) ){ $column = $this->db->tfn($table).'.'.$this->db->csn($ele['attr']['name']); } $this->db->insert($this->admin_db.'.'.$this->prefix.'fields',[ 'id_obj' => $id, 'column' => ( $column ?: null ), 'title' => isset($ele['label']) ? $ele['label'] : null, 'position' => $i, 'configuration' => json_encode($ele) ]); $i++; } return $id; } }
[ "public", "function", "save_config", "(", "array", "$", "cfg", ",", "$", "description", ",", "$", "class", "=", "'grid'", ")", "{", "if", "(", "isset", "(", "$", "cfg", "[", "'elements'", "]", ")", ")", "{", "$", "copy", "=", "$", "cfg", ";", "unset", "(", "$", "copy", "[", "'elements'", "]", ")", ";", "$", "obj_param", "=", "[", "'id_project'", "=>", "1", ",", "'class'", "=>", "$", "class", ",", "'description'", "=>", "$", "description", ",", "'configuration'", "=>", "json_encode", "(", "$", "copy", ")", "]", ";", "if", "(", "isset", "(", "$", "cfg", "[", "'table'", "]", ")", ")", "{", "$", "obj_param", "[", "'table'", "]", "=", "$", "cfg", "[", "'table'", "]", ";", "}", "$", "this", "->", "db", "->", "insert", "(", "$", "this", "->", "admin_db", ".", "'.'", ".", "$", "this", "->", "prefix", ".", "'objects'", ",", "$", "obj_param", ")", ";", "$", "id", "=", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "$", "i", "=", "1", ";", "foreach", "(", "$", "cfg", "[", "'elements'", "]", "as", "$", "name", "=>", "$", "ele", ")", "{", "$", "table", "=", "$", "column", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "ele", "[", "'appui'", "]", "[", "'table'", "]", ")", ")", "{", "$", "table", "=", "$", "ele", "[", "'appui'", "]", "[", "'table'", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "ele", "[", "'table'", "]", ")", ")", "{", "$", "table", "=", "$", "ele", "[", "'table'", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "cfg", "[", "'table'", "]", ")", ")", "{", "$", "table", "=", "$", "cfg", "[", "'table'", "]", ";", "}", "if", "(", "$", "table", "&&", "isset", "(", "$", "ele", "[", "'attr'", "]", "[", "'name'", "]", ")", ")", "{", "$", "column", "=", "$", "this", "->", "db", "->", "tfn", "(", "$", "table", ")", ".", "'.'", ".", "$", "this", "->", "db", "->", "csn", "(", "$", "ele", "[", "'attr'", "]", "[", "'name'", "]", ")", ";", "}", "$", "this", "->", "db", "->", "insert", "(", "$", "this", "->", "admin_db", ".", "'.'", ".", "$", "this", "->", "prefix", ".", "'fields'", ",", "[", "'id_obj'", "=>", "$", "id", ",", "'column'", "=>", "(", "$", "column", "?", ":", "null", ")", ",", "'title'", "=>", "isset", "(", "$", "ele", "[", "'label'", "]", ")", "?", "$", "ele", "[", "'label'", "]", ":", "null", ",", "'position'", "=>", "$", "i", ",", "'configuration'", "=>", "json_encode", "(", "$", "ele", ")", "]", ")", ";", "$", "i", "++", ";", "}", "return", "$", "id", ";", "}", "}" ]
Saves the given configuration in the database and returns the new ID @param array $cfg @param string $class @return int|false
[ "Saves", "the", "given", "configuration", "in", "the", "database", "and", "returns", "the", "new", "ID" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/mapperv2.php#L122-L169
22,147
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.getSubscriptionById
public function getSubscriptionById($subscriptionId) { $subscriptions = $this ->getSubscriptions(null, null, null, $subscriptionId) ->getResponse() ->getSubscriptions(); return count($subscriptions) ? reset($subscriptions) : null; }
php
public function getSubscriptionById($subscriptionId) { $subscriptions = $this ->getSubscriptions(null, null, null, $subscriptionId) ->getResponse() ->getSubscriptions(); return count($subscriptions) ? reset($subscriptions) : null; }
[ "public", "function", "getSubscriptionById", "(", "$", "subscriptionId", ")", "{", "$", "subscriptions", "=", "$", "this", "->", "getSubscriptions", "(", "null", ",", "null", ",", "null", ",", "$", "subscriptionId", ")", "->", "getResponse", "(", ")", "->", "getSubscriptions", "(", ")", ";", "return", "count", "(", "$", "subscriptions", ")", "?", "reset", "(", "$", "subscriptions", ")", ":", "null", ";", "}" ]
Get one subscription by using the Monsum subscription ID. @param integer $subscriptionId The Monsum subscription ID. @return Subscription|null
[ "Get", "one", "subscription", "by", "using", "the", "Monsum", "subscription", "ID", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L21-L29
22,148
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.getSubscriptions
public function getSubscriptions( $customerId = null, $externalCustomerId = null, $subscriptionExternalId = null, $subscriptionId = null ) { $requestData = new Get\RequestData(); $requestData->setCustomerId($customerId); $requestData->setExternalCustomerId($externalCustomerId); $requestData->setSubscriptionExternalId($subscriptionExternalId); $requestData->setSubscriptionId($subscriptionId); $request = new Get\Request($requestData); return $this->sendRequest($request, Get\ApiResponse::class); }
php
public function getSubscriptions( $customerId = null, $externalCustomerId = null, $subscriptionExternalId = null, $subscriptionId = null ) { $requestData = new Get\RequestData(); $requestData->setCustomerId($customerId); $requestData->setExternalCustomerId($externalCustomerId); $requestData->setSubscriptionExternalId($subscriptionExternalId); $requestData->setSubscriptionId($subscriptionId); $request = new Get\Request($requestData); return $this->sendRequest($request, Get\ApiResponse::class); }
[ "public", "function", "getSubscriptions", "(", "$", "customerId", "=", "null", ",", "$", "externalCustomerId", "=", "null", ",", "$", "subscriptionExternalId", "=", "null", ",", "$", "subscriptionId", "=", "null", ")", "{", "$", "requestData", "=", "new", "Get", "\\", "RequestData", "(", ")", ";", "$", "requestData", "->", "setCustomerId", "(", "$", "customerId", ")", ";", "$", "requestData", "->", "setExternalCustomerId", "(", "$", "externalCustomerId", ")", ";", "$", "requestData", "->", "setSubscriptionExternalId", "(", "$", "subscriptionExternalId", ")", ";", "$", "requestData", "->", "setSubscriptionId", "(", "$", "subscriptionId", ")", ";", "$", "request", "=", "new", "Get", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Get", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Get the subscriptions. @param integer $customerId The customer ID. @param string $externalCustomerId The external customer ID. @param string $subscriptionExternalId The external subscription ID. @param integer $subscriptionId The subscription ID. @return Get\ApiResponse
[ "Get", "the", "subscriptions", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L40-L55
22,149
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.getAllSubscriptions
public function getAllSubscriptions() { $limit = RequestInterface::MAX_LIST_LIMIT; $offset = 0; $subscriptions = [[]]; while (true) { $subscriptionBatch = $this->getSubscriptionsResponse($offset); $subscriptions[] = $subscriptionBatch; $offset += $limit; if (\count($subscriptionBatch) < $limit) { break; } } return \array_merge(...$subscriptions); }
php
public function getAllSubscriptions() { $limit = RequestInterface::MAX_LIST_LIMIT; $offset = 0; $subscriptions = [[]]; while (true) { $subscriptionBatch = $this->getSubscriptionsResponse($offset); $subscriptions[] = $subscriptionBatch; $offset += $limit; if (\count($subscriptionBatch) < $limit) { break; } } return \array_merge(...$subscriptions); }
[ "public", "function", "getAllSubscriptions", "(", ")", "{", "$", "limit", "=", "RequestInterface", "::", "MAX_LIST_LIMIT", ";", "$", "offset", "=", "0", ";", "$", "subscriptions", "=", "[", "[", "]", "]", ";", "while", "(", "true", ")", "{", "$", "subscriptionBatch", "=", "$", "this", "->", "getSubscriptionsResponse", "(", "$", "offset", ")", ";", "$", "subscriptions", "[", "]", "=", "$", "subscriptionBatch", ";", "$", "offset", "+=", "$", "limit", ";", "if", "(", "\\", "count", "(", "$", "subscriptionBatch", ")", "<", "$", "limit", ")", "{", "break", ";", "}", "}", "return", "\\", "array_merge", "(", "...", "$", "subscriptions", ")", ";", "}" ]
Get all subscriptions. @return Subscription[]
[ "Get", "all", "subscriptions", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L62-L78
22,150
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.createSubscription
public function createSubscription(Create\RequestData $requestData) { $request = new Create\Request($requestData); return $this->sendRequest($request, Create\ApiResponse::class); }
php
public function createSubscription(Create\RequestData $requestData) { $request = new Create\Request($requestData); return $this->sendRequest($request, Create\ApiResponse::class); }
[ "public", "function", "createSubscription", "(", "Create", "\\", "RequestData", "$", "requestData", ")", "{", "$", "request", "=", "new", "Create", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Create", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Create a subscription. @param Create\RequestData $requestData The request data. @return Create\ApiResponse
[ "Create", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L86-L91
22,151
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.updateSubscription
public function updateSubscription( $subscriptionId, $nextEvent = null, $subscriptionExternalId = null, $status = null, array $xAttributes = [], array $features = [] ) { $requestData = new Update\RequestData($subscriptionId); $requestData->setSubscriptionId($subscriptionId); $requestData->setNextEvent($nextEvent); $requestData->setSubscriptionExternalId($subscriptionExternalId); $requestData->setStatus($status); $requestData->setXAttributes($xAttributes); $requestData->setFeatures($features); $request = new Update\Request($requestData); return $this->sendRequest($request, Update\ApiResponse::class); }
php
public function updateSubscription( $subscriptionId, $nextEvent = null, $subscriptionExternalId = null, $status = null, array $xAttributes = [], array $features = [] ) { $requestData = new Update\RequestData($subscriptionId); $requestData->setSubscriptionId($subscriptionId); $requestData->setNextEvent($nextEvent); $requestData->setSubscriptionExternalId($subscriptionExternalId); $requestData->setStatus($status); $requestData->setXAttributes($xAttributes); $requestData->setFeatures($features); $request = new Update\Request($requestData); return $this->sendRequest($request, Update\ApiResponse::class); }
[ "public", "function", "updateSubscription", "(", "$", "subscriptionId", ",", "$", "nextEvent", "=", "null", ",", "$", "subscriptionExternalId", "=", "null", ",", "$", "status", "=", "null", ",", "array", "$", "xAttributes", "=", "[", "]", ",", "array", "$", "features", "=", "[", "]", ")", "{", "$", "requestData", "=", "new", "Update", "\\", "RequestData", "(", "$", "subscriptionId", ")", ";", "$", "requestData", "->", "setSubscriptionId", "(", "$", "subscriptionId", ")", ";", "$", "requestData", "->", "setNextEvent", "(", "$", "nextEvent", ")", ";", "$", "requestData", "->", "setSubscriptionExternalId", "(", "$", "subscriptionExternalId", ")", ";", "$", "requestData", "->", "setStatus", "(", "$", "status", ")", ";", "$", "requestData", "->", "setXAttributes", "(", "$", "xAttributes", ")", ";", "$", "requestData", "->", "setFeatures", "(", "$", "features", ")", ";", "$", "request", "=", "new", "Update", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Update", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Update a subscription. @param integer $subscriptionId The subscription ID. @param \DateTime $nextEvent The next event date and time. @param string $subscriptionExternalId The external subscription ID. @param string $status The subscription status. @param array $xAttributes The subscription x attributes. @param Feature[] $features The features. @return Update\ApiResponse
[ "Update", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L104-L124
22,152
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.changeSubscriptionArticle
public function changeSubscriptionArticle(ChangeArticle\RequestData $requestData) { $request = new ChangeArticle\Request($requestData); return $this->sendRequest($request, ChangeArticle\ApiResponse::class); }
php
public function changeSubscriptionArticle(ChangeArticle\RequestData $requestData) { $request = new ChangeArticle\Request($requestData); return $this->sendRequest($request, ChangeArticle\ApiResponse::class); }
[ "public", "function", "changeSubscriptionArticle", "(", "ChangeArticle", "\\", "RequestData", "$", "requestData", ")", "{", "$", "request", "=", "new", "ChangeArticle", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "ChangeArticle", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Change article of a subscription. @param ChangeArticle\RequestData $requestData The request data. @return ChangeArticle\ApiResponse
[ "Change", "article", "of", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L132-L137
22,153
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.setSubscriptionAddon
public function setSubscriptionAddon(SetAddon\RequestData $requestData) { $request = new SetAddon\Request($requestData); return $this->sendRequest($request, SetAddon\ApiResponse::class); }
php
public function setSubscriptionAddon(SetAddon\RequestData $requestData) { $request = new SetAddon\Request($requestData); return $this->sendRequest($request, SetAddon\ApiResponse::class); }
[ "public", "function", "setSubscriptionAddon", "(", "SetAddon", "\\", "RequestData", "$", "requestData", ")", "{", "$", "request", "=", "new", "SetAddon", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "SetAddon", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Set the addon for a subscription. @param SetAddon\RequestData $requestData The request data. @return SetAddon\ApiResponse
[ "Set", "the", "addon", "for", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L145-L150
22,154
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.setSubscriptionUsageData
public function setSubscriptionUsageData(SetUsageData\RequestData $requestData) { $request = new SetUsageData\Request($requestData); return $this->sendRequest($request, SetUsageData\ApiResponse::class); }
php
public function setSubscriptionUsageData(SetUsageData\RequestData $requestData) { $request = new SetUsageData\Request($requestData); return $this->sendRequest($request, SetUsageData\ApiResponse::class); }
[ "public", "function", "setSubscriptionUsageData", "(", "SetUsageData", "\\", "RequestData", "$", "requestData", ")", "{", "$", "request", "=", "new", "SetUsageData", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "SetUsageData", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Set the usage data of a subscription. @param SetUsageData\RequestData $requestData The request data. @return SetUsageData\ApiResponse
[ "Set", "the", "usage", "data", "of", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L158-L163
22,155
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.getUpcomingAmount
public function getUpcomingAmount(GetUpcomingAmount\RequestData $requestData = null) { if ($requestData === null) { $requestData = new GetUpcomingAmount\RequestData(); } $request = new GetUpcomingAmount\Request($requestData); return $this->sendRequest($request, GetUpcomingAmount\ApiResponse::class); }
php
public function getUpcomingAmount(GetUpcomingAmount\RequestData $requestData = null) { if ($requestData === null) { $requestData = new GetUpcomingAmount\RequestData(); } $request = new GetUpcomingAmount\Request($requestData); return $this->sendRequest($request, GetUpcomingAmount\ApiResponse::class); }
[ "public", "function", "getUpcomingAmount", "(", "GetUpcomingAmount", "\\", "RequestData", "$", "requestData", "=", "null", ")", "{", "if", "(", "$", "requestData", "===", "null", ")", "{", "$", "requestData", "=", "new", "GetUpcomingAmount", "\\", "RequestData", "(", ")", ";", "}", "$", "request", "=", "new", "GetUpcomingAmount", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "GetUpcomingAmount", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Get the upcoming amount. @param GetUpcomingAmount\RequestData $requestData The request data filter. @return GetUpcomingAmount\ApiResponse
[ "Get", "the", "upcoming", "amount", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L209-L218
22,156
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.postponeSubscription
public function postponeSubscription($subscriptionId, $month) { $requestData = new Postpone\RequestData($subscriptionId, $month); $request = new Postpone\Request($requestData); return $this->sendRequest($request, Postpone\ApiResponse::class); }
php
public function postponeSubscription($subscriptionId, $month) { $requestData = new Postpone\RequestData($subscriptionId, $month); $request = new Postpone\Request($requestData); return $this->sendRequest($request, Postpone\ApiResponse::class); }
[ "public", "function", "postponeSubscription", "(", "$", "subscriptionId", ",", "$", "month", ")", "{", "$", "requestData", "=", "new", "Postpone", "\\", "RequestData", "(", "$", "subscriptionId", ",", "$", "month", ")", ";", "$", "request", "=", "new", "Postpone", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Postpone", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Postpone a subscription shipping. @param integer $subscriptionId @param integer $month The month to postpone. @return Postpone\ApiResponse
[ "Postpone", "a", "subscription", "shipping", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L227-L233
22,157
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.renewSubscription
public function renewSubscription($subscriptionId) { $requestData = new Renew\RequestData($subscriptionId); $request = new Renew\Request($requestData); return $this->sendRequest($request, Renew\ApiResponse::class); }
php
public function renewSubscription($subscriptionId) { $requestData = new Renew\RequestData($subscriptionId); $request = new Renew\Request($requestData); return $this->sendRequest($request, Renew\ApiResponse::class); }
[ "public", "function", "renewSubscription", "(", "$", "subscriptionId", ")", "{", "$", "requestData", "=", "new", "Renew", "\\", "RequestData", "(", "$", "subscriptionId", ")", ";", "$", "request", "=", "new", "Renew", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Renew", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Renew a subscription. @param integer $subscriptionId The subscription ID to renew. @return Renew\ApiResponse
[ "Renew", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L241-L247
22,158
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.createSecureLink
public function createSecureLink($subscriptionId) { $requestData = new CreateSecureLink\RequestData($subscriptionId); $request = new CreateSecureLink\Request($requestData); return $this->sendRequest($request, CreateSecureLink\ApiResponse::class); }
php
public function createSecureLink($subscriptionId) { $requestData = new CreateSecureLink\RequestData($subscriptionId); $request = new CreateSecureLink\Request($requestData); return $this->sendRequest($request, CreateSecureLink\ApiResponse::class); }
[ "public", "function", "createSecureLink", "(", "$", "subscriptionId", ")", "{", "$", "requestData", "=", "new", "CreateSecureLink", "\\", "RequestData", "(", "$", "subscriptionId", ")", ";", "$", "request", "=", "new", "CreateSecureLink", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "CreateSecureLink", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Create a secure link for a subscription. @param integer $subscriptionId The subscription ID for which to create the secure link. @return CreateSecureLink\ApiResponse
[ "Create", "a", "secure", "link", "for", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L255-L261
22,159
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.cancelSubscription
public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null) { $requestData = new Cancel\RequestData($subscriptionId); $requestData->setCancellationDate($cancellationDate); $requestData->setCancellationNote($cancellationNote); $request = new Cancel\Request($requestData); return $this->sendRequest($request, Cancel\ApiResponse::class); }
php
public function cancelSubscription($subscriptionId, \DateTime $cancellationDate = null, $cancellationNote = null) { $requestData = new Cancel\RequestData($subscriptionId); $requestData->setCancellationDate($cancellationDate); $requestData->setCancellationNote($cancellationNote); $request = new Cancel\Request($requestData); return $this->sendRequest($request, Cancel\ApiResponse::class); }
[ "public", "function", "cancelSubscription", "(", "$", "subscriptionId", ",", "\\", "DateTime", "$", "cancellationDate", "=", "null", ",", "$", "cancellationNote", "=", "null", ")", "{", "$", "requestData", "=", "new", "Cancel", "\\", "RequestData", "(", "$", "subscriptionId", ")", ";", "$", "requestData", "->", "setCancellationDate", "(", "$", "cancellationDate", ")", ";", "$", "requestData", "->", "setCancellationNote", "(", "$", "cancellationNote", ")", ";", "$", "request", "=", "new", "Cancel", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Cancel", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Cancel a subscription. @param integer $subscriptionId The subscription ID. @param \DateTime $cancellationDate The cancellation date and time. @param string $cancellationNote The cancellation note. @return Cancel\ApiResponse
[ "Cancel", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L271-L280
22,160
Speicher210/monsum-api
src/Service/Subscription/SubscriptionService.php
SubscriptionService.reactivateSubscription
public function reactivateSubscription($subscriptionId) { $requestData = new Reactivate\RequestData($subscriptionId); $request = new Reactivate\Request($requestData); return $this->sendRequest($request, Reactivate\ApiResponse::class); }
php
public function reactivateSubscription($subscriptionId) { $requestData = new Reactivate\RequestData($subscriptionId); $request = new Reactivate\Request($requestData); return $this->sendRequest($request, Reactivate\ApiResponse::class); }
[ "public", "function", "reactivateSubscription", "(", "$", "subscriptionId", ")", "{", "$", "requestData", "=", "new", "Reactivate", "\\", "RequestData", "(", "$", "subscriptionId", ")", ";", "$", "request", "=", "new", "Reactivate", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Reactivate", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Reactivate a subscription. @param integer $subscriptionId The subscription ID to reactivate. @return Reactivate\ApiResponse
[ "Reactivate", "a", "subscription", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Subscription/SubscriptionService.php#L288-L294
22,161
ekuiter/feature-php
FeaturePhp/Helper/Path.php
Path.stripBase
public static function stripBase($path, $base = null) { if ($base === null) $base = getcwd(); if (substr($path, 0, strlen($base)) === $base) return ltrim(substr($path, strlen($base) + 1), "/"); else throw new PathException("\"$path\" does not contain base path \"$base\""); }
php
public static function stripBase($path, $base = null) { if ($base === null) $base = getcwd(); if (substr($path, 0, strlen($base)) === $base) return ltrim(substr($path, strlen($base) + 1), "/"); else throw new PathException("\"$path\" does not contain base path \"$base\""); }
[ "public", "static", "function", "stripBase", "(", "$", "path", ",", "$", "base", "=", "null", ")", "{", "if", "(", "$", "base", "===", "null", ")", "$", "base", "=", "getcwd", "(", ")", ";", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "strlen", "(", "$", "base", ")", ")", "===", "$", "base", ")", "return", "ltrim", "(", "substr", "(", "$", "path", ",", "strlen", "(", "$", "base", ")", "+", "1", ")", ",", "\"/\"", ")", ";", "else", "throw", "new", "PathException", "(", "\"\\\"$path\\\" does not contain base path \\\"$base\\\"\"", ")", ";", "}" ]
Strips a base from a file or directory path. If no base is supplied, the working directory is used. @param string $path @param string $base @return string
[ "Strips", "a", "base", "from", "a", "file", "or", "directory", "path", ".", "If", "no", "base", "is", "supplied", "the", "working", "directory", "is", "used", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L26-L33
22,162
ekuiter/feature-php
FeaturePhp/Helper/Path.php
Path.rootPath
public static function rootPath($directory) { $num = count(explode("/", $directory)); $path = ""; for ($i = 0; $i < $num; $i++) $path = self::join("..", $path); return $path; }
php
public static function rootPath($directory) { $num = count(explode("/", $directory)); $path = ""; for ($i = 0; $i < $num; $i++) $path = self::join("..", $path); return $path; }
[ "public", "static", "function", "rootPath", "(", "$", "directory", ")", "{", "$", "num", "=", "count", "(", "explode", "(", "\"/\"", ",", "$", "directory", ")", ")", ";", "$", "path", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "num", ";", "$", "i", "++", ")", "$", "path", "=", "self", "::", "join", "(", "\"..\"", ",", "$", "path", ")", ";", "return", "$", "path", ";", "}" ]
Builds a path referring to the root directory from a relative path. @param string $directory return string
[ "Builds", "a", "path", "referring", "to", "the", "root", "directory", "from", "a", "relative", "path", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/Path.php#L110-L116
22,163
zicht/z
src/Zicht/Tool/Packager/Node/StaticStub.php
StaticStub.compileInitialization
protected function compileInitialization(Buffer $buffer) { $configurationLoader = new Configuration\ConfigurationLoader( $this->staticConfig, new FileLocator(array(getcwd())), new Configuration\FileLoader( new Configuration\PathDefaultFileLocator( 'ZPLUGINPATH', $this->staticPluginPaths ) ) ); $compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array()); $this->phar['container.php'] = $compiler->compileContainerCode(); $buffer->writeln('$container = require_once \'phar://z.phar/container.php\';'); foreach ($configurationLoader->getPlugins() as $name => $plugin) { $className = get_class($plugin); $embeddedFilename = 'plugins/' . $name . '.php'; $class = new \ReflectionClass($className); $this->phar[$embeddedFilename] = file_get_contents($class->getFileName()); $buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol(); $buffer->write('$p = new ')->write($className)->raw('();')->eol(); $buffer->writeln('$p->setContainer($container);'); } $buffer ->writeln('Zicht\Tool\Application::$HEADER = \'\';') ->write('$app = new Zicht\Tool\Application(') ->asPhp($this->appName) ->raw(', Zicht\Version\Version::fromString(') ->asPhp($this->appVersion) ->raw(') ?: new Zicht\Version\Version());') ->eol() ; $buffer->writeln('$app->setContainer($container);'); }
php
protected function compileInitialization(Buffer $buffer) { $configurationLoader = new Configuration\ConfigurationLoader( $this->staticConfig, new FileLocator(array(getcwd())), new Configuration\FileLoader( new Configuration\PathDefaultFileLocator( 'ZPLUGINPATH', $this->staticPluginPaths ) ) ); $compiler = new ContainerCompiler($configurationLoader->processConfiguration(), array()); $this->phar['container.php'] = $compiler->compileContainerCode(); $buffer->writeln('$container = require_once \'phar://z.phar/container.php\';'); foreach ($configurationLoader->getPlugins() as $name => $plugin) { $className = get_class($plugin); $embeddedFilename = 'plugins/' . $name . '.php'; $class = new \ReflectionClass($className); $this->phar[$embeddedFilename] = file_get_contents($class->getFileName()); $buffer->write('require_once ')->asPhp('phar://z.phar/' . $embeddedFilename)->raw(';')->eol(); $buffer->write('$p = new ')->write($className)->raw('();')->eol(); $buffer->writeln('$p->setContainer($container);'); } $buffer ->writeln('Zicht\Tool\Application::$HEADER = \'\';') ->write('$app = new Zicht\Tool\Application(') ->asPhp($this->appName) ->raw(', Zicht\Version\Version::fromString(') ->asPhp($this->appVersion) ->raw(') ?: new Zicht\Version\Version());') ->eol() ; $buffer->writeln('$app->setContainer($container);'); }
[ "protected", "function", "compileInitialization", "(", "Buffer", "$", "buffer", ")", "{", "$", "configurationLoader", "=", "new", "Configuration", "\\", "ConfigurationLoader", "(", "$", "this", "->", "staticConfig", ",", "new", "FileLocator", "(", "array", "(", "getcwd", "(", ")", ")", ")", ",", "new", "Configuration", "\\", "FileLoader", "(", "new", "Configuration", "\\", "PathDefaultFileLocator", "(", "'ZPLUGINPATH'", ",", "$", "this", "->", "staticPluginPaths", ")", ")", ")", ";", "$", "compiler", "=", "new", "ContainerCompiler", "(", "$", "configurationLoader", "->", "processConfiguration", "(", ")", ",", "array", "(", ")", ")", ";", "$", "this", "->", "phar", "[", "'container.php'", "]", "=", "$", "compiler", "->", "compileContainerCode", "(", ")", ";", "$", "buffer", "->", "writeln", "(", "'$container = require_once \\'phar://z.phar/container.php\\';'", ")", ";", "foreach", "(", "$", "configurationLoader", "->", "getPlugins", "(", ")", "as", "$", "name", "=>", "$", "plugin", ")", "{", "$", "className", "=", "get_class", "(", "$", "plugin", ")", ";", "$", "embeddedFilename", "=", "'plugins/'", ".", "$", "name", ".", "'.php'", ";", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "$", "this", "->", "phar", "[", "$", "embeddedFilename", "]", "=", "file_get_contents", "(", "$", "class", "->", "getFileName", "(", ")", ")", ";", "$", "buffer", "->", "write", "(", "'require_once '", ")", "->", "asPhp", "(", "'phar://z.phar/'", ".", "$", "embeddedFilename", ")", "->", "raw", "(", "';'", ")", "->", "eol", "(", ")", ";", "$", "buffer", "->", "write", "(", "'$p = new '", ")", "->", "write", "(", "$", "className", ")", "->", "raw", "(", "'();'", ")", "->", "eol", "(", ")", ";", "$", "buffer", "->", "writeln", "(", "'$p->setContainer($container);'", ")", ";", "}", "$", "buffer", "->", "writeln", "(", "'Zicht\\Tool\\Application::$HEADER = \\'\\';'", ")", "->", "write", "(", "'$app = new Zicht\\Tool\\Application('", ")", "->", "asPhp", "(", "$", "this", "->", "appName", ")", "->", "raw", "(", "', Zicht\\Version\\Version::fromString('", ")", "->", "asPhp", "(", "$", "this", "->", "appVersion", ")", "->", "raw", "(", "') ?: new Zicht\\Version\\Version());'", ")", "->", "eol", "(", ")", ";", "$", "buffer", "->", "writeln", "(", "'$app->setContainer($container);'", ")", ";", "}" ]
Writes the initialization code for a static build of Z. @param \Zicht\Tool\Script\Buffer $buffer @return mixed|void
[ "Writes", "the", "initialization", "code", "for", "a", "static", "build", "of", "Z", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Packager/Node/StaticStub.php#L45-L83
22,164
InfiniteSoftware/ISEcommpayPayum
Action/Api/Signer.php
Signer.getParamsToSign
private static function getParamsToSign( array $params, array $ignoreParamKeys = [], int $currentLevel = 1, string $prefix = '' ): array { $paramsToSign = []; foreach ($params as $key => $value) { if ((in_array($key, $ignoreParamKeys) && $currentLevel == 1)) { continue; } $paramKey = ($prefix ? $prefix . ':' : '') . $key; if (is_array($value)) { if ($currentLevel >= self::MAXIMUM_RECURSION_DEPTH) { $paramsToSign[$paramKey] = (string)$paramKey.':'; } else { $subArray = self::getParamsToSign($value, $ignoreParamKeys, $currentLevel + 1, $paramKey); $paramsToSign = array_merge($paramsToSign, $subArray); } } else { if (is_bool($value)) { $value = $value ? '1' : '0'; } else { $value = (string)$value; } $paramsToSign[$paramKey] = (string)$paramKey.':'.$value; } } if ($currentLevel == 1) { ksort($paramsToSign, SORT_NATURAL); } return $paramsToSign; }
php
private static function getParamsToSign( array $params, array $ignoreParamKeys = [], int $currentLevel = 1, string $prefix = '' ): array { $paramsToSign = []; foreach ($params as $key => $value) { if ((in_array($key, $ignoreParamKeys) && $currentLevel == 1)) { continue; } $paramKey = ($prefix ? $prefix . ':' : '') . $key; if (is_array($value)) { if ($currentLevel >= self::MAXIMUM_RECURSION_DEPTH) { $paramsToSign[$paramKey] = (string)$paramKey.':'; } else { $subArray = self::getParamsToSign($value, $ignoreParamKeys, $currentLevel + 1, $paramKey); $paramsToSign = array_merge($paramsToSign, $subArray); } } else { if (is_bool($value)) { $value = $value ? '1' : '0'; } else { $value = (string)$value; } $paramsToSign[$paramKey] = (string)$paramKey.':'.$value; } } if ($currentLevel == 1) { ksort($paramsToSign, SORT_NATURAL); } return $paramsToSign; }
[ "private", "static", "function", "getParamsToSign", "(", "array", "$", "params", ",", "array", "$", "ignoreParamKeys", "=", "[", "]", ",", "int", "$", "currentLevel", "=", "1", ",", "string", "$", "prefix", "=", "''", ")", ":", "array", "{", "$", "paramsToSign", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "(", "in_array", "(", "$", "key", ",", "$", "ignoreParamKeys", ")", "&&", "$", "currentLevel", "==", "1", ")", ")", "{", "continue", ";", "}", "$", "paramKey", "=", "(", "$", "prefix", "?", "$", "prefix", ".", "':'", ":", "''", ")", ".", "$", "key", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "$", "currentLevel", ">=", "self", "::", "MAXIMUM_RECURSION_DEPTH", ")", "{", "$", "paramsToSign", "[", "$", "paramKey", "]", "=", "(", "string", ")", "$", "paramKey", ".", "':'", ";", "}", "else", "{", "$", "subArray", "=", "self", "::", "getParamsToSign", "(", "$", "value", ",", "$", "ignoreParamKeys", ",", "$", "currentLevel", "+", "1", ",", "$", "paramKey", ")", ";", "$", "paramsToSign", "=", "array_merge", "(", "$", "paramsToSign", ",", "$", "subArray", ")", ";", "}", "}", "else", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "value", "?", "'1'", ":", "'0'", ";", "}", "else", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", "}", "$", "paramsToSign", "[", "$", "paramKey", "]", "=", "(", "string", ")", "$", "paramKey", ".", "':'", ".", "$", "value", ";", "}", "}", "if", "(", "$", "currentLevel", "==", "1", ")", "{", "ksort", "(", "$", "paramsToSign", ",", "SORT_NATURAL", ")", ";", "}", "return", "$", "paramsToSign", ";", "}" ]
Get parameters to sign @param array $params @param array $ignoreParamKeys @param int $currentLevel @param string $prefix @return array
[ "Get", "parameters", "to", "sign" ]
44a073e3d885d9007aa54d6ff13aea93a9e52e7c
https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/Api/Signer.php#L39-L72
22,165
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addConstants
protected function addConstants($constants, $fileDescriptor) { foreach ($constants as $constant) { $constantDescriptor = $this->getBuilder()->buildDescriptor($constant); if ($constantDescriptor) { $constantDescriptor->setLocation($fileDescriptor, $constant->getLineNumber()); if (count($constantDescriptor->getTags()->get('package', new Collection())) == 0) { $constantDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getConstants()->set( $constantDescriptor->getFullyQualifiedStructuralElementName(), $constantDescriptor ); } } }
php
protected function addConstants($constants, $fileDescriptor) { foreach ($constants as $constant) { $constantDescriptor = $this->getBuilder()->buildDescriptor($constant); if ($constantDescriptor) { $constantDescriptor->setLocation($fileDescriptor, $constant->getLineNumber()); if (count($constantDescriptor->getTags()->get('package', new Collection())) == 0) { $constantDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getConstants()->set( $constantDescriptor->getFullyQualifiedStructuralElementName(), $constantDescriptor ); } } }
[ "protected", "function", "addConstants", "(", "$", "constants", ",", "$", "fileDescriptor", ")", "{", "foreach", "(", "$", "constants", "as", "$", "constant", ")", "{", "$", "constantDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "constant", ")", ";", "if", "(", "$", "constantDescriptor", ")", "{", "$", "constantDescriptor", "->", "setLocation", "(", "$", "fileDescriptor", ",", "$", "constant", "->", "getLineNumber", "(", ")", ")", ";", "if", "(", "count", "(", "$", "constantDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", "==", "0", ")", "{", "$", "constantDescriptor", "->", "getTags", "(", ")", "->", "set", "(", "'package'", ",", "$", "fileDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", ";", "}", "$", "fileDescriptor", "->", "getConstants", "(", ")", "->", "set", "(", "$", "constantDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ",", "$", "constantDescriptor", ")", ";", "}", "}", "}" ]
Registers the child constants with the generated File Descriptor. @param ConstantReflector[] $constants @param FileDescriptor $fileDescriptor @return void
[ "Registers", "the", "child", "constants", "with", "the", "generated", "File", "Descriptor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L71-L88
22,166
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addFunctions
protected function addFunctions($functions, $fileDescriptor) { foreach ($functions as $function) { $functionDescriptor = $this->getBuilder()->buildDescriptor($function); if ($functionDescriptor) { $functionDescriptor->setLocation($fileDescriptor, $function->getLineNumber()); if (count($functionDescriptor->getTags()->get('package', new Collection())) == 0) { $functionDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getFunctions()->set( $functionDescriptor->getFullyQualifiedStructuralElementName(), $functionDescriptor ); } } }
php
protected function addFunctions($functions, $fileDescriptor) { foreach ($functions as $function) { $functionDescriptor = $this->getBuilder()->buildDescriptor($function); if ($functionDescriptor) { $functionDescriptor->setLocation($fileDescriptor, $function->getLineNumber()); if (count($functionDescriptor->getTags()->get('package', new Collection())) == 0) { $functionDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getFunctions()->set( $functionDescriptor->getFullyQualifiedStructuralElementName(), $functionDescriptor ); } } }
[ "protected", "function", "addFunctions", "(", "$", "functions", ",", "$", "fileDescriptor", ")", "{", "foreach", "(", "$", "functions", "as", "$", "function", ")", "{", "$", "functionDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "function", ")", ";", "if", "(", "$", "functionDescriptor", ")", "{", "$", "functionDescriptor", "->", "setLocation", "(", "$", "fileDescriptor", ",", "$", "function", "->", "getLineNumber", "(", ")", ")", ";", "if", "(", "count", "(", "$", "functionDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", "==", "0", ")", "{", "$", "functionDescriptor", "->", "getTags", "(", ")", "->", "set", "(", "'package'", ",", "$", "fileDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", ";", "}", "$", "fileDescriptor", "->", "getFunctions", "(", ")", "->", "set", "(", "$", "functionDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ",", "$", "functionDescriptor", ")", ";", "}", "}", "}" ]
Registers the child functions with the generated File Descriptor. @param FunctionReflector[] $functions @param FileDescriptor $fileDescriptor @return void
[ "Registers", "the", "child", "functions", "with", "the", "generated", "File", "Descriptor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L98-L115
22,167
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addInterfaces
protected function addInterfaces($interfaces, $fileDescriptor) { foreach ($interfaces as $interface) { $interfaceDescriptor = $this->getBuilder()->buildDescriptor($interface); if ($interfaceDescriptor) { $interfaceDescriptor->setLocation($fileDescriptor, $interface->getLineNumber()); if (count($interfaceDescriptor->getTags()->get('package', new Collection())) == 0) { $interfaceDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getInterfaces()->set( $interfaceDescriptor->getFullyQualifiedStructuralElementName(), $interfaceDescriptor ); } } }
php
protected function addInterfaces($interfaces, $fileDescriptor) { foreach ($interfaces as $interface) { $interfaceDescriptor = $this->getBuilder()->buildDescriptor($interface); if ($interfaceDescriptor) { $interfaceDescriptor->setLocation($fileDescriptor, $interface->getLineNumber()); if (count($interfaceDescriptor->getTags()->get('package', new Collection())) == 0) { $interfaceDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getInterfaces()->set( $interfaceDescriptor->getFullyQualifiedStructuralElementName(), $interfaceDescriptor ); } } }
[ "protected", "function", "addInterfaces", "(", "$", "interfaces", ",", "$", "fileDescriptor", ")", "{", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "$", "interfaceDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "interface", ")", ";", "if", "(", "$", "interfaceDescriptor", ")", "{", "$", "interfaceDescriptor", "->", "setLocation", "(", "$", "fileDescriptor", ",", "$", "interface", "->", "getLineNumber", "(", ")", ")", ";", "if", "(", "count", "(", "$", "interfaceDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", "==", "0", ")", "{", "$", "interfaceDescriptor", "->", "getTags", "(", ")", "->", "set", "(", "'package'", ",", "$", "fileDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", ";", "}", "$", "fileDescriptor", "->", "getInterfaces", "(", ")", "->", "set", "(", "$", "interfaceDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ",", "$", "interfaceDescriptor", ")", ";", "}", "}", "}" ]
Registers the child interfaces with the generated File Descriptor. @param InterfaceReflector[] $interfaces @param FileDescriptor $fileDescriptor @return void
[ "Registers", "the", "child", "interfaces", "with", "the", "generated", "File", "Descriptor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L154-L171
22,168
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addTraits
protected function addTraits($traits, $fileDescriptor) { foreach ($traits as $trait) { $traitDescriptor = $this->getBuilder()->buildDescriptor($trait); if ($traitDescriptor) { $traitDescriptor->setLocation($fileDescriptor, $trait->getLineNumber()); if (count($traitDescriptor->getTags()->get('package', new Collection())) == 0) { $traitDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getTraits()->set( $traitDescriptor->getFullyQualifiedStructuralElementName(), $traitDescriptor ); } } }
php
protected function addTraits($traits, $fileDescriptor) { foreach ($traits as $trait) { $traitDescriptor = $this->getBuilder()->buildDescriptor($trait); if ($traitDescriptor) { $traitDescriptor->setLocation($fileDescriptor, $trait->getLineNumber()); if (count($traitDescriptor->getTags()->get('package', new Collection())) == 0) { $traitDescriptor->getTags() ->set('package', $fileDescriptor->getTags()->get('package', new Collection())); } $fileDescriptor->getTraits()->set( $traitDescriptor->getFullyQualifiedStructuralElementName(), $traitDescriptor ); } } }
[ "protected", "function", "addTraits", "(", "$", "traits", ",", "$", "fileDescriptor", ")", "{", "foreach", "(", "$", "traits", "as", "$", "trait", ")", "{", "$", "traitDescriptor", "=", "$", "this", "->", "getBuilder", "(", ")", "->", "buildDescriptor", "(", "$", "trait", ")", ";", "if", "(", "$", "traitDescriptor", ")", "{", "$", "traitDescriptor", "->", "setLocation", "(", "$", "fileDescriptor", ",", "$", "trait", "->", "getLineNumber", "(", ")", ")", ";", "if", "(", "count", "(", "$", "traitDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", "==", "0", ")", "{", "$", "traitDescriptor", "->", "getTags", "(", ")", "->", "set", "(", "'package'", ",", "$", "fileDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ",", "new", "Collection", "(", ")", ")", ")", ";", "}", "$", "fileDescriptor", "->", "getTraits", "(", ")", "->", "set", "(", "$", "traitDescriptor", "->", "getFullyQualifiedStructuralElementName", "(", ")", ",", "$", "traitDescriptor", ")", ";", "}", "}", "}" ]
Registers the child traits with the generated File Descriptor. @param TraitReflector[] $traits @param FileDescriptor $fileDescriptor @return void
[ "Registers", "the", "child", "traits", "with", "the", "generated", "File", "Descriptor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L181-L198
22,169
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php
FileAssembler.addMarkers
protected function addMarkers($markers, $fileDescriptor) { foreach ($markers as $marker) { list($type, $message, $line) = $marker; $fileDescriptor->getMarkers()->add( array( 'type' => $type, 'message' => $message, 'line' => $line, ) ); } }
php
protected function addMarkers($markers, $fileDescriptor) { foreach ($markers as $marker) { list($type, $message, $line) = $marker; $fileDescriptor->getMarkers()->add( array( 'type' => $type, 'message' => $message, 'line' => $line, ) ); } }
[ "protected", "function", "addMarkers", "(", "$", "markers", ",", "$", "fileDescriptor", ")", "{", "foreach", "(", "$", "markers", "as", "$", "marker", ")", "{", "list", "(", "$", "type", ",", "$", "message", ",", "$", "line", ")", "=", "$", "marker", ";", "$", "fileDescriptor", "->", "getMarkers", "(", ")", "->", "add", "(", "array", "(", "'type'", "=>", "$", "type", ",", "'message'", "=>", "$", "message", ",", "'line'", "=>", "$", "line", ",", ")", ")", ";", "}", "}" ]
Registers the markers that were found in a File with the File Descriptor. @param string[] $markers @param FileDescriptor $fileDescriptor @return void
[ "Registers", "the", "markers", "that", "were", "found", "in", "a", "File", "with", "the", "File", "Descriptor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FileAssembler.php#L208-L220
22,170
bpolaszek/simple-dbal
src/Model/Adapter/PDO/Statement.php
Statement.bindNumericParameters
protected function bindNumericParameters(): void { $values = $this->getValues(); $cnt = count($values); for ($index0 = 0, $index1 = 1; $index0 < $cnt; $index0++, $index1++) { $value = $this->toScalar($values[$index0]); $this->getWrappedStatement()->bindValue($index1, $value, $this->getPdoType($value)); } }
php
protected function bindNumericParameters(): void { $values = $this->getValues(); $cnt = count($values); for ($index0 = 0, $index1 = 1; $index0 < $cnt; $index0++, $index1++) { $value = $this->toScalar($values[$index0]); $this->getWrappedStatement()->bindValue($index1, $value, $this->getPdoType($value)); } }
[ "protected", "function", "bindNumericParameters", "(", ")", ":", "void", "{", "$", "values", "=", "$", "this", "->", "getValues", "(", ")", ";", "$", "cnt", "=", "count", "(", "$", "values", ")", ";", "for", "(", "$", "index0", "=", "0", ",", "$", "index1", "=", "1", ";", "$", "index0", "<", "$", "cnt", ";", "$", "index0", "++", ",", "$", "index1", "++", ")", "{", "$", "value", "=", "$", "this", "->", "toScalar", "(", "$", "values", "[", "$", "index0", "]", ")", ";", "$", "this", "->", "getWrappedStatement", "(", ")", "->", "bindValue", "(", "$", "index1", ",", "$", "value", ",", "$", "this", "->", "getPdoType", "(", "$", "value", ")", ")", ";", "}", "}" ]
Bind ? parameters
[ "Bind", "?", "parameters" ]
52cb50d326ba5854191814b470f5e84950ebb6e6
https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/PDO/Statement.php#L92-L100
22,171
thupan/framework
src/Service/Minifier.php
Minifier.loop
protected function loop() { while ($this->a !== false && !is_null($this->a) && $this->a !== '') { switch ($this->a) { // new lines case "\n": // if the next line is something that can't stand alone preserve the newline if (strpos('(-+{[@', $this->b) !== false) { echo $this->a; $this->saveString(); break; } // if B is a space we skip the rest of the switch block and go down to the // string/regex check below, resetting $this->b with getReal if($this->b === ' ') break; // otherwise we treat the newline like a space case ' ': if(static::isAlphaNumeric($this->b)) echo $this->a; $this->saveString(); break; default: switch ($this->b) { case "\n": if (strpos('}])+-"\'', $this->a) !== false) { echo $this->a; $this->saveString(); break; } else { if (static::isAlphaNumeric($this->a)) { echo $this->a; $this->saveString(); } } break; case ' ': if(!static::isAlphaNumeric($this->a)) break; default: // check for some regex that breaks stuff if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) { $this->saveRegex(); continue; } echo $this->a; $this->saveString(); break; } } // do reg check of doom $this->b = $this->getReal(); if(($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false)) $this->saveRegex(); } }
php
protected function loop() { while ($this->a !== false && !is_null($this->a) && $this->a !== '') { switch ($this->a) { // new lines case "\n": // if the next line is something that can't stand alone preserve the newline if (strpos('(-+{[@', $this->b) !== false) { echo $this->a; $this->saveString(); break; } // if B is a space we skip the rest of the switch block and go down to the // string/regex check below, resetting $this->b with getReal if($this->b === ' ') break; // otherwise we treat the newline like a space case ' ': if(static::isAlphaNumeric($this->b)) echo $this->a; $this->saveString(); break; default: switch ($this->b) { case "\n": if (strpos('}])+-"\'', $this->a) !== false) { echo $this->a; $this->saveString(); break; } else { if (static::isAlphaNumeric($this->a)) { echo $this->a; $this->saveString(); } } break; case ' ': if(!static::isAlphaNumeric($this->a)) break; default: // check for some regex that breaks stuff if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) { $this->saveRegex(); continue; } echo $this->a; $this->saveString(); break; } } // do reg check of doom $this->b = $this->getReal(); if(($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false)) $this->saveRegex(); } }
[ "protected", "function", "loop", "(", ")", "{", "while", "(", "$", "this", "->", "a", "!==", "false", "&&", "!", "is_null", "(", "$", "this", "->", "a", ")", "&&", "$", "this", "->", "a", "!==", "''", ")", "{", "switch", "(", "$", "this", "->", "a", ")", "{", "// new lines", "case", "\"\\n\"", ":", "// if the next line is something that can't stand alone preserve the newline", "if", "(", "strpos", "(", "'(-+{[@'", ",", "$", "this", "->", "b", ")", "!==", "false", ")", "{", "echo", "$", "this", "->", "a", ";", "$", "this", "->", "saveString", "(", ")", ";", "break", ";", "}", "// if B is a space we skip the rest of the switch block and go down to the", "// string/regex check below, resetting $this->b with getReal", "if", "(", "$", "this", "->", "b", "===", "' '", ")", "break", ";", "// otherwise we treat the newline like a space", "case", "' '", ":", "if", "(", "static", "::", "isAlphaNumeric", "(", "$", "this", "->", "b", ")", ")", "echo", "$", "this", "->", "a", ";", "$", "this", "->", "saveString", "(", ")", ";", "break", ";", "default", ":", "switch", "(", "$", "this", "->", "b", ")", "{", "case", "\"\\n\"", ":", "if", "(", "strpos", "(", "'}])+-\"\\''", ",", "$", "this", "->", "a", ")", "!==", "false", ")", "{", "echo", "$", "this", "->", "a", ";", "$", "this", "->", "saveString", "(", ")", ";", "break", ";", "}", "else", "{", "if", "(", "static", "::", "isAlphaNumeric", "(", "$", "this", "->", "a", ")", ")", "{", "echo", "$", "this", "->", "a", ";", "$", "this", "->", "saveString", "(", ")", ";", "}", "}", "break", ";", "case", "' '", ":", "if", "(", "!", "static", "::", "isAlphaNumeric", "(", "$", "this", "->", "a", ")", ")", "break", ";", "default", ":", "// check for some regex that breaks stuff", "if", "(", "$", "this", "->", "a", "===", "'/'", "&&", "(", "$", "this", "->", "b", "===", "'\\''", "||", "$", "this", "->", "b", "===", "'\"'", ")", ")", "{", "$", "this", "->", "saveRegex", "(", ")", ";", "continue", ";", "}", "echo", "$", "this", "->", "a", ";", "$", "this", "->", "saveString", "(", ")", ";", "break", ";", "}", "}", "// do reg check of doom", "$", "this", "->", "b", "=", "$", "this", "->", "getReal", "(", ")", ";", "if", "(", "(", "$", "this", "->", "b", "==", "'/'", "&&", "strpos", "(", "'(,=:[!&|?'", ",", "$", "this", "->", "a", ")", "!==", "false", ")", ")", "$", "this", "->", "saveRegex", "(", ")", ";", "}", "}" ]
The primary action occurs here. This function loops through the input string, outputting anything that's relevant and discarding anything that is not.
[ "The", "primary", "action", "occurs", "here", ".", "This", "function", "loops", "through", "the", "input", "string", "outputting", "anything", "that", "s", "relevant", "and", "discarding", "anything", "that", "is", "not", "." ]
43193c67e87942930fb0cbc53aa069b60b27e749
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Minifier.php#L176-L242
22,172
thupan/framework
src/Service/Minifier.php
Minifier.getChar
protected function getChar() { // Check to see if we had anything in the look ahead buffer and use that. if (isset($this->c)) { $char = $this->c; unset($this->c); // Otherwise we start pulling from the input. } else { $char = substr($this->input, $this->index, 1); // If the next character doesn't exist return false. if (isset($char) && $char === false) { return false; } // Otherwise increment the pointer and use this char. $this->index++; } // Normalize all whitespace except for the newline character into a // standard space. if($char !== "\n" && ord($char) < 32) return ' '; return $char; }
php
protected function getChar() { // Check to see if we had anything in the look ahead buffer and use that. if (isset($this->c)) { $char = $this->c; unset($this->c); // Otherwise we start pulling from the input. } else { $char = substr($this->input, $this->index, 1); // If the next character doesn't exist return false. if (isset($char) && $char === false) { return false; } // Otherwise increment the pointer and use this char. $this->index++; } // Normalize all whitespace except for the newline character into a // standard space. if($char !== "\n" && ord($char) < 32) return ' '; return $char; }
[ "protected", "function", "getChar", "(", ")", "{", "// Check to see if we had anything in the look ahead buffer and use that.", "if", "(", "isset", "(", "$", "this", "->", "c", ")", ")", "{", "$", "char", "=", "$", "this", "->", "c", ";", "unset", "(", "$", "this", "->", "c", ")", ";", "// Otherwise we start pulling from the input.", "}", "else", "{", "$", "char", "=", "substr", "(", "$", "this", "->", "input", ",", "$", "this", "->", "index", ",", "1", ")", ";", "// If the next character doesn't exist return false.", "if", "(", "isset", "(", "$", "char", ")", "&&", "$", "char", "===", "false", ")", "{", "return", "false", ";", "}", "// Otherwise increment the pointer and use this char.", "$", "this", "->", "index", "++", ";", "}", "// Normalize all whitespace except for the newline character into a", "// standard space.", "if", "(", "$", "char", "!==", "\"\\n\"", "&&", "ord", "(", "$", "char", ")", "<", "32", ")", "return", "' '", ";", "return", "$", "char", ";", "}" ]
Returns the next string for processing based off of the current index. @return string
[ "Returns", "the", "next", "string", "for", "processing", "based", "off", "of", "the", "current", "index", "." ]
43193c67e87942930fb0cbc53aa069b60b27e749
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Minifier.php#L263-L290
22,173
jasny/controller
src/Controller/Session/Flash.php
Flash.get
public function get() { if (!isset($this->data) && isset($this->session[$this->key])) { $this->data = $this->session[$this->key]; unset($this->session[$this->key]); } return $this->data ? (object)$this->data : null; }
php
public function get() { if (!isset($this->data) && isset($this->session[$this->key])) { $this->data = $this->session[$this->key]; unset($this->session[$this->key]); } return $this->data ? (object)$this->data : null; }
[ "public", "function", "get", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", ")", "&&", "isset", "(", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", ")", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", ";", "unset", "(", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", ")", ";", "}", "return", "$", "this", "->", "data", "?", "(", "object", ")", "$", "this", "->", "data", ":", "null", ";", "}" ]
Get the flash. @return object
[ "Get", "the", "flash", "." ]
28edf64343f1d8218c166c0c570128e1ee6153d8
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session/Flash.php#L63-L71
22,174
jasny/controller
src/Controller/Session/Flash.php
Flash.reissue
public function reissue() { if (!isset($this->data) && isset($this->session[$this->key])) { $this->data = $this->session[$this->key]; } else { $this->session[$this->key] = $this->data; } }
php
public function reissue() { if (!isset($this->data) && isset($this->session[$this->key])) { $this->data = $this->session[$this->key]; } else { $this->session[$this->key] = $this->data; } }
[ "public", "function", "reissue", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", ")", "&&", "isset", "(", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", ")", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", ";", "}", "else", "{", "$", "this", "->", "session", "[", "$", "this", "->", "key", "]", "=", "$", "this", "->", "data", ";", "}", "}" ]
Reissue the flash.
[ "Reissue", "the", "flash", "." ]
28edf64343f1d8218c166c0c570128e1ee6153d8
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/Session/Flash.php#L76-L83
22,175
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.build_query
final protected function build_query(){ $select = empty($this->_select) ? $this->default_select() : implode(', ', $this->_select); $calc = $this->_calc_rows ? ' SQL_CALC_FOUND_ROWS' : ''; $distinct = $this->_distinct ? sprintf('DISTINCT(%s)', $this->escape_column_name($this->_distinct)) : ''; $from = empty($this->_from) ? $this->table : $this->_from; // Build query $sql = <<<SQL SELECT{$calc} {$distinct} {$select} FROM {$from} SQL; // Add join $join = []; if( !empty($this->_join) ){ $join = $this->_join; }else{ $default_join = $this->default_join(); if( !empty($default_join) ){ $join = $default_join; } } foreach($join as list($table, $on, $method)){ $method = 'INNER' === strtoupper($method) ? 'INNER' : 'LEFT'; $sql .= <<<SQL {$method} JOIN {$table} ON {$on} SQL; } // Add where if( !empty($this->_wheres) ){ $where_clause = $this->build_where($this->_wheres); $sql .= <<<SQL WHERE {$where_clause} SQL; } // Add group by if( !empty($this->_group_by) ){ $group_by = implode(', ', $this->_group_by); $sql .= <<<SQL GROUP BY {$group_by} SQL; } // Add order by if( !empty($this->_order_by) ){ $order_by = implode(', ', $this->_order_by); $sql .= <<<SQL ORDER BY {$order_by} SQL; } // Add limit if( !empty($this->_limit) ){ list($per_page, $offset) = $this->_limit; $limit = <<<SQL LIMIT %d, %d SQL; $sql .= sprintf($limit, $offset, $per_page); } return $sql; }
php
final protected function build_query(){ $select = empty($this->_select) ? $this->default_select() : implode(', ', $this->_select); $calc = $this->_calc_rows ? ' SQL_CALC_FOUND_ROWS' : ''; $distinct = $this->_distinct ? sprintf('DISTINCT(%s)', $this->escape_column_name($this->_distinct)) : ''; $from = empty($this->_from) ? $this->table : $this->_from; // Build query $sql = <<<SQL SELECT{$calc} {$distinct} {$select} FROM {$from} SQL; // Add join $join = []; if( !empty($this->_join) ){ $join = $this->_join; }else{ $default_join = $this->default_join(); if( !empty($default_join) ){ $join = $default_join; } } foreach($join as list($table, $on, $method)){ $method = 'INNER' === strtoupper($method) ? 'INNER' : 'LEFT'; $sql .= <<<SQL {$method} JOIN {$table} ON {$on} SQL; } // Add where if( !empty($this->_wheres) ){ $where_clause = $this->build_where($this->_wheres); $sql .= <<<SQL WHERE {$where_clause} SQL; } // Add group by if( !empty($this->_group_by) ){ $group_by = implode(', ', $this->_group_by); $sql .= <<<SQL GROUP BY {$group_by} SQL; } // Add order by if( !empty($this->_order_by) ){ $order_by = implode(', ', $this->_order_by); $sql .= <<<SQL ORDER BY {$order_by} SQL; } // Add limit if( !empty($this->_limit) ){ list($per_page, $offset) = $this->_limit; $limit = <<<SQL LIMIT %d, %d SQL; $sql .= sprintf($limit, $offset, $per_page); } return $sql; }
[ "final", "protected", "function", "build_query", "(", ")", "{", "$", "select", "=", "empty", "(", "$", "this", "->", "_select", ")", "?", "$", "this", "->", "default_select", "(", ")", ":", "implode", "(", "', '", ",", "$", "this", "->", "_select", ")", ";", "$", "calc", "=", "$", "this", "->", "_calc_rows", "?", "' SQL_CALC_FOUND_ROWS'", ":", "''", ";", "$", "distinct", "=", "$", "this", "->", "_distinct", "?", "sprintf", "(", "'DISTINCT(%s)'", ",", "$", "this", "->", "escape_column_name", "(", "$", "this", "->", "_distinct", ")", ")", ":", "''", ";", "$", "from", "=", "empty", "(", "$", "this", "->", "_from", ")", "?", "$", "this", "->", "table", ":", "$", "this", "->", "_from", ";", "// Build query", "$", "sql", "=", " <<<SQL\n SELECT{$calc} {$distinct} {$select} FROM {$from}\nSQL", ";", "// Add join", "$", "join", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_join", ")", ")", "{", "$", "join", "=", "$", "this", "->", "_join", ";", "}", "else", "{", "$", "default_join", "=", "$", "this", "->", "default_join", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "default_join", ")", ")", "{", "$", "join", "=", "$", "default_join", ";", "}", "}", "foreach", "(", "$", "join", "as", "list", "(", "$", "table", ",", "$", "on", ",", "$", "method", ")", ")", "{", "$", "method", "=", "'INNER'", "===", "strtoupper", "(", "$", "method", ")", "?", "'INNER'", ":", "'LEFT'", ";", "$", "sql", ".=", " <<<SQL\n {$method} JOIN {$table}\n ON {$on}\nSQL", ";", "}", "// Add where", "if", "(", "!", "empty", "(", "$", "this", "->", "_wheres", ")", ")", "{", "$", "where_clause", "=", "$", "this", "->", "build_where", "(", "$", "this", "->", "_wheres", ")", ";", "$", "sql", ".=", " <<<SQL\n WHERE {$where_clause}\nSQL", ";", "}", "// Add group by", "if", "(", "!", "empty", "(", "$", "this", "->", "_group_by", ")", ")", "{", "$", "group_by", "=", "implode", "(", "', '", ",", "$", "this", "->", "_group_by", ")", ";", "$", "sql", ".=", " <<<SQL\n GROUP BY {$group_by}\nSQL", ";", "}", "// Add order by", "if", "(", "!", "empty", "(", "$", "this", "->", "_order_by", ")", ")", "{", "$", "order_by", "=", "implode", "(", "', '", ",", "$", "this", "->", "_order_by", ")", ";", "$", "sql", ".=", " <<<SQL\n ORDER BY {$order_by}\nSQL", ";", "}", "// Add limit", "if", "(", "!", "empty", "(", "$", "this", "->", "_limit", ")", ")", "{", "list", "(", "$", "per_page", ",", "$", "offset", ")", "=", "$", "this", "->", "_limit", ";", "$", "limit", "=", " <<<SQL\n LIMIT %d, %d\nSQL", ";", "$", "sql", ".=", "sprintf", "(", "$", "limit", ",", "$", "offset", ",", "$", "per_page", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Build query with current setting @return string
[ "Build", "query", "with", "current", "setting" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L118-L174
22,176
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.build_where
private function build_where(array $where_array){ $where_clause = []; $counter = 0; foreach( $where_array as list($glue, $where) ){ if( $counter ){ $where_clause[] = $glue; } if( is_array($where) ){ $where_clause[] = $this->build_where($where_array); }else{ $where_clause[] = sprintf('(%s)', $where); } $counter++; } return sprintf('(%s)', implode(' ', $where_clause)); }
php
private function build_where(array $where_array){ $where_clause = []; $counter = 0; foreach( $where_array as list($glue, $where) ){ if( $counter ){ $where_clause[] = $glue; } if( is_array($where) ){ $where_clause[] = $this->build_where($where_array); }else{ $where_clause[] = sprintf('(%s)', $where); } $counter++; } return sprintf('(%s)', implode(' ', $where_clause)); }
[ "private", "function", "build_where", "(", "array", "$", "where_array", ")", "{", "$", "where_clause", "=", "[", "]", ";", "$", "counter", "=", "0", ";", "foreach", "(", "$", "where_array", "as", "list", "(", "$", "glue", ",", "$", "where", ")", ")", "{", "if", "(", "$", "counter", ")", "{", "$", "where_clause", "[", "]", "=", "$", "glue", ";", "}", "if", "(", "is_array", "(", "$", "where", ")", ")", "{", "$", "where_clause", "[", "]", "=", "$", "this", "->", "build_where", "(", "$", "where_array", ")", ";", "}", "else", "{", "$", "where_clause", "[", "]", "=", "sprintf", "(", "'(%s)'", ",", "$", "where", ")", ";", "}", "$", "counter", "++", ";", "}", "return", "sprintf", "(", "'(%s)'", ",", "implode", "(", "' '", ",", "$", "where_clause", ")", ")", ";", "}" ]
Build where clause @param array $where_array @return string
[ "Build", "where", "clause" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L182-L197
22,177
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.select
final protected function select($name, $escape = true){ $this->_select[] = $escape ? $this->escape_column_name($name) : $name; return $this; }
php
final protected function select($name, $escape = true){ $this->_select[] = $escape ? $this->escape_column_name($name) : $name; return $this; }
[ "final", "protected", "function", "select", "(", "$", "name", ",", "$", "escape", "=", "true", ")", "{", "$", "this", "->", "_select", "[", "]", "=", "$", "escape", "?", "$", "this", "->", "escape_column_name", "(", "$", "name", ")", ":", "$", "name", ";", "return", "$", "this", ";", "}" ]
Set select param @param string $name @param bool $escape Default true @return $this
[ "Set", "select", "param" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L206-L211
22,178
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.where_not_null
final protected function where_not_null($column, $or = false){ $this->_wheres[] = [$this->and_or($or), sprintf("%s IS NOT NULL", $this->escape_column_name($column))]; return $this; }
php
final protected function where_not_null($column, $or = false){ $this->_wheres[] = [$this->and_or($or), sprintf("%s IS NOT NULL", $this->escape_column_name($column))]; return $this; }
[ "final", "protected", "function", "where_not_null", "(", "$", "column", ",", "$", "or", "=", "false", ")", "{", "$", "this", "->", "_wheres", "[", "]", "=", "[", "$", "this", "->", "and_or", "(", "$", "or", ")", ",", "sprintf", "(", "\"%s IS NOT NULL\"", ",", "$", "this", "->", "escape_column_name", "(", "$", "column", ")", ")", "]", ";", "return", "$", "this", ";", "}" ]
Add where not null clause @param string $column @param bool $or Default false @return $this
[ "Add", "where", "not", "null", "clause" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L285-L288
22,179
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.where_like
final protected function where_like($column, $replace, $position = 'both', $or = false){ switch( strtolower($position) ){ case 'left': $replace = '%'.$replace; break; case 'right': $replace = $replace.'%'; break; default: $replace = '%'.$replace.'%'; break; } $column = $this->escape_column_name($column); $this->_wheres[] = [$this->and_or($or), $this->db->prepare("{$column} LIKE %s", $replace)]; return $this; }
php
final protected function where_like($column, $replace, $position = 'both', $or = false){ switch( strtolower($position) ){ case 'left': $replace = '%'.$replace; break; case 'right': $replace = $replace.'%'; break; default: $replace = '%'.$replace.'%'; break; } $column = $this->escape_column_name($column); $this->_wheres[] = [$this->and_or($or), $this->db->prepare("{$column} LIKE %s", $replace)]; return $this; }
[ "final", "protected", "function", "where_like", "(", "$", "column", ",", "$", "replace", ",", "$", "position", "=", "'both'", ",", "$", "or", "=", "false", ")", "{", "switch", "(", "strtolower", "(", "$", "position", ")", ")", "{", "case", "'left'", ":", "$", "replace", "=", "'%'", ".", "$", "replace", ";", "break", ";", "case", "'right'", ":", "$", "replace", "=", "$", "replace", ".", "'%'", ";", "break", ";", "default", ":", "$", "replace", "=", "'%'", ".", "$", "replace", ".", "'%'", ";", "break", ";", "}", "$", "column", "=", "$", "this", "->", "escape_column_name", "(", "$", "column", ")", ";", "$", "this", "->", "_wheres", "[", "]", "=", "[", "$", "this", "->", "and_or", "(", "$", "or", ")", ",", "$", "this", "->", "db", "->", "prepare", "(", "\"{$column} LIKE %s\"", ",", "$", "replace", ")", "]", ";", "return", "$", "this", ";", "}" ]
Add Where LIKE @param string $column @param string $replace @param string $position Position of %. 'left', 'right' or 'both' @param bool $or @return $this
[ "Add", "Where", "LIKE" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L299-L314
22,180
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.wheres
final protected function wheres(array $wheres, $or = false){ foreach($wheres as $where => $replace){ $this->where($where, $replace, $or); } return $this; }
php
final protected function wheres(array $wheres, $or = false){ foreach($wheres as $where => $replace){ $this->where($where, $replace, $or); } return $this; }
[ "final", "protected", "function", "wheres", "(", "array", "$", "wheres", ",", "$", "or", "=", "false", ")", "{", "foreach", "(", "$", "wheres", "as", "$", "where", "=>", "$", "replace", ")", "{", "$", "this", "->", "where", "(", "$", "where", ",", "$", "replace", ",", "$", "or", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add where in one shot @param array $wheres @param bool $or @return $this
[ "Add", "where", "in", "one", "shot" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L323-L328
22,181
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.group_by
final protected function group_by($column, $order = 'ASC'){ $order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC'; $this->_group_by[] = sprintf('%s %s', $this->escape_column_name($column), $order); return $this; }
php
final protected function group_by($column, $order = 'ASC'){ $order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC'; $this->_group_by[] = sprintf('%s %s', $this->escape_column_name($column), $order); return $this; }
[ "final", "protected", "function", "group_by", "(", "$", "column", ",", "$", "order", "=", "'ASC'", ")", "{", "$", "order", "=", "'DESC'", "===", "strtoupper", "(", "$", "order", ")", "?", "'DESC'", ":", "'ASC'", ";", "$", "this", "->", "_group_by", "[", "]", "=", "sprintf", "(", "'%s %s'", ",", "$", "this", "->", "escape_column_name", "(", "$", "column", ")", ",", "$", "order", ")", ";", "return", "$", "this", ";", "}" ]
Add group by @param string $column @param string $order @return $this
[ "Add", "group", "by" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L367-L371
22,182
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.order_by
final protected function order_by($column, $order = 'ASC'){ $order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC'; $this->_order_by[] = sprintf('%s %s', $this->escape_column_name($column), $order); return $this; }
php
final protected function order_by($column, $order = 'ASC'){ $order = 'DESC' === strtoupper($order) ? 'DESC' : 'ASC'; $this->_order_by[] = sprintf('%s %s', $this->escape_column_name($column), $order); return $this; }
[ "final", "protected", "function", "order_by", "(", "$", "column", ",", "$", "order", "=", "'ASC'", ")", "{", "$", "order", "=", "'DESC'", "===", "strtoupper", "(", "$", "order", ")", "?", "'DESC'", ":", "'ASC'", ";", "$", "this", "->", "_order_by", "[", "]", "=", "sprintf", "(", "'%s %s'", ",", "$", "this", "->", "escape_column_name", "(", "$", "column", ")", ",", "$", "order", ")", ";", "return", "$", "this", ";", "}" ]
Add order by @param string $column @param string $order @return $this
[ "Add", "order", "by" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L380-L384
22,183
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.escape_column_name
private function escape_column_name($column_names){ $columns = []; foreach( explode(',', $column_names) as $column_name ){ // trim $column_name = trim($column_name); // Remove special chars $columns[] = preg_replace('/[`\'";\n\r\\\\\\0]/u', '', $column_name); } return implode(', ', $columns); }
php
private function escape_column_name($column_names){ $columns = []; foreach( explode(',', $column_names) as $column_name ){ // trim $column_name = trim($column_name); // Remove special chars $columns[] = preg_replace('/[`\'";\n\r\\\\\\0]/u', '', $column_name); } return implode(', ', $columns); }
[ "private", "function", "escape_column_name", "(", "$", "column_names", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "explode", "(", "','", ",", "$", "column_names", ")", "as", "$", "column_name", ")", "{", "// trim", "$", "column_name", "=", "trim", "(", "$", "column_name", ")", ";", "// Remove special chars", "$", "columns", "[", "]", "=", "preg_replace", "(", "'/[`\\'\";\\n\\r\\\\\\\\\\\\0]/u'", ",", "''", ",", "$", "column_name", ")", ";", "}", "return", "implode", "(", "', '", ",", "$", "columns", ")", ";", "}" ]
Wrap table name with backtick @param string $column_names @return string
[ "Wrap", "table", "name", "with", "backtick" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L440-L449
22,184
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.clear
final protected function clear(){ $this->_distinct = false; $this->_select = []; $this->_from = ''; $this->_join = []; $this->_wheres = []; $this->_group_by = []; $this->_order_by = []; $this->_limit = []; }
php
final protected function clear(){ $this->_distinct = false; $this->_select = []; $this->_from = ''; $this->_join = []; $this->_wheres = []; $this->_group_by = []; $this->_order_by = []; $this->_limit = []; }
[ "final", "protected", "function", "clear", "(", ")", "{", "$", "this", "->", "_distinct", "=", "false", ";", "$", "this", "->", "_select", "=", "[", "]", ";", "$", "this", "->", "_from", "=", "''", ";", "$", "this", "->", "_join", "=", "[", "]", ";", "$", "this", "->", "_wheres", "=", "[", "]", ";", "$", "this", "->", "_group_by", "=", "[", "]", ";", "$", "this", "->", "_order_by", "=", "[", "]", ";", "$", "this", "->", "_limit", "=", "[", "]", ";", "}" ]
Clear all result
[ "Clear", "all", "result" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L491-L500
22,185
hametuha/wpametu
src/WPametu/DB/QueryBuilder.php
QueryBuilder.cache_query
final protected function cache_query($sql, $result){ if( isset($this->query_cache[$sql]) ){ $this->query_cache[$sql] = $result; }elseif( count($this->query_cache) >= $this->cache_limit ){ // Remove oldest cache array_shift($this->query_cache); // save query $this->query_cache[$sql] = $result; } }
php
final protected function cache_query($sql, $result){ if( isset($this->query_cache[$sql]) ){ $this->query_cache[$sql] = $result; }elseif( count($this->query_cache) >= $this->cache_limit ){ // Remove oldest cache array_shift($this->query_cache); // save query $this->query_cache[$sql] = $result; } }
[ "final", "protected", "function", "cache_query", "(", "$", "sql", ",", "$", "result", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "query_cache", "[", "$", "sql", "]", ")", ")", "{", "$", "this", "->", "query_cache", "[", "$", "sql", "]", "=", "$", "result", ";", "}", "elseif", "(", "count", "(", "$", "this", "->", "query_cache", ")", ">=", "$", "this", "->", "cache_limit", ")", "{", "// Remove oldest cache", "array_shift", "(", "$", "this", "->", "query_cache", ")", ";", "// save query", "$", "this", "->", "query_cache", "[", "$", "sql", "]", "=", "$", "result", ";", "}", "}" ]
Save query cache @param string $sql @param mixed $result
[ "Save", "query", "cache" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/QueryBuilder.php#L508-L517
22,186
nabab/bbn
src/bbn/appui/chat.php
chat.create
public function create(array $users, int $public = 0): ?string { if ( $this->check() ){ $join = ''; $where = ''; $values = [$this->user->get_id(), $public]; foreach ( $users as $i => $u ){ $join .= "JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id".PHP_EOL; $where .= "AND u$i.id_user = ?".PHP_EOL; $values[] = $u; } $sql = <<<SQL SELECT id FROM bbn_chats $join WHERE creator = ? AND public = ? $where SQL; if ( ($id_chat = $this->db->get_one($sql, $values)) && (count($users) === $this->db->count('bbn_chat_users', ['id_chat' => $id_chat])) ){ return $id_chat; } if ( $this->db->insert('bbn_chats', [ 'creator' => $this->user->get_id(), 'creation' => date('Y-m-d H:i:s'), 'public' => $public ? 1 : 0 ]) ){ $id_chat = $this->db->last_id(); $this->db->insert('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $this->user->get_id(), 'entrance' => microtime(true), 'admin' => 1 ]); foreach ( $users as $user ){ $this->db->insert_ignore('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $user, 'entrance' => microtime(true), 'admin' => 0 ]); } return $id_chat; } } return null; }
php
public function create(array $users, int $public = 0): ?string { if ( $this->check() ){ $join = ''; $where = ''; $values = [$this->user->get_id(), $public]; foreach ( $users as $i => $u ){ $join .= "JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id".PHP_EOL; $where .= "AND u$i.id_user = ?".PHP_EOL; $values[] = $u; } $sql = <<<SQL SELECT id FROM bbn_chats $join WHERE creator = ? AND public = ? $where SQL; if ( ($id_chat = $this->db->get_one($sql, $values)) && (count($users) === $this->db->count('bbn_chat_users', ['id_chat' => $id_chat])) ){ return $id_chat; } if ( $this->db->insert('bbn_chats', [ 'creator' => $this->user->get_id(), 'creation' => date('Y-m-d H:i:s'), 'public' => $public ? 1 : 0 ]) ){ $id_chat = $this->db->last_id(); $this->db->insert('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $this->user->get_id(), 'entrance' => microtime(true), 'admin' => 1 ]); foreach ( $users as $user ){ $this->db->insert_ignore('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $user, 'entrance' => microtime(true), 'admin' => 0 ]); } return $id_chat; } } return null; }
[ "public", "function", "create", "(", "array", "$", "users", ",", "int", "$", "public", "=", "0", ")", ":", "?", "string", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "$", "join", "=", "''", ";", "$", "where", "=", "''", ";", "$", "values", "=", "[", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "$", "public", "]", ";", "foreach", "(", "$", "users", "as", "$", "i", "=>", "$", "u", ")", "{", "$", "join", ".=", "\"JOIN bbn_chats_users AS u$i ON u$i.id_chat = bbn_chats.id\"", ".", "PHP_EOL", ";", "$", "where", ".=", "\"AND u$i.id_user = ?\"", ".", "PHP_EOL", ";", "$", "values", "[", "]", "=", "$", "u", ";", "}", "$", "sql", "=", " <<<SQL\nSELECT id\nFROM bbn_chats\n $join\nWHERE creator = ?\nAND public = ? \n$where\nSQL", ";", "if", "(", "(", "$", "id_chat", "=", "$", "this", "->", "db", "->", "get_one", "(", "$", "sql", ",", "$", "values", ")", ")", "&&", "(", "count", "(", "$", "users", ")", "===", "$", "this", "->", "db", "->", "count", "(", "'bbn_chat_users'", ",", "[", "'id_chat'", "=>", "$", "id_chat", "]", ")", ")", ")", "{", "return", "$", "id_chat", ";", "}", "if", "(", "$", "this", "->", "db", "->", "insert", "(", "'bbn_chats'", ",", "[", "'creator'", "=>", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "'creation'", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "'public'", "=>", "$", "public", "?", "1", ":", "0", "]", ")", ")", "{", "$", "id_chat", "=", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "$", "this", "->", "db", "->", "insert", "(", "'bbn_chats_users'", ",", "[", "'id_chat'", "=>", "$", "id_chat", ",", "'id_user'", "=>", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "'entrance'", "=>", "microtime", "(", "true", ")", ",", "'admin'", "=>", "1", "]", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "this", "->", "db", "->", "insert_ignore", "(", "'bbn_chats_users'", ",", "[", "'id_chat'", "=>", "$", "id_chat", ",", "'id_user'", "=>", "$", "user", ",", "'entrance'", "=>", "microtime", "(", "true", ")", ",", "'admin'", "=>", "0", "]", ")", ";", "}", "return", "$", "id_chat", ";", "}", "}", "return", "null", ";", "}" ]
Creates a new chat with the current userr and another participant. @param array $users @param int $public @return null|string
[ "Creates", "a", "new", "chat", "with", "the", "current", "userr", "and", "another", "participant", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L58-L104
22,187
nabab/bbn
src/bbn/appui/chat.php
chat.make_admin
public function make_admin(string $id_chat, string $id_user): bool { if ( $this->is_admin($id_chat) ){ return (bool)$this->db->update_ignore('bbn_chats_users', [ 'admin' => 1 ], [ 'id_chat' => $id_chat, 'id_user' => $id_user, ]); } return false; }
php
public function make_admin(string $id_chat, string $id_user): bool { if ( $this->is_admin($id_chat) ){ return (bool)$this->db->update_ignore('bbn_chats_users', [ 'admin' => 1 ], [ 'id_chat' => $id_chat, 'id_user' => $id_user, ]); } return false; }
[ "public", "function", "make_admin", "(", "string", "$", "id_chat", ",", "string", "$", "id_user", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "is_admin", "(", "$", "id_chat", ")", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "update_ignore", "(", "'bbn_chats_users'", ",", "[", "'admin'", "=>", "1", "]", ",", "[", "'id_chat'", "=>", "$", "id_chat", ",", "'id_user'", "=>", "$", "id_user", ",", "]", ")", ";", "}", "return", "false", ";", "}" ]
Makes the given participant an admin of the given chat provided the current user is admin of this chat. @param string $id_chat @param string $id_user @return bool
[ "Makes", "the", "given", "participant", "an", "admin", "of", "the", "given", "chat", "provided", "the", "current", "user", "is", "admin", "of", "this", "chat", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L133-L144
22,188
nabab/bbn
src/bbn/appui/chat.php
chat.is_participant
public function is_participant(string $id_chat, string $id_user = null): ?bool { if ( $this->check() ){ return (bool)$this->db->count('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $id_user ?: $this->user->get_id() ]); } return null; }
php
public function is_participant(string $id_chat, string $id_user = null): ?bool { if ( $this->check() ){ return (bool)$this->db->count('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $id_user ?: $this->user->get_id() ]); } return null; }
[ "public", "function", "is_participant", "(", "string", "$", "id_chat", ",", "string", "$", "id_user", "=", "null", ")", ":", "?", "bool", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "count", "(", "'bbn_chats_users'", ",", "[", "'id_chat'", "=>", "$", "id_chat", ",", "'id_user'", "=>", "$", "id_user", "?", ":", "$", "this", "->", "user", "->", "get_id", "(", ")", "]", ")", ";", "}", "return", "null", ";", "}" ]
Checks whether the given user is participant of the given chat. @param string $id_chat @param string $id_user @return bool|null
[ "Checks", "whether", "the", "given", "user", "is", "participant", "of", "the", "given", "chat", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L153-L162
22,189
nabab/bbn
src/bbn/appui/chat.php
chat.info
public function info($id_chat): ?array { if ( $this->check() ){ return $this->db->rselect('bbn_chats', [], ['id' => $id_chat]) ?: null; } return null; }
php
public function info($id_chat): ?array { if ( $this->check() ){ return $this->db->rselect('bbn_chats', [], ['id' => $id_chat]) ?: null; } return null; }
[ "public", "function", "info", "(", "$", "id_chat", ")", ":", "?", "array", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "db", "->", "rselect", "(", "'bbn_chats'", ",", "[", "]", ",", "[", "'id'", "=>", "$", "id_chat", "]", ")", "?", ":", "null", ";", "}", "return", "null", ";", "}" ]
Gets information about the given chat. @param $id_chat @return array|null
[ "Gets", "information", "about", "the", "given", "chat", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L170-L176
22,190
nabab/bbn
src/bbn/appui/chat.php
chat.get_participants
public function get_participants(string $id_chat): ?array { if ( $this->check() ){ return $this->db->get_field_values('bbn_chats_users', 'id_user', ['id_chat' => $id_chat]); } return null; }
php
public function get_participants(string $id_chat): ?array { if ( $this->check() ){ return $this->db->get_field_values('bbn_chats_users', 'id_user', ['id_chat' => $id_chat]); } return null; }
[ "public", "function", "get_participants", "(", "string", "$", "id_chat", ")", ":", "?", "array", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "db", "->", "get_field_values", "(", "'bbn_chats_users'", ",", "'id_user'", ",", "[", "'id_chat'", "=>", "$", "id_chat", "]", ")", ";", "}", "return", "null", ";", "}" ]
Returns the participants of the given chat as an array of id_user. @param string $id_chat @return array|null
[ "Returns", "the", "participants", "of", "the", "given", "chat", "as", "an", "array", "of", "id_user", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L184-L190
22,191
nabab/bbn
src/bbn/appui/chat.php
chat.talk
public function talk(string $id_chat, string $message): ?int { if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){ $users = $this->get_participants($id_chat); if ( \in_array($this->user->get_id(), $users, true) ){ $time = microtime(true); $st = bbn\util\enc::crypt(json_encode(['time' => $time, 'user' => $this->user->get_id(), 'message' => $message])); $day = date('Y-m-d'); foreach ( $users as $user ){ $dir = BBN_DATA_PATH.'users/'.$user.'/chat/'.$id_chat.'/'.$day; if ( bbn\file\dir::create_path($dir) ){ file_put_contents($dir.'/'.$time.'.msg', $st); } } return $this->db->update('bbn_chats', ['last_message' => $time], ['id' => $id_chat]); } } return null; }
php
public function talk(string $id_chat, string $message): ?int { if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){ $users = $this->get_participants($id_chat); if ( \in_array($this->user->get_id(), $users, true) ){ $time = microtime(true); $st = bbn\util\enc::crypt(json_encode(['time' => $time, 'user' => $this->user->get_id(), 'message' => $message])); $day = date('Y-m-d'); foreach ( $users as $user ){ $dir = BBN_DATA_PATH.'users/'.$user.'/chat/'.$id_chat.'/'.$day; if ( bbn\file\dir::create_path($dir) ){ file_put_contents($dir.'/'.$time.'.msg', $st); } } return $this->db->update('bbn_chats', ['last_message' => $time], ['id' => $id_chat]); } } return null; }
[ "public", "function", "talk", "(", "string", "$", "id_chat", ",", "string", "$", "message", ")", ":", "?", "int", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "(", "$", "chat", "=", "$", "this", "->", "info", "(", "$", "id_chat", ")", ")", "&&", "!", "$", "chat", "[", "'blocked'", "]", ")", "{", "$", "users", "=", "$", "this", "->", "get_participants", "(", "$", "id_chat", ")", ";", "if", "(", "\\", "in_array", "(", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "$", "users", ",", "true", ")", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", ";", "$", "st", "=", "bbn", "\\", "util", "\\", "enc", "::", "crypt", "(", "json_encode", "(", "[", "'time'", "=>", "$", "time", ",", "'user'", "=>", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "'message'", "=>", "$", "message", "]", ")", ")", ";", "$", "day", "=", "date", "(", "'Y-m-d'", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "dir", "=", "BBN_DATA_PATH", ".", "'users/'", ".", "$", "user", ".", "'/chat/'", ".", "$", "id_chat", ".", "'/'", ".", "$", "day", ";", "if", "(", "bbn", "\\", "file", "\\", "dir", "::", "create_path", "(", "$", "dir", ")", ")", "{", "file_put_contents", "(", "$", "dir", ".", "'/'", ".", "$", "time", ".", "'.msg'", ",", "$", "st", ")", ";", "}", "}", "return", "$", "this", "->", "db", "->", "update", "(", "'bbn_chats'", ",", "[", "'last_message'", "=>", "$", "time", "]", ",", "[", "'id'", "=>", "$", "id_chat", "]", ")", ";", "}", "}", "return", "null", ";", "}" ]
Sends a new message from the current user in the given chat. @param string $id_chat @param string $message @return int|null
[ "Sends", "a", "new", "message", "from", "the", "current", "user", "in", "the", "given", "chat", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L199-L217
22,192
nabab/bbn
src/bbn/appui/chat.php
chat.is_admin
public function is_admin($id_chat): ?bool { if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){ return (bool)$this->db->count('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $this->user->get_id(), 'admin' => 1 ]); } return null; }
php
public function is_admin($id_chat): ?bool { if ( $this->check() && ($chat = $this->info($id_chat)) && !$chat['blocked'] ){ return (bool)$this->db->count('bbn_chats_users', [ 'id_chat' => $id_chat, 'id_user' => $this->user->get_id(), 'admin' => 1 ]); } return null; }
[ "public", "function", "is_admin", "(", "$", "id_chat", ")", ":", "?", "bool", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "(", "$", "chat", "=", "$", "this", "->", "info", "(", "$", "id_chat", ")", ")", "&&", "!", "$", "chat", "[", "'blocked'", "]", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "count", "(", "'bbn_chats_users'", ",", "[", "'id_chat'", "=>", "$", "id_chat", ",", "'id_user'", "=>", "$", "this", "->", "user", "->", "get_id", "(", ")", ",", "'admin'", "=>", "1", "]", ")", ";", "}", "return", "null", ";", "}" ]
Checks whether the current user is an admin of the given chat or not. @param $id_chat @return bool|null
[ "Checks", "whether", "the", "current", "user", "is", "an", "admin", "of", "the", "given", "chat", "or", "not", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L225-L235
22,193
nabab/bbn
src/bbn/appui/chat.php
chat.block
public function block($id_chat): bool { if ( $this->is_admin($id_chat) ){ return (bool)$this->db->update('bbn_chats', ['blocked' => 1], ['id' => $id_chat]); } return false; }
php
public function block($id_chat): bool { if ( $this->is_admin($id_chat) ){ return (bool)$this->db->update('bbn_chats', ['blocked' => 1], ['id' => $id_chat]); } return false; }
[ "public", "function", "block", "(", "$", "id_chat", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "is_admin", "(", "$", "id_chat", ")", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "update", "(", "'bbn_chats'", ",", "[", "'blocked'", "=>", "1", "]", ",", "[", "'id'", "=>", "$", "id_chat", "]", ")", ";", "}", "return", "false", ";", "}" ]
Close a chat by setting blocked to 1. @param $id_chat @return bool
[ "Close", "a", "chat", "by", "setting", "blocked", "to", "1", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/chat.php#L243-L249
22,194
ArrowSphere/Client
src/xAC.php
xAC.setApiVersion
public static function setApiVersion($version) { if (! in_array($version, [1,2])) { throw new \Exception(sprintf("The %d version is not supported", $version)); } self::$apiVersion = $version; // Refresh services if version is changed and base url is defined if (self::$url) { self::initServices(); } }
php
public static function setApiVersion($version) { if (! in_array($version, [1,2])) { throw new \Exception(sprintf("The %d version is not supported", $version)); } self::$apiVersion = $version; // Refresh services if version is changed and base url is defined if (self::$url) { self::initServices(); } }
[ "public", "static", "function", "setApiVersion", "(", "$", "version", ")", "{", "if", "(", "!", "in_array", "(", "$", "version", ",", "[", "1", ",", "2", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "\"The %d version is not supported\"", ",", "$", "version", ")", ")", ";", "}", "self", "::", "$", "apiVersion", "=", "$", "version", ";", "// Refresh services if version is changed and base url is defined", "if", "(", "self", "::", "$", "url", ")", "{", "self", "::", "initServices", "(", ")", ";", "}", "}" ]
Define which API version to use @param integer $version
[ "Define", "which", "API", "version", "to", "use" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L137-L148
22,195
ArrowSphere/Client
src/xAC.php
xAC.initServices
public static function initServices($refresh = false) { // Define full definition file path $path = sprintf('%s%sxac-services-v%d.conf' , ! empty(self::$logPath) ? self::$logPath : sys_get_temp_dir() , DIRECTORY_SEPARATOR , self::$apiVersion ); if ($refresh === true || ! file_exists($path)) { self::log(sprintf("Refresh services definition on-demand for v%d API", self::$apiVersion)); $res = self::getInstance()->call('endpoints'); $res['_timestamp'] = time(); file_put_contents($path, serialize($res)); chmod($path, 0777); self::$services = $res; } else { self::$services = unserialize(file_get_contents($path)); // Check that content is not expired if (time() - self::$services['_timestamp'] > self::$ttl) { self::log(sprintf("Refresh outdated services definition for v%d API", self::$apiVersion)); self::initServices(true); } } }
php
public static function initServices($refresh = false) { // Define full definition file path $path = sprintf('%s%sxac-services-v%d.conf' , ! empty(self::$logPath) ? self::$logPath : sys_get_temp_dir() , DIRECTORY_SEPARATOR , self::$apiVersion ); if ($refresh === true || ! file_exists($path)) { self::log(sprintf("Refresh services definition on-demand for v%d API", self::$apiVersion)); $res = self::getInstance()->call('endpoints'); $res['_timestamp'] = time(); file_put_contents($path, serialize($res)); chmod($path, 0777); self::$services = $res; } else { self::$services = unserialize(file_get_contents($path)); // Check that content is not expired if (time() - self::$services['_timestamp'] > self::$ttl) { self::log(sprintf("Refresh outdated services definition for v%d API", self::$apiVersion)); self::initServices(true); } } }
[ "public", "static", "function", "initServices", "(", "$", "refresh", "=", "false", ")", "{", "// Define full definition file path", "$", "path", "=", "sprintf", "(", "'%s%sxac-services-v%d.conf'", ",", "!", "empty", "(", "self", "::", "$", "logPath", ")", "?", "self", "::", "$", "logPath", ":", "sys_get_temp_dir", "(", ")", ",", "DIRECTORY_SEPARATOR", ",", "self", "::", "$", "apiVersion", ")", ";", "if", "(", "$", "refresh", "===", "true", "||", "!", "file_exists", "(", "$", "path", ")", ")", "{", "self", "::", "log", "(", "sprintf", "(", "\"Refresh services definition on-demand for v%d API\"", ",", "self", "::", "$", "apiVersion", ")", ")", ";", "$", "res", "=", "self", "::", "getInstance", "(", ")", "->", "call", "(", "'endpoints'", ")", ";", "$", "res", "[", "'_timestamp'", "]", "=", "time", "(", ")", ";", "file_put_contents", "(", "$", "path", ",", "serialize", "(", "$", "res", ")", ")", ";", "chmod", "(", "$", "path", ",", "0777", ")", ";", "self", "::", "$", "services", "=", "$", "res", ";", "}", "else", "{", "self", "::", "$", "services", "=", "unserialize", "(", "file_get_contents", "(", "$", "path", ")", ")", ";", "// Check that content is not expired", "if", "(", "time", "(", ")", "-", "self", "::", "$", "services", "[", "'_timestamp'", "]", ">", "self", "::", "$", "ttl", ")", "{", "self", "::", "log", "(", "sprintf", "(", "\"Refresh outdated services definition for v%d API\"", ",", "self", "::", "$", "apiVersion", ")", ")", ";", "self", "::", "initServices", "(", "true", ")", ";", "}", "}", "}" ]
Retrieve definition of available API services @param boolean $refresh
[ "Retrieve", "definition", "of", "available", "API", "services" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L172-L196
22,196
ArrowSphere/Client
src/xAC.php
xAC.call
public function call($endpoint, $method = 'GET', array $data = []) { if (substr($endpoint, -1) == '/') { $endpoint = substr($endpoint, 0, strlen($endpoint)-1); } self::log("Calling $method /api/$endpoint"); $params = [ 'headers'=> [ 'Accept' => sprintf('application/vnd.xac.v%d+json', self::$apiVersion), 'AC-API-KEY' => self::$apiKey, ], ]; if (count($data) > 0) { $params['json'] = $data; } try { $this->initTransport(); $res = $this->transport->request($method, $endpoint, $params); } catch (ConnectException $e) { self::log($e->getMessage(), Logger::ERROR); throw new \Exception($e->getMessage()); } catch (ServerException $e) { $response = json_decode((string) $e->getResponse()->getBody(), true); self::$lastResponse = $response['ACResponse']; self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode(); self::log($e->getMessage(), Logger::ERROR); throw new \Exception(self::$lastResponse['message']); } catch (ClientException $e) { $response = json_decode((string) $e->getResponse()->getBody(), true); self::$lastResponse = $response['ACResponse']; self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode(); self::log($e->getMessage(), Logger::ERROR); throw new \Exception(self::$lastResponse['message']); } finally { if (isset($res)) { $response = json_decode((string) $res->getBody(), !self::$returnObject); $response = $response['ACResponse']; } } self::$lastResponse = $response; return $response['body']['data']; }
php
public function call($endpoint, $method = 'GET', array $data = []) { if (substr($endpoint, -1) == '/') { $endpoint = substr($endpoint, 0, strlen($endpoint)-1); } self::log("Calling $method /api/$endpoint"); $params = [ 'headers'=> [ 'Accept' => sprintf('application/vnd.xac.v%d+json', self::$apiVersion), 'AC-API-KEY' => self::$apiKey, ], ]; if (count($data) > 0) { $params['json'] = $data; } try { $this->initTransport(); $res = $this->transport->request($method, $endpoint, $params); } catch (ConnectException $e) { self::log($e->getMessage(), Logger::ERROR); throw new \Exception($e->getMessage()); } catch (ServerException $e) { $response = json_decode((string) $e->getResponse()->getBody(), true); self::$lastResponse = $response['ACResponse']; self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode(); self::log($e->getMessage(), Logger::ERROR); throw new \Exception(self::$lastResponse['message']); } catch (ClientException $e) { $response = json_decode((string) $e->getResponse()->getBody(), true); self::$lastResponse = $response['ACResponse']; self::$lastResponse['httpCode'] = $e->getResponse()->getStatusCode(); self::log($e->getMessage(), Logger::ERROR); throw new \Exception(self::$lastResponse['message']); } finally { if (isset($res)) { $response = json_decode((string) $res->getBody(), !self::$returnObject); $response = $response['ACResponse']; } } self::$lastResponse = $response; return $response['body']['data']; }
[ "public", "function", "call", "(", "$", "endpoint", ",", "$", "method", "=", "'GET'", ",", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "substr", "(", "$", "endpoint", ",", "-", "1", ")", "==", "'/'", ")", "{", "$", "endpoint", "=", "substr", "(", "$", "endpoint", ",", "0", ",", "strlen", "(", "$", "endpoint", ")", "-", "1", ")", ";", "}", "self", "::", "log", "(", "\"Calling $method /api/$endpoint\"", ")", ";", "$", "params", "=", "[", "'headers'", "=>", "[", "'Accept'", "=>", "sprintf", "(", "'application/vnd.xac.v%d+json'", ",", "self", "::", "$", "apiVersion", ")", ",", "'AC-API-KEY'", "=>", "self", "::", "$", "apiKey", ",", "]", ",", "]", ";", "if", "(", "count", "(", "$", "data", ")", ">", "0", ")", "{", "$", "params", "[", "'json'", "]", "=", "$", "data", ";", "}", "try", "{", "$", "this", "->", "initTransport", "(", ")", ";", "$", "res", "=", "$", "this", "->", "transport", "->", "request", "(", "$", "method", ",", "$", "endpoint", ",", "$", "params", ")", ";", "}", "catch", "(", "ConnectException", "$", "e", ")", "{", "self", "::", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "Logger", "::", "ERROR", ")", ";", "throw", "new", "\\", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "ServerException", "$", "e", ")", "{", "$", "response", "=", "json_decode", "(", "(", "string", ")", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "true", ")", ";", "self", "::", "$", "lastResponse", "=", "$", "response", "[", "'ACResponse'", "]", ";", "self", "::", "$", "lastResponse", "[", "'httpCode'", "]", "=", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ";", "self", "::", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "Logger", "::", "ERROR", ")", ";", "throw", "new", "\\", "Exception", "(", "self", "::", "$", "lastResponse", "[", "'message'", "]", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "$", "response", "=", "json_decode", "(", "(", "string", ")", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "true", ")", ";", "self", "::", "$", "lastResponse", "=", "$", "response", "[", "'ACResponse'", "]", ";", "self", "::", "$", "lastResponse", "[", "'httpCode'", "]", "=", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ";", "self", "::", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "Logger", "::", "ERROR", ")", ";", "throw", "new", "\\", "Exception", "(", "self", "::", "$", "lastResponse", "[", "'message'", "]", ")", ";", "}", "finally", "{", "if", "(", "isset", "(", "$", "res", ")", ")", "{", "$", "response", "=", "json_decode", "(", "(", "string", ")", "$", "res", "->", "getBody", "(", ")", ",", "!", "self", "::", "$", "returnObject", ")", ";", "$", "response", "=", "$", "response", "[", "'ACResponse'", "]", ";", "}", "}", "self", "::", "$", "lastResponse", "=", "$", "response", ";", "return", "$", "response", "[", "'body'", "]", "[", "'data'", "]", ";", "}" ]
Make a HTTP Request and return response @param string $endpoint @param string $method @param array $data @throws \Exception @return array
[ "Make", "a", "HTTP", "Request", "and", "return", "response" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L227-L278
22,197
ArrowSphere/Client
src/xAC.php
xAC.log
public static function log($message, $level = Logger::INFO) { if (! self::$logger) { $logfile = sprintf('%s%sarrowsphere-client.log', sys_get_temp_dir(), DIRECTORY_SEPARATOR); // create a log channel self::$logger = new Logger('xAC'); self::$logger->pushHandler(new StreamHandler($logfile, Logger::INFO)); } return self::$logger->addRecord($level, $message); }
php
public static function log($message, $level = Logger::INFO) { if (! self::$logger) { $logfile = sprintf('%s%sarrowsphere-client.log', sys_get_temp_dir(), DIRECTORY_SEPARATOR); // create a log channel self::$logger = new Logger('xAC'); self::$logger->pushHandler(new StreamHandler($logfile, Logger::INFO)); } return self::$logger->addRecord($level, $message); }
[ "public", "static", "function", "log", "(", "$", "message", ",", "$", "level", "=", "Logger", "::", "INFO", ")", "{", "if", "(", "!", "self", "::", "$", "logger", ")", "{", "$", "logfile", "=", "sprintf", "(", "'%s%sarrowsphere-client.log'", ",", "sys_get_temp_dir", "(", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "// create a log channel", "self", "::", "$", "logger", "=", "new", "Logger", "(", "'xAC'", ")", ";", "self", "::", "$", "logger", "->", "pushHandler", "(", "new", "StreamHandler", "(", "$", "logfile", ",", "Logger", "::", "INFO", ")", ")", ";", "}", "return", "self", "::", "$", "logger", "->", "addRecord", "(", "$", "level", ",", "$", "message", ")", ";", "}" ]
Log messages to client log file @param string $message @param integer $level @return boolean
[ "Log", "messages", "to", "client", "log", "file" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L295-L306
22,198
ArrowSphere/Client
src/xAC.php
xAC.getInstance
public static function getInstance(HttpClient $transport = null) { if (is_null(self::$client)) { self::$client = new self(); if (! is_null($transport)) { self::$client->setTransport($transport); } } return self::$client; }
php
public static function getInstance(HttpClient $transport = null) { if (is_null(self::$client)) { self::$client = new self(); if (! is_null($transport)) { self::$client->setTransport($transport); } } return self::$client; }
[ "public", "static", "function", "getInstance", "(", "HttpClient", "$", "transport", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "client", ")", ")", "{", "self", "::", "$", "client", "=", "new", "self", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "transport", ")", ")", "{", "self", "::", "$", "client", "->", "setTransport", "(", "$", "transport", ")", ";", "}", "}", "return", "self", "::", "$", "client", ";", "}" ]
Return a singleton instance of the class @param GuzzleHttp\Client $transport @return Arrowsphere\Client\xAC
[ "Return", "a", "singleton", "instance", "of", "the", "class" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L314-L325
22,199
ArrowSphere/Client
src/xAC.php
xAC.getServicesList
public static function getServicesList() { $map = [ 'GET' => 'get', 'POST' => 'create', 'PUT' => 'update', 'DELETE' => 'delete', ]; $table = new \Console_Table(); $table->setHeaders(['Method', 'Type', 'Description', 'Parameters']); foreach (self::getServices() as $key => $service) { if ($service['type'] == 'entity') { foreach ($service['actions'] as $action) { $table->addRow([ sprintf('xAC::%s()->%s()' , $service['endpoint'] , $action['endpoint'] == 'default' ? $map[$action['method']] : $action['endpoint'] ), 'entity/' . $action['type'], $action['description'] ]); } } else { $table->addRow(['xAC::' . $service['endpoint'] . '()->get()', $service['type'], $service['description']]); } } echo $table->getTable(); }
php
public static function getServicesList() { $map = [ 'GET' => 'get', 'POST' => 'create', 'PUT' => 'update', 'DELETE' => 'delete', ]; $table = new \Console_Table(); $table->setHeaders(['Method', 'Type', 'Description', 'Parameters']); foreach (self::getServices() as $key => $service) { if ($service['type'] == 'entity') { foreach ($service['actions'] as $action) { $table->addRow([ sprintf('xAC::%s()->%s()' , $service['endpoint'] , $action['endpoint'] == 'default' ? $map[$action['method']] : $action['endpoint'] ), 'entity/' . $action['type'], $action['description'] ]); } } else { $table->addRow(['xAC::' . $service['endpoint'] . '()->get()', $service['type'], $service['description']]); } } echo $table->getTable(); }
[ "public", "static", "function", "getServicesList", "(", ")", "{", "$", "map", "=", "[", "'GET'", "=>", "'get'", ",", "'POST'", "=>", "'create'", ",", "'PUT'", "=>", "'update'", ",", "'DELETE'", "=>", "'delete'", ",", "]", ";", "$", "table", "=", "new", "\\", "Console_Table", "(", ")", ";", "$", "table", "->", "setHeaders", "(", "[", "'Method'", ",", "'Type'", ",", "'Description'", ",", "'Parameters'", "]", ")", ";", "foreach", "(", "self", "::", "getServices", "(", ")", "as", "$", "key", "=>", "$", "service", ")", "{", "if", "(", "$", "service", "[", "'type'", "]", "==", "'entity'", ")", "{", "foreach", "(", "$", "service", "[", "'actions'", "]", "as", "$", "action", ")", "{", "$", "table", "->", "addRow", "(", "[", "sprintf", "(", "'xAC::%s()->%s()'", ",", "$", "service", "[", "'endpoint'", "]", ",", "$", "action", "[", "'endpoint'", "]", "==", "'default'", "?", "$", "map", "[", "$", "action", "[", "'method'", "]", "]", ":", "$", "action", "[", "'endpoint'", "]", ")", ",", "'entity/'", ".", "$", "action", "[", "'type'", "]", ",", "$", "action", "[", "'description'", "]", "]", ")", ";", "}", "}", "else", "{", "$", "table", "->", "addRow", "(", "[", "'xAC::'", ".", "$", "service", "[", "'endpoint'", "]", ".", "'()->get()'", ",", "$", "service", "[", "'type'", "]", ",", "$", "service", "[", "'description'", "]", "]", ")", ";", "}", "}", "echo", "$", "table", "->", "getTable", "(", ")", ";", "}" ]
Display a list of available service on console execute from the application folder: php -r "require 'vendor/autoload.php'; Arrowsphere\Client\xAC::getServicesList();"
[ "Display", "a", "list", "of", "available", "service", "on", "console" ]
6608f8257060375e7d3a27c485b23268b73f6ef7
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC.php#L352-L381