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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
tw88/sso
src/Broker.php
Broker.login
public function login($username = null, $password = null) { if (!isset($username) && isset($_POST['username'])) { $username = $_POST['username']; } if (!isset($password) && isset($_POST['password'])) { $password = $_POST['password']; } $result = $this->request('POST', 'login', compact('username', 'password')); $this->userinfo = $result; return $this->userinfo; }
php
public function login($username = null, $password = null) { if (!isset($username) && isset($_POST['username'])) { $username = $_POST['username']; } if (!isset($password) && isset($_POST['password'])) { $password = $_POST['password']; } $result = $this->request('POST', 'login', compact('username', 'password')); $this->userinfo = $result; return $this->userinfo; }
[ "public", "function", "login", "(", "$", "username", "=", "null", ",", "$", "password", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "username", ")", "&&", "isset", "(", "$", "_POST", "[", "'username'", "]", ")", ")", "{", "$", "username", "=", "$", "_POST", "[", "'username'", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "password", ")", "&&", "isset", "(", "$", "_POST", "[", "'password'", "]", ")", ")", "{", "$", "password", "=", "$", "_POST", "[", "'password'", "]", ";", "}", "$", "result", "=", "$", "this", "->", "request", "(", "'POST'", ",", "'login'", ",", "compact", "(", "'username'", ",", "'password'", ")", ")", ";", "$", "this", "->", "userinfo", "=", "$", "result", ";", "return", "$", "this", "->", "userinfo", ";", "}" ]
Log the client in at the SSO server. Only brokers marked trused can collect and send the user's credentials. Other brokers should omit $username and $password. @param string $username @param string $password @return array user info @throws Exception if login fails eg due to incorrect credentials
[ "Log", "the", "client", "in", "at", "the", "SSO", "server", "." ]
746323f3087af5a06769f7c207ab4ed5124a14bb
https://github.com/tw88/sso/blob/746323f3087af5a06769f7c207ab4ed5124a14bb/src/Broker.php#L283-L296
train
squareproton/Bond
src/Bond/Pg/QueryExceptionFactory.php
QueryExceptionFactory.get
public function get() { $class = null; // decide the most accurate exception we've got for this state and throw that if( $this->state ) { for( $i = 5; $i > 0; $i-- ) { $exceptionQueue[] = sprintf( "State%s", substr( $this->state, 0, $i ) ); } while( !$class and $_class = array_shift( $exceptionQueue ) ) { $file = __DIR__ . "/Exception/States/{$_class}.php"; if( file_exists($file) ) { $class = $_class; } } } // decide on class if( !$class ) { $class = 'Bond\Pg\Exception\QueryException'; } else { $class = 'Bond\Pg\Exception\States\\'. $class; } //die( $class ); return new $class( $this->sqlError, $this->state, self::getStateMessage($this->state), $this->sql ); }
php
public function get() { $class = null; // decide the most accurate exception we've got for this state and throw that if( $this->state ) { for( $i = 5; $i > 0; $i-- ) { $exceptionQueue[] = sprintf( "State%s", substr( $this->state, 0, $i ) ); } while( !$class and $_class = array_shift( $exceptionQueue ) ) { $file = __DIR__ . "/Exception/States/{$_class}.php"; if( file_exists($file) ) { $class = $_class; } } } // decide on class if( !$class ) { $class = 'Bond\Pg\Exception\QueryException'; } else { $class = 'Bond\Pg\Exception\States\\'. $class; } //die( $class ); return new $class( $this->sqlError, $this->state, self::getStateMessage($this->state), $this->sql ); }
[ "public", "function", "get", "(", ")", "{", "$", "class", "=", "null", ";", "// decide the most accurate exception we've got for this state and throw that", "if", "(", "$", "this", "->", "state", ")", "{", "for", "(", "$", "i", "=", "5", ";", "$", "i", ">", "0", ";", "$", "i", "--", ")", "{", "$", "exceptionQueue", "[", "]", "=", "sprintf", "(", "\"State%s\"", ",", "substr", "(", "$", "this", "->", "state", ",", "0", ",", "$", "i", ")", ")", ";", "}", "while", "(", "!", "$", "class", "and", "$", "_class", "=", "array_shift", "(", "$", "exceptionQueue", ")", ")", "{", "$", "file", "=", "__DIR__", ".", "\"/Exception/States/{$_class}.php\"", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "class", "=", "$", "_class", ";", "}", "}", "}", "// decide on class", "if", "(", "!", "$", "class", ")", "{", "$", "class", "=", "'Bond\\Pg\\Exception\\QueryException'", ";", "}", "else", "{", "$", "class", "=", "'Bond\\Pg\\Exception\\States\\\\'", ".", "$", "class", ";", "}", "//die( $class );", "return", "new", "$", "class", "(", "$", "this", "->", "sqlError", ",", "$", "this", "->", "state", ",", "self", "::", "getStateMessage", "(", "$", "this", "->", "state", ")", ",", "$", "this", "->", "sql", ")", ";", "}" ]
Get the actual exception @return Bond\Pg\Exception\QueryException
[ "Get", "the", "actual", "exception" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/QueryExceptionFactory.php#L328-L368
train
native5/native5-sdk-client-php
src/Native5/Control/ProtectedController.php
ProtectedController.execute
public function execute($request) { $logger = $GLOBALS['logger']; try { parent::execute($request); } catch(AuthenticationException $ex) { $logger->error('Unauthorized attempt to access resource, being redirected to home page', array($ex->getMessage())); $this->_handleUnauthenticatedAccess(); $this->_response->send(); } }
php
public function execute($request) { $logger = $GLOBALS['logger']; try { parent::execute($request); } catch(AuthenticationException $ex) { $logger->error('Unauthorized attempt to access resource, being redirected to home page', array($ex->getMessage())); $this->_handleUnauthenticatedAccess(); $this->_response->send(); } }
[ "public", "function", "execute", "(", "$", "request", ")", "{", "$", "logger", "=", "$", "GLOBALS", "[", "'logger'", "]", ";", "try", "{", "parent", "::", "execute", "(", "$", "request", ")", ";", "}", "catch", "(", "AuthenticationException", "$", "ex", ")", "{", "$", "logger", "->", "error", "(", "'Unauthorized attempt to access resource, being redirected to home page'", ",", "array", "(", "$", "ex", "->", "getMessage", "(", ")", ")", ")", ";", "$", "this", "->", "_handleUnauthenticatedAccess", "(", ")", ";", "$", "this", "->", "_response", "->", "send", "(", ")", ";", "}", "}" ]
Checks for secure routing, currently security is handled at a base route level, @param mixed $request Execute request. @access public @return void
[ "Checks", "for", "secure", "routing", "currently", "security", "is", "handled", "at", "a", "base", "route", "level" ]
e1f598cf27654d81bb5facace1990b737242a2f9
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Control/ProtectedController.php#L72-L83
train
native5/native5-sdk-client-php
src/Native5/Control/ProtectedController.php
ProtectedController._handleUnauthenticatedAccess
protected function _handleUnauthenticatedAccess() { header("HTTP/1.0 401 Unauthorized"); $renderer = new TwigRenderer(); $output = $renderer->render('unauth.tmpl', array()); $result = array("code"=>"401","message" => $output); echo parent::encodeData($result); exit; }
php
protected function _handleUnauthenticatedAccess() { header("HTTP/1.0 401 Unauthorized"); $renderer = new TwigRenderer(); $output = $renderer->render('unauth.tmpl', array()); $result = array("code"=>"401","message" => $output); echo parent::encodeData($result); exit; }
[ "protected", "function", "_handleUnauthenticatedAccess", "(", ")", "{", "header", "(", "\"HTTP/1.0 401 Unauthorized\"", ")", ";", "$", "renderer", "=", "new", "TwigRenderer", "(", ")", ";", "$", "output", "=", "$", "renderer", "->", "render", "(", "'unauth.tmpl'", ",", "array", "(", ")", ")", ";", "$", "result", "=", "array", "(", "\"code\"", "=>", "\"401\"", ",", "\"message\"", "=>", "$", "output", ")", ";", "echo", "parent", "::", "encodeData", "(", "$", "result", ")", ";", "exit", ";", "}" ]
Handle Unauthenticated access. @access protected @return void
[ "Handle", "Unauthenticated", "access", "." ]
e1f598cf27654d81bb5facace1990b737242a2f9
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/Control/ProtectedController.php#L106-L115
train
Kris-Kuiper/sFire-Framework
src/Routing/Extend/Redirect.php
Redirect.domain
public function domain($domain = null) { if(null !== $domain) { if(false === is_string($domain)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR); } //Check if identifier exists if(false === Router :: routeExists($this -> identifier, $domain)) { return trigger_error(sprintf('Identifier "%s" with domain "%s" does not exists', $this -> identifier, $domain), E_USER_ERROR); } $this -> domain = $domain; } return $this; }
php
public function domain($domain = null) { if(null !== $domain) { if(false === is_string($domain)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($domain)), E_USER_ERROR); } //Check if identifier exists if(false === Router :: routeExists($this -> identifier, $domain)) { return trigger_error(sprintf('Identifier "%s" with domain "%s" does not exists', $this -> identifier, $domain), E_USER_ERROR); } $this -> domain = $domain; } return $this; }
[ "public", "function", "domain", "(", "$", "domain", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "domain", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "domain", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "domain", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "//Check if identifier exists\r", "if", "(", "false", "===", "Router", "::", "routeExists", "(", "$", "this", "->", "identifier", ",", "$", "domain", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Identifier \"%s\" with domain \"%s\" does not exists'", ",", "$", "this", "->", "identifier", ",", "$", "domain", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "domain", "=", "$", "domain", ";", "}", "return", "$", "this", ";", "}" ]
Set the domain @param string $domain @return sFire\Routing\Redirect
[ "Set", "the", "domain" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Routing/Extend/Redirect.php#L77-L94
train
dann95/ts3-php
TeamSpeak3/Adapter/Update.php
Update.syn
public function syn() { if (!isset($this->options["host"]) || empty($this->options["host"])) { $this->options["host"] = $this->default_host; } if (!isset($this->options["port"]) || empty($this->options["port"])) { $this->options["port"] = $this->default_port; } $this->initTransport($this->options, "UDP"); $this->transport->setAdapter($this); Profiler::init(spl_object_hash($this)); $this->getTransport()->send(String::fromHex(33)); if (!preg_match_all( "/,?(\d+)#([0-9a-zA-Z\._-]+),?/", $this->getTransport()->read(96), $matches ) || !isset($matches[1]) || !isset($matches[2]) ) { throw new Ts3Exception("invalid reply from the server"); } $this->build_datetimes = $matches[1]; $this->version_strings = $matches[2]; Signal::getInstance()->emit("updateConnected", $this); }
php
public function syn() { if (!isset($this->options["host"]) || empty($this->options["host"])) { $this->options["host"] = $this->default_host; } if (!isset($this->options["port"]) || empty($this->options["port"])) { $this->options["port"] = $this->default_port; } $this->initTransport($this->options, "UDP"); $this->transport->setAdapter($this); Profiler::init(spl_object_hash($this)); $this->getTransport()->send(String::fromHex(33)); if (!preg_match_all( "/,?(\d+)#([0-9a-zA-Z\._-]+),?/", $this->getTransport()->read(96), $matches ) || !isset($matches[1]) || !isset($matches[2]) ) { throw new Ts3Exception("invalid reply from the server"); } $this->build_datetimes = $matches[1]; $this->version_strings = $matches[2]; Signal::getInstance()->emit("updateConnected", $this); }
[ "public", "function", "syn", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "\"host\"", "]", ")", "||", "empty", "(", "$", "this", "->", "options", "[", "\"host\"", "]", ")", ")", "{", "$", "this", "->", "options", "[", "\"host\"", "]", "=", "$", "this", "->", "default_host", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "\"port\"", "]", ")", "||", "empty", "(", "$", "this", "->", "options", "[", "\"port\"", "]", ")", ")", "{", "$", "this", "->", "options", "[", "\"port\"", "]", "=", "$", "this", "->", "default_port", ";", "}", "$", "this", "->", "initTransport", "(", "$", "this", "->", "options", ",", "\"UDP\"", ")", ";", "$", "this", "->", "transport", "->", "setAdapter", "(", "$", "this", ")", ";", "Profiler", "::", "init", "(", "spl_object_hash", "(", "$", "this", ")", ")", ";", "$", "this", "->", "getTransport", "(", ")", "->", "send", "(", "String", "::", "fromHex", "(", "33", ")", ")", ";", "if", "(", "!", "preg_match_all", "(", "\"/,?(\\d+)#([0-9a-zA-Z\\._-]+),?/\"", ",", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "96", ")", ",", "$", "matches", ")", "||", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", "||", "!", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "throw", "new", "Ts3Exception", "(", "\"invalid reply from the server\"", ")", ";", "}", "$", "this", "->", "build_datetimes", "=", "$", "matches", "[", "1", "]", ";", "$", "this", "->", "version_strings", "=", "$", "matches", "[", "2", "]", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"updateConnected\"", ",", "$", "this", ")", ";", "}" ]
Connects the AbstractTransport object and performs initial actions on the remote server. @throws Ts3Exception @return void
[ "Connects", "the", "AbstractTransport", "object", "and", "performs", "initial", "actions", "on", "the", "remote", "server", "." ]
d4693d78b54be0177a2b5fab316c0ff9d036238d
https://github.com/dann95/ts3-php/blob/d4693d78b54be0177a2b5fab316c0ff9d036238d/TeamSpeak3/Adapter/Update.php#L78-L107
train
t3v/t3v_datamapper
Classes/Command/PageLanguageOverlayCommandController.php
PageLanguageOverlayCommandController.listCommand
public function listCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '') { $this->beforeCommand(); $table = new ConsoleTable(); $table->setHeaders(['UID', 'Title', 'Page ID', 'Status']); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = StringUtility::asciify($languageOverlay->title); $status = $languageOverlay->hidden ? 'hidden' : 'visible'; $table->addRow([$uid, $title, $pageUid, $status]); } } $table->display(); }
php
public function listCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '') { $this->beforeCommand(); $table = new ConsoleTable(); $table->setHeaders(['UID', 'Title', 'Page ID', 'Status']); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = StringUtility::asciify($languageOverlay->title); $status = $languageOverlay->hidden ? 'hidden' : 'visible'; $table->addRow([$uid, $title, $pageUid, $status]); } } $table->display(); }
[ "public", "function", "listCommand", "(", "int", "$", "sysLanguageUid", ",", "int", "$", "pid", "=", "1", ",", "int", "$", "recursion", "=", "99", ",", "string", "$", "exclude", "=", "''", ")", "{", "$", "this", "->", "beforeCommand", "(", ")", ";", "$", "table", "=", "new", "ConsoleTable", "(", ")", ";", "$", "table", "->", "setHeaders", "(", "[", "'UID'", ",", "'Title'", ",", "'Page ID'", ",", "'Status'", "]", ")", ";", "foreach", "(", "$", "this", "->", "getPageUids", "(", "$", "pid", ",", "$", "recursion", ",", "$", "exclude", ")", "as", "$", "pageUid", ")", "{", "$", "languageOverlay", "=", "LanguageOverlay", "::", "where", "(", "[", "[", "'pid'", ",", "'='", ",", "$", "pageUid", "]", ",", "[", "'sys_language_uid'", ",", "'='", ",", "$", "sysLanguageUid", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "languageOverlay", ")", "{", "$", "uid", "=", "$", "languageOverlay", "->", "uid", ";", "$", "title", "=", "StringUtility", "::", "asciify", "(", "$", "languageOverlay", "->", "title", ")", ";", "$", "status", "=", "$", "languageOverlay", "->", "hidden", "?", "'hidden'", ":", "'visible'", ";", "$", "table", "->", "addRow", "(", "[", "$", "uid", ",", "$", "title", ",", "$", "pageUid", ",", "$", "status", "]", ")", ";", "}", "}", "$", "table", "->", "display", "(", ")", ";", "}" ]
Lists page language overlays. @param int $sysLanguageUid The system language UID of the page language overlays to list @param int $pid The optional PID of the page to search from, defaults to `1` @param int $recursion The optional recursion, defaults to `99` @param string $exclude The optional UIDs of pages to exclude from as string, seperated by `,`, empty by default
[ "Lists", "page", "language", "overlays", "." ]
bab2de90f467936fbe4270cd133cb4109d1108eb
https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Command/PageLanguageOverlayCommandController.php#L46-L65
train
t3v/t3v_datamapper
Classes/Command/PageLanguageOverlayCommandController.php
PageLanguageOverlayCommandController.initializeCommand
public function initializeCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '', bool $verbose = false) { $this->beforeCommand(); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = $languageOverlay->title; $this->log("Language overlay `{$title}` ({$uid}) for the page with UID {$pageUid} already exists, skipping...", 'warning', $verbose); } else { $page = Page::where([['uid', '=', $pageUid]])->first(); $languageOverlay = new LanguageOverlay; $languageOverlay->pid = $pageUid; $languageOverlay->sys_language_uid = $sysLanguageUid; $languageOverlay->doktype = $page->doktype; $languageOverlay->title = $page->title; $languageOverlay->nav_title = $page->nav_title; $languageOverlay->title = $page->title; $languageOverlay->keywords = $page->keywords; $languageOverlay->description = $page->description; $languageOverlay->abstract = $page->abstract; $languageOverlay->author = $page->author; $languageOverlay->author_email = $page->author_email; $languageOverlay->tx_t3vpage_summary = $page->tx_t3vpage_summary; $languageOverlay->tx_t3vpage_claim = $page->tx_t3vpage_claim; $languageOverlay->tx_t3vpage_outline = $page->tx_t3vpage_outline; $languageOverlay->save(); $this->log("New page language overlay for the page with UID {$pageUid} initialized.", 'ok', $verbose); } } }
php
public function initializeCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '', bool $verbose = false) { $this->beforeCommand(); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = $languageOverlay->title; $this->log("Language overlay `{$title}` ({$uid}) for the page with UID {$pageUid} already exists, skipping...", 'warning', $verbose); } else { $page = Page::where([['uid', '=', $pageUid]])->first(); $languageOverlay = new LanguageOverlay; $languageOverlay->pid = $pageUid; $languageOverlay->sys_language_uid = $sysLanguageUid; $languageOverlay->doktype = $page->doktype; $languageOverlay->title = $page->title; $languageOverlay->nav_title = $page->nav_title; $languageOverlay->title = $page->title; $languageOverlay->keywords = $page->keywords; $languageOverlay->description = $page->description; $languageOverlay->abstract = $page->abstract; $languageOverlay->author = $page->author; $languageOverlay->author_email = $page->author_email; $languageOverlay->tx_t3vpage_summary = $page->tx_t3vpage_summary; $languageOverlay->tx_t3vpage_claim = $page->tx_t3vpage_claim; $languageOverlay->tx_t3vpage_outline = $page->tx_t3vpage_outline; $languageOverlay->save(); $this->log("New page language overlay for the page with UID {$pageUid} initialized.", 'ok', $verbose); } } }
[ "public", "function", "initializeCommand", "(", "int", "$", "sysLanguageUid", ",", "int", "$", "pid", "=", "1", ",", "int", "$", "recursion", "=", "99", ",", "string", "$", "exclude", "=", "''", ",", "bool", "$", "verbose", "=", "false", ")", "{", "$", "this", "->", "beforeCommand", "(", ")", ";", "foreach", "(", "$", "this", "->", "getPageUids", "(", "$", "pid", ",", "$", "recursion", ",", "$", "exclude", ")", "as", "$", "pageUid", ")", "{", "$", "languageOverlay", "=", "LanguageOverlay", "::", "where", "(", "[", "[", "'pid'", ",", "'='", ",", "$", "pageUid", "]", ",", "[", "'sys_language_uid'", ",", "'='", ",", "$", "sysLanguageUid", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "languageOverlay", ")", "{", "$", "uid", "=", "$", "languageOverlay", "->", "uid", ";", "$", "title", "=", "$", "languageOverlay", "->", "title", ";", "$", "this", "->", "log", "(", "\"Language overlay `{$title}` ({$uid}) for the page with UID {$pageUid} already exists, skipping...\"", ",", "'warning'", ",", "$", "verbose", ")", ";", "}", "else", "{", "$", "page", "=", "Page", "::", "where", "(", "[", "[", "'uid'", ",", "'='", ",", "$", "pageUid", "]", "]", ")", "->", "first", "(", ")", ";", "$", "languageOverlay", "=", "new", "LanguageOverlay", ";", "$", "languageOverlay", "->", "pid", "=", "$", "pageUid", ";", "$", "languageOverlay", "->", "sys_language_uid", "=", "$", "sysLanguageUid", ";", "$", "languageOverlay", "->", "doktype", "=", "$", "page", "->", "doktype", ";", "$", "languageOverlay", "->", "title", "=", "$", "page", "->", "title", ";", "$", "languageOverlay", "->", "nav_title", "=", "$", "page", "->", "nav_title", ";", "$", "languageOverlay", "->", "title", "=", "$", "page", "->", "title", ";", "$", "languageOverlay", "->", "keywords", "=", "$", "page", "->", "keywords", ";", "$", "languageOverlay", "->", "description", "=", "$", "page", "->", "description", ";", "$", "languageOverlay", "->", "abstract", "=", "$", "page", "->", "abstract", ";", "$", "languageOverlay", "->", "author", "=", "$", "page", "->", "author", ";", "$", "languageOverlay", "->", "author_email", "=", "$", "page", "->", "author_email", ";", "$", "languageOverlay", "->", "tx_t3vpage_summary", "=", "$", "page", "->", "tx_t3vpage_summary", ";", "$", "languageOverlay", "->", "tx_t3vpage_claim", "=", "$", "page", "->", "tx_t3vpage_claim", ";", "$", "languageOverlay", "->", "tx_t3vpage_outline", "=", "$", "page", "->", "tx_t3vpage_outline", ";", "$", "languageOverlay", "->", "save", "(", ")", ";", "$", "this", "->", "log", "(", "\"New page language overlay for the page with UID {$pageUid} initialized.\"", ",", "'ok'", ",", "$", "verbose", ")", ";", "}", "}", "}" ]
Initializes page language overlays. @param int $sysLanguageUid The system language UID of the page language overlays to initialize @param int $pid The optional PID of the page to search from, defaults to `1` @param int $recursion The optional recursion, defaults to `99` @param string $exclude The optional UIDs of pages to exclude from as string, seperated by `,`, empty by default @param bool $verbose The optional verbosity, defaults to `false`
[ "Initializes", "page", "language", "overlays", "." ]
bab2de90f467936fbe4270cd133cb4109d1108eb
https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Command/PageLanguageOverlayCommandController.php#L76-L110
train
t3v/t3v_datamapper
Classes/Command/PageLanguageOverlayCommandController.php
PageLanguageOverlayCommandController.hideCommand
public function hideCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '', bool $verbose = false) { $this->beforeCommand(); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = $languageOverlay->title; $hidden = $languageOverlay->hidden; if (!$hidden) { $languageOverlay->hidden = true; $languageOverlay->save(); $this->log("Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is now hidden.", 'ok', $verbose); } else { $this->log("Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is already hidden, skipping...", 'warning', $verbose); } } } }
php
public function hideCommand(int $sysLanguageUid, int $pid = 1, int $recursion = 99, string $exclude = '', bool $verbose = false) { $this->beforeCommand(); foreach ($this->getPageUids($pid, $recursion, $exclude) as $pageUid) { $languageOverlay = LanguageOverlay::where([['pid', '=', $pageUid], ['sys_language_uid', '=', $sysLanguageUid]])->first(); if ($languageOverlay) { $uid = $languageOverlay->uid; $title = $languageOverlay->title; $hidden = $languageOverlay->hidden; if (!$hidden) { $languageOverlay->hidden = true; $languageOverlay->save(); $this->log("Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is now hidden.", 'ok', $verbose); } else { $this->log("Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is already hidden, skipping...", 'warning', $verbose); } } } }
[ "public", "function", "hideCommand", "(", "int", "$", "sysLanguageUid", ",", "int", "$", "pid", "=", "1", ",", "int", "$", "recursion", "=", "99", ",", "string", "$", "exclude", "=", "''", ",", "bool", "$", "verbose", "=", "false", ")", "{", "$", "this", "->", "beforeCommand", "(", ")", ";", "foreach", "(", "$", "this", "->", "getPageUids", "(", "$", "pid", ",", "$", "recursion", ",", "$", "exclude", ")", "as", "$", "pageUid", ")", "{", "$", "languageOverlay", "=", "LanguageOverlay", "::", "where", "(", "[", "[", "'pid'", ",", "'='", ",", "$", "pageUid", "]", ",", "[", "'sys_language_uid'", ",", "'='", ",", "$", "sysLanguageUid", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "languageOverlay", ")", "{", "$", "uid", "=", "$", "languageOverlay", "->", "uid", ";", "$", "title", "=", "$", "languageOverlay", "->", "title", ";", "$", "hidden", "=", "$", "languageOverlay", "->", "hidden", ";", "if", "(", "!", "$", "hidden", ")", "{", "$", "languageOverlay", "->", "hidden", "=", "true", ";", "$", "languageOverlay", "->", "save", "(", ")", ";", "$", "this", "->", "log", "(", "\"Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is now hidden.\"", ",", "'ok'", ",", "$", "verbose", ")", ";", "}", "else", "{", "$", "this", "->", "log", "(", "\"Language overlay `{$title}` ({$uid}) of the page with UID {$pageUid} is already hidden, skipping...\"", ",", "'warning'", ",", "$", "verbose", ")", ";", "}", "}", "}", "}" ]
Hides page language overlays. @param int $sysLanguageUid The system language UID of the page language overlays to hide @param int $pid The optional PID of the page to search from, defaults to `1` @param int $recursion The optional recursion, defaults to `99` @param string $exclude The optional UIDs of pages to exclude from as string, seperated by `,`, empty by default @param bool $verbose The optional verbosity, defaults to `false`
[ "Hides", "page", "language", "overlays", "." ]
bab2de90f467936fbe4270cd133cb4109d1108eb
https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Command/PageLanguageOverlayCommandController.php#L121-L142
train
t3v/t3v_datamapper
Classes/Command/PageLanguageOverlayCommandController.php
PageLanguageOverlayCommandController.getPageUids
protected function getPageUids(int $pid = 1, int $recursion = 99, string $exclude = '') { $exclude = $exclude === '-' ? '' : $exclude; $exclude = GeneralUtility::intExplode(',', $exclude, true); $pagesTreeList = $this->queryGenerator->getTreeList($pid, $recursion, 0, 1); $pageUids = GeneralUtility::intExplode(',', $pagesTreeList, true); $pageUids = array_diff($pageUids, $exclude); return $pageUids; }
php
protected function getPageUids(int $pid = 1, int $recursion = 99, string $exclude = '') { $exclude = $exclude === '-' ? '' : $exclude; $exclude = GeneralUtility::intExplode(',', $exclude, true); $pagesTreeList = $this->queryGenerator->getTreeList($pid, $recursion, 0, 1); $pageUids = GeneralUtility::intExplode(',', $pagesTreeList, true); $pageUids = array_diff($pageUids, $exclude); return $pageUids; }
[ "protected", "function", "getPageUids", "(", "int", "$", "pid", "=", "1", ",", "int", "$", "recursion", "=", "99", ",", "string", "$", "exclude", "=", "''", ")", "{", "$", "exclude", "=", "$", "exclude", "===", "'-'", "?", "''", ":", "$", "exclude", ";", "$", "exclude", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "exclude", ",", "true", ")", ";", "$", "pagesTreeList", "=", "$", "this", "->", "queryGenerator", "->", "getTreeList", "(", "$", "pid", ",", "$", "recursion", ",", "0", ",", "1", ")", ";", "$", "pageUids", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "pagesTreeList", ",", "true", ")", ";", "$", "pageUids", "=", "array_diff", "(", "$", "pageUids", ",", "$", "exclude", ")", ";", "return", "$", "pageUids", ";", "}" ]
Gets page UIDs. @param int $pid The optional PID of the page to search from, defaults to `1` @param int $recursion The optional recursion, defaults to `99` @param string $exclude The optional UIDs of pages to exclude from as string, seperated by `,`, empty by default
[ "Gets", "page", "UIDs", "." ]
bab2de90f467936fbe4270cd133cb4109d1108eb
https://github.com/t3v/t3v_datamapper/blob/bab2de90f467936fbe4270cd133cb4109d1108eb/Classes/Command/PageLanguageOverlayCommandController.php#L190-L198
train
JurJean/SpraySerializerBundle
src/DependencyInjection/CompilerPass/TaggedSerializerCompilerPass.php
TaggedSerializerCompilerPass.process
public function process(ContainerBuilder $container) { $registryDefinition = $container->getDefinition('spray_serializer.serializer_registry'); $tagged = $container->findTaggedServiceIds('spray_serializer'); foreach ($tagged as $id => $tags) { foreach ($tags as $attr) { $registryDefinition->addMethodCall('add', array( new Reference($id) )); } } }
php
public function process(ContainerBuilder $container) { $registryDefinition = $container->getDefinition('spray_serializer.serializer_registry'); $tagged = $container->findTaggedServiceIds('spray_serializer'); foreach ($tagged as $id => $tags) { foreach ($tags as $attr) { $registryDefinition->addMethodCall('add', array( new Reference($id) )); } } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "registryDefinition", "=", "$", "container", "->", "getDefinition", "(", "'spray_serializer.serializer_registry'", ")", ";", "$", "tagged", "=", "$", "container", "->", "findTaggedServiceIds", "(", "'spray_serializer'", ")", ";", "foreach", "(", "$", "tagged", "as", "$", "id", "=>", "$", "tags", ")", "{", "foreach", "(", "$", "tags", "as", "$", "attr", ")", "{", "$", "registryDefinition", "->", "addMethodCall", "(", "'add'", ",", "array", "(", "new", "Reference", "(", "$", "id", ")", ")", ")", ";", "}", "}", "}" ]
Find services tagged with "spray_serializer" and attach them to the serializer registry. @param ContainerBuilder $container @return void
[ "Find", "services", "tagged", "with", "spray_serializer", "and", "attach", "them", "to", "the", "serializer", "registry", "." ]
2b822f81bd7a49f120dbe6d75672908727fc40f9
https://github.com/JurJean/SpraySerializerBundle/blob/2b822f81bd7a49f120dbe6d75672908727fc40f9/src/DependencyInjection/CompilerPass/TaggedSerializerCompilerPass.php#L18-L30
train
Vectrex/vxPHP
src/Security/Csrf/CsrfTokenManager.php
CsrfTokenManager.getToken
public function getToken($tokenId) { if($this->storage->hasToken($tokenId)) { return $this->storage->getToken($tokenId); } $token = new CsrfToken( $tokenId, $this->generateValue((int) $this->tokenLength) ); $this->storage->setToken($tokenId, $token); return $token; }
php
public function getToken($tokenId) { if($this->storage->hasToken($tokenId)) { return $this->storage->getToken($tokenId); } $token = new CsrfToken( $tokenId, $this->generateValue((int) $this->tokenLength) ); $this->storage->setToken($tokenId, $token); return $token; }
[ "public", "function", "getToken", "(", "$", "tokenId", ")", "{", "if", "(", "$", "this", "->", "storage", "->", "hasToken", "(", "$", "tokenId", ")", ")", "{", "return", "$", "this", "->", "storage", "->", "getToken", "(", "$", "tokenId", ")", ";", "}", "$", "token", "=", "new", "CsrfToken", "(", "$", "tokenId", ",", "$", "this", "->", "generateValue", "(", "(", "int", ")", "$", "this", "->", "tokenLength", ")", ")", ";", "$", "this", "->", "storage", "->", "setToken", "(", "$", "tokenId", ",", "$", "token", ")", ";", "return", "$", "token", ";", "}" ]
returns a CSRF token for the given token id if previously no token existed for the given id, a new token is generated, stored and returned; otherwise the existing token is returned @param string $tokenId @return CsrfToken
[ "returns", "a", "CSRF", "token", "for", "the", "given", "token", "id" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Security/Csrf/CsrfTokenManager.php#L69-L83
train
Vectrex/vxPHP
src/Security/Csrf/CsrfTokenManager.php
CsrfTokenManager.refreshToken
public function refreshToken($tokenId) { $this->storage->removeToken($tokenId); $token = new CsrfToken( $tokenId, $this->generateValue((int) $this->tokenLength) ); $this->storage->setToken($tokenId, $token); return $token; }
php
public function refreshToken($tokenId) { $this->storage->removeToken($tokenId); $token = new CsrfToken( $tokenId, $this->generateValue((int) $this->tokenLength) ); $this->storage->setToken($tokenId, $token); return $token; }
[ "public", "function", "refreshToken", "(", "$", "tokenId", ")", "{", "$", "this", "->", "storage", "->", "removeToken", "(", "$", "tokenId", ")", ";", "$", "token", "=", "new", "CsrfToken", "(", "$", "tokenId", ",", "$", "this", "->", "generateValue", "(", "(", "int", ")", "$", "this", "->", "tokenLength", ")", ")", ";", "$", "this", "->", "storage", "->", "setToken", "(", "$", "tokenId", ",", "$", "token", ")", ";", "return", "$", "token", ";", "}" ]
generates a new token for the given id a new token will be generated, independent of whether a token value previously existed or not useful to enforce once-only tokens @param string $tokenId @return CsrfToken
[ "generates", "a", "new", "token", "for", "the", "given", "id", "a", "new", "token", "will", "be", "generated", "independent", "of", "whether", "a", "token", "value", "previously", "existed", "or", "not", "useful", "to", "enforce", "once", "-", "only", "tokens" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Security/Csrf/CsrfTokenManager.php#L94-L107
train
Vectrex/vxPHP
src/Security/Csrf/CsrfTokenManager.php
CsrfTokenManager.isTokenValid
public function isTokenValid(CsrfToken $token) { $tokenId = $token->getId(); if (!$this->storage->hasToken($tokenId)) { return FALSE; } return hash_equals($this->storage->getToken($tokenId)->getValue(), $token->getValue()); }
php
public function isTokenValid(CsrfToken $token) { $tokenId = $token->getId(); if (!$this->storage->hasToken($tokenId)) { return FALSE; } return hash_equals($this->storage->getToken($tokenId)->getValue(), $token->getValue()); }
[ "public", "function", "isTokenValid", "(", "CsrfToken", "$", "token", ")", "{", "$", "tokenId", "=", "$", "token", "->", "getId", "(", ")", ";", "if", "(", "!", "$", "this", "->", "storage", "->", "hasToken", "(", "$", "tokenId", ")", ")", "{", "return", "FALSE", ";", "}", "return", "hash_equals", "(", "$", "this", "->", "storage", "->", "getToken", "(", "$", "tokenId", ")", "->", "getValue", "(", ")", ",", "$", "token", "->", "getValue", "(", ")", ")", ";", "}" ]
check whether the given CSRF token is valid returns TRUE if the token is valid, FALSE otherwise @param CsrfToken $token @return bool
[ "check", "whether", "the", "given", "CSRF", "token", "is", "valid", "returns", "TRUE", "if", "the", "token", "is", "valid", "FALSE", "otherwise" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Security/Csrf/CsrfTokenManager.php#L130-L140
train
kkthek/diqa-util
src/Util/RequestUtils.php
RequestUtils.getSessionCookieForExportUser
public static function getSessionCookieForExportUser($user, $pass) { global $wgServerHTTP, $wgScriptPath, $wgODBTechnicalUser; $user = urlencode ( $user ); $pass = urlencode ( $pass ); // first: request a token $apiPath = "/api.php?action=login&format=json&lgname=$user&lgpassword=$pass"; $response = Http::post ( $wgServerHTTP . $wgScriptPath . $apiPath, array () ); $responseObj = json_decode ( $response ); if (isset ( $responseObj->login->result ) && $responseObj->login->result == 'NeedToken') { // second: re-send token and request the final sessionId $cookieprefix = $responseObj->login->cookieprefix; $sessionId = $responseObj->login->sessionid; $token = urlencode($responseObj->login->token); $response = static::post ( $wgServerHTTP . $wgScriptPath . $apiPath . "&lgtoken=$token", array (), array ( $cookieprefix . '_session' => $sessionId ) ); $responseObj = json_decode ( $response ); // check if login was successful if (isset ( $responseObj->login->result ) && $responseObj->login->result != 'Success') { throw new Exception ( "Could not login user $wgODBTechnicalUser" ); } $cookieprefix = $responseObj->login->cookieprefix; $sessionId = $responseObj->login->sessionid; $lguserid = $responseObj->login->lguserid; $lgusername = $responseObj->login->lgusername; return [ 'cookieprefix' => $cookieprefix, 'sessionId' => $sessionId, 'lguserid' => $lguserid, 'lgusername' => $lgusername ]; } throw new Exception( "Could not login user '$user'." ); }
php
public static function getSessionCookieForExportUser($user, $pass) { global $wgServerHTTP, $wgScriptPath, $wgODBTechnicalUser; $user = urlencode ( $user ); $pass = urlencode ( $pass ); // first: request a token $apiPath = "/api.php?action=login&format=json&lgname=$user&lgpassword=$pass"; $response = Http::post ( $wgServerHTTP . $wgScriptPath . $apiPath, array () ); $responseObj = json_decode ( $response ); if (isset ( $responseObj->login->result ) && $responseObj->login->result == 'NeedToken') { // second: re-send token and request the final sessionId $cookieprefix = $responseObj->login->cookieprefix; $sessionId = $responseObj->login->sessionid; $token = urlencode($responseObj->login->token); $response = static::post ( $wgServerHTTP . $wgScriptPath . $apiPath . "&lgtoken=$token", array (), array ( $cookieprefix . '_session' => $sessionId ) ); $responseObj = json_decode ( $response ); // check if login was successful if (isset ( $responseObj->login->result ) && $responseObj->login->result != 'Success') { throw new Exception ( "Could not login user $wgODBTechnicalUser" ); } $cookieprefix = $responseObj->login->cookieprefix; $sessionId = $responseObj->login->sessionid; $lguserid = $responseObj->login->lguserid; $lgusername = $responseObj->login->lgusername; return [ 'cookieprefix' => $cookieprefix, 'sessionId' => $sessionId, 'lguserid' => $lguserid, 'lgusername' => $lgusername ]; } throw new Exception( "Could not login user '$user'." ); }
[ "public", "static", "function", "getSessionCookieForExportUser", "(", "$", "user", ",", "$", "pass", ")", "{", "global", "$", "wgServerHTTP", ",", "$", "wgScriptPath", ",", "$", "wgODBTechnicalUser", ";", "$", "user", "=", "urlencode", "(", "$", "user", ")", ";", "$", "pass", "=", "urlencode", "(", "$", "pass", ")", ";", "// first: request a token", "$", "apiPath", "=", "\"/api.php?action=login&format=json&lgname=$user&lgpassword=$pass\"", ";", "$", "response", "=", "Http", "::", "post", "(", "$", "wgServerHTTP", ".", "$", "wgScriptPath", ".", "$", "apiPath", ",", "array", "(", ")", ")", ";", "$", "responseObj", "=", "json_decode", "(", "$", "response", ")", ";", "if", "(", "isset", "(", "$", "responseObj", "->", "login", "->", "result", ")", "&&", "$", "responseObj", "->", "login", "->", "result", "==", "'NeedToken'", ")", "{", "// second: re-send token and request the final sessionId", "$", "cookieprefix", "=", "$", "responseObj", "->", "login", "->", "cookieprefix", ";", "$", "sessionId", "=", "$", "responseObj", "->", "login", "->", "sessionid", ";", "$", "token", "=", "urlencode", "(", "$", "responseObj", "->", "login", "->", "token", ")", ";", "$", "response", "=", "static", "::", "post", "(", "$", "wgServerHTTP", ".", "$", "wgScriptPath", ".", "$", "apiPath", ".", "\"&lgtoken=$token\"", ",", "array", "(", ")", ",", "array", "(", "$", "cookieprefix", ".", "'_session'", "=>", "$", "sessionId", ")", ")", ";", "$", "responseObj", "=", "json_decode", "(", "$", "response", ")", ";", "// check if login was successful", "if", "(", "isset", "(", "$", "responseObj", "->", "login", "->", "result", ")", "&&", "$", "responseObj", "->", "login", "->", "result", "!=", "'Success'", ")", "{", "throw", "new", "Exception", "(", "\"Could not login user $wgODBTechnicalUser\"", ")", ";", "}", "$", "cookieprefix", "=", "$", "responseObj", "->", "login", "->", "cookieprefix", ";", "$", "sessionId", "=", "$", "responseObj", "->", "login", "->", "sessionid", ";", "$", "lguserid", "=", "$", "responseObj", "->", "login", "->", "lguserid", ";", "$", "lgusername", "=", "$", "responseObj", "->", "login", "->", "lgusername", ";", "return", "[", "'cookieprefix'", "=>", "$", "cookieprefix", ",", "'sessionId'", "=>", "$", "sessionId", ",", "'lguserid'", "=>", "$", "lguserid", ",", "'lgusername'", "=>", "$", "lgusername", "]", ";", "}", "throw", "new", "Exception", "(", "\"Could not login user '$user'.\"", ")", ";", "}" ]
Requests a session cookie for a user. @param string $user @param string $pass @throws \Exception @return [ 'cookieprefix' => ... , 'sessionId' => ... ]
[ "Requests", "a", "session", "cookie", "for", "a", "user", "." ]
df35d16403b5dbf0f7570daded6cfa26814ae7e0
https://github.com/kkthek/diqa-util/blob/df35d16403b5dbf0f7570daded6cfa26814ae7e0/src/Util/RequestUtils.php#L25-L65
train
geoffadams/bedrest-events
library/BedRest/Events/EventManager.php
EventManager.addClassListeners
public function addClassListeners($instance) { if (!$this->driver) { throw Exception::noDriver(); } foreach ($this->driver->getListenersForClass($instance) as $listener) { $this->addListener($listener['event'], array($instance, $listener['method'])); } }
php
public function addClassListeners($instance) { if (!$this->driver) { throw Exception::noDriver(); } foreach ($this->driver->getListenersForClass($instance) as $listener) { $this->addListener($listener['event'], array($instance, $listener['method'])); } }
[ "public", "function", "addClassListeners", "(", "$", "instance", ")", "{", "if", "(", "!", "$", "this", "->", "driver", ")", "{", "throw", "Exception", "::", "noDriver", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "driver", "->", "getListenersForClass", "(", "$", "instance", ")", "as", "$", "listener", ")", "{", "$", "this", "->", "addListener", "(", "$", "listener", "[", "'event'", "]", ",", "array", "(", "$", "instance", ",", "$", "listener", "[", "'method'", "]", ")", ")", ";", "}", "}" ]
Automatically maps event listeners associated with a class using the driver provided to this instance and registers them. @param object $instance @throws \BedRest\Events\MappingException
[ "Automatically", "maps", "event", "listeners", "associated", "with", "a", "class", "using", "the", "driver", "provided", "to", "this", "instance", "and", "registers", "them", "." ]
470f7b5358b80e3c69e8337670e8d347d4e3dbff
https://github.com/geoffadams/bedrest-events/blob/470f7b5358b80e3c69e8337670e8d347d4e3dbff/library/BedRest/Events/EventManager.php#L62-L71
train
geoffadams/bedrest-events
library/BedRest/Events/EventManager.php
EventManager.addListeners
public function addListeners($event, $listeners) { foreach ($listeners as $listener) { $this->addListener($event, $listener); } }
php
public function addListeners($event, $listeners) { foreach ($listeners as $listener) { $this->addListener($event, $listener); } }
[ "public", "function", "addListeners", "(", "$", "event", ",", "$", "listeners", ")", "{", "foreach", "(", "$", "listeners", "as", "$", "listener", ")", "{", "$", "this", "->", "addListener", "(", "$", "event", ",", "$", "listener", ")", ";", "}", "}" ]
Adds a set of listeners. @param string $event @param callable $listeners
[ "Adds", "a", "set", "of", "listeners", "." ]
470f7b5358b80e3c69e8337670e8d347d4e3dbff
https://github.com/geoffadams/bedrest-events/blob/470f7b5358b80e3c69e8337670e8d347d4e3dbff/library/BedRest/Events/EventManager.php#L94-L99
train
geoffadams/bedrest-events
library/BedRest/Events/EventManager.php
EventManager.getListeners
public function getListeners($event) { if (!isset($this->listeners[$event]) || !is_array($this->listeners[$event])) { return array(); } return $this->listeners[$event]; }
php
public function getListeners($event) { if (!isset($this->listeners[$event]) || !is_array($this->listeners[$event])) { return array(); } return $this->listeners[$event]; }
[ "public", "function", "getListeners", "(", "$", "event", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "$", "this", "->", "listeners", "[", "$", "event", "]", ";", "}" ]
Retrieves all listeners for an event. @param string $event @return array
[ "Retrieves", "all", "listeners", "for", "an", "event", "." ]
470f7b5358b80e3c69e8337670e8d347d4e3dbff
https://github.com/geoffadams/bedrest-events/blob/470f7b5358b80e3c69e8337670e8d347d4e3dbff/library/BedRest/Events/EventManager.php#L107-L114
train
geoffadams/bedrest-events
library/BedRest/Events/EventManager.php
EventManager.dispatch
public function dispatch($event, Event $eventObject) { if (!isset($this->listeners[$event])) { return; } foreach ($this->listeners[$event] as $listener) { call_user_func_array($listener, array($eventObject)); if ($eventObject->propagationHalted()) { break; } } }
php
public function dispatch($event, Event $eventObject) { if (!isset($this->listeners[$event])) { return; } foreach ($this->listeners[$event] as $listener) { call_user_func_array($listener, array($eventObject)); if ($eventObject->propagationHalted()) { break; } } }
[ "public", "function", "dispatch", "(", "$", "event", ",", "Event", "$", "eventObject", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", "as", "$", "listener", ")", "{", "call_user_func_array", "(", "$", "listener", ",", "array", "(", "$", "eventObject", ")", ")", ";", "if", "(", "$", "eventObject", "->", "propagationHalted", "(", ")", ")", "{", "break", ";", "}", "}", "}" ]
Dispatches an event to all listeners. @param string $event @param \BedRest\Events\Event $eventObject
[ "Dispatches", "an", "event", "to", "all", "listeners", "." ]
470f7b5358b80e3c69e8337670e8d347d4e3dbff
https://github.com/geoffadams/bedrest-events/blob/470f7b5358b80e3c69e8337670e8d347d4e3dbff/library/BedRest/Events/EventManager.php#L122-L135
train
agentmedia/phine-core
src/Core/Logic/Module/TemplateModule.php
TemplateModule.BuiltInTemplateFile
protected final function BuiltInTemplateFile() { $class = new \ReflectionClass($this); $classFile = Str::Replace('\\', '/', $class->getFileName()); $templatePath = Str::Replace('/Modules/', '/Templates/', $classFile); return Path::AddExtension($templatePath, 'phtml', true); }
php
protected final function BuiltInTemplateFile() { $class = new \ReflectionClass($this); $classFile = Str::Replace('\\', '/', $class->getFileName()); $templatePath = Str::Replace('/Modules/', '/Templates/', $classFile); return Path::AddExtension($templatePath, 'phtml', true); }
[ "protected", "final", "function", "BuiltInTemplateFile", "(", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "classFile", "=", "Str", "::", "Replace", "(", "'\\\\'", ",", "'/'", ",", "$", "class", "->", "getFileName", "(", ")", ")", ";", "$", "templatePath", "=", "Str", "::", "Replace", "(", "'/Modules/'", ",", "'/Templates/'", ",", "$", "classFile", ")", ";", "return", "Path", "::", "AddExtension", "(", "$", "templatePath", ",", "'phtml'", ",", "true", ")", ";", "}" ]
Returns the template file that comes with the bundle module @return string
[ "Returns", "the", "template", "file", "that", "comes", "with", "the", "bundle", "module" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/TemplateModule.php#L30-L36
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.up
public function up ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0], $this->_currentPosition[1] - $count, ); return $this; }
php
public function up ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0], $this->_currentPosition[1] - $count, ); return $this; }
[ "public", "function", "up", "(", "$", "count", "=", "0", ")", "{", "$", "this", "->", "_currentPosition", "=", "array", "(", "$", "this", "->", "_currentPosition", "[", "0", "]", ",", "$", "this", "->", "_currentPosition", "[", "1", "]", "-", "$", "count", ",", ")", ";", "return", "$", "this", ";", "}" ]
Move up current position @param int $count Move count @return CursorObject Self instance
[ "Move", "up", "current", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L56-L62
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.down
public function down ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0], $this->_currentPosition[1] + $count, ); return $this; }
php
public function down ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0], $this->_currentPosition[1] + $count, ); return $this; }
[ "public", "function", "down", "(", "$", "count", "=", "0", ")", "{", "$", "this", "->", "_currentPosition", "=", "array", "(", "$", "this", "->", "_currentPosition", "[", "0", "]", ",", "$", "this", "->", "_currentPosition", "[", "1", "]", "+", "$", "count", ",", ")", ";", "return", "$", "this", ";", "}" ]
Move down current position @param int $count Move count @return CursorObject Self instance
[ "Move", "down", "current", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L70-L76
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.left
public function left ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0] - $count, $this->_currentPosition[1], ); return $this; }
php
public function left ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0] - $count, $this->_currentPosition[1], ); return $this; }
[ "public", "function", "left", "(", "$", "count", "=", "0", ")", "{", "$", "this", "->", "_currentPosition", "=", "array", "(", "$", "this", "->", "_currentPosition", "[", "0", "]", "-", "$", "count", ",", "$", "this", "->", "_currentPosition", "[", "1", "]", ",", ")", ";", "return", "$", "this", ";", "}" ]
Move left current position @param int $count Move count @return CursorObject Self instance
[ "Move", "left", "current", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L84-L90
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.right
public function right ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0] + $count, $this->_currentPosition[1], ); return $this; }
php
public function right ( $count = 0 ) { $this->_currentPosition = array( $this->_currentPosition[0] + $count, $this->_currentPosition[1], ); return $this; }
[ "public", "function", "right", "(", "$", "count", "=", "0", ")", "{", "$", "this", "->", "_currentPosition", "=", "array", "(", "$", "this", "->", "_currentPosition", "[", "0", "]", "+", "$", "count", ",", "$", "this", "->", "_currentPosition", "[", "1", "]", ",", ")", ";", "return", "$", "this", ";", "}" ]
Move right current position @param int $count Move count @return CursorObject Self instance
[ "Move", "right", "current", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L98-L104
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.move
public function move ( $dx, $dy ) { if ( $dx < 0 ) { $this->left(abs($dx)); } else { $this->right(abs($dx)); } if ( $dy < 0 ) { $this->up(abs($dy)); } else { $this->down(abs($dy)); } return $this; }
php
public function move ( $dx, $dy ) { if ( $dx < 0 ) { $this->left(abs($dx)); } else { $this->right(abs($dx)); } if ( $dy < 0 ) { $this->up(abs($dy)); } else { $this->down(abs($dy)); } return $this; }
[ "public", "function", "move", "(", "$", "dx", ",", "$", "dy", ")", "{", "if", "(", "$", "dx", "<", "0", ")", "{", "$", "this", "->", "left", "(", "abs", "(", "$", "dx", ")", ")", ";", "}", "else", "{", "$", "this", "->", "right", "(", "abs", "(", "$", "dx", ")", ")", ";", "}", "if", "(", "$", "dy", "<", "0", ")", "{", "$", "this", "->", "up", "(", "abs", "(", "$", "dy", ")", ")", ";", "}", "else", "{", "$", "this", "->", "down", "(", "abs", "(", "$", "dy", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Move current position @param int $dx Horizontal displacement @param int $dy Vertical displacement @return CursorObject Self instance
[ "Move", "current", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L113-L125
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.setAncor
public function setAncor ( $position = null ) { if ( is_null($position) === true ) { $position = $this->_currentPosition; } $this->_ancorPosition = $position; return $this; }
php
public function setAncor ( $position = null ) { if ( is_null($position) === true ) { $position = $this->_currentPosition; } $this->_ancorPosition = $position; return $this; }
[ "public", "function", "setAncor", "(", "$", "position", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "position", ")", "===", "true", ")", "{", "$", "position", "=", "$", "this", "->", "_currentPosition", ";", "}", "$", "this", "->", "_ancorPosition", "=", "$", "position", ";", "return", "$", "this", ";", "}" ]
Set ancor position @param array $position (x, y) @return CursorObject Self instance
[ "Set", "ancor", "position" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L154-L160
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.getEscapeSequencesByPath
public function getEscapeSequencesByPath ( $dx = null, $dy = null ) { if ( is_null($dx) === true ) { $dx = $this->_currentPosition[0] - $this->_ancorPosition[0]; } if ( is_null($dy) === true ) { $dy = $this->_currentPosition[1] - $this->_ancorPosition[1]; } return self::getMovingEscapeSequences($dx, $dy); }
php
public function getEscapeSequencesByPath ( $dx = null, $dy = null ) { if ( is_null($dx) === true ) { $dx = $this->_currentPosition[0] - $this->_ancorPosition[0]; } if ( is_null($dy) === true ) { $dy = $this->_currentPosition[1] - $this->_ancorPosition[1]; } return self::getMovingEscapeSequences($dx, $dy); }
[ "public", "function", "getEscapeSequencesByPath", "(", "$", "dx", "=", "null", ",", "$", "dy", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "dx", ")", "===", "true", ")", "{", "$", "dx", "=", "$", "this", "->", "_currentPosition", "[", "0", "]", "-", "$", "this", "->", "_ancorPosition", "[", "0", "]", ";", "}", "if", "(", "is_null", "(", "$", "dy", ")", "===", "true", ")", "{", "$", "dy", "=", "$", "this", "->", "_currentPosition", "[", "1", "]", "-", "$", "this", "->", "_ancorPosition", "[", "1", "]", ";", "}", "return", "self", "::", "getMovingEscapeSequences", "(", "$", "dx", ",", "$", "dy", ")", ";", "}" ]
Get escape sequences by path @param int $dx Horizontal displacement @param int $dy Vertical displacement @return string Escape sequences
[ "Get", "escape", "sequences", "by", "path" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L169-L177
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/CuiUtility/CursorObject.php
CursorObject.getMovingEscapeSequences
public static function getMovingEscapeSequences ( $dx, $dy ) { $escapeSequences = ''; if ( $dy < 0 ) { $escapeSequences .= self::getUpEscapeSequence(abs($dy)); } else if ( $dy > 0 ) { $escapeSequences .= self::getDownEscapeSequence(abs($dy)); } if ( $dx < 0 ) { $escapeSequences .= self::getLeftEscapeSequence(abs($dx)); } else if ( $dx > 0 ) { $escapeSequences .= self::getRightEscapeSequece(abs($dx)); } return $escapeSequences; }
php
public static function getMovingEscapeSequences ( $dx, $dy ) { $escapeSequences = ''; if ( $dy < 0 ) { $escapeSequences .= self::getUpEscapeSequence(abs($dy)); } else if ( $dy > 0 ) { $escapeSequences .= self::getDownEscapeSequence(abs($dy)); } if ( $dx < 0 ) { $escapeSequences .= self::getLeftEscapeSequence(abs($dx)); } else if ( $dx > 0 ) { $escapeSequences .= self::getRightEscapeSequece(abs($dx)); } return $escapeSequences; }
[ "public", "static", "function", "getMovingEscapeSequences", "(", "$", "dx", ",", "$", "dy", ")", "{", "$", "escapeSequences", "=", "''", ";", "if", "(", "$", "dy", "<", "0", ")", "{", "$", "escapeSequences", ".=", "self", "::", "getUpEscapeSequence", "(", "abs", "(", "$", "dy", ")", ")", ";", "}", "else", "if", "(", "$", "dy", ">", "0", ")", "{", "$", "escapeSequences", ".=", "self", "::", "getDownEscapeSequence", "(", "abs", "(", "$", "dy", ")", ")", ";", "}", "if", "(", "$", "dx", "<", "0", ")", "{", "$", "escapeSequences", ".=", "self", "::", "getLeftEscapeSequence", "(", "abs", "(", "$", "dx", ")", ")", ";", "}", "else", "if", "(", "$", "dx", ">", "0", ")", "{", "$", "escapeSequences", ".=", "self", "::", "getRightEscapeSequece", "(", "abs", "(", "$", "dx", ")", ")", ";", "}", "return", "$", "escapeSequences", ";", "}" ]
Get moving escape sequences @param int $dx @param int $dy @return string Moving escape sequences
[ "Get", "moving", "escape", "sequences" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/CuiUtility/CursorObject.php#L186-L199
train
PenoaksDev/Milky-Framework
src/Milky/Queue/Console/RetryCommand.php
RetryCommand.retryJob
protected function retryJob($id) { $failed = $this->laravel['queue.failer']->find($id); if (! is_null($failed)) { $failed = (object) $failed; $failed->payload = $this->resetAttempts($failed->payload); $this->laravel['queue']->connection($failed->connection) ->pushRaw($failed->payload, $failed->queue); $this->laravel['queue.failer']->forget($failed->id); $this->info("The failed job [{$id}] has been pushed back onto the queue!"); } else { $this->error("No failed job matches the given ID [{$id}]."); } }
php
protected function retryJob($id) { $failed = $this->laravel['queue.failer']->find($id); if (! is_null($failed)) { $failed = (object) $failed; $failed->payload = $this->resetAttempts($failed->payload); $this->laravel['queue']->connection($failed->connection) ->pushRaw($failed->payload, $failed->queue); $this->laravel['queue.failer']->forget($failed->id); $this->info("The failed job [{$id}] has been pushed back onto the queue!"); } else { $this->error("No failed job matches the given ID [{$id}]."); } }
[ "protected", "function", "retryJob", "(", "$", "id", ")", "{", "$", "failed", "=", "$", "this", "->", "laravel", "[", "'queue.failer'", "]", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "is_null", "(", "$", "failed", ")", ")", "{", "$", "failed", "=", "(", "object", ")", "$", "failed", ";", "$", "failed", "->", "payload", "=", "$", "this", "->", "resetAttempts", "(", "$", "failed", "->", "payload", ")", ";", "$", "this", "->", "laravel", "[", "'queue'", "]", "->", "connection", "(", "$", "failed", "->", "connection", ")", "->", "pushRaw", "(", "$", "failed", "->", "payload", ",", "$", "failed", "->", "queue", ")", ";", "$", "this", "->", "laravel", "[", "'queue.failer'", "]", "->", "forget", "(", "$", "failed", "->", "id", ")", ";", "$", "this", "->", "info", "(", "\"The failed job [{$id}] has been pushed back onto the queue!\"", ")", ";", "}", "else", "{", "$", "this", "->", "error", "(", "\"No failed job matches the given ID [{$id}].\"", ")", ";", "}", "}" ]
Retry the queue job with the given ID. @param string $id @return void
[ "Retry", "the", "queue", "job", "with", "the", "given", "ID", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Queue/Console/RetryCommand.php#L47-L65
train
PenoaksDev/Milky-Framework
src/Milky/Queue/Console/RetryCommand.php
RetryCommand.resetAttempts
protected function resetAttempts($payload) { $payload = json_decode($payload, true); if (isset($payload['attempts'])) { $payload['attempts'] = 1; } return json_encode($payload); }
php
protected function resetAttempts($payload) { $payload = json_decode($payload, true); if (isset($payload['attempts'])) { $payload['attempts'] = 1; } return json_encode($payload); }
[ "protected", "function", "resetAttempts", "(", "$", "payload", ")", "{", "$", "payload", "=", "json_decode", "(", "$", "payload", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "payload", "[", "'attempts'", "]", ")", ")", "{", "$", "payload", "[", "'attempts'", "]", "=", "1", ";", "}", "return", "json_encode", "(", "$", "payload", ")", ";", "}" ]
Reset the payload attempts. @param string $payload @return string
[ "Reset", "the", "payload", "attempts", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Queue/Console/RetryCommand.php#L73-L82
train
hiqdev/minii-validators
src/Validator.php
Validator.validate
public function validate($value, &$error = null) { $result = $this->validateValue($value); if (empty($result)) { return true; } list($message, $params) = $result; $params['attribute'] = Yii::t('yii', 'the input value'); $params['value'] = is_array($value) ? 'array()' : $value; $error = Yii::$app->getI18n()->format($message, $params, Yii::$app->language); return false; }
php
public function validate($value, &$error = null) { $result = $this->validateValue($value); if (empty($result)) { return true; } list($message, $params) = $result; $params['attribute'] = Yii::t('yii', 'the input value'); $params['value'] = is_array($value) ? 'array()' : $value; $error = Yii::$app->getI18n()->format($message, $params, Yii::$app->language); return false; }
[ "public", "function", "validate", "(", "$", "value", ",", "&", "$", "error", "=", "null", ")", "{", "$", "result", "=", "$", "this", "->", "validateValue", "(", "$", "value", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "return", "true", ";", "}", "list", "(", "$", "message", ",", "$", "params", ")", "=", "$", "result", ";", "$", "params", "[", "'attribute'", "]", "=", "Yii", "::", "t", "(", "'yii'", ",", "'the input value'", ")", ";", "$", "params", "[", "'value'", "]", "=", "is_array", "(", "$", "value", ")", "?", "'array()'", ":", "$", "value", ";", "$", "error", "=", "Yii", "::", "$", "app", "->", "getI18n", "(", ")", "->", "format", "(", "$", "message", ",", "$", "params", ",", "Yii", "::", "$", "app", "->", "language", ")", ";", "return", "false", ";", "}" ]
Validates a given value. You may use this method to validate a value out of the context of a data model. @param mixed $value the data value to be validated. @param string $error the error message to be returned, if the validation fails. @return boolean whether the data is valid.
[ "Validates", "a", "given", "value", ".", "You", "may", "use", "this", "method", "to", "validate", "a", "value", "out", "of", "the", "context", "of", "a", "data", "model", "." ]
3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741
https://github.com/hiqdev/minii-validators/blob/3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741/src/Validator.php#L270-L283
train
hiqdev/minii-validators
src/Validator.php
Validator.addError
public function addError($model, $attribute, $message, $params = []) { $value = $model->$attribute; $params['attribute'] = $model->getAttributeLabel($attribute); $params['value'] = is_array($value) ? 'array()' : $value; $model->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language)); }
php
public function addError($model, $attribute, $message, $params = []) { $value = $model->$attribute; $params['attribute'] = $model->getAttributeLabel($attribute); $params['value'] = is_array($value) ? 'array()' : $value; $model->addError($attribute, Yii::$app->getI18n()->format($message, $params, Yii::$app->language)); }
[ "public", "function", "addError", "(", "$", "model", ",", "$", "attribute", ",", "$", "message", ",", "$", "params", "=", "[", "]", ")", "{", "$", "value", "=", "$", "model", "->", "$", "attribute", ";", "$", "params", "[", "'attribute'", "]", "=", "$", "model", "->", "getAttributeLabel", "(", "$", "attribute", ")", ";", "$", "params", "[", "'value'", "]", "=", "is_array", "(", "$", "value", ")", "?", "'array()'", ":", "$", "value", ";", "$", "model", "->", "addError", "(", "$", "attribute", ",", "Yii", "::", "$", "app", "->", "getI18n", "(", ")", "->", "format", "(", "$", "message", ",", "$", "params", ",", "Yii", "::", "$", "app", "->", "language", ")", ")", ";", "}" ]
Adds an error about the specified attribute to the model object. This is a helper method that performs message selection and internationalization. @param \yii\base\Model $model the data model being validated @param string $attribute the attribute being validated @param string $message the error message @param array $params values for the placeholders in the error message
[ "Adds", "an", "error", "about", "the", "specified", "attribute", "to", "the", "model", "object", ".", "This", "is", "a", "helper", "method", "that", "performs", "message", "selection", "and", "internationalization", "." ]
3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741
https://github.com/hiqdev/minii-validators/blob/3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741/src/Validator.php#L357-L363
train
WesamMikhail/Utils
src/Explorer.php
Explorer.getAllFiles
public static function getAllFiles($dir, $subdir = false) { $path = ''; $stack[] = $dir; while ($stack) { $thisdir = array_pop($stack); if ($dircont = scandir($thisdir)) { $i = 0; while (isset($dircont[$i])) { if ($dircont[$i] !== '.' && $dircont[$i] !== '..') { $current_file = "{$thisdir}/{$dircont[$i]}"; if (is_file($current_file)) { $path[] = "{$thisdir}/{$dircont[$i]}"; } elseif (is_dir($current_file)) { $path[] = "{$thisdir}/{$dircont[$i]}/"; if ($subdir === true) $stack[] = $current_file; } } $i++; } } } return $path; }
php
public static function getAllFiles($dir, $subdir = false) { $path = ''; $stack[] = $dir; while ($stack) { $thisdir = array_pop($stack); if ($dircont = scandir($thisdir)) { $i = 0; while (isset($dircont[$i])) { if ($dircont[$i] !== '.' && $dircont[$i] !== '..') { $current_file = "{$thisdir}/{$dircont[$i]}"; if (is_file($current_file)) { $path[] = "{$thisdir}/{$dircont[$i]}"; } elseif (is_dir($current_file)) { $path[] = "{$thisdir}/{$dircont[$i]}/"; if ($subdir === true) $stack[] = $current_file; } } $i++; } } } return $path; }
[ "public", "static", "function", "getAllFiles", "(", "$", "dir", ",", "$", "subdir", "=", "false", ")", "{", "$", "path", "=", "''", ";", "$", "stack", "[", "]", "=", "$", "dir", ";", "while", "(", "$", "stack", ")", "{", "$", "thisdir", "=", "array_pop", "(", "$", "stack", ")", ";", "if", "(", "$", "dircont", "=", "scandir", "(", "$", "thisdir", ")", ")", "{", "$", "i", "=", "0", ";", "while", "(", "isset", "(", "$", "dircont", "[", "$", "i", "]", ")", ")", "{", "if", "(", "$", "dircont", "[", "$", "i", "]", "!==", "'.'", "&&", "$", "dircont", "[", "$", "i", "]", "!==", "'..'", ")", "{", "$", "current_file", "=", "\"{$thisdir}/{$dircont[$i]}\"", ";", "if", "(", "is_file", "(", "$", "current_file", ")", ")", "{", "$", "path", "[", "]", "=", "\"{$thisdir}/{$dircont[$i]}\"", ";", "}", "elseif", "(", "is_dir", "(", "$", "current_file", ")", ")", "{", "$", "path", "[", "]", "=", "\"{$thisdir}/{$dircont[$i]}/\"", ";", "if", "(", "$", "subdir", "===", "true", ")", "$", "stack", "[", "]", "=", "$", "current_file", ";", "}", "}", "$", "i", "++", ";", "}", "}", "}", "return", "$", "path", ";", "}" ]
Get all directory files and directories @param string $dir directory location @param boolean $subdir include subdirectories of directory @return array
[ "Get", "all", "directory", "files", "and", "directories" ]
54933740f4500a7a1ebd37c7226cc00bc36e58db
https://github.com/WesamMikhail/Utils/blob/54933740f4500a7a1ebd37c7226cc00bc36e58db/src/Explorer.php#L18-L42
train
WesamMikhail/Utils
src/Explorer.php
Explorer.getAllSubdirectories
public static function getAllSubdirectories($dir, $subdir = false) { $path = ''; $stack[] = $dir; while ($stack) { $thisdir = array_shift($stack); if ($dircont = scandir($thisdir)) { $i = 0; while (isset($dircont[$i])) { if ($dircont[$i] !== '.' && $dircont[$i] !== '..') { $current_file = "{$thisdir}/{$dircont[$i]}"; if (is_dir($current_file)) { $temp = explode("/", $current_file); $path[$temp[count($temp) - 1]] = "{$thisdir}/{$dircont[$i]}"; if ($subdir === true) $stack[] = $current_file; } } $i++; } } } return $path; }
php
public static function getAllSubdirectories($dir, $subdir = false) { $path = ''; $stack[] = $dir; while ($stack) { $thisdir = array_shift($stack); if ($dircont = scandir($thisdir)) { $i = 0; while (isset($dircont[$i])) { if ($dircont[$i] !== '.' && $dircont[$i] !== '..') { $current_file = "{$thisdir}/{$dircont[$i]}"; if (is_dir($current_file)) { $temp = explode("/", $current_file); $path[$temp[count($temp) - 1]] = "{$thisdir}/{$dircont[$i]}"; if ($subdir === true) $stack[] = $current_file; } } $i++; } } } return $path; }
[ "public", "static", "function", "getAllSubdirectories", "(", "$", "dir", ",", "$", "subdir", "=", "false", ")", "{", "$", "path", "=", "''", ";", "$", "stack", "[", "]", "=", "$", "dir", ";", "while", "(", "$", "stack", ")", "{", "$", "thisdir", "=", "array_shift", "(", "$", "stack", ")", ";", "if", "(", "$", "dircont", "=", "scandir", "(", "$", "thisdir", ")", ")", "{", "$", "i", "=", "0", ";", "while", "(", "isset", "(", "$", "dircont", "[", "$", "i", "]", ")", ")", "{", "if", "(", "$", "dircont", "[", "$", "i", "]", "!==", "'.'", "&&", "$", "dircont", "[", "$", "i", "]", "!==", "'..'", ")", "{", "$", "current_file", "=", "\"{$thisdir}/{$dircont[$i]}\"", ";", "if", "(", "is_dir", "(", "$", "current_file", ")", ")", "{", "$", "temp", "=", "explode", "(", "\"/\"", ",", "$", "current_file", ")", ";", "$", "path", "[", "$", "temp", "[", "count", "(", "$", "temp", ")", "-", "1", "]", "]", "=", "\"{$thisdir}/{$dircont[$i]}\"", ";", "if", "(", "$", "subdir", "===", "true", ")", "$", "stack", "[", "]", "=", "$", "current_file", ";", "}", "}", "$", "i", "++", ";", "}", "}", "}", "return", "$", "path", ";", "}" ]
Get all subdirectories of directory @param string $dir directory location @param boolean $subdir include subdirectories of subdirectory @return array
[ "Get", "all", "subdirectories", "of", "directory" ]
54933740f4500a7a1ebd37c7226cc00bc36e58db
https://github.com/WesamMikhail/Utils/blob/54933740f4500a7a1ebd37c7226cc00bc36e58db/src/Explorer.php#L51-L74
train
LitGroup/enumerable.php
src/Enumerable.php
Enumerable.getValueOf
final public static function getValueOf($rawValue) { $values = static::getValues(); if (!array_key_exists($rawValue, $values)) { throw new OutOfBoundsException( sprintf('Enum "%s" has no value with raw value "%s".', get_called_class(), $rawValue) ); } return $values[$rawValue]; }
php
final public static function getValueOf($rawValue) { $values = static::getValues(); if (!array_key_exists($rawValue, $values)) { throw new OutOfBoundsException( sprintf('Enum "%s" has no value with raw value "%s".', get_called_class(), $rawValue) ); } return $values[$rawValue]; }
[ "final", "public", "static", "function", "getValueOf", "(", "$", "rawValue", ")", "{", "$", "values", "=", "static", "::", "getValues", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "rawValue", ",", "$", "values", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "sprintf", "(", "'Enum \"%s\" has no value with raw value \"%s\".'", ",", "get_called_class", "(", ")", ",", "$", "rawValue", ")", ")", ";", "}", "return", "$", "values", "[", "$", "rawValue", "]", ";", "}" ]
Returns an instance of Enumerable by raw value. @param int|string $rawValue @return static
[ "Returns", "an", "instance", "of", "Enumerable", "by", "raw", "value", "." ]
35e49d360a1ceade4c849a6322d0aeed8e120a64
https://github.com/LitGroup/enumerable.php/blob/35e49d360a1ceade4c849a6322d0aeed8e120a64/src/Enumerable.php#L54-L64
train
LitGroup/enumerable.php
src/Enumerable.php
Enumerable.initializeEnum
private static function initializeEnum($enumClass) { self::$isInInitializationState = true; try { $classReflection = new ReflectionClass($enumClass); // Enumerable must be final: if (!$classReflection->isFinal()) { throw new LogicException( sprintf('Enumerable class must be final, but "%s" is not final.', $enumClass) ); } // Enumerable cannot be Serializable: if (is_subclass_of($enumClass, \Serializable::class)) { throw new LogicException( sprintf( 'Enumerable cannot be serializable, but enum class "%s" implements "Serializable" interface.', $enumClass ) ); } $methods = $classReflection->getMethods(ReflectionMethod::IS_STATIC); self::$enums[$enumClass] = []; foreach ($methods as $method) { if (self::isServiceMethod($method)) { continue; } /** @var Enumerable $value */ $value = $method->invoke(null); if (!is_object($value) || get_class($value) !== $enumClass) { throw new LogicException(sprintf( '"%s:%s()" should return an instance of its class. But value of type "%s" returned.', $enumClass, $method, is_object($value) ? get_class($value) : gettype($value) )); } // Detect duplication of indexes: if (array_key_exists($value->getRawValue(), self::$enums[$enumClass])) { throw new LogicException( sprintf('Duplicate of index "%s" in enumerable "%s".', $value->getRawValue(), $enumClass) ); } self::$enums[$enumClass][$value->getRawValue()] = $value; } } finally { self::$isInInitializationState = false; } }
php
private static function initializeEnum($enumClass) { self::$isInInitializationState = true; try { $classReflection = new ReflectionClass($enumClass); // Enumerable must be final: if (!$classReflection->isFinal()) { throw new LogicException( sprintf('Enumerable class must be final, but "%s" is not final.', $enumClass) ); } // Enumerable cannot be Serializable: if (is_subclass_of($enumClass, \Serializable::class)) { throw new LogicException( sprintf( 'Enumerable cannot be serializable, but enum class "%s" implements "Serializable" interface.', $enumClass ) ); } $methods = $classReflection->getMethods(ReflectionMethod::IS_STATIC); self::$enums[$enumClass] = []; foreach ($methods as $method) { if (self::isServiceMethod($method)) { continue; } /** @var Enumerable $value */ $value = $method->invoke(null); if (!is_object($value) || get_class($value) !== $enumClass) { throw new LogicException(sprintf( '"%s:%s()" should return an instance of its class. But value of type "%s" returned.', $enumClass, $method, is_object($value) ? get_class($value) : gettype($value) )); } // Detect duplication of indexes: if (array_key_exists($value->getRawValue(), self::$enums[$enumClass])) { throw new LogicException( sprintf('Duplicate of index "%s" in enumerable "%s".', $value->getRawValue(), $enumClass) ); } self::$enums[$enumClass][$value->getRawValue()] = $value; } } finally { self::$isInInitializationState = false; } }
[ "private", "static", "function", "initializeEnum", "(", "$", "enumClass", ")", "{", "self", "::", "$", "isInInitializationState", "=", "true", ";", "try", "{", "$", "classReflection", "=", "new", "ReflectionClass", "(", "$", "enumClass", ")", ";", "// Enumerable must be final:", "if", "(", "!", "$", "classReflection", "->", "isFinal", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Enumerable class must be final, but \"%s\" is not final.'", ",", "$", "enumClass", ")", ")", ";", "}", "// Enumerable cannot be Serializable:", "if", "(", "is_subclass_of", "(", "$", "enumClass", ",", "\\", "Serializable", "::", "class", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Enumerable cannot be serializable, but enum class \"%s\" implements \"Serializable\" interface.'", ",", "$", "enumClass", ")", ")", ";", "}", "$", "methods", "=", "$", "classReflection", "->", "getMethods", "(", "ReflectionMethod", "::", "IS_STATIC", ")", ";", "self", "::", "$", "enums", "[", "$", "enumClass", "]", "=", "[", "]", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "self", "::", "isServiceMethod", "(", "$", "method", ")", ")", "{", "continue", ";", "}", "/** @var Enumerable $value */", "$", "value", "=", "$", "method", "->", "invoke", "(", "null", ")", ";", "if", "(", "!", "is_object", "(", "$", "value", ")", "||", "get_class", "(", "$", "value", ")", "!==", "$", "enumClass", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'\"%s:%s()\" should return an instance of its class. But value of type \"%s\" returned.'", ",", "$", "enumClass", ",", "$", "method", ",", "is_object", "(", "$", "value", ")", "?", "get_class", "(", "$", "value", ")", ":", "gettype", "(", "$", "value", ")", ")", ")", ";", "}", "// Detect duplication of indexes:", "if", "(", "array_key_exists", "(", "$", "value", "->", "getRawValue", "(", ")", ",", "self", "::", "$", "enums", "[", "$", "enumClass", "]", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Duplicate of index \"%s\" in enumerable \"%s\".'", ",", "$", "value", "->", "getRawValue", "(", ")", ",", "$", "enumClass", ")", ")", ";", "}", "self", "::", "$", "enums", "[", "$", "enumClass", "]", "[", "$", "value", "->", "getRawValue", "(", ")", "]", "=", "$", "value", ";", "}", "}", "finally", "{", "self", "::", "$", "isInInitializationState", "=", "false", ";", "}", "}" ]
Initializes values of enumerable class. @param string $enumClass
[ "Initializes", "values", "of", "enumerable", "class", "." ]
35e49d360a1ceade4c849a6322d0aeed8e120a64
https://github.com/LitGroup/enumerable.php/blob/35e49d360a1ceade4c849a6322d0aeed8e120a64/src/Enumerable.php#L121-L175
train
LitGroup/enumerable.php
src/Enumerable.php
Enumerable.isServiceMethod
private static function isServiceMethod(ReflectionMethod $method) { return !$method->isPublic() || in_array($method->getShortName(), self::getServiceMethods()); }
php
private static function isServiceMethod(ReflectionMethod $method) { return !$method->isPublic() || in_array($method->getShortName(), self::getServiceMethods()); }
[ "private", "static", "function", "isServiceMethod", "(", "ReflectionMethod", "$", "method", ")", "{", "return", "!", "$", "method", "->", "isPublic", "(", ")", "||", "in_array", "(", "$", "method", "->", "getShortName", "(", ")", ",", "self", "::", "getServiceMethods", "(", ")", ")", ";", "}" ]
Checks that given method is for the internal use. @param ReflectionMethod $method @return boolean
[ "Checks", "that", "given", "method", "is", "for", "the", "internal", "use", "." ]
35e49d360a1ceade4c849a6322d0aeed8e120a64
https://github.com/LitGroup/enumerable.php/blob/35e49d360a1ceade4c849a6322d0aeed8e120a64/src/Enumerable.php#L194-L197
train
agentmedia/phine-core
src/Core/Modules/Backend/JsonPageTree.php
JsonPageTree.BeforeDelete
protected function BeforeDelete() { foreach (self::$deleteHooks as $hook) { $hook->BeforeDelete($this->item); } $logger = new Logger(BackendModule::Guard()->GetUser()); $logger->ReportPageAction($this->item, Action::Delete()); $file = Path::Combine(PHINE_PATH, 'Public/.htaccess'); if (!File::Exists($file)) { return; } $this->UpdateHtaccess($file); }
php
protected function BeforeDelete() { foreach (self::$deleteHooks as $hook) { $hook->BeforeDelete($this->item); } $logger = new Logger(BackendModule::Guard()->GetUser()); $logger->ReportPageAction($this->item, Action::Delete()); $file = Path::Combine(PHINE_PATH, 'Public/.htaccess'); if (!File::Exists($file)) { return; } $this->UpdateHtaccess($file); }
[ "protected", "function", "BeforeDelete", "(", ")", "{", "foreach", "(", "self", "::", "$", "deleteHooks", "as", "$", "hook", ")", "{", "$", "hook", "->", "BeforeDelete", "(", "$", "this", "->", "item", ")", ";", "}", "$", "logger", "=", "new", "Logger", "(", "BackendModule", "::", "Guard", "(", ")", "->", "GetUser", "(", ")", ")", ";", "$", "logger", "->", "ReportPageAction", "(", "$", "this", "->", "item", ",", "Action", "::", "Delete", "(", ")", ")", ";", "$", "file", "=", "Path", "::", "Combine", "(", "PHINE_PATH", ",", "'Public/.htaccess'", ")", ";", "if", "(", "!", "File", "::", "Exists", "(", "$", "file", ")", ")", "{", "return", ";", "}", "$", "this", "->", "UpdateHtaccess", "(", "$", "file", ")", ";", "}" ]
Remove htaccess page commands before page is deleted
[ "Remove", "htaccess", "page", "commands", "before", "page", "is", "deleted" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/JsonPageTree.php#L51-L66
train
TiMESPLiNTER/tsFramework
src/ch/timesplinter/core/HttpRequest.php
HttpRequest.sanitize
private function sanitize($value, $sanitizers) { if(is_string($sanitizers) === true) return call_user_func($sanitizers, $value); if(is_array($sanitizers) === true) { $valueFiltered = $value; if(count($sanitizers) === 2 && is_callable($sanitizers) === true) return call_user_func($sanitizers, $valueFiltered); foreach($sanitizers as $f) $valueFiltered = call_user_func($f, $valueFiltered); return $valueFiltered; } return $value; }
php
private function sanitize($value, $sanitizers) { if(is_string($sanitizers) === true) return call_user_func($sanitizers, $value); if(is_array($sanitizers) === true) { $valueFiltered = $value; if(count($sanitizers) === 2 && is_callable($sanitizers) === true) return call_user_func($sanitizers, $valueFiltered); foreach($sanitizers as $f) $valueFiltered = call_user_func($f, $valueFiltered); return $valueFiltered; } return $value; }
[ "private", "function", "sanitize", "(", "$", "value", ",", "$", "sanitizers", ")", "{", "if", "(", "is_string", "(", "$", "sanitizers", ")", "===", "true", ")", "return", "call_user_func", "(", "$", "sanitizers", ",", "$", "value", ")", ";", "if", "(", "is_array", "(", "$", "sanitizers", ")", "===", "true", ")", "{", "$", "valueFiltered", "=", "$", "value", ";", "if", "(", "count", "(", "$", "sanitizers", ")", "===", "2", "&&", "is_callable", "(", "$", "sanitizers", ")", "===", "true", ")", "return", "call_user_func", "(", "$", "sanitizers", ",", "$", "valueFiltered", ")", ";", "foreach", "(", "$", "sanitizers", "as", "$", "f", ")", "$", "valueFiltered", "=", "call_user_func", "(", "$", "f", ",", "$", "valueFiltered", ")", ";", "return", "$", "valueFiltered", ";", "}", "return", "$", "value", ";", "}" ]
Sanitizes a value with the given functions and callbacks @param string|int|null $value The value to sanitize @param string|array $sanitizers The functions to sanitize the string. A simple function as string or a callback as array or an array with simple functions and callback arrays @return string|int|null The sanitized value
[ "Sanitizes", "a", "value", "with", "the", "given", "functions", "and", "callbacks" ]
b3b9fd98f6d456a9e571015877ecca203786fd0c
https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/core/HttpRequest.php#L252-L269
train
MARCspec/php-marc-spec
src/MARCspecParser.php
MARCspecParser.parse
public function parse($marcspec) { if (!preg_match_all('/'.$this->MARCSPEC.'/', $marcspec, $this->parsed, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::MISSINGFIELD, $marcspec ); } $this->parsed = array_filter($this->parsed[0], 'strlen'); if (!array_key_exists('field', $this->parsed)) { // TODO: check if 'tag' is the required key throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::FTAG, $marcspec ); } if (strlen($this->parsed[0]) !== strlen($marcspec)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::USELESS, $marcspec ); } if (array_key_exists('charpos', $this->parsed)) { if (array_key_exists('indicatorpos', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::CHARORIND, $marcspec ); } if (array_key_exists('subfields', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::CHARORSF, $marcspec ); } } if (array_key_exists('subfields', $this->parsed)) { if (array_key_exists('indicatorpos', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::INDORSF, $marcspec ); } } if (array_key_exists('subspecs', $this->parsed)) { $_subSpecs = $this->matchSubSpecs($this->parsed['subspecs']); $this->parsed['subspecs'] = []; foreach ($_subSpecs as $subSpec) { if (1 < count($subSpec)) { foreach ($subSpec as $orSubSpec) { $_or[] = $this->matchSubTerms($orSubSpec); } $this->parsed['subspecs'][] = $_or; // TODO: Check if array is required since $_or is an array } else { $this->parsed['subspecs'][] = $this->matchSubTerms($subSpec[0]); } } } }
php
public function parse($marcspec) { if (!preg_match_all('/'.$this->MARCSPEC.'/', $marcspec, $this->parsed, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::MISSINGFIELD, $marcspec ); } $this->parsed = array_filter($this->parsed[0], 'strlen'); if (!array_key_exists('field', $this->parsed)) { // TODO: check if 'tag' is the required key throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::FTAG, $marcspec ); } if (strlen($this->parsed[0]) !== strlen($marcspec)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::USELESS, $marcspec ); } if (array_key_exists('charpos', $this->parsed)) { if (array_key_exists('indicatorpos', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::CHARORIND, $marcspec ); } if (array_key_exists('subfields', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::CHARORSF, $marcspec ); } } if (array_key_exists('subfields', $this->parsed)) { if (array_key_exists('indicatorpos', $this->parsed)) { throw new InvalidMARCspecException( InvalidMARCspecException::FS. InvalidMARCspecException::INDORSF, $marcspec ); } } if (array_key_exists('subspecs', $this->parsed)) { $_subSpecs = $this->matchSubSpecs($this->parsed['subspecs']); $this->parsed['subspecs'] = []; foreach ($_subSpecs as $subSpec) { if (1 < count($subSpec)) { foreach ($subSpec as $orSubSpec) { $_or[] = $this->matchSubTerms($orSubSpec); } $this->parsed['subspecs'][] = $_or; // TODO: Check if array is required since $_or is an array } else { $this->parsed['subspecs'][] = $this->matchSubTerms($subSpec[0]); } } } }
[ "public", "function", "parse", "(", "$", "marcspec", ")", "{", "if", "(", "!", "preg_match_all", "(", "'/'", ".", "$", "this", "->", "MARCSPEC", ".", "'/'", ",", "$", "marcspec", ",", "$", "this", "->", "parsed", ",", "PREG_SET_ORDER", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "MISSINGFIELD", ",", "$", "marcspec", ")", ";", "}", "$", "this", "->", "parsed", "=", "array_filter", "(", "$", "this", "->", "parsed", "[", "0", "]", ",", "'strlen'", ")", ";", "if", "(", "!", "array_key_exists", "(", "'field'", ",", "$", "this", "->", "parsed", ")", ")", "{", "// TODO: check if 'tag' is the required key", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "FTAG", ",", "$", "marcspec", ")", ";", "}", "if", "(", "strlen", "(", "$", "this", "->", "parsed", "[", "0", "]", ")", "!==", "strlen", "(", "$", "marcspec", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "USELESS", ",", "$", "marcspec", ")", ";", "}", "if", "(", "array_key_exists", "(", "'charpos'", ",", "$", "this", "->", "parsed", ")", ")", "{", "if", "(", "array_key_exists", "(", "'indicatorpos'", ",", "$", "this", "->", "parsed", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "CHARORIND", ",", "$", "marcspec", ")", ";", "}", "if", "(", "array_key_exists", "(", "'subfields'", ",", "$", "this", "->", "parsed", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "CHARORSF", ",", "$", "marcspec", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'subfields'", ",", "$", "this", "->", "parsed", ")", ")", "{", "if", "(", "array_key_exists", "(", "'indicatorpos'", ",", "$", "this", "->", "parsed", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "FS", ".", "InvalidMARCspecException", "::", "INDORSF", ",", "$", "marcspec", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'subspecs'", ",", "$", "this", "->", "parsed", ")", ")", "{", "$", "_subSpecs", "=", "$", "this", "->", "matchSubSpecs", "(", "$", "this", "->", "parsed", "[", "'subspecs'", "]", ")", ";", "$", "this", "->", "parsed", "[", "'subspecs'", "]", "=", "[", "]", ";", "foreach", "(", "$", "_subSpecs", "as", "$", "subSpec", ")", "{", "if", "(", "1", "<", "count", "(", "$", "subSpec", ")", ")", "{", "foreach", "(", "$", "subSpec", "as", "$", "orSubSpec", ")", "{", "$", "_or", "[", "]", "=", "$", "this", "->", "matchSubTerms", "(", "$", "orSubSpec", ")", ";", "}", "$", "this", "->", "parsed", "[", "'subspecs'", "]", "[", "]", "=", "$", "_or", ";", "// TODO: Check if array is required since $_or is an array", "}", "else", "{", "$", "this", "->", "parsed", "[", "'subspecs'", "]", "[", "]", "=", "$", "this", "->", "matchSubTerms", "(", "$", "subSpec", "[", "0", "]", ")", ";", "}", "}", "}", "}" ]
parses MARCspec. @param string $marcspec The MARCspec @throws CK\MARCspec\Exception\InvalidMARCspecException
[ "parses", "MARCspec", "." ]
853d77ad3d510ce05c33535bfa3f1068dccdeef6
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/MARCspecParser.php#L126-L198
train
MARCspec/php-marc-spec
src/MARCspecParser.php
MARCspecParser.parseSubfields
public function parseSubfields($subfieldspec) { if (!preg_match_all('/'.$this->SUBFIELD.'/', $subfieldspec, $_subfieldMatches, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::SFCHAR, $subfieldspec ); } /* * For each subfield (array) do anonymous function * - first filter empty elements * - second look for subspecs * - match subspecs and match subTerms * - return everything in the array of subfields */ array_walk( $_subfieldMatches, function (&$_subfield) use (&$test) { $_subfield = array_filter($_subfield, 'strlen'); $test .= $_subfield['subfield']; if (array_key_exists('subspecs', $_subfield)) { $_ss = []; if (!$_subfieldSubSpecs = $this->matchSubSpecs($_subfield['subspecs'])) { // TODO: raise error; } foreach ($_subfieldSubSpecs as $key => $_subfieldSubSpec) { if (1 < count($_subfieldSubSpec)) { foreach ($_subfieldSubSpec as $orSubSpec) { $_or[] = $this->matchSubTerms($orSubSpec); } $_ss[] = $_or; } else { $_ss[] = $this->matchSubTerms($_subfieldSubSpec[0]); } } $_subfield['subspecs'] = $_ss; } } ); if ($test !== $subfieldspec) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::USELESS, $subfieldspec ); } return $_subfieldMatches; }
php
public function parseSubfields($subfieldspec) { if (!preg_match_all('/'.$this->SUBFIELD.'/', $subfieldspec, $_subfieldMatches, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::SFCHAR, $subfieldspec ); } /* * For each subfield (array) do anonymous function * - first filter empty elements * - second look for subspecs * - match subspecs and match subTerms * - return everything in the array of subfields */ array_walk( $_subfieldMatches, function (&$_subfield) use (&$test) { $_subfield = array_filter($_subfield, 'strlen'); $test .= $_subfield['subfield']; if (array_key_exists('subspecs', $_subfield)) { $_ss = []; if (!$_subfieldSubSpecs = $this->matchSubSpecs($_subfield['subspecs'])) { // TODO: raise error; } foreach ($_subfieldSubSpecs as $key => $_subfieldSubSpec) { if (1 < count($_subfieldSubSpec)) { foreach ($_subfieldSubSpec as $orSubSpec) { $_or[] = $this->matchSubTerms($orSubSpec); } $_ss[] = $_or; } else { $_ss[] = $this->matchSubTerms($_subfieldSubSpec[0]); } } $_subfield['subspecs'] = $_ss; } } ); if ($test !== $subfieldspec) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::USELESS, $subfieldspec ); } return $_subfieldMatches; }
[ "public", "function", "parseSubfields", "(", "$", "subfieldspec", ")", "{", "if", "(", "!", "preg_match_all", "(", "'/'", ".", "$", "this", "->", "SUBFIELD", ".", "'/'", ",", "$", "subfieldspec", ",", "$", "_subfieldMatches", ",", "PREG_SET_ORDER", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SF", ".", "InvalidMARCspecException", "::", "SFCHAR", ",", "$", "subfieldspec", ")", ";", "}", "/*\n * For each subfield (array) do anonymous function\n * - first filter empty elements\n * - second look for subspecs\n * - match subspecs and match subTerms\n * - return everything in the array of subfields\n */", "array_walk", "(", "$", "_subfieldMatches", ",", "function", "(", "&", "$", "_subfield", ")", "use", "(", "&", "$", "test", ")", "{", "$", "_subfield", "=", "array_filter", "(", "$", "_subfield", ",", "'strlen'", ")", ";", "$", "test", ".=", "$", "_subfield", "[", "'subfield'", "]", ";", "if", "(", "array_key_exists", "(", "'subspecs'", ",", "$", "_subfield", ")", ")", "{", "$", "_ss", "=", "[", "]", ";", "if", "(", "!", "$", "_subfieldSubSpecs", "=", "$", "this", "->", "matchSubSpecs", "(", "$", "_subfield", "[", "'subspecs'", "]", ")", ")", "{", "// TODO: raise error;", "}", "foreach", "(", "$", "_subfieldSubSpecs", "as", "$", "key", "=>", "$", "_subfieldSubSpec", ")", "{", "if", "(", "1", "<", "count", "(", "$", "_subfieldSubSpec", ")", ")", "{", "foreach", "(", "$", "_subfieldSubSpec", "as", "$", "orSubSpec", ")", "{", "$", "_or", "[", "]", "=", "$", "this", "->", "matchSubTerms", "(", "$", "orSubSpec", ")", ";", "}", "$", "_ss", "[", "]", "=", "$", "_or", ";", "}", "else", "{", "$", "_ss", "[", "]", "=", "$", "this", "->", "matchSubTerms", "(", "$", "_subfieldSubSpec", "[", "0", "]", ")", ";", "}", "}", "$", "_subfield", "[", "'subspecs'", "]", "=", "$", "_ss", ";", "}", "}", ")", ";", "if", "(", "$", "test", "!==", "$", "subfieldspec", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SF", ".", "InvalidMARCspecException", "::", "USELESS", ",", "$", "subfieldspec", ")", ";", "}", "return", "$", "_subfieldMatches", ";", "}" ]
Matches subfieldspecs. @param string $subfieldspec A string of one or more subfieldspecs
[ "Matches", "subfieldspecs", "." ]
853d77ad3d510ce05c33535bfa3f1068dccdeef6
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/MARCspecParser.php#L205-L260
train
MARCspec/php-marc-spec
src/MARCspecParser.php
MARCspecParser.subfieldToArray
public function subfieldToArray($subfieldspec) { if (!$_sf = $this->parseSubfields($subfieldspec)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::UNKNOWN, $subfieldspec ); } if (1 < count($_sf)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::MULTISF, $subfieldspec ); } if ($_sf[0]['subfield'] !== $subfieldspec) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::USELESS, $subfieldspec ); } return $_sf[0]; }
php
public function subfieldToArray($subfieldspec) { if (!$_sf = $this->parseSubfields($subfieldspec)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::UNKNOWN, $subfieldspec ); } if (1 < count($_sf)) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::MULTISF, $subfieldspec ); } if ($_sf[0]['subfield'] !== $subfieldspec) { throw new InvalidMARCspecException( InvalidMARCspecException::SF. InvalidMARCspecException::USELESS, $subfieldspec ); } return $_sf[0]; }
[ "public", "function", "subfieldToArray", "(", "$", "subfieldspec", ")", "{", "if", "(", "!", "$", "_sf", "=", "$", "this", "->", "parseSubfields", "(", "$", "subfieldspec", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SF", ".", "InvalidMARCspecException", "::", "UNKNOWN", ",", "$", "subfieldspec", ")", ";", "}", "if", "(", "1", "<", "count", "(", "$", "_sf", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SF", ".", "InvalidMARCspecException", "::", "MULTISF", ",", "$", "subfieldspec", ")", ";", "}", "if", "(", "$", "_sf", "[", "0", "]", "[", "'subfield'", "]", "!==", "$", "subfieldspec", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SF", ".", "InvalidMARCspecException", "::", "USELESS", ",", "$", "subfieldspec", ")", ";", "}", "return", "$", "_sf", "[", "0", "]", ";", "}" ]
calls parseSubfields but makes sure only one subfield is present. @param string $subfieldspec A subfieldspec @return array An Array of subfieldspec
[ "calls", "parseSubfields", "but", "makes", "sure", "only", "one", "subfield", "is", "present", "." ]
853d77ad3d510ce05c33535bfa3f1068dccdeef6
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/MARCspecParser.php#L269-L296
train
MARCspec/php-marc-spec
src/MARCspecParser.php
MARCspecParser.matchSubSpecs
private function matchSubSpecs($subSpecs) { $_subSpecs = []; if (!preg_match_all('/'.$this->SUBSPEC.'/U', $subSpecs, $_subSpecMatches, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpecs ); } foreach ($_subSpecMatches as $key => $_subSpecMatch) { if (array_key_exists(1, $_subSpecMatch) && !empty($_subSpecMatch[1])) { $_subSpecs[$key] = preg_split('/(?<!\\\)\|/', $_subSpecMatch[1], -1, PREG_SPLIT_NO_EMPTY); } else { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpecs ); } } return $_subSpecs; }
php
private function matchSubSpecs($subSpecs) { $_subSpecs = []; if (!preg_match_all('/'.$this->SUBSPEC.'/U', $subSpecs, $_subSpecMatches, PREG_SET_ORDER)) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpecs ); } foreach ($_subSpecMatches as $key => $_subSpecMatch) { if (array_key_exists(1, $_subSpecMatch) && !empty($_subSpecMatch[1])) { $_subSpecs[$key] = preg_split('/(?<!\\\)\|/', $_subSpecMatch[1], -1, PREG_SPLIT_NO_EMPTY); } else { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpecs ); } } return $_subSpecs; }
[ "private", "function", "matchSubSpecs", "(", "$", "subSpecs", ")", "{", "$", "_subSpecs", "=", "[", "]", ";", "if", "(", "!", "preg_match_all", "(", "'/'", ".", "$", "this", "->", "SUBSPEC", ".", "'/U'", ",", "$", "subSpecs", ",", "$", "_subSpecMatches", ",", "PREG_SET_ORDER", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SS", ".", "InvalidMARCspecException", "::", "UNKNOWN", ",", "$", "subSpecs", ")", ";", "}", "foreach", "(", "$", "_subSpecMatches", "as", "$", "key", "=>", "$", "_subSpecMatch", ")", "{", "if", "(", "array_key_exists", "(", "1", ",", "$", "_subSpecMatch", ")", "&&", "!", "empty", "(", "$", "_subSpecMatch", "[", "1", "]", ")", ")", "{", "$", "_subSpecs", "[", "$", "key", "]", "=", "preg_split", "(", "'/(?<!\\\\\\)\\|/'", ",", "$", "_subSpecMatch", "[", "1", "]", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "}", "else", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SS", ".", "InvalidMARCspecException", "::", "UNKNOWN", ",", "$", "subSpecs", ")", ";", "}", "}", "return", "$", "_subSpecs", ";", "}" ]
parses subspecs into an array. @param string $subSpecs One or more subspecs @return array Array of subspecs
[ "parses", "subspecs", "into", "an", "array", "." ]
853d77ad3d510ce05c33535bfa3f1068dccdeef6
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/MARCspecParser.php#L305-L329
train
MARCspec/php-marc-spec
src/MARCspecParser.php
MARCspecParser.matchSubTerms
private function matchSubTerms($subSpec) { if (preg_match('/(?<![\\\\\$])[\{\}]/', $subSpec, $_error, PREG_OFFSET_CAPTURE)) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::ESCAPE, $subSpec ); } if (preg_match_all('/'.$this->SUBTERMS.'/', $subSpec, $_subTermMatches, PREG_SET_ORDER)) { if (empty($_subTermMatches[0]['operator'])) { $_subTermMatches[0]['operator'] = '?'; } if (!$_subTermMatches[0]['rightsubterm']) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::MISSINGRIGHT, $subSpec ); } return array_filter($_subTermMatches[0], 'strlen'); } else { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpec ); } }
php
private function matchSubTerms($subSpec) { if (preg_match('/(?<![\\\\\$])[\{\}]/', $subSpec, $_error, PREG_OFFSET_CAPTURE)) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::ESCAPE, $subSpec ); } if (preg_match_all('/'.$this->SUBTERMS.'/', $subSpec, $_subTermMatches, PREG_SET_ORDER)) { if (empty($_subTermMatches[0]['operator'])) { $_subTermMatches[0]['operator'] = '?'; } if (!$_subTermMatches[0]['rightsubterm']) { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::MISSINGRIGHT, $subSpec ); } return array_filter($_subTermMatches[0], 'strlen'); } else { throw new InvalidMARCspecException( InvalidMARCspecException::SS. InvalidMARCspecException::UNKNOWN, $subSpec ); } }
[ "private", "function", "matchSubTerms", "(", "$", "subSpec", ")", "{", "if", "(", "preg_match", "(", "'/(?<![\\\\\\\\\\$])[\\{\\}]/'", ",", "$", "subSpec", ",", "$", "_error", ",", "PREG_OFFSET_CAPTURE", ")", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SS", ".", "InvalidMARCspecException", "::", "ESCAPE", ",", "$", "subSpec", ")", ";", "}", "if", "(", "preg_match_all", "(", "'/'", ".", "$", "this", "->", "SUBTERMS", ".", "'/'", ",", "$", "subSpec", ",", "$", "_subTermMatches", ",", "PREG_SET_ORDER", ")", ")", "{", "if", "(", "empty", "(", "$", "_subTermMatches", "[", "0", "]", "[", "'operator'", "]", ")", ")", "{", "$", "_subTermMatches", "[", "0", "]", "[", "'operator'", "]", "=", "'?'", ";", "}", "if", "(", "!", "$", "_subTermMatches", "[", "0", "]", "[", "'rightsubterm'", "]", ")", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SS", ".", "InvalidMARCspecException", "::", "MISSINGRIGHT", ",", "$", "subSpec", ")", ";", "}", "return", "array_filter", "(", "$", "_subTermMatches", "[", "0", "]", ",", "'strlen'", ")", ";", "}", "else", "{", "throw", "new", "InvalidMARCspecException", "(", "InvalidMARCspecException", "::", "SS", ".", "InvalidMARCspecException", "::", "UNKNOWN", ",", "$", "subSpec", ")", ";", "}", "}" ]
Parses a single SubSpec into sunTerms. @param string $subSpec A single SubSpec @return array subTerms as array
[ "Parses", "a", "single", "SubSpec", "into", "sunTerms", "." ]
853d77ad3d510ce05c33535bfa3f1068dccdeef6
https://github.com/MARCspec/php-marc-spec/blob/853d77ad3d510ce05c33535bfa3f1068dccdeef6/src/MARCspecParser.php#L338-L368
train
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/WalletService.php
WalletService.getBalance
public function getBalance($user_id, $type = -1){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_CREDITS_BALANCE; $url = sprintf($url, $user_id, $type); $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ return $result['results']; }else{ return 0; } }
php
public function getBalance($user_id, $type = -1){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_CREDITS_BALANCE; $url = sprintf($url, $user_id, $type); $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ return $result['results']; }else{ return 0; } }
[ "public", "function", "getBalance", "(", "$", "user_id", ",", "$", "type", "=", "-", "1", ")", "{", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_WALLET", ".", "Endpoints", "::", "WALLET_CREDITS_BALANCE", ";", "$", "url", "=", "sprintf", "(", "$", "url", ",", "$", "user_id", ",", "$", "type", ")", ";", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ")", "{", "return", "$", "result", "[", "'results'", "]", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
Get the wallet balance of a user @param $user_id @param int $type @return float @throws Exception @throws \CodeMojo\Client\Http\InvalidArgumentException
[ "Get", "the", "wallet", "balance", "of", "a", "user" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/WalletService.php#L50-L60
train
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/WalletService.php
WalletService.getTransactionDetail
public function getTransactionDetail($transaction_id){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_TRANSACTION; $url = sprintf($url,$transaction_id); $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ // Wrap it in a array since maskData takes an Array of Array $maskWrapper = array($result['results']); $this->maskData($maskWrapper); return $maskWrapper[0]; }else{ return 0; } }
php
public function getTransactionDetail($transaction_id){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_TRANSACTION; $url = sprintf($url,$transaction_id); $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ // Wrap it in a array since maskData takes an Array of Array $maskWrapper = array($result['results']); $this->maskData($maskWrapper); return $maskWrapper[0]; }else{ return 0; } }
[ "public", "function", "getTransactionDetail", "(", "$", "transaction_id", ")", "{", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_WALLET", ".", "Endpoints", "::", "WALLET_TRANSACTION", ";", "$", "url", "=", "sprintf", "(", "$", "url", ",", "$", "transaction_id", ")", ";", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ")", "{", "// Wrap it in a array since maskData takes an Array of Array", "$", "maskWrapper", "=", "array", "(", "$", "result", "[", "'results'", "]", ")", ";", "$", "this", "->", "maskData", "(", "$", "maskWrapper", ")", ";", "return", "$", "maskWrapper", "[", "0", "]", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
Get details about a particular transaction @param $transaction_id @return array @throws Exception @throws InvalidArgumentException
[ "Get", "details", "about", "a", "particular", "transaction" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/WalletService.php#L69-L82
train
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/WalletService.php
WalletService.getTransactionDetailsForUser
public function getTransactionDetailsForUser($user_id, $count = 10, $paginated_url = null, $page = 1){ if($paginated_url) { $url = $paginated_url; }else { $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_TRANSACTIONS_USER . ($paginated_url ? '' : '?page=' . (int) $page); $url = sprintf($url, $user_id, $count); } $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ $this->maskData($result['results']['data']); $paginatedResult = new PaginatedResults($result['results'],array($this,'getTransactionDetailsForUser'),array($user_id,$count)); return $paginatedResult; }else{ return new PaginatedResults(array(),null,null); } }
php
public function getTransactionDetailsForUser($user_id, $count = 10, $paginated_url = null, $page = 1){ if($paginated_url) { $url = $paginated_url; }else { $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_TRANSACTIONS_USER . ($paginated_url ? '' : '?page=' . (int) $page); $url = sprintf($url, $user_id, $count); } $result = $this->authenticationService->getTransport()->fetch($url); if($result["code"] == APIResponse::RESPONSE_SUCCESS){ $this->maskData($result['results']['data']); $paginatedResult = new PaginatedResults($result['results'],array($this,'getTransactionDetailsForUser'),array($user_id,$count)); return $paginatedResult; }else{ return new PaginatedResults(array(),null,null); } }
[ "public", "function", "getTransactionDetailsForUser", "(", "$", "user_id", ",", "$", "count", "=", "10", ",", "$", "paginated_url", "=", "null", ",", "$", "page", "=", "1", ")", "{", "if", "(", "$", "paginated_url", ")", "{", "$", "url", "=", "$", "paginated_url", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_WALLET", ".", "Endpoints", "::", "WALLET_TRANSACTIONS_USER", ".", "(", "$", "paginated_url", "?", "''", ":", "'?page='", ".", "(", "int", ")", "$", "page", ")", ";", "$", "url", "=", "sprintf", "(", "$", "url", ",", "$", "user_id", ",", "$", "count", ")", ";", "}", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ")", "{", "$", "this", "->", "maskData", "(", "$", "result", "[", "'results'", "]", "[", "'data'", "]", ")", ";", "$", "paginatedResult", "=", "new", "PaginatedResults", "(", "$", "result", "[", "'results'", "]", ",", "array", "(", "$", "this", ",", "'getTransactionDetailsForUser'", ")", ",", "array", "(", "$", "user_id", ",", "$", "count", ")", ")", ";", "return", "$", "paginatedResult", ";", "}", "else", "{", "return", "new", "PaginatedResults", "(", "array", "(", ")", ",", "null", ",", "null", ")", ";", "}", "}" ]
Get all transactions for a particular user @param $user_id @param int $count @param null $paginated_url @param int $page @return PaginatedResults @throws Exception @throws \CodeMojo\Client\Http\InvalidArgumentException
[ "Get", "all", "transactions", "for", "a", "particular", "user" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/WalletService.php#L94-L113
train
codemojo-dr/startkit-php-sdk
src/CodeMojo/Client/Services/WalletService.php
WalletService.addBalance
public function addBalance($user_id, $value_to_add, $transaction_type = WalletTransactionTypes::TRANSACTIONAL, $expires_in_days = 0, $transaction_id = null, $meta_data = null, $tag = null, $frozen = false){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_CREDITS; $params = array( 'customer_id' => $user_id, 'value'=>$value_to_add, 'transaction_type' => $transaction_type, 'transaction_id'=>$transaction_id, 'hold' => $frozen ? 1 : 0, 'meta' => $meta_data, 'tag' => $tag, 'expiry' => $expires_in_days ); $result = $this->authenticationService->getTransport()->fetch($url,$params,'PUT',array(),0); if($result["code"] == APIResponse::OVERFLOW){ throw new QuotaExceededException("Wallet value quota exeeded"); } return $result["code"] == APIResponse::RESPONSE_SUCCESS; }
php
public function addBalance($user_id, $value_to_add, $transaction_type = WalletTransactionTypes::TRANSACTIONAL, $expires_in_days = 0, $transaction_id = null, $meta_data = null, $tag = null, $frozen = false){ $url = $this->authenticationService->getServerEndPoint() . Endpoints::VERSION . Endpoints::BASE_WALLET . Endpoints::WALLET_CREDITS; $params = array( 'customer_id' => $user_id, 'value'=>$value_to_add, 'transaction_type' => $transaction_type, 'transaction_id'=>$transaction_id, 'hold' => $frozen ? 1 : 0, 'meta' => $meta_data, 'tag' => $tag, 'expiry' => $expires_in_days ); $result = $this->authenticationService->getTransport()->fetch($url,$params,'PUT',array(),0); if($result["code"] == APIResponse::OVERFLOW){ throw new QuotaExceededException("Wallet value quota exeeded"); } return $result["code"] == APIResponse::RESPONSE_SUCCESS; }
[ "public", "function", "addBalance", "(", "$", "user_id", ",", "$", "value_to_add", ",", "$", "transaction_type", "=", "WalletTransactionTypes", "::", "TRANSACTIONAL", ",", "$", "expires_in_days", "=", "0", ",", "$", "transaction_id", "=", "null", ",", "$", "meta_data", "=", "null", ",", "$", "tag", "=", "null", ",", "$", "frozen", "=", "false", ")", "{", "$", "url", "=", "$", "this", "->", "authenticationService", "->", "getServerEndPoint", "(", ")", ".", "Endpoints", "::", "VERSION", ".", "Endpoints", "::", "BASE_WALLET", ".", "Endpoints", "::", "WALLET_CREDITS", ";", "$", "params", "=", "array", "(", "'customer_id'", "=>", "$", "user_id", ",", "'value'", "=>", "$", "value_to_add", ",", "'transaction_type'", "=>", "$", "transaction_type", ",", "'transaction_id'", "=>", "$", "transaction_id", ",", "'hold'", "=>", "$", "frozen", "?", "1", ":", "0", ",", "'meta'", "=>", "$", "meta_data", ",", "'tag'", "=>", "$", "tag", ",", "'expiry'", "=>", "$", "expires_in_days", ")", ";", "$", "result", "=", "$", "this", "->", "authenticationService", "->", "getTransport", "(", ")", "->", "fetch", "(", "$", "url", ",", "$", "params", ",", "'PUT'", ",", "array", "(", ")", ",", "0", ")", ";", "if", "(", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "OVERFLOW", ")", "{", "throw", "new", "QuotaExceededException", "(", "\"Wallet value quota exeeded\"", ")", ";", "}", "return", "$", "result", "[", "\"code\"", "]", "==", "APIResponse", "::", "RESPONSE_SUCCESS", ";", "}" ]
Add balance to a particular user's wallet @param $user_id @param $value_to_add @param int $transaction_type @param int|null $expires_in_days @param null $transaction_id @param null $meta_data @param null $tag @param bool|false $frozen @return bool @throws QuotaExceededException
[ "Add", "balance", "to", "a", "particular", "user", "s", "wallet" ]
cd2227e1a221be2cd75dc96d1c9e0acfda936fb3
https://github.com/codemojo-dr/startkit-php-sdk/blob/cd2227e1a221be2cd75dc96d1c9e0acfda936fb3/src/CodeMojo/Client/Services/WalletService.php#L223-L239
train
zapheus/zapheus
src/Http/Message/UriFactory.php
UriFactory.make
public function make() { $authority = $this->host; $fragment = $this->fragment; $query = $this->query; if ($this->host !== '' && $this->user !== null) { $user = $this->user; if ($this->pass) { $user = $this->user . ':' . $this->pass; } $authority = $user . '@' . $authority; $authority = $authority . ':' . $this->port; } if ($query) { $query = '?' . $query; } if ($fragment) { $fragment = '#' . $fragment; } return new Uri($this->scheme . '://' . $authority . $this->path . $query . $fragment); }
php
public function make() { $authority = $this->host; $fragment = $this->fragment; $query = $this->query; if ($this->host !== '' && $this->user !== null) { $user = $this->user; if ($this->pass) { $user = $this->user . ':' . $this->pass; } $authority = $user . '@' . $authority; $authority = $authority . ':' . $this->port; } if ($query) { $query = '?' . $query; } if ($fragment) { $fragment = '#' . $fragment; } return new Uri($this->scheme . '://' . $authority . $this->path . $query . $fragment); }
[ "public", "function", "make", "(", ")", "{", "$", "authority", "=", "$", "this", "->", "host", ";", "$", "fragment", "=", "$", "this", "->", "fragment", ";", "$", "query", "=", "$", "this", "->", "query", ";", "if", "(", "$", "this", "->", "host", "!==", "''", "&&", "$", "this", "->", "user", "!==", "null", ")", "{", "$", "user", "=", "$", "this", "->", "user", ";", "if", "(", "$", "this", "->", "pass", ")", "{", "$", "user", "=", "$", "this", "->", "user", ".", "':'", ".", "$", "this", "->", "pass", ";", "}", "$", "authority", "=", "$", "user", ".", "'@'", ".", "$", "authority", ";", "$", "authority", "=", "$", "authority", ".", "':'", ".", "$", "this", "->", "port", ";", "}", "if", "(", "$", "query", ")", "{", "$", "query", "=", "'?'", ".", "$", "query", ";", "}", "if", "(", "$", "fragment", ")", "{", "$", "fragment", "=", "'#'", ".", "$", "fragment", ";", "}", "return", "new", "Uri", "(", "$", "this", "->", "scheme", ".", "'://'", ".", "$", "authority", ".", "$", "this", "->", "path", ".", "$", "query", ".", "$", "fragment", ")", ";", "}" ]
Creates the URI instance. @return \Zapheus\Http\Message\UriInterface
[ "Creates", "the", "URI", "instance", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/UriFactory.php#L116-L149
train
zapheus/zapheus
src/Http/Message/UriFactory.php
UriFactory.user
public function user($user, $pass = null) { if ($pass) { $this->pass = $pass; } $this->user = $user; return $this; }
php
public function user($user, $pass = null) { if ($pass) { $this->pass = $pass; } $this->user = $user; return $this; }
[ "public", "function", "user", "(", "$", "user", ",", "$", "pass", "=", "null", ")", "{", "if", "(", "$", "pass", ")", "{", "$", "this", "->", "pass", "=", "$", "pass", ";", "}", "$", "this", "->", "user", "=", "$", "user", ";", "return", "$", "this", ";", "}" ]
Sets the user component. @param string $user @return self
[ "Sets", "the", "user", "component", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/UriFactory.php#L209-L219
train
RocketPropelledTortoise/Core
src/Taxonomy/TaxonomyTrait.php
TaxonomyTrait.getTerms
public function getTerms($vocabulary_id) { if (!$data = Cache::get($this->getTaxonomyCacheKey())) { $data = $this->cacheTermsForContent(); } if (!is_numeric($vocabulary_id)) { $vocabulary_id = T::vocabulary($vocabulary_id); } $results = new Collection(); if (array_key_exists($vocabulary_id, $data)) { foreach ($data[$vocabulary_id] as $term) { $results[] = T::getTerm($term); } } return $results; }
php
public function getTerms($vocabulary_id) { if (!$data = Cache::get($this->getTaxonomyCacheKey())) { $data = $this->cacheTermsForContent(); } if (!is_numeric($vocabulary_id)) { $vocabulary_id = T::vocabulary($vocabulary_id); } $results = new Collection(); if (array_key_exists($vocabulary_id, $data)) { foreach ($data[$vocabulary_id] as $term) { $results[] = T::getTerm($term); } } return $results; }
[ "public", "function", "getTerms", "(", "$", "vocabulary_id", ")", "{", "if", "(", "!", "$", "data", "=", "Cache", "::", "get", "(", "$", "this", "->", "getTaxonomyCacheKey", "(", ")", ")", ")", "{", "$", "data", "=", "$", "this", "->", "cacheTermsForContent", "(", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "vocabulary_id", ")", ")", "{", "$", "vocabulary_id", "=", "T", "::", "vocabulary", "(", "$", "vocabulary_id", ")", ";", "}", "$", "results", "=", "new", "Collection", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "vocabulary_id", ",", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "[", "$", "vocabulary_id", "]", "as", "$", "term", ")", "{", "$", "results", "[", "]", "=", "T", "::", "getTerm", "(", "$", "term", ")", ";", "}", "}", "return", "$", "results", ";", "}" ]
Get the terms from a content @param int|string $vocabulary_id @return Collection
[ "Get", "the", "terms", "from", "a", "content" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/TaxonomyTrait.php#L85-L103
train
RocketPropelledTortoise/Core
src/Taxonomy/TaxonomyTrait.php
TaxonomyTrait.addTerm
public function addTerm($term_id) { TermContainer::findOrFail($term_id); // Cancel if the user wants to add the same term again if ($this->getTaxonomyQuery()->where('term_id', $term_id)->count()) { return; } $this->taxonomies()->attach($term_id); Cache::forget($this->getTaxonomyCacheKey()); }
php
public function addTerm($term_id) { TermContainer::findOrFail($term_id); // Cancel if the user wants to add the same term again if ($this->getTaxonomyQuery()->where('term_id', $term_id)->count()) { return; } $this->taxonomies()->attach($term_id); Cache::forget($this->getTaxonomyCacheKey()); }
[ "public", "function", "addTerm", "(", "$", "term_id", ")", "{", "TermContainer", "::", "findOrFail", "(", "$", "term_id", ")", ";", "// Cancel if the user wants to add the same term again", "if", "(", "$", "this", "->", "getTaxonomyQuery", "(", ")", "->", "where", "(", "'term_id'", ",", "$", "term_id", ")", "->", "count", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "taxonomies", "(", ")", "->", "attach", "(", "$", "term_id", ")", ";", "Cache", "::", "forget", "(", "$", "this", "->", "getTaxonomyCacheKey", "(", ")", ")", ";", "}" ]
Link a term to this content @param int $term_id
[ "Link", "a", "term", "to", "this", "content" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/TaxonomyTrait.php#L110-L122
train
RocketPropelledTortoise/Core
src/Taxonomy/TaxonomyTrait.php
TaxonomyTrait.removeTerms
public function removeTerms($vocabulary_id = null) { if ($vocabulary_id === null) { return $this->getTaxonomyQuery()->delete(); } if (!is_numeric($vocabulary_id)) { $vocabulary_id = T::vocabulary($vocabulary_id); } return $this->getTaxonomyQuery()->whereIn('term_id', function ($query) use ($vocabulary_id) { $query->select('id')->where('vocabulary_id', $vocabulary_id)->from((new TermContainer)->getTable()); })->delete(); }
php
public function removeTerms($vocabulary_id = null) { if ($vocabulary_id === null) { return $this->getTaxonomyQuery()->delete(); } if (!is_numeric($vocabulary_id)) { $vocabulary_id = T::vocabulary($vocabulary_id); } return $this->getTaxonomyQuery()->whereIn('term_id', function ($query) use ($vocabulary_id) { $query->select('id')->where('vocabulary_id', $vocabulary_id)->from((new TermContainer)->getTable()); })->delete(); }
[ "public", "function", "removeTerms", "(", "$", "vocabulary_id", "=", "null", ")", "{", "if", "(", "$", "vocabulary_id", "===", "null", ")", "{", "return", "$", "this", "->", "getTaxonomyQuery", "(", ")", "->", "delete", "(", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "vocabulary_id", ")", ")", "{", "$", "vocabulary_id", "=", "T", "::", "vocabulary", "(", "$", "vocabulary_id", ")", ";", "}", "return", "$", "this", "->", "getTaxonomyQuery", "(", ")", "->", "whereIn", "(", "'term_id'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "vocabulary_id", ")", "{", "$", "query", "->", "select", "(", "'id'", ")", "->", "where", "(", "'vocabulary_id'", ",", "$", "vocabulary_id", ")", "->", "from", "(", "(", "new", "TermContainer", ")", "->", "getTable", "(", ")", ")", ";", "}", ")", "->", "delete", "(", ")", ";", "}" ]
Removes terms specified by a vocabulary, or all @param int|string $vocabulary_id @return bool
[ "Removes", "terms", "specified", "by", "a", "vocabulary", "or", "all" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/TaxonomyTrait.php#L145-L158
train
RocketPropelledTortoise/Core
src/Taxonomy/TaxonomyTrait.php
TaxonomyTrait.getTaxonomyQuery
private function getTaxonomyQuery() { $t = $this->taxonomies(); return $t->newPivotStatement() ->where($t->getForeignKey(), $this->getKey()) ->where($t->getMorphType(), $t->getMorphClass()); }
php
private function getTaxonomyQuery() { $t = $this->taxonomies(); return $t->newPivotStatement() ->where($t->getForeignKey(), $this->getKey()) ->where($t->getMorphType(), $t->getMorphClass()); }
[ "private", "function", "getTaxonomyQuery", "(", ")", "{", "$", "t", "=", "$", "this", "->", "taxonomies", "(", ")", ";", "return", "$", "t", "->", "newPivotStatement", "(", ")", "->", "where", "(", "$", "t", "->", "getForeignKey", "(", ")", ",", "$", "this", "->", "getKey", "(", ")", ")", "->", "where", "(", "$", "t", "->", "getMorphType", "(", ")", ",", "$", "t", "->", "getMorphClass", "(", ")", ")", ";", "}" ]
Get a new plain query builder for the pivot table. @return Builder
[ "Get", "a", "new", "plain", "query", "builder", "for", "the", "pivot", "table", "." ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/TaxonomyTrait.php#L202-L209
train
codeblanche/Web
src/Web/Response/Cookie.php
Cookie.commit
public function commit() { return setcookie( $this->name, $this->value, $this->expires, $this->path, $this->domain, $this->secure, $this->httpOnly ); }
php
public function commit() { return setcookie( $this->name, $this->value, $this->expires, $this->path, $this->domain, $this->secure, $this->httpOnly ); }
[ "public", "function", "commit", "(", ")", "{", "return", "setcookie", "(", "$", "this", "->", "name", ",", "$", "this", "->", "value", ",", "$", "this", "->", "expires", ",", "$", "this", "->", "path", ",", "$", "this", "->", "domain", ",", "$", "this", "->", "secure", ",", "$", "this", "->", "httpOnly", ")", ";", "}" ]
Send the cookie
[ "Send", "the", "cookie" ]
3e9ebf1943d3ea468f619ba99f7cc10714cb16e9
https://github.com/codeblanche/Web/blob/3e9ebf1943d3ea468f619ba99f7cc10714cb16e9/src/Web/Response/Cookie.php#L39-L50
train
linpax/microphp-framework
src/base/Dispatcher.php
Dispatcher.addListener
public function addListener($listener, $event, $prior = null) { if (!is_callable($event)) { return false; } if (!array_key_exists($listener, $this->listeners)) { $this->listeners[$listener] = []; } if (!$prior) { $this->listeners[$listener][] = $event; } else { array_splice($this->listeners[$listener], $prior, 0, $event); } return true; }
php
public function addListener($listener, $event, $prior = null) { if (!is_callable($event)) { return false; } if (!array_key_exists($listener, $this->listeners)) { $this->listeners[$listener] = []; } if (!$prior) { $this->listeners[$listener][] = $event; } else { array_splice($this->listeners[$listener], $prior, 0, $event); } return true; }
[ "public", "function", "addListener", "(", "$", "listener", ",", "$", "event", ",", "$", "prior", "=", "null", ")", "{", "if", "(", "!", "is_callable", "(", "$", "event", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "listener", ",", "$", "this", "->", "listeners", ")", ")", "{", "$", "this", "->", "listeners", "[", "$", "listener", "]", "=", "[", "]", ";", "}", "if", "(", "!", "$", "prior", ")", "{", "$", "this", "->", "listeners", "[", "$", "listener", "]", "[", "]", "=", "$", "event", ";", "}", "else", "{", "array_splice", "(", "$", "this", "->", "listeners", "[", "$", "listener", "]", ",", "$", "prior", ",", "0", ",", "$", "event", ")", ";", "}", "return", "true", ";", "}" ]
Add listener on event @access public @param string $listener listener name @param array $event ['Object', 'method'] or callable @param int|null $prior priority @return bool
[ "Add", "listener", "on", "event" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/base/Dispatcher.php#L36-L53
train
linpax/microphp-framework
src/base/Dispatcher.php
Dispatcher.signal
public function signal($listener, array $params = []) { $result = null; if (array_key_exists($listener, $this->listeners) && 0 !== count($this->listeners[$listener])) { /** @noinspection ForeachSourceInspection */ foreach ($this->listeners[$listener] as $listen) { $result = call_user_func($listen, $params); if ($result instanceof ResponseInterface) { return $result; } } } return $result; }
php
public function signal($listener, array $params = []) { $result = null; if (array_key_exists($listener, $this->listeners) && 0 !== count($this->listeners[$listener])) { /** @noinspection ForeachSourceInspection */ foreach ($this->listeners[$listener] as $listen) { $result = call_user_func($listen, $params); if ($result instanceof ResponseInterface) { return $result; } } } return $result; }
[ "public", "function", "signal", "(", "$", "listener", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "result", "=", "null", ";", "if", "(", "array_key_exists", "(", "$", "listener", ",", "$", "this", "->", "listeners", ")", "&&", "0", "!==", "count", "(", "$", "this", "->", "listeners", "[", "$", "listener", "]", ")", ")", "{", "/** @noinspection ForeachSourceInspection */", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "listener", "]", "as", "$", "listen", ")", "{", "$", "result", "=", "call_user_func", "(", "$", "listen", ",", "$", "params", ")", ";", "if", "(", "$", "result", "instanceof", "ResponseInterface", ")", "{", "return", "$", "result", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Send signal to run event @access public @param string $listener listener name @param array $params Signal parameters @return mixed
[ "Send", "signal", "to", "run", "event" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/base/Dispatcher.php#L65-L81
train
koolkode/security
src/Authentication/Token/NtlmAuthToken.php
NtlmAuthToken.isValidResponse
public function isValidResponse($username, $hash, $challenge) { if(self::NTLM_BLOB_HEADER != substr($this->clientBlob, 0, 8)) { return false; } // Timstamp, seconds since january 1, 1601, used in replay-attack prevention. // $str = (float)vsprintf('%u%04u%04u%04u', array_reverse(unpack('vt1/vt2/vt3/vt4', substr($this->clientBlob, 8, 8)))); // $seconds = floor($str / 1000000); // Client nonce, useful in replay-attack prevention. // $cnonce = substr($this->clientBlob, 16, 8); if(!SecurityUtil::timingSafeEquals($username, $this->username)) { return false; } if(!SecurityUtil::timingSafeEquals($this->provider->getDomain(), $this->domain)) { return false; } $ntlmhash = $this->computeHmacMd5($hash, $this->encodeUtf16(strtoupper($this->username) . $this->domain)); $hash = (string)$this->computeHmacMd5($ntlmhash, $challenge . $this->clientBlob); if(!SecurityUtil::timingSafeEquals($hash, $this->clientHash)) { return false; } return true; }
php
public function isValidResponse($username, $hash, $challenge) { if(self::NTLM_BLOB_HEADER != substr($this->clientBlob, 0, 8)) { return false; } // Timstamp, seconds since january 1, 1601, used in replay-attack prevention. // $str = (float)vsprintf('%u%04u%04u%04u', array_reverse(unpack('vt1/vt2/vt3/vt4', substr($this->clientBlob, 8, 8)))); // $seconds = floor($str / 1000000); // Client nonce, useful in replay-attack prevention. // $cnonce = substr($this->clientBlob, 16, 8); if(!SecurityUtil::timingSafeEquals($username, $this->username)) { return false; } if(!SecurityUtil::timingSafeEquals($this->provider->getDomain(), $this->domain)) { return false; } $ntlmhash = $this->computeHmacMd5($hash, $this->encodeUtf16(strtoupper($this->username) . $this->domain)); $hash = (string)$this->computeHmacMd5($ntlmhash, $challenge . $this->clientBlob); if(!SecurityUtil::timingSafeEquals($hash, $this->clientHash)) { return false; } return true; }
[ "public", "function", "isValidResponse", "(", "$", "username", ",", "$", "hash", ",", "$", "challenge", ")", "{", "if", "(", "self", "::", "NTLM_BLOB_HEADER", "!=", "substr", "(", "$", "this", "->", "clientBlob", ",", "0", ",", "8", ")", ")", "{", "return", "false", ";", "}", "// Timstamp, seconds since january 1, 1601, used in replay-attack prevention.", "// \t$str = (float)vsprintf('%u%04u%04u%04u', array_reverse(unpack('vt1/vt2/vt3/vt4', substr($this->clientBlob, 8, 8))));", "// \t$seconds = floor($str / 1000000);", "// Client nonce, useful in replay-attack prevention.", "// \t$cnonce = substr($this->clientBlob, 16, 8);", "if", "(", "!", "SecurityUtil", "::", "timingSafeEquals", "(", "$", "username", ",", "$", "this", "->", "username", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "SecurityUtil", "::", "timingSafeEquals", "(", "$", "this", "->", "provider", "->", "getDomain", "(", ")", ",", "$", "this", "->", "domain", ")", ")", "{", "return", "false", ";", "}", "$", "ntlmhash", "=", "$", "this", "->", "computeHmacMd5", "(", "$", "hash", ",", "$", "this", "->", "encodeUtf16", "(", "strtoupper", "(", "$", "this", "->", "username", ")", ".", "$", "this", "->", "domain", ")", ")", ";", "$", "hash", "=", "(", "string", ")", "$", "this", "->", "computeHmacMd5", "(", "$", "ntlmhash", ",", "$", "challenge", ".", "$", "this", "->", "clientBlob", ")", ";", "if", "(", "!", "SecurityUtil", "::", "timingSafeEquals", "(", "$", "hash", ",", "$", "this", "->", "clientHash", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Needs the MD4 hash of the UTF-16LE encoded password of the user in hex- or binary format. @param string $username @param string $hash @param unknown $challenge
[ "Needs", "the", "MD4", "hash", "of", "the", "UTF", "-", "16LE", "encoded", "password", "of", "the", "user", "in", "hex", "-", "or", "binary", "format", "." ]
d3d8d42392f520754847d29b6df19aaa38c79e8e
https://github.com/koolkode/security/blob/d3d8d42392f520754847d29b6df19aaa38c79e8e/src/Authentication/Token/NtlmAuthToken.php#L389-L422
train
gocom/rah_beacon
src/Rah/Beacon.php
Rah_Beacon.light
public function light() { $forms = safe_column( 'name', 'txp_form', '1 = 1' ); $beacon = new Rah_Beacon_Handler(); foreach ($forms as $name) { if (!preg_match('/^[a-z][a-z0-9_]*$/', $name)) { trace_add('[rah_beacon: '.$name.' skipped]'); continue; } Txp::get('Textpattern_Tag_Registry')->register(array($beacon, $name), $name); } }
php
public function light() { $forms = safe_column( 'name', 'txp_form', '1 = 1' ); $beacon = new Rah_Beacon_Handler(); foreach ($forms as $name) { if (!preg_match('/^[a-z][a-z0-9_]*$/', $name)) { trace_add('[rah_beacon: '.$name.' skipped]'); continue; } Txp::get('Textpattern_Tag_Registry')->register(array($beacon, $name), $name); } }
[ "public", "function", "light", "(", ")", "{", "$", "forms", "=", "safe_column", "(", "'name'", ",", "'txp_form'", ",", "'1 = 1'", ")", ";", "$", "beacon", "=", "new", "Rah_Beacon_Handler", "(", ")", ";", "foreach", "(", "$", "forms", "as", "$", "name", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[a-z][a-z0-9_]*$/'", ",", "$", "name", ")", ")", "{", "trace_add", "(", "'[rah_beacon: '", ".", "$", "name", ".", "' skipped]'", ")", ";", "continue", ";", "}", "Txp", "::", "get", "(", "'Textpattern_Tag_Registry'", ")", "->", "register", "(", "array", "(", "$", "beacon", ",", "$", "name", ")", ",", "$", "name", ")", ";", "}", "}" ]
Registers forms as tags.
[ "Registers", "forms", "as", "tags", "." ]
a5cacf3c7293fb3524c55cc073c820cfbf31e8f7
https://github.com/gocom/rah_beacon/blob/a5cacf3c7293fb3524c55cc073c820cfbf31e8f7/src/Rah/Beacon.php#L44-L62
train
gocom/rah_beacon
src/Rah/Beacon.php
Rah_Beacon.atts
public function atts($atts) { global $variable; foreach (lAtts($atts, $variable, false) as $name => $value) { $variable[$name] = $value; } }
php
public function atts($atts) { global $variable; foreach (lAtts($atts, $variable, false) as $name => $value) { $variable[$name] = $value; } }
[ "public", "function", "atts", "(", "$", "atts", ")", "{", "global", "$", "variable", ";", "foreach", "(", "lAtts", "(", "$", "atts", ",", "$", "variable", ",", "false", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "variable", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}" ]
A tag for assigning attribute defaults for tags. This tag should be called within the Form partial if it requires defaults for it's variables. <code> <txp:rah_beacon_atts color="blue" size="small" /> </code> The above would create a variable named "color" and "size" with values "blue" and "small" if one of them isn't specified as attributes in the tag calling the form. @param array $atts Attributes @return null
[ "A", "tag", "for", "assigning", "attribute", "defaults", "for", "tags", "." ]
a5cacf3c7293fb3524c55cc073c820cfbf31e8f7
https://github.com/gocom/rah_beacon/blob/a5cacf3c7293fb3524c55cc073c820cfbf31e8f7/src/Rah/Beacon.php#L82-L89
train
eureka-framework/component-application
src/Application/Applicationv3.php
Applicationv3.loadConfigPackages
private function loadConfigPackages() { $config = Container::getInstance()->get('config'); $list = $config->get('global.package'); if (empty($list) || !is_array($list)) { return; } foreach ($list as $name => $data) { if (!isset($data['config'])) { continue; } $config->loadYamlFromDirectory($data['config']); } }
php
private function loadConfigPackages() { $config = Container::getInstance()->get('config'); $list = $config->get('global.package'); if (empty($list) || !is_array($list)) { return; } foreach ($list as $name => $data) { if (!isset($data['config'])) { continue; } $config->loadYamlFromDirectory($data['config']); } }
[ "private", "function", "loadConfigPackages", "(", ")", "{", "$", "config", "=", "Container", "::", "getInstance", "(", ")", "->", "get", "(", "'config'", ")", ";", "$", "list", "=", "$", "config", "->", "get", "(", "'global.package'", ")", ";", "if", "(", "empty", "(", "$", "list", ")", "||", "!", "is_array", "(", "$", "list", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "list", "as", "$", "name", "=>", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'config'", "]", ")", ")", "{", "continue", ";", "}", "$", "config", "->", "loadYamlFromDirectory", "(", "$", "data", "[", "'config'", "]", ")", ";", "}", "}" ]
Load configs from packages. @return void
[ "Load", "configs", "from", "packages", "." ]
5bf70f20967ef15515abe764b465641277a51537
https://github.com/eureka-framework/component-application/blob/5bf70f20967ef15515abe764b465641277a51537/src/Application/Applicationv3.php#L55-L71
train
realboard/DBInstance
src/Realboard/Component/Database/DBInstance/Executor.php
Executor._merge_values
private function _merge_values($data, $values, $columns) { foreach ($values as $key => $value) { if (!is_numeric($key) && $key != '[]') { if (isset($columns[$key])) { $type = strtolower($columns[$key]); if ($value === null) { $type = 'null'; } switch ($type) { case 'int': case 'int4': case 'tiny': case 'long': case 'integer': $value = intval($value); break; case 'bool': case 'boolean': $value = (bool) $value; break; case 'float': case 'double': $value = floatval($value); break; case 'null': $value = null; break; default: $value = utf8_encode($value); break; } } if ($data instanceof DataInterface) { $data->set($key, $value); } elseif (is_array($data)) { $data[$key] = $value; } } } return $data; }
php
private function _merge_values($data, $values, $columns) { foreach ($values as $key => $value) { if (!is_numeric($key) && $key != '[]') { if (isset($columns[$key])) { $type = strtolower($columns[$key]); if ($value === null) { $type = 'null'; } switch ($type) { case 'int': case 'int4': case 'tiny': case 'long': case 'integer': $value = intval($value); break; case 'bool': case 'boolean': $value = (bool) $value; break; case 'float': case 'double': $value = floatval($value); break; case 'null': $value = null; break; default: $value = utf8_encode($value); break; } } if ($data instanceof DataInterface) { $data->set($key, $value); } elseif (is_array($data)) { $data[$key] = $value; } } } return $data; }
[ "private", "function", "_merge_values", "(", "$", "data", ",", "$", "values", ",", "$", "columns", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", "&&", "$", "key", "!=", "'[]'", ")", "{", "if", "(", "isset", "(", "$", "columns", "[", "$", "key", "]", ")", ")", "{", "$", "type", "=", "strtolower", "(", "$", "columns", "[", "$", "key", "]", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "$", "type", "=", "'null'", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "case", "'int4'", ":", "case", "'tiny'", ":", "case", "'long'", ":", "case", "'integer'", ":", "$", "value", "=", "intval", "(", "$", "value", ")", ";", "break", ";", "case", "'bool'", ":", "case", "'boolean'", ":", "$", "value", "=", "(", "bool", ")", "$", "value", ";", "break", ";", "case", "'float'", ":", "case", "'double'", ":", "$", "value", "=", "floatval", "(", "$", "value", ")", ";", "break", ";", "case", "'null'", ":", "$", "value", "=", "null", ";", "break", ";", "default", ":", "$", "value", "=", "utf8_encode", "(", "$", "value", ")", ";", "break", ";", "}", "}", "if", "(", "$", "data", "instanceof", "DataInterface", ")", "{", "$", "data", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Attach Value to row data. @param array|\Realboard\Component\Database\DBInstance\DBInterface\DataInterface $data data @param array $values @param array $columns @return array|\Realboard\Component\Database\DBInstance\DBInterface\DataInterface
[ "Attach", "Value", "to", "row", "data", "." ]
f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35
https://github.com/realboard/DBInstance/blob/f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35/src/Realboard/Component/Database/DBInstance/Executor.php#L169-L212
train
realboard/DBInstance
src/Realboard/Component/Database/DBInstance/Executor.php
Executor._define_column_types
private function _define_column_types(\PDOStatement $result) { $columns = array(); $intTypes = array('int', 'integer', 'long', 'tiny', 'smallint', 'int4'); try { for ($i = 0; $i < $result->columnCount(); ++$i) { $meta = $result->getColumnMeta($i); if ($meta && $meta['name'] != '[]') { $metaType = strtolower($meta['native_type']); $pdoType = $meta['pdo_type']; if (in_array($pdoType, array(\PDO::PARAM_STR, \PDO::PARAM_LOB))) { $metaType = 'string'; } elseif (in_array($metaType, $intTypes)) { $metaType = 'integer'; } elseif ($pdoType === \PDO::PARAM_NULL) { $metaType = 'null'; } $columns[$meta['name']] = $metaType; } } } catch (\PDOException $e) { } return $columns; }
php
private function _define_column_types(\PDOStatement $result) { $columns = array(); $intTypes = array('int', 'integer', 'long', 'tiny', 'smallint', 'int4'); try { for ($i = 0; $i < $result->columnCount(); ++$i) { $meta = $result->getColumnMeta($i); if ($meta && $meta['name'] != '[]') { $metaType = strtolower($meta['native_type']); $pdoType = $meta['pdo_type']; if (in_array($pdoType, array(\PDO::PARAM_STR, \PDO::PARAM_LOB))) { $metaType = 'string'; } elseif (in_array($metaType, $intTypes)) { $metaType = 'integer'; } elseif ($pdoType === \PDO::PARAM_NULL) { $metaType = 'null'; } $columns[$meta['name']] = $metaType; } } } catch (\PDOException $e) { } return $columns; }
[ "private", "function", "_define_column_types", "(", "\\", "PDOStatement", "$", "result", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "$", "intTypes", "=", "array", "(", "'int'", ",", "'integer'", ",", "'long'", ",", "'tiny'", ",", "'smallint'", ",", "'int4'", ")", ";", "try", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "result", "->", "columnCount", "(", ")", ";", "++", "$", "i", ")", "{", "$", "meta", "=", "$", "result", "->", "getColumnMeta", "(", "$", "i", ")", ";", "if", "(", "$", "meta", "&&", "$", "meta", "[", "'name'", "]", "!=", "'[]'", ")", "{", "$", "metaType", "=", "strtolower", "(", "$", "meta", "[", "'native_type'", "]", ")", ";", "$", "pdoType", "=", "$", "meta", "[", "'pdo_type'", "]", ";", "if", "(", "in_array", "(", "$", "pdoType", ",", "array", "(", "\\", "PDO", "::", "PARAM_STR", ",", "\\", "PDO", "::", "PARAM_LOB", ")", ")", ")", "{", "$", "metaType", "=", "'string'", ";", "}", "elseif", "(", "in_array", "(", "$", "metaType", ",", "$", "intTypes", ")", ")", "{", "$", "metaType", "=", "'integer'", ";", "}", "elseif", "(", "$", "pdoType", "===", "\\", "PDO", "::", "PARAM_NULL", ")", "{", "$", "metaType", "=", "'null'", ";", "}", "$", "columns", "[", "$", "meta", "[", "'name'", "]", "]", "=", "$", "metaType", ";", "}", "}", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "}", "return", "$", "columns", ";", "}" ]
Define columns from result. @param \PDOStatement $result @return array
[ "Define", "columns", "from", "result", "." ]
f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35
https://github.com/realboard/DBInstance/blob/f2cde7fdf480d5eb5a491a5cf81ff7f4b3be0a35/src/Realboard/Component/Database/DBInstance/Executor.php#L221-L246
train
Stillat/Common
src/Stillat/Common/Collections/Sorting/CollectionSortMap.php
CollectionSortMap.addThreshold
public function addThreshold($threshold, $driver) { if (!is_int($threshold) || $threshold <= 0) { throw new InvalidArgumentException("The threshold '{$threshold}' is invalid. The threshold must be an integer and greater than '0'."); } $this->sortThresholds[$threshold] = $driver; }
php
public function addThreshold($threshold, $driver) { if (!is_int($threshold) || $threshold <= 0) { throw new InvalidArgumentException("The threshold '{$threshold}' is invalid. The threshold must be an integer and greater than '0'."); } $this->sortThresholds[$threshold] = $driver; }
[ "public", "function", "addThreshold", "(", "$", "threshold", ",", "$", "driver", ")", "{", "if", "(", "!", "is_int", "(", "$", "threshold", ")", "||", "$", "threshold", "<=", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"The threshold '{$threshold}' is invalid. The threshold must be an integer and greater than '0'.\"", ")", ";", "}", "$", "this", "->", "sortThresholds", "[", "$", "threshold", "]", "=", "$", "driver", ";", "}" ]
Adds a new sorting algorithm with the specified threshold @throws InvalidArgumentException if the $threshold is not an integer, or is not greater than 0 @param int $threshold The collection count threshold @param string $driver The sorting driver to use at the threshold
[ "Adds", "a", "new", "sorting", "algorithm", "with", "the", "specified", "threshold" ]
9f69105292740c307aece588cf58a85892bad350
https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Collections/Sorting/CollectionSortMap.php#L20-L27
train
Stillat/Common
src/Stillat/Common/Collections/Sorting/CollectionSortMap.php
CollectionSortMap.determineDriver
public function determineDriver($collectionCount) { $determinedDriver = 'native'; ksort($this->sortThresholds, SORT_NUMERIC); foreach ($this->sortThresholds as $threshold => $driver) { if ($collectionCount <= $threshold) { $determinedDriver = $driver; break; } } return $determinedDriver; }
php
public function determineDriver($collectionCount) { $determinedDriver = 'native'; ksort($this->sortThresholds, SORT_NUMERIC); foreach ($this->sortThresholds as $threshold => $driver) { if ($collectionCount <= $threshold) { $determinedDriver = $driver; break; } } return $determinedDriver; }
[ "public", "function", "determineDriver", "(", "$", "collectionCount", ")", "{", "$", "determinedDriver", "=", "'native'", ";", "ksort", "(", "$", "this", "->", "sortThresholds", ",", "SORT_NUMERIC", ")", ";", "foreach", "(", "$", "this", "->", "sortThresholds", "as", "$", "threshold", "=>", "$", "driver", ")", "{", "if", "(", "$", "collectionCount", "<=", "$", "threshold", ")", "{", "$", "determinedDriver", "=", "$", "driver", ";", "break", ";", "}", "}", "return", "$", "determinedDriver", ";", "}" ]
Determines the driver to use based on a collection's size @param int $collectionCount The size of the collection @return string The driver to use
[ "Determines", "the", "driver", "to", "use", "based", "on", "a", "collection", "s", "size" ]
9f69105292740c307aece588cf58a85892bad350
https://github.com/Stillat/Common/blob/9f69105292740c307aece588cf58a85892bad350/src/Stillat/Common/Collections/Sorting/CollectionSortMap.php#L46-L61
train
Scoilnet/PhpSDK
scoilnetsdk/ScoilnetClient.php
ScoilnetClient.getSessionObject
protected function getSessionObject($access_token = NULL) { $session = NULL; // Try generate local version of session cookie. if (!empty($access_token) && isset($access_token['access_token'])) { $session['access_token'] = $access_token['access_token']; $session['base_domain'] = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN); $session['expires'] = isset($access_token['expires_in']) ? time() + $access_token['expires_in'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN); $session['refresh_token'] = isset($access_token['refresh_token']) ? $access_token['refresh_token'] : ''; $session['scope'] = isset($access_token['scope']) ? $access_token['scope'] : ''; $session['secret'] = md5(base64_encode(pack('N6', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid()))); // Provide our own signature. $sig = self::generateSignature( $session, $this->getVariable('client_secret') ); $session['sig'] = $sig; } // Try loading session from $_REQUEST. if (!$session && isset($_REQUEST['session'])) { $session = json_decode( get_magic_quotes_gpc() ? stripslashes($_REQUEST['session']) : $_REQUEST['session'], TRUE ); } //Try and get session from file cache if(!$session && $this->getVariable('use_file_cache') == TRUE){ $session = $this->getSessionFromFileCache(); } return $session; }
php
protected function getSessionObject($access_token = NULL) { $session = NULL; // Try generate local version of session cookie. if (!empty($access_token) && isset($access_token['access_token'])) { $session['access_token'] = $access_token['access_token']; $session['base_domain'] = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN); $session['expires'] = isset($access_token['expires_in']) ? time() + $access_token['expires_in'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN); $session['refresh_token'] = isset($access_token['refresh_token']) ? $access_token['refresh_token'] : ''; $session['scope'] = isset($access_token['scope']) ? $access_token['scope'] : ''; $session['secret'] = md5(base64_encode(pack('N6', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), uniqid()))); // Provide our own signature. $sig = self::generateSignature( $session, $this->getVariable('client_secret') ); $session['sig'] = $sig; } // Try loading session from $_REQUEST. if (!$session && isset($_REQUEST['session'])) { $session = json_decode( get_magic_quotes_gpc() ? stripslashes($_REQUEST['session']) : $_REQUEST['session'], TRUE ); } //Try and get session from file cache if(!$session && $this->getVariable('use_file_cache') == TRUE){ $session = $this->getSessionFromFileCache(); } return $session; }
[ "protected", "function", "getSessionObject", "(", "$", "access_token", "=", "NULL", ")", "{", "$", "session", "=", "NULL", ";", "// Try generate local version of session cookie.\r", "if", "(", "!", "empty", "(", "$", "access_token", ")", "&&", "isset", "(", "$", "access_token", "[", "'access_token'", "]", ")", ")", "{", "$", "session", "[", "'access_token'", "]", "=", "$", "access_token", "[", "'access_token'", "]", ";", "$", "session", "[", "'base_domain'", "]", "=", "$", "this", "->", "getVariable", "(", "'base_domain'", ",", "self", "::", "DEFAULT_BASE_DOMAIN", ")", ";", "$", "session", "[", "'expires'", "]", "=", "isset", "(", "$", "access_token", "[", "'expires_in'", "]", ")", "?", "time", "(", ")", "+", "$", "access_token", "[", "'expires_in'", "]", ":", "time", "(", ")", "+", "$", "this", "->", "getVariable", "(", "'expires_in'", ",", "self", "::", "DEFAULT_EXPIRES_IN", ")", ";", "$", "session", "[", "'refresh_token'", "]", "=", "isset", "(", "$", "access_token", "[", "'refresh_token'", "]", ")", "?", "$", "access_token", "[", "'refresh_token'", "]", ":", "''", ";", "$", "session", "[", "'scope'", "]", "=", "isset", "(", "$", "access_token", "[", "'scope'", "]", ")", "?", "$", "access_token", "[", "'scope'", "]", ":", "''", ";", "$", "session", "[", "'secret'", "]", "=", "md5", "(", "base64_encode", "(", "pack", "(", "'N6'", ",", "mt_rand", "(", ")", ",", "mt_rand", "(", ")", ",", "mt_rand", "(", ")", ",", "mt_rand", "(", ")", ",", "mt_rand", "(", ")", ",", "uniqid", "(", ")", ")", ")", ")", ";", "// Provide our own signature.\r", "$", "sig", "=", "self", "::", "generateSignature", "(", "$", "session", ",", "$", "this", "->", "getVariable", "(", "'client_secret'", ")", ")", ";", "$", "session", "[", "'sig'", "]", "=", "$", "sig", ";", "}", "// Try loading session from $_REQUEST.\r", "if", "(", "!", "$", "session", "&&", "isset", "(", "$", "_REQUEST", "[", "'session'", "]", ")", ")", "{", "$", "session", "=", "json_decode", "(", "get_magic_quotes_gpc", "(", ")", "?", "stripslashes", "(", "$", "_REQUEST", "[", "'session'", "]", ")", ":", "$", "_REQUEST", "[", "'session'", "]", ",", "TRUE", ")", ";", "}", "//Try and get session from file cache\r", "if", "(", "!", "$", "session", "&&", "$", "this", "->", "getVariable", "(", "'use_file_cache'", ")", "==", "TRUE", ")", "{", "$", "session", "=", "$", "this", "->", "getSessionFromFileCache", "(", ")", ";", "}", "return", "$", "session", ";", "}" ]
Try to get session object from custom method. By default we generate session object based on access_token response, or if it is provided from server with $_REQUEST. For sure, if it is provided by server it should follow our session object format. Session object provided by server can ensure the correct expires and base_domain setup as predefined in server, also you may get more useful information for custom functionality, too. BTW, this may require for additional remote call overhead. You may wish to override this function with your custom version due to your own server-side implementation. @param $access_token (optional) A valid access token in associative array as below: - access_token: A valid access_token generated by OAuth2.0 authorization endpoint. - expires_in: (optional) A valid expires_in generated by OAuth2.0 authorization endpoint. - refresh_token: (optional) A valid refresh_token generated by OAuth2.0 authorization endpoint. - scope: (optional) A valid scope generated by OAuth2.0 authorization endpoint. @return A valid session object in associative array for setup cookie, and NULL if not able to generate it with custom method.
[ "Try", "to", "get", "session", "object", "from", "custom", "method", "." ]
c2d033b020015b3c9c8a741bff857e7d599f18c0
https://github.com/Scoilnet/PhpSDK/blob/c2d033b020015b3c9c8a741bff857e7d599f18c0/scoilnetsdk/ScoilnetClient.php#L157-L193
train
Scoilnet/PhpSDK
scoilnetsdk/ScoilnetClient.php
ScoilnetClient.makeOAuth2Request
protected function makeOAuth2Request($path, $method = 'GET', $params = array()) { if ((!isset($params['access_token']) || empty($params['access_token'])) && $oauth_token = $this->getAccessToken()) { $params['access_token'] = $oauth_token; } return $this->makeRequest($path, $method, $params); }
php
protected function makeOAuth2Request($path, $method = 'GET', $params = array()) { if ((!isset($params['access_token']) || empty($params['access_token'])) && $oauth_token = $this->getAccessToken()) { $params['access_token'] = $oauth_token; } return $this->makeRequest($path, $method, $params); }
[ "protected", "function", "makeOAuth2Request", "(", "$", "path", ",", "$", "method", "=", "'GET'", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "(", "!", "isset", "(", "$", "params", "[", "'access_token'", "]", ")", "||", "empty", "(", "$", "params", "[", "'access_token'", "]", ")", ")", "&&", "$", "oauth_token", "=", "$", "this", "->", "getAccessToken", "(", ")", ")", "{", "$", "params", "[", "'access_token'", "]", "=", "$", "oauth_token", ";", "}", "return", "$", "this", "->", "makeRequest", "(", "$", "path", ",", "$", "method", ",", "$", "params", ")", ";", "}" ]
Make an OAuth2.0 Request. Automatically append "oauth_token" in query parameters if not yet exists and able to discover a valid access token from session. Otherwise just ignore setup with "oauth_token" and handle the API call AS-IS, and so may issue a plain API call without OAuth2.0 protection. @param $path The target path, relative to base_path/service_uri or an absolute URI. @param $method (optional) The HTTP method (default 'GET'). @param $params (optional The GET/POST parameters. @return The JSON decoded response object. @throws OAuth2Exception
[ "Make", "an", "OAuth2", ".", "0", "Request", "." ]
c2d033b020015b3c9c8a741bff857e7d599f18c0
https://github.com/Scoilnet/PhpSDK/blob/c2d033b020015b3c9c8a741bff857e7d599f18c0/scoilnetsdk/ScoilnetClient.php#L247-L253
train
PatrolServer/patrolsdk-php
lib/Exploit.php
Exploit.all
public function all($scopes = []) { return $this->_get('servers/' . $this->server_id . '/software/' . $this->software_id . '/exploits', null, $scopes); }
php
public function all($scopes = []) { return $this->_get('servers/' . $this->server_id . '/software/' . $this->software_id . '/exploits', null, $scopes); }
[ "public", "function", "all", "(", "$", "scopes", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_get", "(", "'servers/'", ".", "$", "this", "->", "server_id", ".", "'/software/'", ".", "$", "this", "->", "software_id", ".", "'/exploits'", ",", "null", ",", "$", "scopes", ")", ";", "}" ]
Gets a list of all exploits of this particular software @param array $scopes optional @return array List of PatrolSdk\Exploit
[ "Gets", "a", "list", "of", "all", "exploits", "of", "this", "particular", "software" ]
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/Exploit.php#L38-L40
train
Stinger-Soft/DoctrineCommons
src/StingerSoft/DoctrineCommons/Utils/Helper/ImportListener.php
ImportListener.tableExists
protected function tableExists($tableName) { if(isset($this->nonExistingTables[$tableName])) return false; if(isset($this->existingTables[$tableName])) return true; $exists = $this->schemaManager->tablesExist(array( $tableName )); if(!$exists) { $this->nonExistingTables[$tableName] = 1; } else { $this->existingTables[$tableName] = 1; } return $exists; }
php
protected function tableExists($tableName) { if(isset($this->nonExistingTables[$tableName])) return false; if(isset($this->existingTables[$tableName])) return true; $exists = $this->schemaManager->tablesExist(array( $tableName )); if(!$exists) { $this->nonExistingTables[$tableName] = 1; } else { $this->existingTables[$tableName] = 1; } return $exists; }
[ "protected", "function", "tableExists", "(", "$", "tableName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "nonExistingTables", "[", "$", "tableName", "]", ")", ")", "return", "false", ";", "if", "(", "isset", "(", "$", "this", "->", "existingTables", "[", "$", "tableName", "]", ")", ")", "return", "true", ";", "$", "exists", "=", "$", "this", "->", "schemaManager", "->", "tablesExist", "(", "array", "(", "$", "tableName", ")", ")", ";", "if", "(", "!", "$", "exists", ")", "{", "$", "this", "->", "nonExistingTables", "[", "$", "tableName", "]", "=", "1", ";", "}", "else", "{", "$", "this", "->", "existingTables", "[", "$", "tableName", "]", "=", "1", ";", "}", "return", "$", "exists", ";", "}" ]
Checks if the given table exists @param string $tableName The table name to check @return boolean Returns true if the table exists, otherwise false
[ "Checks", "if", "the", "given", "table", "exists" ]
1f0dd56a94654c8de63927d7eec2175aab3cf809
https://github.com/Stinger-Soft/DoctrineCommons/blob/1f0dd56a94654c8de63927d7eec2175aab3cf809/src/StingerSoft/DoctrineCommons/Utils/Helper/ImportListener.php#L257-L271
train
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Expression/Condition/Operator/Operator.php
Operator.validateMappings
protected function validateMappings($mappings, $allowAssociations) { $type = null; foreach ($mappings as $mapping) { //compatible date or number types are identical for our purposes here switch ($mapping->type) { case Type::TIMESTAMP: $thisType = Type::DATE; break; case Type::FLOAT: $thisType = Type::INT; break; default: if (!$mapping->isAssociation()) { $thisType = $mapping->type; break; } if (!$allowAssociations) { throw ODMException::queryOperatorAssociationsNotSupported(static::class); } if ($mapping->isMany()) { if (!isset($collectionType)) { $collectionType = $mapping->type; } elseif ($collectionType !== $mapping->type) { throw ODMException::queryIncompatibleTypes(); } } $thisType = $mapping->association; if (!$mapping->reference) { //embedded documents are serialized according to their class's //mapping - irrespective of any association mapping options - //so no further validation is required here break; } //reference serialization depends on storeAs, targetDocument, //and discriminator options. if (!isset($storeAs)) { $storeAs = $mapping->storeAs; } elseif ($storeAs !== $mapping->storeAs) { throw ODMException::queryIncompatibleTypes(); } if (!isset($targetDoc)) { $targetDoc = $mapping->targetDocument; } elseif ($targetDoc !== $mapping->targetDocument) { throw ODMException::queryIncompatibleTypes(); } if ($targetDoc !== null) { break; } if (!isset($discriminatorAttribute)) { $discriminatorAttribute = $mapping->discriminatorAttribute; } elseif ($discriminatorAttribute !== $mapping->discriminatorAttribute) { throw ODMException::queryIncompatibleTypes(); } if (!isset($discriminatorDefaultValue)) { $discriminatorDefaultValue = $mapping->discriminatorDefaultValue; } elseif ($discriminatorDefaultValue !== $mapping->discriminatorDefaultValue) { throw ODMException::queryIncompatibleTypes(); } if (!isset($discriminatorMap)) { $discriminatorMap = $mapping->discriminatorMap; } elseif ($discriminatorMap !== $mapping->discriminatorMap) { throw ODMException::queryIncompatibleTypes(); } } if ($type === null) { $type = $thisType; } elseif ($thisType !== $type) { throw ODMException::queryIncompatibleTypes(); } } }
php
protected function validateMappings($mappings, $allowAssociations) { $type = null; foreach ($mappings as $mapping) { //compatible date or number types are identical for our purposes here switch ($mapping->type) { case Type::TIMESTAMP: $thisType = Type::DATE; break; case Type::FLOAT: $thisType = Type::INT; break; default: if (!$mapping->isAssociation()) { $thisType = $mapping->type; break; } if (!$allowAssociations) { throw ODMException::queryOperatorAssociationsNotSupported(static::class); } if ($mapping->isMany()) { if (!isset($collectionType)) { $collectionType = $mapping->type; } elseif ($collectionType !== $mapping->type) { throw ODMException::queryIncompatibleTypes(); } } $thisType = $mapping->association; if (!$mapping->reference) { //embedded documents are serialized according to their class's //mapping - irrespective of any association mapping options - //so no further validation is required here break; } //reference serialization depends on storeAs, targetDocument, //and discriminator options. if (!isset($storeAs)) { $storeAs = $mapping->storeAs; } elseif ($storeAs !== $mapping->storeAs) { throw ODMException::queryIncompatibleTypes(); } if (!isset($targetDoc)) { $targetDoc = $mapping->targetDocument; } elseif ($targetDoc !== $mapping->targetDocument) { throw ODMException::queryIncompatibleTypes(); } if ($targetDoc !== null) { break; } if (!isset($discriminatorAttribute)) { $discriminatorAttribute = $mapping->discriminatorAttribute; } elseif ($discriminatorAttribute !== $mapping->discriminatorAttribute) { throw ODMException::queryIncompatibleTypes(); } if (!isset($discriminatorDefaultValue)) { $discriminatorDefaultValue = $mapping->discriminatorDefaultValue; } elseif ($discriminatorDefaultValue !== $mapping->discriminatorDefaultValue) { throw ODMException::queryIncompatibleTypes(); } if (!isset($discriminatorMap)) { $discriminatorMap = $mapping->discriminatorMap; } elseif ($discriminatorMap !== $mapping->discriminatorMap) { throw ODMException::queryIncompatibleTypes(); } } if ($type === null) { $type = $thisType; } elseif ($thisType !== $type) { throw ODMException::queryIncompatibleTypes(); } } }
[ "protected", "function", "validateMappings", "(", "$", "mappings", ",", "$", "allowAssociations", ")", "{", "$", "type", "=", "null", ";", "foreach", "(", "$", "mappings", "as", "$", "mapping", ")", "{", "//compatible date or number types are identical for our purposes here", "switch", "(", "$", "mapping", "->", "type", ")", "{", "case", "Type", "::", "TIMESTAMP", ":", "$", "thisType", "=", "Type", "::", "DATE", ";", "break", ";", "case", "Type", "::", "FLOAT", ":", "$", "thisType", "=", "Type", "::", "INT", ";", "break", ";", "default", ":", "if", "(", "!", "$", "mapping", "->", "isAssociation", "(", ")", ")", "{", "$", "thisType", "=", "$", "mapping", "->", "type", ";", "break", ";", "}", "if", "(", "!", "$", "allowAssociations", ")", "{", "throw", "ODMException", "::", "queryOperatorAssociationsNotSupported", "(", "static", "::", "class", ")", ";", "}", "if", "(", "$", "mapping", "->", "isMany", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "collectionType", ")", ")", "{", "$", "collectionType", "=", "$", "mapping", "->", "type", ";", "}", "elseif", "(", "$", "collectionType", "!==", "$", "mapping", "->", "type", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "}", "$", "thisType", "=", "$", "mapping", "->", "association", ";", "if", "(", "!", "$", "mapping", "->", "reference", ")", "{", "//embedded documents are serialized according to their class's", "//mapping - irrespective of any association mapping options -", "//so no further validation is required here", "break", ";", "}", "//reference serialization depends on storeAs, targetDocument,", "//and discriminator options.", "if", "(", "!", "isset", "(", "$", "storeAs", ")", ")", "{", "$", "storeAs", "=", "$", "mapping", "->", "storeAs", ";", "}", "elseif", "(", "$", "storeAs", "!==", "$", "mapping", "->", "storeAs", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "targetDoc", ")", ")", "{", "$", "targetDoc", "=", "$", "mapping", "->", "targetDocument", ";", "}", "elseif", "(", "$", "targetDoc", "!==", "$", "mapping", "->", "targetDocument", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "if", "(", "$", "targetDoc", "!==", "null", ")", "{", "break", ";", "}", "if", "(", "!", "isset", "(", "$", "discriminatorAttribute", ")", ")", "{", "$", "discriminatorAttribute", "=", "$", "mapping", "->", "discriminatorAttribute", ";", "}", "elseif", "(", "$", "discriminatorAttribute", "!==", "$", "mapping", "->", "discriminatorAttribute", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "discriminatorDefaultValue", ")", ")", "{", "$", "discriminatorDefaultValue", "=", "$", "mapping", "->", "discriminatorDefaultValue", ";", "}", "elseif", "(", "$", "discriminatorDefaultValue", "!==", "$", "mapping", "->", "discriminatorDefaultValue", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "discriminatorMap", ")", ")", "{", "$", "discriminatorMap", "=", "$", "mapping", "->", "discriminatorMap", ";", "}", "elseif", "(", "$", "discriminatorMap", "!==", "$", "mapping", "->", "discriminatorMap", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "}", "if", "(", "$", "type", "===", "null", ")", "{", "$", "type", "=", "$", "thisType", ";", "}", "elseif", "(", "$", "thisType", "!==", "$", "type", ")", "{", "throw", "ODMException", "::", "queryIncompatibleTypes", "(", ")", ";", "}", "}", "}" ]
Validate that the provided mappings use compatible serialization strategies. Adhere to the fail-fast principle by throwing exceptions here rather than processing nonsensical queries that return misleading results. @param PropertyMetadata[] $mappings @param bool $allowAssociations @return void @throws ODMException
[ "Validate", "that", "the", "provided", "mappings", "use", "compatible", "serialization", "strategies", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Expression/Condition/Operator/Operator.php#L79-L162
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.checkTableExist
public function checkTableExist($table, $con=NULL) { $connection = $this->checkConnection($con); $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); if($query !== false) { return true; } }
php
public function checkTableExist($table, $con=NULL) { $connection = $this->checkConnection($con); $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); if($query !== false) { return true; } }
[ "public", "function", "checkTableExist", "(", "$", "table", ",", "$", "con", "=", "NULL", ")", "{", "$", "connection", "=", "$", "this", "->", "checkConnection", "(", "$", "con", ")", ";", "$", "query", "=", "$", "connection", "->", "query", "(", "\"SELECT 1 FROM {$table} LIMIT 1\"", ")", ";", "if", "(", "$", "query", "!==", "false", ")", "{", "return", "true", ";", "}", "}" ]
checkTableExist Check if table already in the database @param $tablename @param $con @return bool
[ "checkTableExist", "Check", "if", "table", "already", "in", "the", "database" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L128-L136
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.checkTableName
protected static function checkTableName($tableName, $con=NULL) { $connection = self::checkConnection($con); $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); if($query !== false) { return $tableName; } throw new TableDoesNotExistException(); }
php
protected static function checkTableName($tableName, $con=NULL) { $connection = self::checkConnection($con); $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); if($query !== false) { return $tableName; } throw new TableDoesNotExistException(); }
[ "protected", "static", "function", "checkTableName", "(", "$", "tableName", ",", "$", "con", "=", "NULL", ")", "{", "$", "connection", "=", "self", "::", "checkConnection", "(", "$", "con", ")", ";", "$", "query", "=", "$", "connection", "->", "query", "(", "\"SELECT 1 FROM {$tableName} LIMIT 1\"", ")", ";", "if", "(", "$", "query", "!==", "false", ")", "{", "return", "$", "tableName", ";", "}", "throw", "new", "TableDoesNotExistException", "(", ")", ";", "}" ]
checkTableName Return the table name @param $tablename @param $con @return string
[ "checkTableName", "Return", "the", "table", "name" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L146-L156
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.checkColumn
protected static function checkColumn($tableName, $columnName, $con=NULL) { $connection = self::checkConnection($con); $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); $result->execute(); if (! $result->columnCount()) { throw new ColumnNotExistExeption(); } return $columnName; }
php
protected static function checkColumn($tableName, $columnName, $con=NULL) { $connection = self::checkConnection($con); $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); $result->execute(); if (! $result->columnCount()) { throw new ColumnNotExistExeption(); } return $columnName; }
[ "protected", "static", "function", "checkColumn", "(", "$", "tableName", ",", "$", "columnName", ",", "$", "con", "=", "NULL", ")", "{", "$", "connection", "=", "self", "::", "checkConnection", "(", "$", "con", ")", ";", "$", "result", "=", "$", "connection", "->", "prepare", "(", "\"SELECT {$columnName} FROM {$tableName}\"", ")", ";", "$", "result", "->", "execute", "(", ")", ";", "if", "(", "!", "$", "result", "->", "columnCount", "(", ")", ")", "{", "throw", "new", "ColumnNotExistExeption", "(", ")", ";", "}", "return", "$", "columnName", ";", "}" ]
checkColumn Check if column exist in table @param $tableName @param $columnName @param $con @return string
[ "checkColumn", "Check", "if", "column", "exist", "in", "table" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L167-L178
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.buildColumn
protected static function buildColumn($data) { $counter = 0; $insertQuery = ""; $arraySize = count($data); foreach ($data as $key => $value) { $counter++; $insertQuery .= self::sanitize($key); if($arraySize > $counter) $insertQuery .= ", "; } return $insertQuery; }
php
protected static function buildColumn($data) { $counter = 0; $insertQuery = ""; $arraySize = count($data); foreach ($data as $key => $value) { $counter++; $insertQuery .= self::sanitize($key); if($arraySize > $counter) $insertQuery .= ", "; } return $insertQuery; }
[ "protected", "static", "function", "buildColumn", "(", "$", "data", ")", "{", "$", "counter", "=", "0", ";", "$", "insertQuery", "=", "\"\"", ";", "$", "arraySize", "=", "count", "(", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "counter", "++", ";", "$", "insertQuery", ".=", "self", "::", "sanitize", "(", "$", "key", ")", ";", "if", "(", "$", "arraySize", ">", "$", "counter", ")", "$", "insertQuery", ".=", "\", \"", ";", "}", "return", "$", "insertQuery", ";", "}" ]
buildColumn Build the column name @param $data @return string
[ "buildColumn", "Build", "the", "column", "name" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L187-L201
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.buildClause
protected static function buildClause($tableName, $data) { $counter = 0; $updateQuery = ""; $arraySize = count($data); foreach ($data as $key => $value) { $counter++; $columnName = self::checkColumn($tableName, self::sanitize($key)); $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; if ($arraySize > $counter) { $updateQuery .= ", "; } } return $updateQuery; }
php
protected static function buildClause($tableName, $data) { $counter = 0; $updateQuery = ""; $arraySize = count($data); foreach ($data as $key => $value) { $counter++; $columnName = self::checkColumn($tableName, self::sanitize($key)); $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; if ($arraySize > $counter) { $updateQuery .= ", "; } } return $updateQuery; }
[ "protected", "static", "function", "buildClause", "(", "$", "tableName", ",", "$", "data", ")", "{", "$", "counter", "=", "0", ";", "$", "updateQuery", "=", "\"\"", ";", "$", "arraySize", "=", "count", "(", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "counter", "++", ";", "$", "columnName", "=", "self", "::", "checkColumn", "(", "$", "tableName", ",", "self", "::", "sanitize", "(", "$", "key", ")", ")", ";", "$", "updateQuery", ".=", "$", "columnName", ".", "\" = '\"", ".", "self", "::", "sanitize", "(", "$", "value", ")", ".", "\"'\"", ";", "if", "(", "$", "arraySize", ">", "$", "counter", ")", "{", "$", "updateQuery", ".=", "\", \"", ";", "}", "}", "return", "$", "updateQuery", ";", "}" ]
buildClause Build the clause value @param $data @return string
[ "buildClause", "Build", "the", "clause", "value" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L233-L250
train
ibonly/Potato-ORM
src/Database/DatabaseQuery.php
DatabaseQuery.fields
protected function fields() { if (isset($this->fillables)) { $this->output = (sizeof($this->fillables) > 0) ? implode($this->fillables, ',') : '*'; } else { $this->output = '*'; } return $this->output; }
php
protected function fields() { if (isset($this->fillables)) { $this->output = (sizeof($this->fillables) > 0) ? implode($this->fillables, ',') : '*'; } else { $this->output = '*'; } return $this->output; }
[ "protected", "function", "fields", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fillables", ")", ")", "{", "$", "this", "->", "output", "=", "(", "sizeof", "(", "$", "this", "->", "fillables", ")", ">", "0", ")", "?", "implode", "(", "$", "this", "->", "fillables", ",", "','", ")", ":", "'*'", ";", "}", "else", "{", "$", "this", "->", "output", "=", "'*'", ";", "}", "return", "$", "this", "->", "output", ";", "}" ]
Get the fields to be fillables defined in the model @return string
[ "Get", "the", "fields", "to", "be", "fillables", "defined", "in", "the", "model" ]
644962a99e1c0191b732d7729cd466d52c5d8652
https://github.com/ibonly/Potato-ORM/blob/644962a99e1c0191b732d7729cd466d52c5d8652/src/Database/DatabaseQuery.php#L257-L266
train
Wedeto/DB
src/Migrate/Repository.php
Repository.addModule
public function addModule(Module $module) { if ($this->db !== $module->getDB()) throw new MigrationException("The DB instances should be the same"); $name = self::normalizeModule($module->getModule()); $this->modules[$name] = $module; return $this; }
php
public function addModule(Module $module) { if ($this->db !== $module->getDB()) throw new MigrationException("The DB instances should be the same"); $name = self::normalizeModule($module->getModule()); $this->modules[$name] = $module; return $this; }
[ "public", "function", "addModule", "(", "Module", "$", "module", ")", "{", "if", "(", "$", "this", "->", "db", "!==", "$", "module", "->", "getDB", "(", ")", ")", "throw", "new", "MigrationException", "(", "\"The DB instances should be the same\"", ")", ";", "$", "name", "=", "self", "::", "normalizeModule", "(", "$", "module", "->", "getModule", "(", ")", ")", ";", "$", "this", "->", "modules", "[", "$", "name", "]", "=", "$", "module", ";", "return", "$", "this", ";", "}" ]
Register a module that has already been instantiated @param $module The module to register @return Repository Provide fluent interface
[ "Register", "a", "module", "that", "has", "already", "been", "instantiated" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Migrate/Repository.php#L63-L71
train
Wedeto/DB
src/Migrate/Repository.php
Repository.addMigration
public function addMigration(string $module, string $path) { $module = self::normalizeModule($module); if (isset($this->modules[$module])) throw new MigrationException("Duplicate module: " . $module); $instance = new Module($module, $path, $this->db); $this->modules[$module] = $instance; return $instance; }
php
public function addMigration(string $module, string $path) { $module = self::normalizeModule($module); if (isset($this->modules[$module])) throw new MigrationException("Duplicate module: " . $module); $instance = new Module($module, $path, $this->db); $this->modules[$module] = $instance; return $instance; }
[ "public", "function", "addMigration", "(", "string", "$", "module", ",", "string", "$", "path", ")", "{", "$", "module", "=", "self", "::", "normalizeModule", "(", "$", "module", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "modules", "[", "$", "module", "]", ")", ")", "throw", "new", "MigrationException", "(", "\"Duplicate module: \"", ".", "$", "module", ")", ";", "$", "instance", "=", "new", "Module", "(", "$", "module", ",", "$", "path", ",", "$", "this", "->", "db", ")", ";", "$", "this", "->", "modules", "[", "$", "module", "]", "=", "$", "instance", ";", "return", "$", "instance", ";", "}" ]
Add a new migration using a module name and a path The module object will be instantiated and registered. @return Module The module instance
[ "Add", "a", "new", "migration", "using", "a", "module", "name", "and", "a", "path" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Migrate/Repository.php#L80-L89
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/version/VersionService.php
VersionService.getDeploymentRevision
public function getDeploymentRevision() { if ($this->version === false) { $version = $this->cache->get('DeploymentRevision'); if ($version === false) { $version = $this->versionDao->getSystemVersion(); if ($version === false) $version = $this->incrementDeploymentRevision('Initial system version'); $this->cache->put('DeploymentRevision', $version, 0); } $this->version = $version; } return $this->version; }
php
public function getDeploymentRevision() { if ($this->version === false) { $version = $this->cache->get('DeploymentRevision'); if ($version === false) { $version = $this->versionDao->getSystemVersion(); if ($version === false) $version = $this->incrementDeploymentRevision('Initial system version'); $this->cache->put('DeploymentRevision', $version, 0); } $this->version = $version; } return $this->version; }
[ "public", "function", "getDeploymentRevision", "(", ")", "{", "if", "(", "$", "this", "->", "version", "===", "false", ")", "{", "$", "version", "=", "$", "this", "->", "cache", "->", "get", "(", "'DeploymentRevision'", ")", ";", "if", "(", "$", "version", "===", "false", ")", "{", "$", "version", "=", "$", "this", "->", "versionDao", "->", "getSystemVersion", "(", ")", ";", "if", "(", "$", "version", "===", "false", ")", "$", "version", "=", "$", "this", "->", "incrementDeploymentRevision", "(", "'Initial system version'", ")", ";", "$", "this", "->", "cache", "->", "put", "(", "'DeploymentRevision'", ",", "$", "version", ",", "0", ")", ";", "}", "$", "this", "->", "version", "=", "$", "version", ";", "}", "return", "$", "this", "->", "version", ";", "}" ]
Returns the current system version @return integer
[ "Returns", "the", "current", "system", "version" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/version/VersionService.php#L58-L77
train
wb-crowdfusion/crowdfusion
system/core/classes/systemdb/version/VersionService.php
VersionService.incrementDeploymentRevision
public function incrementDeploymentRevision($details = null) { if (!$this->incrementedOnce) { $backtrace = null;//serialize(debug_backtrace()); $version = $this->versionDao->insertSystemVersion($details, $backtrace); $this->Events->trigger('SystemVersion.increment', $version); $this->version = $version; $this->incrementedOnce = true; } else { $this->version = $this->version.'.'.$this->internal++; } $this->cache->delete('DeploymentRevision'); $this->cache->delete('CFVersion'); return $this->version; }
php
public function incrementDeploymentRevision($details = null) { if (!$this->incrementedOnce) { $backtrace = null;//serialize(debug_backtrace()); $version = $this->versionDao->insertSystemVersion($details, $backtrace); $this->Events->trigger('SystemVersion.increment', $version); $this->version = $version; $this->incrementedOnce = true; } else { $this->version = $this->version.'.'.$this->internal++; } $this->cache->delete('DeploymentRevision'); $this->cache->delete('CFVersion'); return $this->version; }
[ "public", "function", "incrementDeploymentRevision", "(", "$", "details", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "incrementedOnce", ")", "{", "$", "backtrace", "=", "null", ";", "//serialize(debug_backtrace());", "$", "version", "=", "$", "this", "->", "versionDao", "->", "insertSystemVersion", "(", "$", "details", ",", "$", "backtrace", ")", ";", "$", "this", "->", "Events", "->", "trigger", "(", "'SystemVersion.increment'", ",", "$", "version", ")", ";", "$", "this", "->", "version", "=", "$", "version", ";", "$", "this", "->", "incrementedOnce", "=", "true", ";", "}", "else", "{", "$", "this", "->", "version", "=", "$", "this", "->", "version", ".", "'.'", ".", "$", "this", "->", "internal", "++", ";", "}", "$", "this", "->", "cache", "->", "delete", "(", "'DeploymentRevision'", ")", ";", "$", "this", "->", "cache", "->", "delete", "(", "'CFVersion'", ")", ";", "return", "$", "this", "->", "version", ";", "}" ]
Increases the current SystemVersion by one should invalidate all cached object which use this version number in their key details are stored in log; details describe circumstance of version update @param string $details A string explaining the reason for the new version @return integer The new version
[ "Increases", "the", "current", "SystemVersion", "by", "one" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/systemdb/version/VersionService.php#L112-L132
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.build
private function build( $pString ) { for ( $i=0; $i < strlen( $pString ); $i++ ) { $this->addChar( $pString[$i] ); } }
php
private function build( $pString ) { for ( $i=0; $i < strlen( $pString ); $i++ ) { $this->addChar( $pString[$i] ); } }
[ "private", "function", "build", "(", "$", "pString", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "pString", ")", ";", "$", "i", "++", ")", "{", "$", "this", "->", "addChar", "(", "$", "pString", "[", "$", "i", "]", ")", ";", "}", "}" ]
Builds the suffix tree off the given string @param string $pString String to build the suffix tree of
[ "Builds", "the", "suffix", "tree", "off", "the", "given", "string" ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L106-L110
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.addSuffixLink
private function addSuffixLink( $pNode ) { if ( $this->needSuffixLink > 0 ) { $this->nodes[$this->needSuffixLink]->link = $pNode; } $this->needSuffixLink = $pNode; }
php
private function addSuffixLink( $pNode ) { if ( $this->needSuffixLink > 0 ) { $this->nodes[$this->needSuffixLink]->link = $pNode; } $this->needSuffixLink = $pNode; }
[ "private", "function", "addSuffixLink", "(", "$", "pNode", ")", "{", "if", "(", "$", "this", "->", "needSuffixLink", ">", "0", ")", "{", "$", "this", "->", "nodes", "[", "$", "this", "->", "needSuffixLink", "]", "->", "link", "=", "$", "pNode", ";", "}", "$", "this", "->", "needSuffixLink", "=", "$", "pNode", ";", "}" ]
Adds the given node as target of the current suffix link @param integer $pNode Index of target node of the suffix link
[ "Adds", "the", "given", "node", "as", "target", "of", "the", "current", "suffix", "link" ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L118-L123
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.newNode
private function newNode( $pStart, $pEnd ) { $this->nodes[++$this->currentNode] = new Node( $pStart, $pEnd, $this->currentNode ); return $this->currentNode; }
php
private function newNode( $pStart, $pEnd ) { $this->nodes[++$this->currentNode] = new Node( $pStart, $pEnd, $this->currentNode ); return $this->currentNode; }
[ "private", "function", "newNode", "(", "$", "pStart", ",", "$", "pEnd", ")", "{", "$", "this", "->", "nodes", "[", "++", "$", "this", "->", "currentNode", "]", "=", "new", "Node", "(", "$", "pStart", ",", "$", "pEnd", ",", "$", "this", "->", "currentNode", ")", ";", "return", "$", "this", "->", "currentNode", ";", "}" ]
Creates as new node with given start and end indexes. Increases the current node by one. @param integer $pStart Start index of node in string represented by this tree @param integer $pEnd End index of node in string represented by this tree @return integer Index of the current node
[ "Creates", "as", "new", "node", "with", "given", "start", "and", "end", "indexes", ".", "Increases", "the", "current", "node", "by", "one", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L159-L163
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.addChar
private function addChar( $pChar ) { $this->text[++$this->position] = $pChar; $this->needSuffixLink = -1; $this->remainder++; while( $this->remainder > 0 ) { if ( $this->activeLength === 0 ) { $this->activeEdge = $this->position; } if ( !array_key_exists( $this->getActiveEdge(), $this->nodes[$this->activeNode]->next ) ) { // suffix does not exist in the parent $leaf = $this->newNode( $this->position, $this->upperBound ); $this->nodes[$this->activeNode]->next[$this->getActiveEdge()] = $leaf; $this->addSuffixLink( $this->activeNode ); } else { $next = $this->nodes[$this->activeNode]->next[$this->getActiveEdge()]; if ( $this->walkDown( $next ) ) { continue; } if ( $this->text[$this->nodes[$next]->start + $this->activeLength] === $pChar ) { $this->activeLength++; $this->addSuffixLink( $this->activeNode ); break; } $split = $this->newNode( $this->nodes[$next]->start, $this->nodes[$next]->start + $this->activeLength ); $this->nodes[$this->activeNode]->next[$this->getActiveEdge()] = $split; $leaf = $this->newNode( $this->position, $this->upperBound ); $this->nodes[$split]->next[$pChar] = $leaf; $this->nodes[$next]->start += $this->activeLength; $this->nodes[$split]->next[$this->text[$this->nodes[$next]->start]] = $next; $this->addSuffixLink( $split ); } $this->remainder--; if ( $this->activeNode == $this->root && $this->activeLength > 0 ) { $this->activeLength--; $this->activeEdge = $this->position - $this->remainder + 1; } else { if ( $this->nodes[$this->activeNode]->link > 0 ) { $this->activeNode = $this->nodes[$this->activeNode]->link; } else { $this->activeNode = $this->root; } } } }
php
private function addChar( $pChar ) { $this->text[++$this->position] = $pChar; $this->needSuffixLink = -1; $this->remainder++; while( $this->remainder > 0 ) { if ( $this->activeLength === 0 ) { $this->activeEdge = $this->position; } if ( !array_key_exists( $this->getActiveEdge(), $this->nodes[$this->activeNode]->next ) ) { // suffix does not exist in the parent $leaf = $this->newNode( $this->position, $this->upperBound ); $this->nodes[$this->activeNode]->next[$this->getActiveEdge()] = $leaf; $this->addSuffixLink( $this->activeNode ); } else { $next = $this->nodes[$this->activeNode]->next[$this->getActiveEdge()]; if ( $this->walkDown( $next ) ) { continue; } if ( $this->text[$this->nodes[$next]->start + $this->activeLength] === $pChar ) { $this->activeLength++; $this->addSuffixLink( $this->activeNode ); break; } $split = $this->newNode( $this->nodes[$next]->start, $this->nodes[$next]->start + $this->activeLength ); $this->nodes[$this->activeNode]->next[$this->getActiveEdge()] = $split; $leaf = $this->newNode( $this->position, $this->upperBound ); $this->nodes[$split]->next[$pChar] = $leaf; $this->nodes[$next]->start += $this->activeLength; $this->nodes[$split]->next[$this->text[$this->nodes[$next]->start]] = $next; $this->addSuffixLink( $split ); } $this->remainder--; if ( $this->activeNode == $this->root && $this->activeLength > 0 ) { $this->activeLength--; $this->activeEdge = $this->position - $this->remainder + 1; } else { if ( $this->nodes[$this->activeNode]->link > 0 ) { $this->activeNode = $this->nodes[$this->activeNode]->link; } else { $this->activeNode = $this->root; } } } }
[ "private", "function", "addChar", "(", "$", "pChar", ")", "{", "$", "this", "->", "text", "[", "++", "$", "this", "->", "position", "]", "=", "$", "pChar", ";", "$", "this", "->", "needSuffixLink", "=", "-", "1", ";", "$", "this", "->", "remainder", "++", ";", "while", "(", "$", "this", "->", "remainder", ">", "0", ")", "{", "if", "(", "$", "this", "->", "activeLength", "===", "0", ")", "{", "$", "this", "->", "activeEdge", "=", "$", "this", "->", "position", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "getActiveEdge", "(", ")", ",", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "next", ")", ")", "{", "// suffix does not exist in the parent", "$", "leaf", "=", "$", "this", "->", "newNode", "(", "$", "this", "->", "position", ",", "$", "this", "->", "upperBound", ")", ";", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "next", "[", "$", "this", "->", "getActiveEdge", "(", ")", "]", "=", "$", "leaf", ";", "$", "this", "->", "addSuffixLink", "(", "$", "this", "->", "activeNode", ")", ";", "}", "else", "{", "$", "next", "=", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "next", "[", "$", "this", "->", "getActiveEdge", "(", ")", "]", ";", "if", "(", "$", "this", "->", "walkDown", "(", "$", "next", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "text", "[", "$", "this", "->", "nodes", "[", "$", "next", "]", "->", "start", "+", "$", "this", "->", "activeLength", "]", "===", "$", "pChar", ")", "{", "$", "this", "->", "activeLength", "++", ";", "$", "this", "->", "addSuffixLink", "(", "$", "this", "->", "activeNode", ")", ";", "break", ";", "}", "$", "split", "=", "$", "this", "->", "newNode", "(", "$", "this", "->", "nodes", "[", "$", "next", "]", "->", "start", ",", "$", "this", "->", "nodes", "[", "$", "next", "]", "->", "start", "+", "$", "this", "->", "activeLength", ")", ";", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "next", "[", "$", "this", "->", "getActiveEdge", "(", ")", "]", "=", "$", "split", ";", "$", "leaf", "=", "$", "this", "->", "newNode", "(", "$", "this", "->", "position", ",", "$", "this", "->", "upperBound", ")", ";", "$", "this", "->", "nodes", "[", "$", "split", "]", "->", "next", "[", "$", "pChar", "]", "=", "$", "leaf", ";", "$", "this", "->", "nodes", "[", "$", "next", "]", "->", "start", "+=", "$", "this", "->", "activeLength", ";", "$", "this", "->", "nodes", "[", "$", "split", "]", "->", "next", "[", "$", "this", "->", "text", "[", "$", "this", "->", "nodes", "[", "$", "next", "]", "->", "start", "]", "]", "=", "$", "next", ";", "$", "this", "->", "addSuffixLink", "(", "$", "split", ")", ";", "}", "$", "this", "->", "remainder", "--", ";", "if", "(", "$", "this", "->", "activeNode", "==", "$", "this", "->", "root", "&&", "$", "this", "->", "activeLength", ">", "0", ")", "{", "$", "this", "->", "activeLength", "--", ";", "$", "this", "->", "activeEdge", "=", "$", "this", "->", "position", "-", "$", "this", "->", "remainder", "+", "1", ";", "}", "else", "{", "if", "(", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "link", ">", "0", ")", "{", "$", "this", "->", "activeNode", "=", "$", "this", "->", "nodes", "[", "$", "this", "->", "activeNode", "]", "->", "link", ";", "}", "else", "{", "$", "this", "->", "activeNode", "=", "$", "this", "->", "root", ";", "}", "}", "}", "}" ]
Adds a single character to the suffix tree. Updates edges as well as nodes @param string $pChar A single character
[ "Adds", "a", "single", "character", "to", "the", "suffix", "tree", ".", "Updates", "edges", "as", "well", "as", "nodes" ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L171-L218
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.getAllSurpriseValues
public function getAllSurpriseValues() { $allSurprises = array(); foreach ( $this->nodes as $node ) { if ( $node->start != -1 && $node->end != -1 ) { $allSurprises[] = $node->surpriseValue; } } return $allSurprises; }
php
public function getAllSurpriseValues() { $allSurprises = array(); foreach ( $this->nodes as $node ) { if ( $node->start != -1 && $node->end != -1 ) { $allSurprises[] = $node->surpriseValue; } } return $allSurprises; }
[ "public", "function", "getAllSurpriseValues", "(", ")", "{", "$", "allSurprises", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "start", "!=", "-", "1", "&&", "$", "node", "->", "end", "!=", "-", "1", ")", "{", "$", "allSurprises", "[", "]", "=", "$", "node", "->", "surpriseValue", ";", "}", "}", "return", "$", "allSurprises", ";", "}" ]
Returns an array containing the surprise values of each node of this tree. @return array The array
[ "Returns", "an", "array", "containing", "the", "surprise", "values", "of", "each", "node", "of", "this", "tree", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L236-L244
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.findSurpriseValue
private function findSurpriseValue( Node $pNode, $pSubstring ) { $length = $pNode->end - $pNode->start; $text = implode('', $this->text); if ( ($pNode->start != -1 && $pNode->end != -1 ) ) { // node is not the root node if ( substr( $text , $pNode->start, $length ) === $pSubstring ) { // found substring return $pNode->surpriseValue; } elseif ( strlen( $pSubstring ) < $length && strlen( $pSubstring ) > 0 ) { // string is only substring of string represented by pNode $substringLength = strlen($pSubstring); for ( $i=0; $i < strlen($text) - $substringLength; $i++ ) { if ( substr( $text, $pNode->start + $i, $substringLength ) === $pSubstring) { return $pNode->surpriseValue; } } } // shorten $pSubstring = substr($pSubstring, $length, strlen($pSubstring)); } // else check childnodes for substring of pSubstring // substring is pSubstring without the letters represented by pNode $ret = $this->upperBound; foreach ( $pNode->next as $childKey => $childValue ) { if ($ret != $this->upperBound) { // we found the substring in another path already return $ret; } // check begin of substring with begin // of string represented by this node if ($childKey !== $pSubstring[0]) { // substring does not start with // the same letter -> check other paths continue; } // found a child starting with the same letter -> check child $childNode = $this->nodes[$childValue]; $childNodeLength = $childNode->end - $childNode->start; $ret = $this->findSurpriseValue( $childNode, $pSubstring ); } return $ret; }
php
private function findSurpriseValue( Node $pNode, $pSubstring ) { $length = $pNode->end - $pNode->start; $text = implode('', $this->text); if ( ($pNode->start != -1 && $pNode->end != -1 ) ) { // node is not the root node if ( substr( $text , $pNode->start, $length ) === $pSubstring ) { // found substring return $pNode->surpriseValue; } elseif ( strlen( $pSubstring ) < $length && strlen( $pSubstring ) > 0 ) { // string is only substring of string represented by pNode $substringLength = strlen($pSubstring); for ( $i=0; $i < strlen($text) - $substringLength; $i++ ) { if ( substr( $text, $pNode->start + $i, $substringLength ) === $pSubstring) { return $pNode->surpriseValue; } } } // shorten $pSubstring = substr($pSubstring, $length, strlen($pSubstring)); } // else check childnodes for substring of pSubstring // substring is pSubstring without the letters represented by pNode $ret = $this->upperBound; foreach ( $pNode->next as $childKey => $childValue ) { if ($ret != $this->upperBound) { // we found the substring in another path already return $ret; } // check begin of substring with begin // of string represented by this node if ($childKey !== $pSubstring[0]) { // substring does not start with // the same letter -> check other paths continue; } // found a child starting with the same letter -> check child $childNode = $this->nodes[$childValue]; $childNodeLength = $childNode->end - $childNode->start; $ret = $this->findSurpriseValue( $childNode, $pSubstring ); } return $ret; }
[ "private", "function", "findSurpriseValue", "(", "Node", "$", "pNode", ",", "$", "pSubstring", ")", "{", "$", "length", "=", "$", "pNode", "->", "end", "-", "$", "pNode", "->", "start", ";", "$", "text", "=", "implode", "(", "''", ",", "$", "this", "->", "text", ")", ";", "if", "(", "(", "$", "pNode", "->", "start", "!=", "-", "1", "&&", "$", "pNode", "->", "end", "!=", "-", "1", ")", ")", "{", "// node is not the root node", "if", "(", "substr", "(", "$", "text", ",", "$", "pNode", "->", "start", ",", "$", "length", ")", "===", "$", "pSubstring", ")", "{", "// found substring", "return", "$", "pNode", "->", "surpriseValue", ";", "}", "elseif", "(", "strlen", "(", "$", "pSubstring", ")", "<", "$", "length", "&&", "strlen", "(", "$", "pSubstring", ")", ">", "0", ")", "{", "// string is only substring of string represented by pNode", "$", "substringLength", "=", "strlen", "(", "$", "pSubstring", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "text", ")", "-", "$", "substringLength", ";", "$", "i", "++", ")", "{", "if", "(", "substr", "(", "$", "text", ",", "$", "pNode", "->", "start", "+", "$", "i", ",", "$", "substringLength", ")", "===", "$", "pSubstring", ")", "{", "return", "$", "pNode", "->", "surpriseValue", ";", "}", "}", "}", "// shorten", "$", "pSubstring", "=", "substr", "(", "$", "pSubstring", ",", "$", "length", ",", "strlen", "(", "$", "pSubstring", ")", ")", ";", "}", "// else check childnodes for substring of pSubstring", "// substring is pSubstring without the letters represented by pNode", "$", "ret", "=", "$", "this", "->", "upperBound", ";", "foreach", "(", "$", "pNode", "->", "next", "as", "$", "childKey", "=>", "$", "childValue", ")", "{", "if", "(", "$", "ret", "!=", "$", "this", "->", "upperBound", ")", "{", "// we found the substring in another path already", "return", "$", "ret", ";", "}", "// check begin of substring with begin ", "// of string represented by this node", "if", "(", "$", "childKey", "!==", "$", "pSubstring", "[", "0", "]", ")", "{", "// substring does not start with ", "// the same letter -> check other paths", "continue", ";", "}", "// found a child starting with the same letter -> check child", "$", "childNode", "=", "$", "this", "->", "nodes", "[", "$", "childValue", "]", ";", "$", "childNodeLength", "=", "$", "childNode", "->", "end", "-", "$", "childNode", "->", "start", ";", "$", "ret", "=", "$", "this", "->", "findSurpriseValue", "(", "$", "childNode", ",", "$", "pSubstring", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Tries to find the surprise value of the given substring in the given node. If not successfull for the given string and a child node starts with the first letter of the given string, it will try its corresponding child. Used in a recursive manner with given node representing the root node at the begin @param Node $pNode Node on which to try to find the given substring @param string $pSubstring String to get occurences of @return integer Amount of surprise for the given substring
[ "Tries", "to", "find", "the", "surprise", "value", "of", "the", "given", "substring", "in", "the", "given", "node", ".", "If", "not", "successfull", "for", "the", "given", "string", "and", "a", "child", "node", "starts", "with", "the", "first", "letter", "of", "the", "given", "string", "it", "will", "try", "its", "corresponding", "child", ".", "Used", "in", "a", "recursive", "manner", "with", "given", "node", "representing", "the", "root", "node", "at", "the", "begin" ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L257-L303
train
rmatil/SAX
lib/Sax/SuffixTree/SuffixTree.php
SuffixTree.hasSubstring
public function hasSubstring( $pSubstring ) { if ( strlen( $pSubstring ) < 1 ) { return -1; } return $this->findSubstring( $this->nodes[$this->root], $pSubstring ); }
php
public function hasSubstring( $pSubstring ) { if ( strlen( $pSubstring ) < 1 ) { return -1; } return $this->findSubstring( $this->nodes[$this->root], $pSubstring ); }
[ "public", "function", "hasSubstring", "(", "$", "pSubstring", ")", "{", "if", "(", "strlen", "(", "$", "pSubstring", ")", "<", "1", ")", "{", "return", "-", "1", ";", "}", "return", "$", "this", "->", "findSubstring", "(", "$", "this", "->", "nodes", "[", "$", "this", "->", "root", "]", ",", "$", "pSubstring", ")", ";", "}" ]
Scan tree for occurences of the given substring. @param string $pSubstring String to check whether it is contained or not @return integer Returns 1 if found, -1 if not
[ "Scan", "tree", "for", "occurences", "of", "the", "given", "substring", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/SuffixTree/SuffixTree.php#L372-L378
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.setSSLKey
public function setSSLKey($certificateFile, $password = null) { if ($password) { $this->options[GuzzleRequestOptions::SSL_KEY] = [$certificateFile, $password]; } else { $this->options[GuzzleRequestOptions::SSL_KEY] = $certificateFile; } }
php
public function setSSLKey($certificateFile, $password = null) { if ($password) { $this->options[GuzzleRequestOptions::SSL_KEY] = [$certificateFile, $password]; } else { $this->options[GuzzleRequestOptions::SSL_KEY] = $certificateFile; } }
[ "public", "function", "setSSLKey", "(", "$", "certificateFile", ",", "$", "password", "=", "null", ")", "{", "if", "(", "$", "password", ")", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "SSL_KEY", "]", "=", "[", "$", "certificateFile", ",", "$", "password", "]", ";", "}", "else", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "SSL_KEY", "]", "=", "$", "certificateFile", ";", "}", "}" ]
Specify the path to a file containing a private SSL key in PEM format. @param string $certificateFile @param null $password
[ "Specify", "the", "path", "to", "a", "file", "containing", "a", "private", "SSL", "key", "in", "PEM", "format", "." ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L83-L90
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.setCertificate
public function setCertificate($certificateFile, $password = null) { if ($password) { $this->options[GuzzleRequestOptions::CERT] = [$certificateFile, $password]; } else { $this->options[GuzzleRequestOptions::CERT] = $certificateFile; } }
php
public function setCertificate($certificateFile, $password = null) { if ($password) { $this->options[GuzzleRequestOptions::CERT] = [$certificateFile, $password]; } else { $this->options[GuzzleRequestOptions::CERT] = $certificateFile; } }
[ "public", "function", "setCertificate", "(", "$", "certificateFile", ",", "$", "password", "=", "null", ")", "{", "if", "(", "$", "password", ")", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "CERT", "]", "=", "[", "$", "certificateFile", ",", "$", "password", "]", ";", "}", "else", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "CERT", "]", "=", "$", "certificateFile", ";", "}", "}" ]
Set to a string to specify the path to a file containing a PEM formatted client side certificate @param string $certificateFile @param null $password
[ "Set", "to", "a", "string", "to", "specify", "the", "path", "to", "a", "file", "containing", "a", "PEM", "formatted", "client", "side", "certificate" ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L98-L105
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.addHeader
public function addHeader($key, $value) { $this->options[GuzzleRequestOptions::HEADERS][$key] = $value; return $this; }
php
public function addHeader($key, $value) { $this->options[GuzzleRequestOptions::HEADERS][$key] = $value; return $this; }
[ "public", "function", "addHeader", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "HEADERS", "]", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Headers to add to the request. @param $key @param $value @return $this
[ "Headers", "to", "add", "to", "the", "request", "." ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L174-L179
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.addQuery
public function addQuery($param, $value) { if (!isset($this->options[GuzzleRequestOptions::QUERY])) { $this->options[GuzzleRequestOptions::QUERY] = []; } if (!is_array($this->options[GuzzleRequestOptions::QUERY])) { throw new \LogicException('The query has been set as string and can`t be modified'); } $this->options[GuzzleRequestOptions::QUERY][$param] = $value; return $this; }
php
public function addQuery($param, $value) { if (!isset($this->options[GuzzleRequestOptions::QUERY])) { $this->options[GuzzleRequestOptions::QUERY] = []; } if (!is_array($this->options[GuzzleRequestOptions::QUERY])) { throw new \LogicException('The query has been set as string and can`t be modified'); } $this->options[GuzzleRequestOptions::QUERY][$param] = $value; return $this; }
[ "public", "function", "addQuery", "(", "$", "param", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "QUERY", "]", ")", ")", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "QUERY", "]", "=", "[", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "QUERY", "]", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'The query has been set as string and can`t be modified'", ")", ";", "}", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "QUERY", "]", "[", "$", "param", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add Query string parameter @param string $param @param mixed $value @return $this
[ "Add", "Query", "string", "parameter" ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L189-L202
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.setAuth
public function setAuth($username, $password, $type = 'basic') { $this->options[GuzzleRequestOptions::AUTH] = [$username, $password, $type]; return $this; }
php
public function setAuth($username, $password, $type = 'basic') { $this->options[GuzzleRequestOptions::AUTH] = [$username, $password, $type]; return $this; }
[ "public", "function", "setAuth", "(", "$", "username", ",", "$", "password", ",", "$", "type", "=", "'basic'", ")", "{", "$", "this", "->", "options", "[", "GuzzleRequestOptions", "::", "AUTH", "]", "=", "[", "$", "username", ",", "$", "password", ",", "$", "type", "]", ";", "return", "$", "this", ";", "}" ]
Specifies HTTP authorization parameters to use with the request This is currently only supported when using the cURL handler. @param string $username @param string $password @param string $type authentication type: "basic" (default), "digest" @return $this
[ "Specifies", "HTTP", "authorization", "parameters", "to", "use", "with", "the", "request" ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L595-L600
train
rafrsr/generic-api
src/Client/RequestOptions.php
RequestOptions.get
public function get($option) { return (isset($this->options[$option]) ? $this->options[$option] : null); }
php
public function get($option) { return (isset($this->options[$option]) ? $this->options[$option] : null); }
[ "public", "function", "get", "(", "$", "option", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "option", "]", ")", "?", "$", "this", "->", "options", "[", "$", "option", "]", ":", "null", ")", ";", "}" ]
Get a option value @param $option @return null
[ "Get", "a", "option", "value" ]
2572d3dcc32e03914cf710f0229d72e1c09ea65b
https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/Client/RequestOptions.php#L620-L623
train
kambalabs/KmbDomain
src/KmbDomain/Model/GroupClass.php
GroupClass.dump
public function dump() { $dump = []; if ($this->hasParameters()) { foreach ($this->parameters as $parameter) { $dump[$parameter->getName()] = $parameter->dump(); } } return $dump; }
php
public function dump() { $dump = []; if ($this->hasParameters()) { foreach ($this->parameters as $parameter) { $dump[$parameter->getName()] = $parameter->dump(); } } return $dump; }
[ "public", "function", "dump", "(", ")", "{", "$", "dump", "=", "[", "]", ";", "if", "(", "$", "this", "->", "hasParameters", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "parameter", ")", "{", "$", "dump", "[", "$", "parameter", "->", "getName", "(", ")", "]", "=", "$", "parameter", "->", "dump", "(", ")", ";", "}", "}", "return", "$", "dump", ";", "}" ]
Dump parameters. @return array
[ "Dump", "parameters", "." ]
b1631bd936c6c6798076b51dfaebd706e1bdc8c2
https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Model/GroupClass.php#L226-L235
train
agentmedia/phine-core
src/Core/Logic/Installation/InstallUtil/Content.php
Content.ClassFile
private function ClassFile() { if (!$this->classFile) { $class = new \ReflectionClass($this); $this->classFile = $class->getFileName(); } return $this->classFile; }
php
private function ClassFile() { if (!$this->classFile) { $class = new \ReflectionClass($this); $this->classFile = $class->getFileName(); } return $this->classFile; }
[ "private", "function", "ClassFile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "classFile", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "this", "->", "classFile", "=", "$", "class", "->", "getFileName", "(", ")", ";", "}", "return", "$", "this", "->", "classFile", ";", "}" ]
The class definition file @return string Returns the path of the file where the content is defined
[ "The", "class", "definition", "file" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/InstallUtil/Content.php#L50-L59
train
agentmedia/phine-core
src/Core/Logic/Installation/InstallUtil/Content.php
Content.Render
function Render() { $templateDir = Path::Combine(__DIR__, 'Templates'); $templateFile = Path::AddExtension(Path::Filename($this->ClassFile()), 'phtml', true); ob_start(); require Path::Combine($templateDir, $templateFile); return ob_get_clean(); }
php
function Render() { $templateDir = Path::Combine(__DIR__, 'Templates'); $templateFile = Path::AddExtension(Path::Filename($this->ClassFile()), 'phtml', true); ob_start(); require Path::Combine($templateDir, $templateFile); return ob_get_clean(); }
[ "function", "Render", "(", ")", "{", "$", "templateDir", "=", "Path", "::", "Combine", "(", "__DIR__", ",", "'Templates'", ")", ";", "$", "templateFile", "=", "Path", "::", "AddExtension", "(", "Path", "::", "Filename", "(", "$", "this", "->", "ClassFile", "(", ")", ")", ",", "'phtml'", ",", "true", ")", ";", "ob_start", "(", ")", ";", "require", "Path", "::", "Combine", "(", "$", "templateDir", ",", "$", "templateFile", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Renders and returns the html output @return string Returns the html of the content
[ "Renders", "and", "returns", "the", "html", "output" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/InstallUtil/Content.php#L81-L88
train
agentmedia/phine-core
src/Core/Logic/Installation/InstallUtil/Content.php
Content.Value
function Value($field, $trim = true) { $result = Request::IsPost() ? Request::PostData($field) : $this->DefaultValue($field); if ($trim) { return trim($result); } return $result; }
php
function Value($field, $trim = true) { $result = Request::IsPost() ? Request::PostData($field) : $this->DefaultValue($field); if ($trim) { return trim($result); } return $result; }
[ "function", "Value", "(", "$", "field", ",", "$", "trim", "=", "true", ")", "{", "$", "result", "=", "Request", "::", "IsPost", "(", ")", "?", "Request", "::", "PostData", "(", "$", "field", ")", ":", "$", "this", "->", "DefaultValue", "(", "$", "field", ")", ";", "if", "(", "$", "trim", ")", "{", "return", "trim", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Gets the value of a field @param string $field The field name @param bool $trim True if the value shall be trimmed by whitespace characters
[ "Gets", "the", "value", "of", "a", "field" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/InstallUtil/Content.php#L138-L146
train
agentmedia/phine-core
src/Core/Logic/Installation/InstallUtil/Content.php
Content.GotoNext
function GotoNext() { $next = Page::NextStep($this->Step()); Response::Redirect(Path::AddExtension($next, 'php')); }
php
function GotoNext() { $next = Page::NextStep($this->Step()); Response::Redirect(Path::AddExtension($next, 'php')); }
[ "function", "GotoNext", "(", ")", "{", "$", "next", "=", "Page", "::", "NextStep", "(", "$", "this", "->", "Step", "(", ")", ")", ";", "Response", "::", "Redirect", "(", "Path", "::", "AddExtension", "(", "$", "next", ",", "'php'", ")", ")", ";", "}" ]
Redirects to the next step
[ "Redirects", "to", "the", "next", "step" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Installation/InstallUtil/Content.php#L160-L164
train
fardus/CRUDBundle
Fardus/Bundle/CrudBundle/Generator/FardusCrudGenerator.php
FardusCrudGenerator.generateDeleteView
protected function generateDeleteView($dir) { $this->renderFile('crud/views/delete.html.twig.twig', $dir.'/delete.html.twig', [ 'route_prefix' => $this->routePrefix, 'route_name_prefix' => $this->routeNamePrefix, 'entity' => $this->entity, 'bundle' => $this->bundle->getName(), 'actions' => $this->actions, ]); }
php
protected function generateDeleteView($dir) { $this->renderFile('crud/views/delete.html.twig.twig', $dir.'/delete.html.twig', [ 'route_prefix' => $this->routePrefix, 'route_name_prefix' => $this->routeNamePrefix, 'entity' => $this->entity, 'bundle' => $this->bundle->getName(), 'actions' => $this->actions, ]); }
[ "protected", "function", "generateDeleteView", "(", "$", "dir", ")", "{", "$", "this", "->", "renderFile", "(", "'crud/views/delete.html.twig.twig'", ",", "$", "dir", ".", "'/delete.html.twig'", ",", "[", "'route_prefix'", "=>", "$", "this", "->", "routePrefix", ",", "'route_name_prefix'", "=>", "$", "this", "->", "routeNamePrefix", ",", "'entity'", "=>", "$", "this", "->", "entity", ",", "'bundle'", "=>", "$", "this", "->", "bundle", "->", "getName", "(", ")", ",", "'actions'", "=>", "$", "this", "->", "actions", ",", "]", ")", ";", "}" ]
Generates the delete.html.twig template in the final bundle. @param string $dir The path to the folder that hosts templates in the bundle
[ "Generates", "the", "delete", ".", "html", ".", "twig", "template", "in", "the", "final", "bundle", "." ]
5d4180f2a1f30da0fc4cbb16a70f656e9e083c5c
https://github.com/fardus/CRUDBundle/blob/5d4180f2a1f30da0fc4cbb16a70f656e9e083c5c/Fardus/Bundle/CrudBundle/Generator/FardusCrudGenerator.php#L156-L165
train
FuzeWorks/Core
src/FuzeWorks/Models.php
Models.get
public function get($modelName, $directory = null) { if (empty($modelName)) { throw new ModelException("Could not load model. No name provided", 1); } // First get the directories where the model can be located $directories = (is_null($directory) ? $this->modelPaths : array($directory)); // Fire a model load event $event = Events::fireEvent('modelLoadEvent', $modelName, $directories); $directories = $event->directories; $modelName = $event->modelName; // If the event is cancelled, stop loading if ($event->isCancelled()) { return false; } // And attempt to load the model return $this->loadModel($modelName, $directories); }
php
public function get($modelName, $directory = null) { if (empty($modelName)) { throw new ModelException("Could not load model. No name provided", 1); } // First get the directories where the model can be located $directories = (is_null($directory) ? $this->modelPaths : array($directory)); // Fire a model load event $event = Events::fireEvent('modelLoadEvent', $modelName, $directories); $directories = $event->directories; $modelName = $event->modelName; // If the event is cancelled, stop loading if ($event->isCancelled()) { return false; } // And attempt to load the model return $this->loadModel($modelName, $directories); }
[ "public", "function", "get", "(", "$", "modelName", ",", "$", "directory", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "modelName", ")", ")", "{", "throw", "new", "ModelException", "(", "\"Could not load model. No name provided\"", ",", "1", ")", ";", "}", "// First get the directories where the model can be located", "$", "directories", "=", "(", "is_null", "(", "$", "directory", ")", "?", "$", "this", "->", "modelPaths", ":", "array", "(", "$", "directory", ")", ")", ";", "// Fire a model load event", "$", "event", "=", "Events", "::", "fireEvent", "(", "'modelLoadEvent'", ",", "$", "modelName", ",", "$", "directories", ")", ";", "$", "directories", "=", "$", "event", "->", "directories", ";", "$", "modelName", "=", "$", "event", "->", "modelName", ";", "// If the event is cancelled, stop loading", "if", "(", "$", "event", "->", "isCancelled", "(", ")", ")", "{", "return", "false", ";", "}", "// And attempt to load the model", "return", "$", "this", "->", "loadModel", "(", "$", "modelName", ",", "$", "directories", ")", ";", "}" ]
Get a model. Supply the name and the model will be loaded from the supplied directory, or from one of the modelPaths (which you can add). @param string $modelName Name of the model @param string|null $directory Directory to load the model from, will ignore $modelPaths @return ModelAbstract|bool The Model object
[ "Get", "a", "model", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Models.php#L75-L98
train