id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
17,200
qcubed/orm
src/Codegen/CodegenBase.php
CodegenBase.dataListItemName
public static function dataListItemName(SqlTable $objTable) { if (($o = $objTable->Options) && isset ($o['ItemName'])) { // Did developer override? return $o['ItemName']; } return QString::wordsFromCamelCase($objTable->ClassName); }
php
public static function dataListItemName(SqlTable $objTable) { if (($o = $objTable->Options) && isset ($o['ItemName'])) { // Did developer override? return $o['ItemName']; } return QString::wordsFromCamelCase($objTable->ClassName); }
[ "public", "static", "function", "dataListItemName", "(", "SqlTable", "$", "objTable", ")", "{", "if", "(", "(", "$", "o", "=", "$", "objTable", "->", "Options", ")", "&&", "isset", "(", "$", "o", "[", "'ItemName'", "]", ")", ")", "{", "// Did developer override?", "return", "$", "o", "[", "'ItemName'", "]", ";", "}", "return", "QString", "::", "wordsFromCamelCase", "(", "$", "objTable", "->", "ClassName", ")", ";", "}" ]
Returns the name of an item in the data list as will be displayed in the edit panel. @param SqlTable $objTable @return string
[ "Returns", "the", "name", "of", "an", "item", "in", "the", "data", "list", "as", "will", "be", "displayed", "in", "the", "edit", "panel", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1026-L1032
17,201
qcubed/orm
src/Codegen/CodegenBase.php
CodegenBase.variableTypeFromDbType
protected function variableTypeFromDbType($strDbType) { switch ($strDbType) { case Database\FieldType::BIT: return Type::BOOLEAN; case Database\FieldType::BLOB: return Type::STRING; case Database\FieldType::CHAR: return Type::STRING; case Database\FieldType::DATE: return Type::DATE_TIME; case Database\FieldType::DATE_TIME: return Type::DATE_TIME; case Database\FieldType::FLOAT: return Type::FLOAT; case Database\FieldType::INTEGER: return Type::INTEGER; case Database\FieldType::TIME: return Type::DATE_TIME; case Database\FieldType::VAR_CHAR: return Type::STRING; case Database\FieldType::JSON: return Type::STRING; default: throw new \Exception("Invalid Db Type to Convert: $strDbType"); } }
php
protected function variableTypeFromDbType($strDbType) { switch ($strDbType) { case Database\FieldType::BIT: return Type::BOOLEAN; case Database\FieldType::BLOB: return Type::STRING; case Database\FieldType::CHAR: return Type::STRING; case Database\FieldType::DATE: return Type::DATE_TIME; case Database\FieldType::DATE_TIME: return Type::DATE_TIME; case Database\FieldType::FLOAT: return Type::FLOAT; case Database\FieldType::INTEGER: return Type::INTEGER; case Database\FieldType::TIME: return Type::DATE_TIME; case Database\FieldType::VAR_CHAR: return Type::STRING; case Database\FieldType::JSON: return Type::STRING; default: throw new \Exception("Invalid Db Type to Convert: $strDbType"); } }
[ "protected", "function", "variableTypeFromDbType", "(", "$", "strDbType", ")", "{", "switch", "(", "$", "strDbType", ")", "{", "case", "Database", "\\", "FieldType", "::", "BIT", ":", "return", "Type", "::", "BOOLEAN", ";", "case", "Database", "\\", "FieldType", "::", "BLOB", ":", "return", "Type", "::", "STRING", ";", "case", "Database", "\\", "FieldType", "::", "CHAR", ":", "return", "Type", "::", "STRING", ";", "case", "Database", "\\", "FieldType", "::", "DATE", ":", "return", "Type", "::", "DATE_TIME", ";", "case", "Database", "\\", "FieldType", "::", "DATE_TIME", ":", "return", "Type", "::", "DATE_TIME", ";", "case", "Database", "\\", "FieldType", "::", "FLOAT", ":", "return", "Type", "::", "FLOAT", ";", "case", "Database", "\\", "FieldType", "::", "INTEGER", ":", "return", "Type", "::", "INTEGER", ";", "case", "Database", "\\", "FieldType", "::", "TIME", ":", "return", "Type", "::", "DATE_TIME", ";", "case", "Database", "\\", "FieldType", "::", "VAR_CHAR", ":", "return", "Type", "::", "STRING", ";", "case", "Database", "\\", "FieldType", "::", "JSON", ":", "return", "Type", "::", "STRING", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "\"Invalid Db Type to Convert: $strDbType\"", ")", ";", "}", "}" ]
Returns the variable type corresponding to the database column type @param string $strDbType @return string @throws \Exception
[ "Returns", "the", "variable", "type", "corresponding", "to", "the", "database", "column", "type" ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1290-L1316
17,202
qcubed/orm
src/Codegen/CodegenBase.php
CodegenBase.pluralize
protected function pluralize($strName) { // Special Rules go Here switch (true) { case (strtolower($strName) == 'play'): return $strName . 's'; } $intLength = strlen($strName); if (substr($strName, $intLength - 1) == "y") { return substr($strName, 0, $intLength - 1) . "ies"; } if (substr($strName, $intLength - 1) == "s") { return $strName . "es"; } if (substr($strName, $intLength - 1) == "x") { return $strName . "es"; } if (substr($strName, $intLength - 1) == "z") { return $strName . "zes"; } if (substr($strName, $intLength - 2) == "sh") { return $strName . "es"; } if (substr($strName, $intLength - 2) == "ch") { return $strName . "es"; } return $strName . "s"; }
php
protected function pluralize($strName) { // Special Rules go Here switch (true) { case (strtolower($strName) == 'play'): return $strName . 's'; } $intLength = strlen($strName); if (substr($strName, $intLength - 1) == "y") { return substr($strName, 0, $intLength - 1) . "ies"; } if (substr($strName, $intLength - 1) == "s") { return $strName . "es"; } if (substr($strName, $intLength - 1) == "x") { return $strName . "es"; } if (substr($strName, $intLength - 1) == "z") { return $strName . "zes"; } if (substr($strName, $intLength - 2) == "sh") { return $strName . "es"; } if (substr($strName, $intLength - 2) == "ch") { return $strName . "es"; } return $strName . "s"; }
[ "protected", "function", "pluralize", "(", "$", "strName", ")", "{", "// Special Rules go Here", "switch", "(", "true", ")", "{", "case", "(", "strtolower", "(", "$", "strName", ")", "==", "'play'", ")", ":", "return", "$", "strName", ".", "'s'", ";", "}", "$", "intLength", "=", "strlen", "(", "$", "strName", ")", ";", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "1", ")", "==", "\"y\"", ")", "{", "return", "substr", "(", "$", "strName", ",", "0", ",", "$", "intLength", "-", "1", ")", ".", "\"ies\"", ";", "}", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "1", ")", "==", "\"s\"", ")", "{", "return", "$", "strName", ".", "\"es\"", ";", "}", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "1", ")", "==", "\"x\"", ")", "{", "return", "$", "strName", ".", "\"es\"", ";", "}", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "1", ")", "==", "\"z\"", ")", "{", "return", "$", "strName", ".", "\"zes\"", ";", "}", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "2", ")", "==", "\"sh\"", ")", "{", "return", "$", "strName", ".", "\"es\"", ";", "}", "if", "(", "substr", "(", "$", "strName", ",", "$", "intLength", "-", "2", ")", "==", "\"ch\"", ")", "{", "return", "$", "strName", ".", "\"es\"", ";", "}", "return", "$", "strName", ".", "\"s\"", ";", "}" ]
Return the plural of the given name. Override this and return the plural version of particular names if this generic version isn't working for you. @param string $strName @return string
[ "Return", "the", "plural", "of", "the", "given", "name", ".", "Override", "this", "and", "return", "the", "plural", "version", "of", "particular", "names", "if", "this", "generic", "version", "isn", "t", "working", "for", "you", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/CodegenBase.php#L1325-L1354
17,203
austinkregel/Warden
src/Warden/Traits/Wardenable.php
Wardenable.toArray
public function toArray() { $attr = !empty($this->getWarden()) ? $this->getWarden() : null; if (empty($attr)) { $attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible(); } $returnable = []; $f_model = \FormModel::using('plain')->withModel($this); foreach ($attr as $old => $new) { if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) { $returnable[$new] = $relations; } if (stripos($old, '_id') !== false) { if (!empty($this->$new)) { $returnable[$new] = $relations; } } else { if (isset($this->$old)) { $returnable[$new] = $this->$old; } } } return $returnable; }
php
public function toArray() { $attr = !empty($this->getWarden()) ? $this->getWarden() : null; if (empty($attr)) { $attr = empty($this->getVisible()) ? $this->getFillable() : $this->getVisible(); } $returnable = []; $f_model = \FormModel::using('plain')->withModel($this); foreach ($attr as $old => $new) { if (!empty($relations = $f_model->getRelationalDataAndModels($this, $old))) { $returnable[$new] = $relations; } if (stripos($old, '_id') !== false) { if (!empty($this->$new)) { $returnable[$new] = $relations; } } else { if (isset($this->$old)) { $returnable[$new] = $this->$old; } } } return $returnable; }
[ "public", "function", "toArray", "(", ")", "{", "$", "attr", "=", "!", "empty", "(", "$", "this", "->", "getWarden", "(", ")", ")", "?", "$", "this", "->", "getWarden", "(", ")", ":", "null", ";", "if", "(", "empty", "(", "$", "attr", ")", ")", "{", "$", "attr", "=", "empty", "(", "$", "this", "->", "getVisible", "(", ")", ")", "?", "$", "this", "->", "getFillable", "(", ")", ":", "$", "this", "->", "getVisible", "(", ")", ";", "}", "$", "returnable", "=", "[", "]", ";", "$", "f_model", "=", "\\", "FormModel", "::", "using", "(", "'plain'", ")", "->", "withModel", "(", "$", "this", ")", ";", "foreach", "(", "$", "attr", "as", "$", "old", "=>", "$", "new", ")", "{", "if", "(", "!", "empty", "(", "$", "relations", "=", "$", "f_model", "->", "getRelationalDataAndModels", "(", "$", "this", ",", "$", "old", ")", ")", ")", "{", "$", "returnable", "[", "$", "new", "]", "=", "$", "relations", ";", "}", "if", "(", "stripos", "(", "$", "old", ",", "'_id'", ")", "!==", "false", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "$", "new", ")", ")", "{", "$", "returnable", "[", "$", "new", "]", "=", "$", "relations", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "$", "old", ")", ")", "{", "$", "returnable", "[", "$", "new", "]", "=", "$", "this", "->", "$", "old", ";", "}", "}", "}", "return", "$", "returnable", ";", "}" ]
Parses the warden config. @return array
[ "Parses", "the", "warden", "config", "." ]
6f5a98bd79a488f0f300f4851061ac6f7d19f8a3
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Traits/Wardenable.php#L36-L61
17,204
ClanCats/Core
src/bundles/Mail/CCMail.php
CCMail.cc
public function cc( $email, $name = null ) { if ( !is_array( $email ) ) { $email = array( $email => $name ); } foreach( $email as $address => $name ) { if ( is_numeric( $address ) && is_string( $name ) ) { $this->cc[$name] = null; } else { $this->cc[$address] = $name; } } return $this; }
php
public function cc( $email, $name = null ) { if ( !is_array( $email ) ) { $email = array( $email => $name ); } foreach( $email as $address => $name ) { if ( is_numeric( $address ) && is_string( $name ) ) { $this->cc[$name] = null; } else { $this->cc[$address] = $name; } } return $this; }
[ "public", "function", "cc", "(", "$", "email", ",", "$", "name", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "email", ")", ")", "{", "$", "email", "=", "array", "(", "$", "email", "=>", "$", "name", ")", ";", "}", "foreach", "(", "$", "email", "as", "$", "address", "=>", "$", "name", ")", "{", "if", "(", "is_numeric", "(", "$", "address", ")", "&&", "is_string", "(", "$", "name", ")", ")", "{", "$", "this", "->", "cc", "[", "$", "name", "]", "=", "null", ";", "}", "else", "{", "$", "this", "->", "cc", "[", "$", "address", "]", "=", "$", "name", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add Carbon copies Works like the 'to' function. @param string $email @param string $name @return self
[ "Add", "Carbon", "copies" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L196-L216
17,205
ClanCats/Core
src/bundles/Mail/CCMail.php
CCMail.send
public function send() { // load the mail configuration $config = \CCConfig::create( 'mail' ); // when mailing is disabled do nothing just return if ( $config->disabled === true ) { return; } // we cannot send a mail without recipients if ( empty( $this->to ) ) { throw new Exception( "Cannot send mail without recipients." ); } // is a catch all enabled? if ( $config->get( 'catch_all.enabled' ) === true ) { // to be able to modify the mail without removing // the user options we have to clone the mail $mail = clone $this; // we have to remove all recipients ( to, ccc, bcc ) and set them // to our catch all recipients $mail->to = array(); $mail->cc = array(); $mail->bcc = array(); $mail->to( $config->get( 'catch_all.addresses' ) ); // transport the cloned mail return $mail->transport( $config->get( 'catch_all.transporter' ) ); } // transport the mail $this->transport(); }
php
public function send() { // load the mail configuration $config = \CCConfig::create( 'mail' ); // when mailing is disabled do nothing just return if ( $config->disabled === true ) { return; } // we cannot send a mail without recipients if ( empty( $this->to ) ) { throw new Exception( "Cannot send mail without recipients." ); } // is a catch all enabled? if ( $config->get( 'catch_all.enabled' ) === true ) { // to be able to modify the mail without removing // the user options we have to clone the mail $mail = clone $this; // we have to remove all recipients ( to, ccc, bcc ) and set them // to our catch all recipients $mail->to = array(); $mail->cc = array(); $mail->bcc = array(); $mail->to( $config->get( 'catch_all.addresses' ) ); // transport the cloned mail return $mail->transport( $config->get( 'catch_all.transporter' ) ); } // transport the mail $this->transport(); }
[ "public", "function", "send", "(", ")", "{", "// load the mail configuration", "$", "config", "=", "\\", "CCConfig", "::", "create", "(", "'mail'", ")", ";", "// when mailing is disabled do nothing just return", "if", "(", "$", "config", "->", "disabled", "===", "true", ")", "{", "return", ";", "}", "// we cannot send a mail without recipients", "if", "(", "empty", "(", "$", "this", "->", "to", ")", ")", "{", "throw", "new", "Exception", "(", "\"Cannot send mail without recipients.\"", ")", ";", "}", "// is a catch all enabled?", "if", "(", "$", "config", "->", "get", "(", "'catch_all.enabled'", ")", "===", "true", ")", "{", "// to be able to modify the mail without removing", "// the user options we have to clone the mail", "$", "mail", "=", "clone", "$", "this", ";", "// we have to remove all recipients ( to, ccc, bcc ) and set them", "// to our catch all recipients", "$", "mail", "->", "to", "=", "array", "(", ")", ";", "$", "mail", "->", "cc", "=", "array", "(", ")", ";", "$", "mail", "->", "bcc", "=", "array", "(", ")", ";", "$", "mail", "->", "to", "(", "$", "config", "->", "get", "(", "'catch_all.addresses'", ")", ")", ";", "// transport the cloned mail", "return", "$", "mail", "->", "transport", "(", "$", "config", "->", "get", "(", "'catch_all.transporter'", ")", ")", ";", "}", "// transport the mail", "$", "this", "->", "transport", "(", ")", ";", "}" ]
Prepare the message for sending to the transport @return void
[ "Prepare", "the", "message", "for", "sending", "to", "the", "transport" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L361-L399
17,206
ClanCats/Core
src/bundles/Mail/CCMail.php
CCMail.transport
protected function transport( $transporter = null ) { if ( !is_null( $transporter ) ) { $transporter = Transporter::create( $transporter ); } else { $transporter = $this->transporter; } // pass the current mail to the transporter $transporter->send( $this ); }
php
protected function transport( $transporter = null ) { if ( !is_null( $transporter ) ) { $transporter = Transporter::create( $transporter ); } else { $transporter = $this->transporter; } // pass the current mail to the transporter $transporter->send( $this ); }
[ "protected", "function", "transport", "(", "$", "transporter", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "transporter", ")", ")", "{", "$", "transporter", "=", "Transporter", "::", "create", "(", "$", "transporter", ")", ";", "}", "else", "{", "$", "transporter", "=", "$", "this", "->", "transporter", ";", "}", "// pass the current mail to the transporter", "$", "transporter", "->", "send", "(", "$", "this", ")", ";", "}" ]
Transport the message @param string $transport Use a diffrent transporter @return void
[ "Transport", "the", "message" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/CCMail.php#L407-L420
17,207
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverBase.php
WebDriverBase.returnExceptionToThrow
public function returnExceptionToThrow($status_code) { static $map = array ( 1 => 'E4xx_IndexOutOfBoundsWebDriverError', 2 => 'E4xx_NoCollectionWebDriverError', 3 => 'E4xx_NoStringWebDriverError', 4 => 'E4xx_NoStringLengthWebDriverError', 5 => 'E4xx_NoStringWrapperWebDriverError', 6 => 'E4xx_NoSuchDriverWebDriverError', 7 => 'E4xx_NoSuchElementWebDriverError', 8 => 'E4xx_NoSuchFrameWebDriverError', 9 => 'E5xx_UnknownCommandWebDriverError', 10 => 'E4xx_ObsoleteElementWebDriverError', 11 => 'E4xx_ElementNotDisplayedWebDriverError', 12 => 'E5xx_InvalidElementStateWebDriverError', 13 => 'E5xx_UnhandledWebDriverError', 14 => 'E4xx_ExpectedWebDriverError', 15 => 'E4xx_ElementNotSelectableWebDriverError', 16 => 'E4xx_NoSuchDocumentWebDriverError', 17 => 'E5xx_UnexpectedJavascriptWebDriverError', 18 => 'E4xx_NoScriptResultWebDriverError', 19 => 'E4xx_XPathLookupWebDriverError', 20 => 'E4xx_NoSuchCollectionWebDriverError', 21 => 'E4xx_TimeOutWebDriverError', 22 => 'E5xx_NullPointerWebDriverError', 23 => 'E4xx_NoSuchWindowWebDriverError', 24 => 'E4xx_InvalidCookieDomainWebDriverError', 25 => 'E4xx_UnableToSetCookieWebDriverError', 26 => 'E4xx_UnexpectedAlertOpenWebDriverError', 27 => 'E4xx_NoAlertOpenWebDriverError', 28 => 'E4xx_ScriptTimeoutWebDriverError', 29 => 'E4xx_InvalidElementCoordinatesWebDriverError', 30 => 'E4xx_IMENotAvailableWebDriverError', 31 => 'E5xx_IMEEngineActivationFailedWebDriverError', 32 => 'E4xx_InvalidSelectorWebDriverError', 33 => 'E5xx_SessionNotCreatedWebDriverError', 34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError', ); // did an error occur? if ($status_code == 0) { return null; } // is this a known problem? if (isset($map[$status_code])) { return __NAMESPACE__ . '\\' . $map[$status_code]; } // we have an unknown exception return __NAMESPACE__ . '\\UnknownWebDriverError'; }
php
public function returnExceptionToThrow($status_code) { static $map = array ( 1 => 'E4xx_IndexOutOfBoundsWebDriverError', 2 => 'E4xx_NoCollectionWebDriverError', 3 => 'E4xx_NoStringWebDriverError', 4 => 'E4xx_NoStringLengthWebDriverError', 5 => 'E4xx_NoStringWrapperWebDriverError', 6 => 'E4xx_NoSuchDriverWebDriverError', 7 => 'E4xx_NoSuchElementWebDriverError', 8 => 'E4xx_NoSuchFrameWebDriverError', 9 => 'E5xx_UnknownCommandWebDriverError', 10 => 'E4xx_ObsoleteElementWebDriverError', 11 => 'E4xx_ElementNotDisplayedWebDriverError', 12 => 'E5xx_InvalidElementStateWebDriverError', 13 => 'E5xx_UnhandledWebDriverError', 14 => 'E4xx_ExpectedWebDriverError', 15 => 'E4xx_ElementNotSelectableWebDriverError', 16 => 'E4xx_NoSuchDocumentWebDriverError', 17 => 'E5xx_UnexpectedJavascriptWebDriverError', 18 => 'E4xx_NoScriptResultWebDriverError', 19 => 'E4xx_XPathLookupWebDriverError', 20 => 'E4xx_NoSuchCollectionWebDriverError', 21 => 'E4xx_TimeOutWebDriverError', 22 => 'E5xx_NullPointerWebDriverError', 23 => 'E4xx_NoSuchWindowWebDriverError', 24 => 'E4xx_InvalidCookieDomainWebDriverError', 25 => 'E4xx_UnableToSetCookieWebDriverError', 26 => 'E4xx_UnexpectedAlertOpenWebDriverError', 27 => 'E4xx_NoAlertOpenWebDriverError', 28 => 'E4xx_ScriptTimeoutWebDriverError', 29 => 'E4xx_InvalidElementCoordinatesWebDriverError', 30 => 'E4xx_IMENotAvailableWebDriverError', 31 => 'E5xx_IMEEngineActivationFailedWebDriverError', 32 => 'E4xx_InvalidSelectorWebDriverError', 33 => 'E5xx_SessionNotCreatedWebDriverError', 34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError', ); // did an error occur? if ($status_code == 0) { return null; } // is this a known problem? if (isset($map[$status_code])) { return __NAMESPACE__ . '\\' . $map[$status_code]; } // we have an unknown exception return __NAMESPACE__ . '\\UnknownWebDriverError'; }
[ "public", "function", "returnExceptionToThrow", "(", "$", "status_code", ")", "{", "static", "$", "map", "=", "array", "(", "1", "=>", "'E4xx_IndexOutOfBoundsWebDriverError'", ",", "2", "=>", "'E4xx_NoCollectionWebDriverError'", ",", "3", "=>", "'E4xx_NoStringWebDriverError'", ",", "4", "=>", "'E4xx_NoStringLengthWebDriverError'", ",", "5", "=>", "'E4xx_NoStringWrapperWebDriverError'", ",", "6", "=>", "'E4xx_NoSuchDriverWebDriverError'", ",", "7", "=>", "'E4xx_NoSuchElementWebDriverError'", ",", "8", "=>", "'E4xx_NoSuchFrameWebDriverError'", ",", "9", "=>", "'E5xx_UnknownCommandWebDriverError'", ",", "10", "=>", "'E4xx_ObsoleteElementWebDriverError'", ",", "11", "=>", "'E4xx_ElementNotDisplayedWebDriverError'", ",", "12", "=>", "'E5xx_InvalidElementStateWebDriverError'", ",", "13", "=>", "'E5xx_UnhandledWebDriverError'", ",", "14", "=>", "'E4xx_ExpectedWebDriverError'", ",", "15", "=>", "'E4xx_ElementNotSelectableWebDriverError'", ",", "16", "=>", "'E4xx_NoSuchDocumentWebDriverError'", ",", "17", "=>", "'E5xx_UnexpectedJavascriptWebDriverError'", ",", "18", "=>", "'E4xx_NoScriptResultWebDriverError'", ",", "19", "=>", "'E4xx_XPathLookupWebDriverError'", ",", "20", "=>", "'E4xx_NoSuchCollectionWebDriverError'", ",", "21", "=>", "'E4xx_TimeOutWebDriverError'", ",", "22", "=>", "'E5xx_NullPointerWebDriverError'", ",", "23", "=>", "'E4xx_NoSuchWindowWebDriverError'", ",", "24", "=>", "'E4xx_InvalidCookieDomainWebDriverError'", ",", "25", "=>", "'E4xx_UnableToSetCookieWebDriverError'", ",", "26", "=>", "'E4xx_UnexpectedAlertOpenWebDriverError'", ",", "27", "=>", "'E4xx_NoAlertOpenWebDriverError'", ",", "28", "=>", "'E4xx_ScriptTimeoutWebDriverError'", ",", "29", "=>", "'E4xx_InvalidElementCoordinatesWebDriverError'", ",", "30", "=>", "'E4xx_IMENotAvailableWebDriverError'", ",", "31", "=>", "'E5xx_IMEEngineActivationFailedWebDriverError'", ",", "32", "=>", "'E4xx_InvalidSelectorWebDriverError'", ",", "33", "=>", "'E5xx_SessionNotCreatedWebDriverError'", ",", "34", "=>", "'E4xx_MoveTargetOutOfBoundsWebDriverError'", ",", ")", ";", "// did an error occur?", "if", "(", "$", "status_code", "==", "0", ")", "{", "return", "null", ";", "}", "// is this a known problem?", "if", "(", "isset", "(", "$", "map", "[", "$", "status_code", "]", ")", ")", "{", "return", "__NAMESPACE__", ".", "'\\\\'", ".", "$", "map", "[", "$", "status_code", "]", ";", "}", "// we have an unknown exception", "return", "__NAMESPACE__", ".", "'\\\\UnknownWebDriverError'", ";", "}" ]
Returns the name of the exception class to throw @param int $status_code the status code returned from webdriver @return string the name of the exception class to throw, or null if no error occurred
[ "Returns", "the", "name", "of", "the", "exception", "class", "to", "throw" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverBase.php#L45-L96
17,208
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverBase.php
WebDriverBase.getHttpVerb
private function getHttpVerb($webdriver_command) { $methods = $this->getMethods(); if (!isset($methods[$webdriver_command])) { throw new E5xx_BadMethodCallWebDriverError(sprintf( '%s is not a valid webdriver command.', $webdriver_command )); } // the first element in the array is the default HTTP verb to use return $methods[$webdriver_command]; }
php
private function getHttpVerb($webdriver_command) { $methods = $this->getMethods(); if (!isset($methods[$webdriver_command])) { throw new E5xx_BadMethodCallWebDriverError(sprintf( '%s is not a valid webdriver command.', $webdriver_command )); } // the first element in the array is the default HTTP verb to use return $methods[$webdriver_command]; }
[ "private", "function", "getHttpVerb", "(", "$", "webdriver_command", ")", "{", "$", "methods", "=", "$", "this", "->", "getMethods", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "methods", "[", "$", "webdriver_command", "]", ")", ")", "{", "throw", "new", "E5xx_BadMethodCallWebDriverError", "(", "sprintf", "(", "'%s is not a valid webdriver command.'", ",", "$", "webdriver_command", ")", ")", ";", "}", "// the first element in the array is the default HTTP verb to use", "return", "$", "methods", "[", "$", "webdriver_command", "]", ";", "}" ]
determine the HTTP verb to use for a given webdriver command @param string $webdriver_command the webdriver command to use @return string the HTTP verb to use
[ "determine", "the", "HTTP", "verb", "to", "use", "for", "a", "given", "webdriver", "command" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverBase.php#L311-L324
17,209
webforge-labs/psc-cms
lib/Psc/CMS/ProjectsFactory.php
ProjectsFactory.getProjectRoot
public function getProjectRoot($name, $mode = Project::MODE_SRC) { /* root entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen dass das projekt in CONFIG[projects.root]/$name/Umsetzung ist wenn der Mode PHAR ist, wird das Phar base Directory genommen wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte @TODO siehe ePaper42 */ if ($mode === Project::MODE_PHAR) { $root = new Dir(PHAR_ROOT); // siehe ProjectBuilder } elseif (($proot = $this->hostConfig->get(array('projects',$name,'root'))) != NULL) $root = new Dir($proot); else $root = $this->getProjectsRoot()->sub($name.'/Umsetzung/'); return $root; }
php
public function getProjectRoot($name, $mode = Project::MODE_SRC) { /* root entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen dass das projekt in CONFIG[projects.root]/$name/Umsetzung ist wenn der Mode PHAR ist, wird das Phar base Directory genommen wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte @TODO siehe ePaper42 */ if ($mode === Project::MODE_PHAR) { $root = new Dir(PHAR_ROOT); // siehe ProjectBuilder } elseif (($proot = $this->hostConfig->get(array('projects',$name,'root'))) != NULL) $root = new Dir($proot); else $root = $this->getProjectsRoot()->sub($name.'/Umsetzung/'); return $root; }
[ "public", "function", "getProjectRoot", "(", "$", "name", ",", "$", "mode", "=", "Project", "::", "MODE_SRC", ")", "{", "/* root\n \n entweder ist projects.$name.root in der host-config gesetzt, oder es wird angenommen\n dass das projekt in\n CONFIG[projects.root]/$name/Umsetzung\n ist\n \n wenn der Mode PHAR ist, wird das Phar base Directory genommen\n \n wir müssen hier noch unterscheiden, wenn das phar aus dem bin verzeichnis aufgerufen werden sollte\n @TODO siehe ePaper42\n */", "if", "(", "$", "mode", "===", "Project", "::", "MODE_PHAR", ")", "{", "$", "root", "=", "new", "Dir", "(", "PHAR_ROOT", ")", ";", "// siehe ProjectBuilder", "}", "elseif", "(", "(", "$", "proot", "=", "$", "this", "->", "hostConfig", "->", "get", "(", "array", "(", "'projects'", ",", "$", "name", ",", "'root'", ")", ")", ")", "!=", "NULL", ")", "$", "root", "=", "new", "Dir", "(", "$", "proot", ")", ";", "else", "$", "root", "=", "$", "this", "->", "getProjectsRoot", "(", ")", "->", "sub", "(", "$", "name", ".", "'/Umsetzung/'", ")", ";", "return", "$", "root", ";", "}" ]
Macht keine Checks ob das Projekt existiert @return Dir
[ "Macht", "keine", "Checks", "ob", "das", "Projekt", "existiert" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ProjectsFactory.php#L134-L155
17,210
spiral-modules/scaffolder
source/Scaffolder/Configs/ScaffolderConfig.php
ScaffolderConfig.parseName
private function parseName(string $name): array { $name = str_replace('/', '\\', $name); if (strpos($name, '\\') !== false) { $names = explode('\\', $name); $class = array_pop($names); return [join('\\', $names), $class]; } //No user namespace return ['', $name]; }
php
private function parseName(string $name): array { $name = str_replace('/', '\\', $name); if (strpos($name, '\\') !== false) { $names = explode('\\', $name); $class = array_pop($names); return [join('\\', $names), $class]; } //No user namespace return ['', $name]; }
[ "private", "function", "parseName", "(", "string", "$", "name", ")", ":", "array", "{", "$", "name", "=", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "name", ")", ";", "if", "(", "strpos", "(", "$", "name", ",", "'\\\\'", ")", "!==", "false", ")", "{", "$", "names", "=", "explode", "(", "'\\\\'", ",", "$", "name", ")", ";", "$", "class", "=", "array_pop", "(", "$", "names", ")", ";", "return", "[", "join", "(", "'\\\\'", ",", "$", "names", ")", ",", "$", "class", "]", ";", "}", "//No user namespace", "return", "[", "''", ",", "$", "name", "]", ";", "}" ]
Split user name into namespace and class name. @param string $name @return array [namespace, name]
[ "Split", "user", "name", "into", "namespace", "and", "class", "name", "." ]
9be9dd0da6e4b02232db24e797fe5c288afbbddf
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Configs/ScaffolderConfig.php#L179-L192
17,211
4devs/ElfinderPhpConnector
Driver/PhotatoesDriver.php
PhotatoesDriver.getGalleryList
private function getGalleryList(Response $response) { $list = $this->manager->getGalleryList(); foreach ($list as $gallery) { /* @var \FDevs\Photatoes\Gallery $gallery */ $file = $this->prepareGallery($gallery); $response->addFile($file); $response->addTreeFile($file); } }
php
private function getGalleryList(Response $response) { $list = $this->manager->getGalleryList(); foreach ($list as $gallery) { /* @var \FDevs\Photatoes\Gallery $gallery */ $file = $this->prepareGallery($gallery); $response->addFile($file); $response->addTreeFile($file); } }
[ "private", "function", "getGalleryList", "(", "Response", "$", "response", ")", "{", "$", "list", "=", "$", "this", "->", "manager", "->", "getGalleryList", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "gallery", ")", "{", "/* @var \\FDevs\\Photatoes\\Gallery $gallery */", "$", "file", "=", "$", "this", "->", "prepareGallery", "(", "$", "gallery", ")", ";", "$", "response", "->", "addFile", "(", "$", "file", ")", ";", "$", "response", "->", "addTreeFile", "(", "$", "file", ")", ";", "}", "}" ]
get Gallery list. @param Response $response
[ "get", "Gallery", "list", "." ]
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L160-L169
17,212
4devs/ElfinderPhpConnector
Driver/PhotatoesDriver.php
PhotatoesDriver.getGallery
private function getGallery(Response $response, $target = '') { if ($target && $gallery = $this->manager->getGallery(basename($target))) { $response->setCwd($this->prepareGallery($gallery)); $images = $gallery->getImages(true); foreach ($images as $img) { $this->addImages( $response, $img, $this->driverOptions['rootName'].DIRECTORY_SEPARATOR.basename($target) ); } } }
php
private function getGallery(Response $response, $target = '') { if ($target && $gallery = $this->manager->getGallery(basename($target))) { $response->setCwd($this->prepareGallery($gallery)); $images = $gallery->getImages(true); foreach ($images as $img) { $this->addImages( $response, $img, $this->driverOptions['rootName'].DIRECTORY_SEPARATOR.basename($target) ); } } }
[ "private", "function", "getGallery", "(", "Response", "$", "response", ",", "$", "target", "=", "''", ")", "{", "if", "(", "$", "target", "&&", "$", "gallery", "=", "$", "this", "->", "manager", "->", "getGallery", "(", "basename", "(", "$", "target", ")", ")", ")", "{", "$", "response", "->", "setCwd", "(", "$", "this", "->", "prepareGallery", "(", "$", "gallery", ")", ")", ";", "$", "images", "=", "$", "gallery", "->", "getImages", "(", "true", ")", ";", "foreach", "(", "$", "images", "as", "$", "img", ")", "{", "$", "this", "->", "addImages", "(", "$", "response", ",", "$", "img", ",", "$", "this", "->", "driverOptions", "[", "'rootName'", "]", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "target", ")", ")", ";", "}", "}", "}" ]
get Gallery. @param Response $response @param string $target
[ "get", "Gallery", "." ]
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L177-L190
17,213
4devs/ElfinderPhpConnector
Driver/PhotatoesDriver.php
PhotatoesDriver.prepareGallery
private function prepareGallery(Gallery $gallery) { $time = $gallery->getUpdatedAt() ? $gallery->getUpdatedAt()->getTimestamp() : time(); $file = new FileInfo($gallery->getName(), $this->driverId, $time, $this->driverOptions['rootName']); $file->setHash( $this->getDriverId().'_'.FileInfo::encode( $this->driverOptions['rootName'].DIRECTORY_SEPARATOR.$gallery->getId() ) ); return $file; }
php
private function prepareGallery(Gallery $gallery) { $time = $gallery->getUpdatedAt() ? $gallery->getUpdatedAt()->getTimestamp() : time(); $file = new FileInfo($gallery->getName(), $this->driverId, $time, $this->driverOptions['rootName']); $file->setHash( $this->getDriverId().'_'.FileInfo::encode( $this->driverOptions['rootName'].DIRECTORY_SEPARATOR.$gallery->getId() ) ); return $file; }
[ "private", "function", "prepareGallery", "(", "Gallery", "$", "gallery", ")", "{", "$", "time", "=", "$", "gallery", "->", "getUpdatedAt", "(", ")", "?", "$", "gallery", "->", "getUpdatedAt", "(", ")", "->", "getTimestamp", "(", ")", ":", "time", "(", ")", ";", "$", "file", "=", "new", "FileInfo", "(", "$", "gallery", "->", "getName", "(", ")", ",", "$", "this", "->", "driverId", ",", "$", "time", ",", "$", "this", "->", "driverOptions", "[", "'rootName'", "]", ")", ";", "$", "file", "->", "setHash", "(", "$", "this", "->", "getDriverId", "(", ")", ".", "'_'", ".", "FileInfo", "::", "encode", "(", "$", "this", "->", "driverOptions", "[", "'rootName'", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "gallery", "->", "getId", "(", ")", ")", ")", ";", "return", "$", "file", ";", "}" ]
prepare Gallery. @param Gallery $gallery @return FileInfo
[ "prepare", "Gallery", "." ]
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L199-L210
17,214
4devs/ElfinderPhpConnector
Driver/PhotatoesDriver.php
PhotatoesDriver.addImage
private function addImage(Response $response, Image $image, $galleryId, $imageSize) { if ($image->get($imageSize)) { $href = $image->get($imageSize)->getHref(); $file = new FileInfo( $image->getTitle().'('.$imageSize.')', $this->getDriverId(), $image->getUpdateAt()->getTimestamp(), $galleryId ); $file->setMime('image/jpeg'); $file->setTmb($image->get($this->driverOptions['thumbSize'])->getHref()); $file->setUrl($href); $file->setPath($href); $response->addFile($file); } }
php
private function addImage(Response $response, Image $image, $galleryId, $imageSize) { if ($image->get($imageSize)) { $href = $image->get($imageSize)->getHref(); $file = new FileInfo( $image->getTitle().'('.$imageSize.')', $this->getDriverId(), $image->getUpdateAt()->getTimestamp(), $galleryId ); $file->setMime('image/jpeg'); $file->setTmb($image->get($this->driverOptions['thumbSize'])->getHref()); $file->setUrl($href); $file->setPath($href); $response->addFile($file); } }
[ "private", "function", "addImage", "(", "Response", "$", "response", ",", "Image", "$", "image", ",", "$", "galleryId", ",", "$", "imageSize", ")", "{", "if", "(", "$", "image", "->", "get", "(", "$", "imageSize", ")", ")", "{", "$", "href", "=", "$", "image", "->", "get", "(", "$", "imageSize", ")", "->", "getHref", "(", ")", ";", "$", "file", "=", "new", "FileInfo", "(", "$", "image", "->", "getTitle", "(", ")", ".", "'('", ".", "$", "imageSize", ".", "')'", ",", "$", "this", "->", "getDriverId", "(", ")", ",", "$", "image", "->", "getUpdateAt", "(", ")", "->", "getTimestamp", "(", ")", ",", "$", "galleryId", ")", ";", "$", "file", "->", "setMime", "(", "'image/jpeg'", ")", ";", "$", "file", "->", "setTmb", "(", "$", "image", "->", "get", "(", "$", "this", "->", "driverOptions", "[", "'thumbSize'", "]", ")", "->", "getHref", "(", ")", ")", ";", "$", "file", "->", "setUrl", "(", "$", "href", ")", ";", "$", "file", "->", "setPath", "(", "$", "href", ")", ";", "$", "response", "->", "addFile", "(", "$", "file", ")", ";", "}", "}" ]
add Image. @param Response $response @param Image $image @param string $galleryId @param string $imageSize
[ "add", "Image", "." ]
510e295dcafeaa0f796986ad87b3ed5f6b0d9338
https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Driver/PhotatoesDriver.php#L236-L252
17,215
qcubed/orm
src/Query/QQ.php
QQ.getVirtualAlias
static public function getVirtualAlias($strName) { $strName = trim($strName); $strName = str_replace(" ", "_", $strName); $strName = strtolower($strName); return $strName; }
php
static public function getVirtualAlias($strName) { $strName = trim($strName); $strName = str_replace(" ", "_", $strName); $strName = strtolower($strName); return $strName; }
[ "static", "public", "function", "getVirtualAlias", "(", "$", "strName", ")", "{", "$", "strName", "=", "trim", "(", "$", "strName", ")", ";", "$", "strName", "=", "str_replace", "(", "\" \"", ",", "\"_\"", ",", "$", "strName", ")", ";", "$", "strName", "=", "strtolower", "(", "$", "strName", ")", ";", "return", "$", "strName", ";", "}" ]
Converts a virtual attribute name to an alias used in the query. The name is converted to an identifier that will work on any SQL database. In the query itself, the name will have two underscores in front of the alias name to prevent conflicts with column names. @param $strName @return mixed|string
[ "Converts", "a", "virtual", "attribute", "name", "to", "an", "alias", "used", "in", "the", "query", ".", "The", "name", "is", "converted", "to", "an", "identifier", "that", "will", "work", "on", "any", "SQL", "database", ".", "In", "the", "query", "itself", "the", "name", "will", "have", "two", "underscores", "in", "front", "of", "the", "alias", "name", "to", "prevent", "conflicts", "with", "column", "names", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L261-L267
17,216
qcubed/orm
src/Query/QQ.php
QQ.extractSelectClause
public static function extractSelectClause($objClauses) { if ($objClauses instanceof Clause\Select) { return $objClauses; } if (is_array($objClauses)) { $hasSelects = false; $objSelect = QQ::select(); foreach ($objClauses as $objClause) { if ($objClause instanceof Clause\Select) { $hasSelects = true; $objSelect->merge($objClause); } } if (!$hasSelects) { return null; } return $objSelect; } return null; }
php
public static function extractSelectClause($objClauses) { if ($objClauses instanceof Clause\Select) { return $objClauses; } if (is_array($objClauses)) { $hasSelects = false; $objSelect = QQ::select(); foreach ($objClauses as $objClause) { if ($objClause instanceof Clause\Select) { $hasSelects = true; $objSelect->merge($objClause); } } if (!$hasSelects) { return null; } return $objSelect; } return null; }
[ "public", "static", "function", "extractSelectClause", "(", "$", "objClauses", ")", "{", "if", "(", "$", "objClauses", "instanceof", "Clause", "\\", "Select", ")", "{", "return", "$", "objClauses", ";", "}", "if", "(", "is_array", "(", "$", "objClauses", ")", ")", "{", "$", "hasSelects", "=", "false", ";", "$", "objSelect", "=", "QQ", "::", "select", "(", ")", ";", "foreach", "(", "$", "objClauses", "as", "$", "objClause", ")", "{", "if", "(", "$", "objClause", "instanceof", "Clause", "\\", "Select", ")", "{", "$", "hasSelects", "=", "true", ";", "$", "objSelect", "->", "merge", "(", "$", "objClause", ")", ";", "}", "}", "if", "(", "!", "$", "hasSelects", ")", "{", "return", "null", ";", "}", "return", "$", "objSelect", ";", "}", "return", "null", ";", "}" ]
Searches for all the Clause\Select clauses and merges them into one clause and returns that clause. Returns null if none found. @param Clause\Base[]|Clause\Base|null $objClauses Clause\Base object or array of Clause\Base objects @return Clause\Select Clause\Select clause containing all the nodes from all the Clause\Select clauses from $objClauses, or null if $objClauses contains no Clause\Select clauses
[ "Searches", "for", "all", "the", "Clause", "\\", "Select", "clauses", "and", "merges", "them", "into", "one", "clause", "and", "returns", "that", "clause", ".", "Returns", "null", "if", "none", "found", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L380-L401
17,217
qcubed/orm
src/Query/QQ.php
QQ.func
static public function func($strName, $param1/** ... */) { $args = func_get_args(); $strFunc = array_shift($args); return new Node\FunctionNode($strFunc, $args); }
php
static public function func($strName, $param1/** ... */) { $args = func_get_args(); $strFunc = array_shift($args); return new Node\FunctionNode($strFunc, $args); }
[ "static", "public", "function", "func", "(", "$", "strName", ",", "$", "param1", "/** ... */", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "strFunc", "=", "array_shift", "(", "$", "args", ")", ";", "return", "new", "Node", "\\", "FunctionNode", "(", "$", "strFunc", ",", "$", "args", ")", ";", "}" ]
Apply an arbitrary scalar function using the given parameters. See below for functions that let you apply common SQL functions. The list below only includes sql operations that are generic to all supported versions of SQL. However, you can call Func directly with any named function that works in your current SQL version, knowing that it might not be cross platform compatible if you ever change SQL engines. @param string $strName The function name, like ABS or POWER @param Node\NodeBase|mixed $param1 The function parameter. Can be a qq node or a number. @return Node\FunctionNode The resulting wrapper node
[ "Apply", "an", "arbitrary", "scalar", "function", "using", "the", "given", "parameters", ".", "See", "below", "for", "functions", "that", "let", "you", "apply", "common", "SQL", "functions", ".", "The", "list", "below", "only", "includes", "sql", "operations", "that", "are", "generic", "to", "all", "supported", "versions", "of", "SQL", ".", "However", "you", "can", "call", "Func", "directly", "with", "any", "named", "function", "that", "works", "in", "your", "current", "SQL", "version", "knowing", "that", "it", "might", "not", "be", "cross", "platform", "compatible", "if", "you", "ever", "change", "SQL", "engines", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L438-L443
17,218
qcubed/orm
src/Query/QQ.php
QQ.mathOp
static public function mathOp($strOperation, $param1/** ... */) { $args = func_get_args(); $strFunc = array_shift($args); return new Node\Math($strFunc, $args); }
php
static public function mathOp($strOperation, $param1/** ... */) { $args = func_get_args(); $strFunc = array_shift($args); return new Node\Math($strFunc, $args); }
[ "static", "public", "function", "mathOp", "(", "$", "strOperation", ",", "$", "param1", "/** ... */", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "strFunc", "=", "array_shift", "(", "$", "args", ")", ";", "return", "new", "Node", "\\", "Math", "(", "$", "strFunc", ",", "$", "args", ")", ";", "}" ]
Apply an arbitrary math operation to 2 or more operands. Operands can be scalar values, or column nodes. @param string $strOperation The operation symbol, like + or * @param Node\NodeBase|mixed $param1 The first parameter @return Node\Math The resulting wrapper node
[ "Apply", "an", "arbitrary", "math", "operation", "to", "2", "or", "more", "operands", ".", "Operands", "can", "be", "scalar", "values", "or", "column", "nodes", "." ]
f320eba671f20874b1f3809c5293f8c02d5b1204
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/QQ.php#L524-L529
17,219
CPSB/Validation-helper
src/FormServiceProvider.php
FormServiceProvider.registerBladeDirectives
protected function registerBladeDirectives() { Blade::directive('form', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php app('Activisme_BE')->model{$expression}; ?>"; }); Blade::directive('input', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->input{$expression}; ?>"; }); Blade::directive('text', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->text{$expression}; ?>"; }); Blade::directive('checkbox', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->checkbox{$expression}; ?>"; }); Blade::directive('radio', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->radio{$expression}; ?>"; }); Blade::directive('options', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->options{$expression}; ?>"; }); Blade::directive('error', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->error{$expression}; ?>"; }); }
php
protected function registerBladeDirectives() { Blade::directive('form', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php app('Activisme_BE')->model{$expression}; ?>"; }); Blade::directive('input', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->input{$expression}; ?>"; }); Blade::directive('text', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->text{$expression}; ?>"; }); Blade::directive('checkbox', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->checkbox{$expression}; ?>"; }); Blade::directive('radio', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->radio{$expression}; ?>"; }); Blade::directive('options', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->options{$expression}; ?>"; }); Blade::directive('error', function ($expression) { $expression = $this->addParenthesis($expression); return "<?php echo app('Activisme_BE')->error{$expression}; ?>"; }); }
[ "protected", "function", "registerBladeDirectives", "(", ")", "{", "Blade", "::", "directive", "(", "'form'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php app('Activisme_BE')->model{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'input'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->input{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'text'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->text{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'checkbox'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->checkbox{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'radio'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->radio{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'options'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->options{$expression}; ?>\"", ";", "}", ")", ";", "Blade", "::", "directive", "(", "'error'", ",", "function", "(", "$", "expression", ")", "{", "$", "expression", "=", "$", "this", "->", "addParenthesis", "(", "$", "expression", ")", ";", "return", "\"<?php echo app('Activisme_BE')->error{$expression}; ?>\"", ";", "}", ")", ";", "}" ]
Register blade directives. @return void
[ "Register", "blade", "directives", "." ]
adb91cb42b7e3c1f88be059a8b4f86de5aba64cc
https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/FormServiceProvider.php#L75-L111
17,220
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Style/Cell.php
PHPWord_Style_Cell.setStyleValue
public function setStyleValue($key, $value) { if($key == '_borderSize') { $this->setBorderSize($value); } elseif($key == '_borderColor') { $this->setBorderColor($value); } else { $this->$key = $value; } }
php
public function setStyleValue($key, $value) { if($key == '_borderSize') { $this->setBorderSize($value); } elseif($key == '_borderColor') { $this->setBorderColor($value); } else { $this->$key = $value; } }
[ "public", "function", "setStyleValue", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", "==", "'_borderSize'", ")", "{", "$", "this", "->", "setBorderSize", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "key", "==", "'_borderColor'", ")", "{", "$", "this", "->", "setBorderColor", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "$", "key", "=", "$", "value", ";", "}", "}" ]
Set style value @var string $key @var mixed $value
[ "Set", "style", "value" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Style/Cell.php#L150-L158
17,221
LeadPages/php_auth_package
src/Auth/LeadpagesLogin.php
LeadpagesLogin.getUser
public function getUser($username, $password) { $authHash = $this->hashUserNameAndPassword($username, $password); $body = json_encode(['clientType' => 'wp-plugin']); try { $response = $this->client->post( $this->loginurl, [ 'headers' => ['Authorization' => 'Basic ' . $authHash], 'verify' => $this->certFile, 'body' => $body //wp-plugin value makes session not expire ]); $this->response = $response->getBody(); } catch (ClientException $e) { $response = [ 'code' => $e->getCode(), 'response' => $e->getMessage(), 'error' => true ]; $this->response = json_encode($response); } catch (ConnectException $e) { $message = 'Can not connect to Leadpages Server:'; $response = $this->parseException($e, $message); $this->response = $response; } return $this; }
php
public function getUser($username, $password) { $authHash = $this->hashUserNameAndPassword($username, $password); $body = json_encode(['clientType' => 'wp-plugin']); try { $response = $this->client->post( $this->loginurl, [ 'headers' => ['Authorization' => 'Basic ' . $authHash], 'verify' => $this->certFile, 'body' => $body //wp-plugin value makes session not expire ]); $this->response = $response->getBody(); } catch (ClientException $e) { $response = [ 'code' => $e->getCode(), 'response' => $e->getMessage(), 'error' => true ]; $this->response = json_encode($response); } catch (ConnectException $e) { $message = 'Can not connect to Leadpages Server:'; $response = $this->parseException($e, $message); $this->response = $response; } return $this; }
[ "public", "function", "getUser", "(", "$", "username", ",", "$", "password", ")", "{", "$", "authHash", "=", "$", "this", "->", "hashUserNameAndPassword", "(", "$", "username", ",", "$", "password", ")", ";", "$", "body", "=", "json_encode", "(", "[", "'clientType'", "=>", "'wp-plugin'", "]", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "loginurl", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Basic '", ".", "$", "authHash", "]", ",", "'verify'", "=>", "$", "this", "->", "certFile", ",", "'body'", "=>", "$", "body", "//wp-plugin value makes session not expire", "]", ")", ";", "$", "this", "->", "response", "=", "$", "response", "->", "getBody", "(", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "$", "response", "=", "[", "'code'", "=>", "$", "e", "->", "getCode", "(", ")", ",", "'response'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'error'", "=>", "true", "]", ";", "$", "this", "->", "response", "=", "json_encode", "(", "$", "response", ")", ";", "}", "catch", "(", "ConnectException", "$", "e", ")", "{", "$", "message", "=", "'Can not connect to Leadpages Server:'", ";", "$", "response", "=", "$", "this", "->", "parseException", "(", "$", "e", ",", "$", "message", ")", ";", "$", "this", "->", "response", "=", "$", "response", ";", "}", "return", "$", "this", ";", "}" ]
get user information @param string $username @param string $password @return array|\GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
[ "get", "user", "information" ]
0294a053ce3d1a13a58fea85b0a14ffc98cf5893
https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L52-L81
17,222
LeadPages/php_auth_package
src/Auth/LeadpagesLogin.php
LeadpagesLogin.createApiKey
public function createApiKey() { if (!isset($this->token)) { return false; } $authHeader = 'LP-Security-Token'; if (stripos($this->token, 'lp ') === 0) { $authHeader = 'Authorization'; } try { $response = $this->client->post($this->keyUrl, [ 'headers' => [ $authHeader => $this->token, 'Content-Type' => 'application/json', ], 'verify' => $this->certFile, 'body' => json_encode(['label' => 'wordpress-plugin']), ]); $body = json_decode($response->getBody(), true); $value = false; if (array_key_exists('value', $body)) { $value = $body['value']; } } catch (ClientException $e) { // token is bad $value = false; } catch (ConnectException $e) { $value = false; } return $value; }
php
public function createApiKey() { if (!isset($this->token)) { return false; } $authHeader = 'LP-Security-Token'; if (stripos($this->token, 'lp ') === 0) { $authHeader = 'Authorization'; } try { $response = $this->client->post($this->keyUrl, [ 'headers' => [ $authHeader => $this->token, 'Content-Type' => 'application/json', ], 'verify' => $this->certFile, 'body' => json_encode(['label' => 'wordpress-plugin']), ]); $body = json_decode($response->getBody(), true); $value = false; if (array_key_exists('value', $body)) { $value = $body['value']; } } catch (ClientException $e) { // token is bad $value = false; } catch (ConnectException $e) { $value = false; } return $value; }
[ "public", "function", "createApiKey", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "token", ")", ")", "{", "return", "false", ";", "}", "$", "authHeader", "=", "'LP-Security-Token'", ";", "if", "(", "stripos", "(", "$", "this", "->", "token", ",", "'lp '", ")", "===", "0", ")", "{", "$", "authHeader", "=", "'Authorization'", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "keyUrl", ",", "[", "'headers'", "=>", "[", "$", "authHeader", "=>", "$", "this", "->", "token", ",", "'Content-Type'", "=>", "'application/json'", ",", "]", ",", "'verify'", "=>", "$", "this", "->", "certFile", ",", "'body'", "=>", "json_encode", "(", "[", "'label'", "=>", "'wordpress-plugin'", "]", ")", ",", "]", ")", ";", "$", "body", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "$", "value", "=", "false", ";", "if", "(", "array_key_exists", "(", "'value'", ",", "$", "body", ")", ")", "{", "$", "value", "=", "$", "body", "[", "'value'", "]", ";", "}", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "// token is bad", "$", "value", "=", "false", ";", "}", "catch", "(", "ConnectException", "$", "e", ")", "{", "$", "value", "=", "false", ";", "}", "return", "$", "value", ";", "}" ]
Create an API key for account @return string|boolean JSON encode key or false
[ "Create", "an", "API", "key", "for", "account" ]
0294a053ce3d1a13a58fea85b0a14ffc98cf5893
https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L88-L125
17,223
LeadPages/php_auth_package
src/Auth/LeadpagesLogin.php
LeadpagesLogin.parseResponse
public function parseResponse($deleteTokenOnFail = false) { $responseArray = json_decode($this->response, true); if (isset($responseArray['error']) && $responseArray['error']) { // token should be unset assumed to be no longer valid unset($this->token); // delete token from data store if param is passed if ($deleteTokenOnFail) { $this->deleteToken(); } return $this->response; } $this->token = $responseArray['securityToken']; return 'success'; }
php
public function parseResponse($deleteTokenOnFail = false) { $responseArray = json_decode($this->response, true); if (isset($responseArray['error']) && $responseArray['error']) { // token should be unset assumed to be no longer valid unset($this->token); // delete token from data store if param is passed if ($deleteTokenOnFail) { $this->deleteToken(); } return $this->response; } $this->token = $responseArray['securityToken']; return 'success'; }
[ "public", "function", "parseResponse", "(", "$", "deleteTokenOnFail", "=", "false", ")", "{", "$", "responseArray", "=", "json_decode", "(", "$", "this", "->", "response", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "responseArray", "[", "'error'", "]", ")", "&&", "$", "responseArray", "[", "'error'", "]", ")", "{", "// token should be unset assumed to be no longer valid", "unset", "(", "$", "this", "->", "token", ")", ";", "// delete token from data store if param is passed", "if", "(", "$", "deleteTokenOnFail", ")", "{", "$", "this", "->", "deleteToken", "(", ")", ";", "}", "return", "$", "this", "->", "response", ";", "}", "$", "this", "->", "token", "=", "$", "responseArray", "[", "'securityToken'", "]", ";", "return", "'success'", ";", "}" ]
Parse response for call to Leadpages Login. If response does not contain a error we will return a response with HttpResponseCode and Message @param bool $deleteTokenOnFail @return string json encoded response for client to handle
[ "Parse", "response", "for", "call", "to", "Leadpages", "Login", ".", "If", "response", "does", "not", "contain", "a", "error", "we", "will", "return", "a", "response", "with", "HttpResponseCode", "and", "Message" ]
0294a053ce3d1a13a58fea85b0a14ffc98cf5893
https://github.com/LeadPages/php_auth_package/blob/0294a053ce3d1a13a58fea85b0a14ffc98cf5893/src/Auth/LeadpagesLogin.php#L135-L149
17,224
tigris-php/telegram-bot-api
src/Types/Updates/Update.php
Update.detectType
protected static function detectType(array $data) { foreach ([ self::TYPE_MESSAGE, self::TYPE_EDITED_MESSAGE, self::TYPE_CHANNEL_POST, self::TYPE_EDITED_CHANNEL_POST, self::TYPE_INLINE_QUERY, self::TYPE_CHOSEN_INLINE_RESULT, self::TYPE_CALLBACK_QUERY, ] as $type) { if (isset($data[$type])) { return $type; } } return static::TYPE_UNKNOWN; }
php
protected static function detectType(array $data) { foreach ([ self::TYPE_MESSAGE, self::TYPE_EDITED_MESSAGE, self::TYPE_CHANNEL_POST, self::TYPE_EDITED_CHANNEL_POST, self::TYPE_INLINE_QUERY, self::TYPE_CHOSEN_INLINE_RESULT, self::TYPE_CALLBACK_QUERY, ] as $type) { if (isset($data[$type])) { return $type; } } return static::TYPE_UNKNOWN; }
[ "protected", "static", "function", "detectType", "(", "array", "$", "data", ")", "{", "foreach", "(", "[", "self", "::", "TYPE_MESSAGE", ",", "self", "::", "TYPE_EDITED_MESSAGE", ",", "self", "::", "TYPE_CHANNEL_POST", ",", "self", "::", "TYPE_EDITED_CHANNEL_POST", ",", "self", "::", "TYPE_INLINE_QUERY", ",", "self", "::", "TYPE_CHOSEN_INLINE_RESULT", ",", "self", "::", "TYPE_CALLBACK_QUERY", ",", "]", "as", "$", "type", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "type", "]", ")", ")", "{", "return", "$", "type", ";", "}", "}", "return", "static", "::", "TYPE_UNKNOWN", ";", "}" ]
Detects update type @param $data @return string
[ "Detects", "update", "type" ]
7350c81d571387005d58079d8c654ee44504cdcf
https://github.com/tigris-php/telegram-bot-api/blob/7350c81d571387005d58079d8c654ee44504cdcf/src/Types/Updates/Update.php#L66-L82
17,225
ClanCats/Core
src/classes/CCRequest.php
CCRequest.perform
public function perform() { // set the input if ( !is_null( $this->input ) ) { CCIn::instance( $this->input ); } else { CCIn::instance( CCServer::instance() ); } // set current request static::$_current =& $this; // route is invalid show 404 if ( !$this->route instanceof CCRoute ) { $this->route = CCRouter::resolve( '#404' ); } /* * call wake events * if one event returns an response all other calls will be skipped also events! */ foreach( CCRouter::events_matching( 'wake', $this->route->uri ) as $callback ) { if ( ( $return = CCContainer::call( $callback ) ) instanceof CCResponse ) { $this->response = $return; return $this; } } /* * a closure */ if ( !is_array( $this->route->callback ) && is_callable( $this->route->callback ) ) { // execute and capture the output ob_start(); // run the closure $return = call_user_func_array( $this->route->callback, $this->route->params ); // catch the output $output = ob_get_clean(); // do we got a response? if ( !$return instanceof CCResponse ) { // if not create one with the captured output $return = CCResponse::create( $output ); } } /* * a callback */ elseif ( is_callable( $this->route->callback ) ) { // execute the callback and get the return $return = call_user_func_array( $this->route->callback, array( $this->route->action, $this->route->params ) ); // do we got a response? if ( !$return instanceof CCResponse ) { // if not create one with the return as string $return = CCResponse::create( (string) $return ); } } /* * 404 error if nothing */ else { $return = CCResponse::error( 404 ); } // set the response $this->response = $return; /* * call sleep events * if one event returns an response all other calls will be skipped also events! */ foreach( CCRouter::events_matching( 'sleep', $this->route->uri ) as $callback ) { if ( $return = CCContainer::call( $callback, $this->response ) instanceof CCResponse ) { $this->response = $return; return $this; } } return $this; }
php
public function perform() { // set the input if ( !is_null( $this->input ) ) { CCIn::instance( $this->input ); } else { CCIn::instance( CCServer::instance() ); } // set current request static::$_current =& $this; // route is invalid show 404 if ( !$this->route instanceof CCRoute ) { $this->route = CCRouter::resolve( '#404' ); } /* * call wake events * if one event returns an response all other calls will be skipped also events! */ foreach( CCRouter::events_matching( 'wake', $this->route->uri ) as $callback ) { if ( ( $return = CCContainer::call( $callback ) ) instanceof CCResponse ) { $this->response = $return; return $this; } } /* * a closure */ if ( !is_array( $this->route->callback ) && is_callable( $this->route->callback ) ) { // execute and capture the output ob_start(); // run the closure $return = call_user_func_array( $this->route->callback, $this->route->params ); // catch the output $output = ob_get_clean(); // do we got a response? if ( !$return instanceof CCResponse ) { // if not create one with the captured output $return = CCResponse::create( $output ); } } /* * a callback */ elseif ( is_callable( $this->route->callback ) ) { // execute the callback and get the return $return = call_user_func_array( $this->route->callback, array( $this->route->action, $this->route->params ) ); // do we got a response? if ( !$return instanceof CCResponse ) { // if not create one with the return as string $return = CCResponse::create( (string) $return ); } } /* * 404 error if nothing */ else { $return = CCResponse::error( 404 ); } // set the response $this->response = $return; /* * call sleep events * if one event returns an response all other calls will be skipped also events! */ foreach( CCRouter::events_matching( 'sleep', $this->route->uri ) as $callback ) { if ( $return = CCContainer::call( $callback, $this->response ) instanceof CCResponse ) { $this->response = $return; return $this; } } return $this; }
[ "public", "function", "perform", "(", ")", "{", "// set the input", "if", "(", "!", "is_null", "(", "$", "this", "->", "input", ")", ")", "{", "CCIn", "::", "instance", "(", "$", "this", "->", "input", ")", ";", "}", "else", "{", "CCIn", "::", "instance", "(", "CCServer", "::", "instance", "(", ")", ")", ";", "}", "// set current request", "static", "::", "$", "_current", "=", "&", "$", "this", ";", "// route is invalid show 404", "if", "(", "!", "$", "this", "->", "route", "instanceof", "CCRoute", ")", "{", "$", "this", "->", "route", "=", "CCRouter", "::", "resolve", "(", "'#404'", ")", ";", "}", "/*\n\t\t * call wake events\n\t\t * if one event returns an response all other calls will be skipped also events!\n\t\t */", "foreach", "(", "CCRouter", "::", "events_matching", "(", "'wake'", ",", "$", "this", "->", "route", "->", "uri", ")", "as", "$", "callback", ")", "{", "if", "(", "(", "$", "return", "=", "CCContainer", "::", "call", "(", "$", "callback", ")", ")", "instanceof", "CCResponse", ")", "{", "$", "this", "->", "response", "=", "$", "return", ";", "return", "$", "this", ";", "}", "}", "/*\n\t\t * a closure\n\t\t */", "if", "(", "!", "is_array", "(", "$", "this", "->", "route", "->", "callback", ")", "&&", "is_callable", "(", "$", "this", "->", "route", "->", "callback", ")", ")", "{", "// execute and capture the output", "ob_start", "(", ")", ";", "// run the closure ", "$", "return", "=", "call_user_func_array", "(", "$", "this", "->", "route", "->", "callback", ",", "$", "this", "->", "route", "->", "params", ")", ";", "// catch the output", "$", "output", "=", "ob_get_clean", "(", ")", ";", "// do we got a response?", "if", "(", "!", "$", "return", "instanceof", "CCResponse", ")", "{", "// if not create one with the captured output", "$", "return", "=", "CCResponse", "::", "create", "(", "$", "output", ")", ";", "}", "}", "/*\n\t\t * a callback\n\t\t */", "elseif", "(", "is_callable", "(", "$", "this", "->", "route", "->", "callback", ")", ")", "{", "// execute the callback and get the return", "$", "return", "=", "call_user_func_array", "(", "$", "this", "->", "route", "->", "callback", ",", "array", "(", "$", "this", "->", "route", "->", "action", ",", "$", "this", "->", "route", "->", "params", ")", ")", ";", "// do we got a response?", "if", "(", "!", "$", "return", "instanceof", "CCResponse", ")", "{", "// if not create one with the return as string", "$", "return", "=", "CCResponse", "::", "create", "(", "(", "string", ")", "$", "return", ")", ";", "}", "}", "/*\n\t\t * 404 error if nothing\n\t\t */", "else", "{", "$", "return", "=", "CCResponse", "::", "error", "(", "404", ")", ";", "}", "// set the response", "$", "this", "->", "response", "=", "$", "return", ";", "/*\n\t\t * call sleep events\n\t\t * if one event returns an response all other calls will be skipped also events!\n\t\t */", "foreach", "(", "CCRouter", "::", "events_matching", "(", "'sleep'", ",", "$", "this", "->", "route", "->", "uri", ")", "as", "$", "callback", ")", "{", "if", "(", "$", "return", "=", "CCContainer", "::", "call", "(", "$", "callback", ",", "$", "this", "->", "response", ")", "instanceof", "CCResponse", ")", "{", "$", "this", "->", "response", "=", "$", "return", ";", "return", "$", "this", ";", "}", "}", "return", "$", "this", ";", "}" ]
Execute the Request @param array $action @param array $params @return self
[ "Execute", "the", "Request" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRequest.php#L110-L199
17,226
PortaText/php-sdk
src/PortaText/Command/Api/CreditCards.php
CreditCards.cardInfo
public function cardInfo($number, $expirationDate, $code) { $this->setArgument('card_number', $number); $this->setArgument('card_expiration_date', $expirationDate); return $this->setArgument('card_code', $code); }
php
public function cardInfo($number, $expirationDate, $code) { $this->setArgument('card_number', $number); $this->setArgument('card_expiration_date', $expirationDate); return $this->setArgument('card_code', $code); }
[ "public", "function", "cardInfo", "(", "$", "number", ",", "$", "expirationDate", ",", "$", "code", ")", "{", "$", "this", "->", "setArgument", "(", "'card_number'", ",", "$", "number", ")", ";", "$", "this", "->", "setArgument", "(", "'card_expiration_date'", ",", "$", "expirationDate", ")", ";", "return", "$", "this", "->", "setArgument", "(", "'card_code'", ",", "$", "code", ")", ";", "}" ]
Set card information. @param string $number The card number. @param string $expirationDate In format: YYYY-MM. @param string $code The card security code. @return PortaText\Command\ICommand
[ "Set", "card", "information", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CreditCards.php#L55-L60
17,227
PortaText/php-sdk
src/PortaText/Command/Api/CreditCards.php
CreditCards.address
public function address($streetAddress, $city, $state, $zip, $country) { $this->setArgument('address', $streetAddress); $this->setArgument('city', $city); $this->setArgument('state', $state); $this->setArgument('zip', $zip); return $this->setArgument('country', $country); }
php
public function address($streetAddress, $city, $state, $zip, $country) { $this->setArgument('address', $streetAddress); $this->setArgument('city', $city); $this->setArgument('state', $state); $this->setArgument('zip', $zip); return $this->setArgument('country', $country); }
[ "public", "function", "address", "(", "$", "streetAddress", ",", "$", "city", ",", "$", "state", ",", "$", "zip", ",", "$", "country", ")", "{", "$", "this", "->", "setArgument", "(", "'address'", ",", "$", "streetAddress", ")", ";", "$", "this", "->", "setArgument", "(", "'city'", ",", "$", "city", ")", ";", "$", "this", "->", "setArgument", "(", "'state'", ",", "$", "state", ")", ";", "$", "this", "->", "setArgument", "(", "'zip'", ",", "$", "zip", ")", ";", "return", "$", "this", "->", "setArgument", "(", "'country'", ",", "$", "country", ")", ";", "}" ]
Set card billing address. @param string $streetAddress The full street address. @param string $city The city name. @param string $state The state name. @param string $zip The ZIP code. @param string $country The country name. @return PortaText\Command\ICommand
[ "Set", "card", "billing", "address", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CreditCards.php#L73-L80
17,228
danrevah/shortify-punit
src/Stub/WhenChainCase.php
WhenChainCase.createChainArrayOfReturnValues
private function createChainArrayOfReturnValues($action, $response) { // Pop first method $methods = $this->methods; $firstMethod = array_pop($methods); $lastValue = $response; $mockClassType = get_class($this->mockClass); if ( ! $this->mockClass instanceof MockInterface) { throw self::generateException('Class is not implementing MockInterface.'); } $mockClassInstanceId = $this->mockClass->getShortifyPunitInstanceId(); foreach($methods as $currentMethod) { $fakeClass = new MockClassOnTheFly(); // extracting methods before the current method into an array $chainedMethodsBefore = $this->extractChainedMethodsBefore( array_reverse($this->methods), $currentMethod ); // adding to the ShortifyPunit chained method response $this->addChainedMethodResponse( $chainedMethodsBefore, $currentMethod, $action, $lastValue, $mockClassInstanceId ); $currentMethodName = key($currentMethod); // closure for MockOnTheFly chained methods $fakeClass->$currentMethodName = function() use ( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod ) { return ShortifyPunit::createChainResponse( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, func_get_args() ); }; $lastValue = $fakeClass; // except from the last method all other chained method `returns` a calls so set the action for the next loop $action = MockAction::RETURNS; } $whenCase = new WhenCase($mockClassType, $this->mockClass->getShortifyPunitInstanceId(), key($firstMethod)); $whenCase->setMethod(current($firstMethod), $action, $lastValue); }
php
private function createChainArrayOfReturnValues($action, $response) { // Pop first method $methods = $this->methods; $firstMethod = array_pop($methods); $lastValue = $response; $mockClassType = get_class($this->mockClass); if ( ! $this->mockClass instanceof MockInterface) { throw self::generateException('Class is not implementing MockInterface.'); } $mockClassInstanceId = $this->mockClass->getShortifyPunitInstanceId(); foreach($methods as $currentMethod) { $fakeClass = new MockClassOnTheFly(); // extracting methods before the current method into an array $chainedMethodsBefore = $this->extractChainedMethodsBefore( array_reverse($this->methods), $currentMethod ); // adding to the ShortifyPunit chained method response $this->addChainedMethodResponse( $chainedMethodsBefore, $currentMethod, $action, $lastValue, $mockClassInstanceId ); $currentMethodName = key($currentMethod); // closure for MockOnTheFly chained methods $fakeClass->$currentMethodName = function() use ( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod ) { return ShortifyPunit::createChainResponse( $mockClassInstanceId, $mockClassType, $chainedMethodsBefore, $currentMethod, func_get_args() ); }; $lastValue = $fakeClass; // except from the last method all other chained method `returns` a calls so set the action for the next loop $action = MockAction::RETURNS; } $whenCase = new WhenCase($mockClassType, $this->mockClass->getShortifyPunitInstanceId(), key($firstMethod)); $whenCase->setMethod(current($firstMethod), $action, $lastValue); }
[ "private", "function", "createChainArrayOfReturnValues", "(", "$", "action", ",", "$", "response", ")", "{", "// Pop first method", "$", "methods", "=", "$", "this", "->", "methods", ";", "$", "firstMethod", "=", "array_pop", "(", "$", "methods", ")", ";", "$", "lastValue", "=", "$", "response", ";", "$", "mockClassType", "=", "get_class", "(", "$", "this", "->", "mockClass", ")", ";", "if", "(", "!", "$", "this", "->", "mockClass", "instanceof", "MockInterface", ")", "{", "throw", "self", "::", "generateException", "(", "'Class is not implementing MockInterface.'", ")", ";", "}", "$", "mockClassInstanceId", "=", "$", "this", "->", "mockClass", "->", "getShortifyPunitInstanceId", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "currentMethod", ")", "{", "$", "fakeClass", "=", "new", "MockClassOnTheFly", "(", ")", ";", "// extracting methods before the current method into an array", "$", "chainedMethodsBefore", "=", "$", "this", "->", "extractChainedMethodsBefore", "(", "array_reverse", "(", "$", "this", "->", "methods", ")", ",", "$", "currentMethod", ")", ";", "// adding to the ShortifyPunit chained method response", "$", "this", "->", "addChainedMethodResponse", "(", "$", "chainedMethodsBefore", ",", "$", "currentMethod", ",", "$", "action", ",", "$", "lastValue", ",", "$", "mockClassInstanceId", ")", ";", "$", "currentMethodName", "=", "key", "(", "$", "currentMethod", ")", ";", "// closure for MockOnTheFly chained methods", "$", "fakeClass", "->", "$", "currentMethodName", "=", "function", "(", ")", "use", "(", "$", "mockClassInstanceId", ",", "$", "mockClassType", ",", "$", "chainedMethodsBefore", ",", "$", "currentMethod", ")", "{", "return", "ShortifyPunit", "::", "createChainResponse", "(", "$", "mockClassInstanceId", ",", "$", "mockClassType", ",", "$", "chainedMethodsBefore", ",", "$", "currentMethod", ",", "func_get_args", "(", ")", ")", ";", "}", ";", "$", "lastValue", "=", "$", "fakeClass", ";", "// except from the last method all other chained method `returns` a calls so set the action for the next loop", "$", "action", "=", "MockAction", "::", "RETURNS", ";", "}", "$", "whenCase", "=", "new", "WhenCase", "(", "$", "mockClassType", ",", "$", "this", "->", "mockClass", "->", "getShortifyPunitInstanceId", "(", ")", ",", "key", "(", "$", "firstMethod", ")", ")", ";", "$", "whenCase", "->", "setMethod", "(", "current", "(", "$", "firstMethod", ")", ",", "$", "action", ",", "$", "lastValue", ")", ";", "}" ]
Creating a chain array of return values @param $action @param $response
[ "Creating", "a", "chain", "array", "of", "return", "values" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenChainCase.php#L59-L122
17,229
danrevah/shortify-punit
src/Stub/WhenChainCase.php
WhenChainCase.extractChainedMethodsBefore
private function extractChainedMethodsBefore($methods, $currentMethod) { $chainedMethodsBefore = []; $currentMethodName = key($currentMethod); foreach ($methods as $method) { $methodName = key($method); if ($methodName == $currentMethodName) { break; } $chainedMethodsBefore[] = $method; } return $chainedMethodsBefore; }
php
private function extractChainedMethodsBefore($methods, $currentMethod) { $chainedMethodsBefore = []; $currentMethodName = key($currentMethod); foreach ($methods as $method) { $methodName = key($method); if ($methodName == $currentMethodName) { break; } $chainedMethodsBefore[] = $method; } return $chainedMethodsBefore; }
[ "private", "function", "extractChainedMethodsBefore", "(", "$", "methods", ",", "$", "currentMethod", ")", "{", "$", "chainedMethodsBefore", "=", "[", "]", ";", "$", "currentMethodName", "=", "key", "(", "$", "currentMethod", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "methodName", "=", "key", "(", "$", "method", ")", ";", "if", "(", "$", "methodName", "==", "$", "currentMethodName", ")", "{", "break", ";", "}", "$", "chainedMethodsBefore", "[", "]", "=", "$", "method", ";", "}", "return", "$", "chainedMethodsBefore", ";", "}" ]
Extracting chained methods before current method into an array @param $methods @param $currentMethod @return array
[ "Extracting", "chained", "methods", "before", "current", "method", "into", "an", "array" ]
cedd08f31de8e7409a07d2630701ef4e924cc5f0
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Stub/WhenChainCase.php#L162-L179
17,230
joomlatools/joomlatools-platform-legacy
code/base/tree.php
JTree.addChild
public function addChild(&$node, $setCurrent = false) { JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated'); $this->_current->addChild($node); if ($setCurrent) { $this->_current = &$node; } }
php
public function addChild(&$node, $setCurrent = false) { JLog::add('JTree::addChild() is deprecated.', JLog::WARNING, 'deprecated'); $this->_current->addChild($node); if ($setCurrent) { $this->_current = &$node; } }
[ "public", "function", "addChild", "(", "&", "$", "node", ",", "$", "setCurrent", "=", "false", ")", "{", "JLog", "::", "add", "(", "'JTree::addChild() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "this", "->", "_current", "->", "addChild", "(", "$", "node", ")", ";", "if", "(", "$", "setCurrent", ")", "{", "$", "this", "->", "_current", "=", "&", "$", "node", ";", "}", "}" ]
Method to add a child @param array &$node The node to process @param boolean $setCurrent True to set as current working node @return mixed @since 11.1
[ "Method", "to", "add", "a", "child" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/tree.php#L60-L70
17,231
joomlatools/joomlatools-platform-legacy
code/base/tree.php
JTree.getParent
public function getParent() { JLog::add('JTree::getParent() is deprecated.', JLog::WARNING, 'deprecated'); $this->_current = &$this->_current->getParent(); }
php
public function getParent() { JLog::add('JTree::getParent() is deprecated.', JLog::WARNING, 'deprecated'); $this->_current = &$this->_current->getParent(); }
[ "public", "function", "getParent", "(", ")", "{", "JLog", "::", "add", "(", "'JTree::getParent() is deprecated.'", ",", "JLog", "::", "WARNING", ",", "'deprecated'", ")", ";", "$", "this", "->", "_current", "=", "&", "$", "this", "->", "_current", "->", "getParent", "(", ")", ";", "}" ]
Method to get the parent @return void @since 11.1
[ "Method", "to", "get", "the", "parent" ]
3a76944e2f2c415faa6504754c75321a3b478c06
https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/base/tree.php#L79-L84
17,232
CakeCMS/Core
src/Helper/Manager.php
Manager.addNamespace
public function addNamespace($name) { if (!Arr::in($name, self::$_namespace)) { self::$_namespace[] = $name; return true; } return false; }
php
public function addNamespace($name) { if (!Arr::in($name, self::$_namespace)) { self::$_namespace[] = $name; return true; } return false; }
[ "public", "function", "addNamespace", "(", "$", "name", ")", "{", "if", "(", "!", "Arr", "::", "in", "(", "$", "name", ",", "self", "::", "$", "_namespace", ")", ")", "{", "self", "::", "$", "_namespace", "[", "]", "=", "$", "name", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add new helper group namespace. @param string $name @return bool
[ "Add", "new", "helper", "group", "namespace", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L71-L79
17,233
CakeCMS/Core
src/Helper/Manager.php
Manager._register
protected function _register($id, $className) { $id = (string) $id; if (class_exists($className)) { self::$_loaded[$id] = $className; $this[$id] = function () use ($className) { return new $className(); }; } else { throw new Exception("Helper \"{{$className}}\" not found!"); } }
php
protected function _register($id, $className) { $id = (string) $id; if (class_exists($className)) { self::$_loaded[$id] = $className; $this[$id] = function () use ($className) { return new $className(); }; } else { throw new Exception("Helper \"{{$className}}\" not found!"); } }
[ "protected", "function", "_register", "(", "$", "id", ",", "$", "className", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "self", "::", "$", "_loaded", "[", "$", "id", "]", "=", "$", "className", ";", "$", "this", "[", "$", "id", "]", "=", "function", "(", ")", "use", "(", "$", "className", ")", "{", "return", "new", "$", "className", "(", ")", ";", "}", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Helper \\\"{{$className}}\\\" not found!\"", ")", ";", "}", "}" ]
Register helper class. @param string $id @param $className
[ "Register", "helper", "class", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L104-L115
17,234
CakeCMS/Core
src/Helper/Manager.php
Manager._getClassName
protected function _getClassName($class) { $class = Str::low($class); list ($plugin, $className) = pluginSplit($class); $return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX; if ($plugin !== null) { return Inflector::camelize($plugin) . '\\' . $return; } return Configure::read('App.namespace') . '\\' . $return; }
php
protected function _getClassName($class) { $class = Str::low($class); list ($plugin, $className) = pluginSplit($class); $return = self::HELPER_SUFFIX . '\\' . Inflector::camelize($className) . self::HELPER_SUFFIX; if ($plugin !== null) { return Inflector::camelize($plugin) . '\\' . $return; } return Configure::read('App.namespace') . '\\' . $return; }
[ "protected", "function", "_getClassName", "(", "$", "class", ")", "{", "$", "class", "=", "Str", "::", "low", "(", "$", "class", ")", ";", "list", "(", "$", "plugin", ",", "$", "className", ")", "=", "pluginSplit", "(", "$", "class", ")", ";", "$", "return", "=", "self", "::", "HELPER_SUFFIX", ".", "'\\\\'", ".", "Inflector", "::", "camelize", "(", "$", "className", ")", ".", "self", "::", "HELPER_SUFFIX", ";", "if", "(", "$", "plugin", "!==", "null", ")", "{", "return", "Inflector", "::", "camelize", "(", "$", "plugin", ")", ".", "'\\\\'", ".", "$", "return", ";", "}", "return", "Configure", "::", "read", "(", "'App.namespace'", ")", ".", "'\\\\'", ".", "$", "return", ";", "}" ]
Get current helper class name. @param string $class @return string
[ "Get", "current", "helper", "class", "name", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Helper/Manager.php#L123-L133
17,235
afrittella/back-project
src/app/Traits/Sluggable.php
Sluggable.createSlug
public function createSlug($value, $id = 0) { $slug = str_slug($value); $relatedSlugs = $this->getRelatedSlugs($slug, $id); if (!$relatedSlugs->contains('slug', $slug)) { return $slug; } $completed = false; $i = 1; while ($completed == false) { $newSlug = $slug .'-'.$i; if (!$relatedSlugs->contains('slug', $newSlug)) { return $newSlug; } $i++; } return $slug; }
php
public function createSlug($value, $id = 0) { $slug = str_slug($value); $relatedSlugs = $this->getRelatedSlugs($slug, $id); if (!$relatedSlugs->contains('slug', $slug)) { return $slug; } $completed = false; $i = 1; while ($completed == false) { $newSlug = $slug .'-'.$i; if (!$relatedSlugs->contains('slug', $newSlug)) { return $newSlug; } $i++; } return $slug; }
[ "public", "function", "createSlug", "(", "$", "value", ",", "$", "id", "=", "0", ")", "{", "$", "slug", "=", "str_slug", "(", "$", "value", ")", ";", "$", "relatedSlugs", "=", "$", "this", "->", "getRelatedSlugs", "(", "$", "slug", ",", "$", "id", ")", ";", "if", "(", "!", "$", "relatedSlugs", "->", "contains", "(", "'slug'", ",", "$", "slug", ")", ")", "{", "return", "$", "slug", ";", "}", "$", "completed", "=", "false", ";", "$", "i", "=", "1", ";", "while", "(", "$", "completed", "==", "false", ")", "{", "$", "newSlug", "=", "$", "slug", ".", "'-'", ".", "$", "i", ";", "if", "(", "!", "$", "relatedSlugs", "->", "contains", "(", "'slug'", ",", "$", "newSlug", ")", ")", "{", "return", "$", "newSlug", ";", "}", "$", "i", "++", ";", "}", "return", "$", "slug", ";", "}" ]
Create a unique slug @param $value @param $id @return string
[ "Create", "a", "unique", "slug" ]
e1aa2e3ee03d453033f75a4b16f073c60b5f32d1
https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Traits/Sluggable.php#L12-L34
17,236
afrittella/back-project
src/app/Traits/Sluggable.php
Sluggable.getRelatedSlugs
protected function getRelatedSlugs($slug, $id = 0) { return $this->select('slug')->where('slug', 'like', $slug.'%')->where('id', '<>', $id)->get(); }
php
protected function getRelatedSlugs($slug, $id = 0) { return $this->select('slug')->where('slug', 'like', $slug.'%')->where('id', '<>', $id)->get(); }
[ "protected", "function", "getRelatedSlugs", "(", "$", "slug", ",", "$", "id", "=", "0", ")", "{", "return", "$", "this", "->", "select", "(", "'slug'", ")", "->", "where", "(", "'slug'", ",", "'like'", ",", "$", "slug", ".", "'%'", ")", "->", "where", "(", "'id'", ",", "'<>'", ",", "$", "id", ")", "->", "get", "(", ")", ";", "}" ]
Get similar slugs @param $slug @param $id @return mixed
[ "Get", "similar", "slugs" ]
e1aa2e3ee03d453033f75a4b16f073c60b5f32d1
https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Traits/Sluggable.php#L42-L45
17,237
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRole.php
BaseUserRole.setUser
public function setUser(User $v = null) { if ($v === null) { $this->setUserId(NULL); } else { $this->setUserId($v->getId()); } $this->aUser = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the User object, it will not be re-added. if ($v !== null) { $v->addUserRole($this); } return $this; }
php
public function setUser(User $v = null) { if ($v === null) { $this->setUserId(NULL); } else { $this->setUserId($v->getId()); } $this->aUser = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the User object, it will not be re-added. if ($v !== null) { $v->addUserRole($this); } return $this; }
[ "public", "function", "setUser", "(", "User", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setUserId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setUserId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aUser", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the User object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addUserRole", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a User object. @param User $v @return UserRole The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "User", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L868-L886
17,238
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRole.php
BaseUserRole.getUser
public function getUser(PropelPDO $con = null, $doQuery = true) { if ($this->aUser === null && ($this->user_id !== null) && $doQuery) { $this->aUser = UserQuery::create()->findPk($this->user_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aUser->addUserRoles($this); */ } return $this->aUser; }
php
public function getUser(PropelPDO $con = null, $doQuery = true) { if ($this->aUser === null && ($this->user_id !== null) && $doQuery) { $this->aUser = UserQuery::create()->findPk($this->user_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aUser->addUserRoles($this); */ } return $this->aUser; }
[ "public", "function", "getUser", "(", "PropelPDO", "$", "con", "=", "null", ",", "$", "doQuery", "=", "true", ")", "{", "if", "(", "$", "this", "->", "aUser", "===", "null", "&&", "(", "$", "this", "->", "user_id", "!==", "null", ")", "&&", "$", "doQuery", ")", "{", "$", "this", "->", "aUser", "=", "UserQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "user_id", ",", "$", "con", ")", ";", "/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aUser->addUserRoles($this);\n */", "}", "return", "$", "this", "->", "aUser", ";", "}" ]
Get the associated User object @param PropelPDO $con Optional Connection object. @param $doQuery Executes a query to get the object if required @return User The associated User object. @throws PropelException
[ "Get", "the", "associated", "User", "object" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L897-L911
17,239
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRole.php
BaseUserRole.setRole
public function setRole(Role $v = null) { if ($v === null) { $this->setRoleId(NULL); } else { $this->setRoleId($v->getId()); } $this->aRole = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Role object, it will not be re-added. if ($v !== null) { $v->addUserRole($this); } return $this; }
php
public function setRole(Role $v = null) { if ($v === null) { $this->setRoleId(NULL); } else { $this->setRoleId($v->getId()); } $this->aRole = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Role object, it will not be re-added. if ($v !== null) { $v->addUserRole($this); } return $this; }
[ "public", "function", "setRole", "(", "Role", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setRoleId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setRoleId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aRole", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the Role object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addUserRole", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a Role object. @param Role $v @return UserRole The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "Role", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L920-L938
17,240
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRole.php
BaseUserRole.getRole
public function getRole(PropelPDO $con = null, $doQuery = true) { if ($this->aRole === null && ($this->role_id !== null) && $doQuery) { $this->aRole = RoleQuery::create()->findPk($this->role_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aRole->addUserRoles($this); */ } return $this->aRole; }
php
public function getRole(PropelPDO $con = null, $doQuery = true) { if ($this->aRole === null && ($this->role_id !== null) && $doQuery) { $this->aRole = RoleQuery::create()->findPk($this->role_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aRole->addUserRoles($this); */ } return $this->aRole; }
[ "public", "function", "getRole", "(", "PropelPDO", "$", "con", "=", "null", ",", "$", "doQuery", "=", "true", ")", "{", "if", "(", "$", "this", "->", "aRole", "===", "null", "&&", "(", "$", "this", "->", "role_id", "!==", "null", ")", "&&", "$", "doQuery", ")", "{", "$", "this", "->", "aRole", "=", "RoleQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "role_id", ",", "$", "con", ")", ";", "/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aRole->addUserRoles($this);\n */", "}", "return", "$", "this", "->", "aRole", ";", "}" ]
Get the associated Role object @param PropelPDO $con Optional Connection object. @param $doQuery Executes a query to get the object if required @return Role The associated Role object. @throws PropelException
[ "Get", "the", "associated", "Role", "object" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRole.php#L949-L963
17,241
dashifen/wordpress-php7-plugin-boilerplate
src/Controller/ControllerTraits/PostTypesTrait.php
PostTypesTrait.initPostTypesTrait
final protected function initPostTypesTrait() { add_action("init", function () { $postTypes = $this->getPostTypes(); foreach ($postTypes as $postType) { $this->registerPostType($postType); } }); }
php
final protected function initPostTypesTrait() { add_action("init", function () { $postTypes = $this->getPostTypes(); foreach ($postTypes as $postType) { $this->registerPostType($postType); } }); }
[ "final", "protected", "function", "initPostTypesTrait", "(", ")", "{", "add_action", "(", "\"init\"", ",", "function", "(", ")", "{", "$", "postTypes", "=", "$", "this", "->", "getPostTypes", "(", ")", ";", "foreach", "(", "$", "postTypes", "as", "$", "postType", ")", "{", "$", "this", "->", "registerPostType", "(", "$", "postType", ")", ";", "}", "}", ")", ";", "}" ]
Called automatically when the plugins are loaded, this method registers our post types for the users of this boilerplate. @return void
[ "Called", "automatically", "when", "the", "plugins", "are", "loaded", "this", "method", "registers", "our", "post", "types", "for", "the", "users", "of", "this", "boilerplate", "." ]
c7875deb403d311efca72dc3c8beb566972a56cb
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/PostTypesTrait.php#L82-L89
17,242
anime-db/app-bundle
src/Event/Listener/Package.php
Package.onUpdated
public function onUpdated(UpdatedEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $this->addPackage($event->getPackage()); } }
php
public function onUpdated(UpdatedEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $this->addPackage($event->getPackage()); } }
[ "public", "function", "onUpdated", "(", "UpdatedEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getType", "(", ")", "==", "self", "::", "PLUGIN_TYPE", ")", "{", "$", "this", "->", "addPackage", "(", "$", "event", "->", "getPackage", "(", ")", ")", ";", "}", "}" ]
Update plugin data. @param UpdatedEvent $event
[ "Update", "plugin", "data", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L85-L90
17,243
anime-db/app-bundle
src/Event/Listener/Package.php
Package.onInstalled
public function onInstalled(InstalledEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $this->addPackage($event->getPackage()); } }
php
public function onInstalled(InstalledEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $this->addPackage($event->getPackage()); } }
[ "public", "function", "onInstalled", "(", "InstalledEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getType", "(", ")", "==", "self", "::", "PLUGIN_TYPE", ")", "{", "$", "this", "->", "addPackage", "(", "$", "event", "->", "getPackage", "(", ")", ")", ";", "}", "}" ]
Registr plugin. @param InstalledEvent $event
[ "Registr", "plugin", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L97-L102
17,244
anime-db/app-bundle
src/Event/Listener/Package.php
Package.addPackage
protected function addPackage(ComposerPackage $package) { $plugin = $this->rep->find($package->getName()); // create new plugin if not exists if (!$plugin) { $plugin = new Plugin(); $plugin->setName($package->getName()); } list($vendor, $package) = explode('/', $plugin->getName()); try { $data = $this->client->getPlugin($vendor, $package); $plugin->setTitle($data['title'])->setDescription($data['description']); if ($data['logo']) { $this->downloader->entity($data['logo'], $plugin, true); } } catch (\Exception $e) { // is not a critical error } $this->em->persist($plugin); $this->em->flush(); }
php
protected function addPackage(ComposerPackage $package) { $plugin = $this->rep->find($package->getName()); // create new plugin if not exists if (!$plugin) { $plugin = new Plugin(); $plugin->setName($package->getName()); } list($vendor, $package) = explode('/', $plugin->getName()); try { $data = $this->client->getPlugin($vendor, $package); $plugin->setTitle($data['title'])->setDescription($data['description']); if ($data['logo']) { $this->downloader->entity($data['logo'], $plugin, true); } } catch (\Exception $e) { // is not a critical error } $this->em->persist($plugin); $this->em->flush(); }
[ "protected", "function", "addPackage", "(", "ComposerPackage", "$", "package", ")", "{", "$", "plugin", "=", "$", "this", "->", "rep", "->", "find", "(", "$", "package", "->", "getName", "(", ")", ")", ";", "// create new plugin if not exists", "if", "(", "!", "$", "plugin", ")", "{", "$", "plugin", "=", "new", "Plugin", "(", ")", ";", "$", "plugin", "->", "setName", "(", "$", "package", "->", "getName", "(", ")", ")", ";", "}", "list", "(", "$", "vendor", ",", "$", "package", ")", "=", "explode", "(", "'/'", ",", "$", "plugin", "->", "getName", "(", ")", ")", ";", "try", "{", "$", "data", "=", "$", "this", "->", "client", "->", "getPlugin", "(", "$", "vendor", ",", "$", "package", ")", ";", "$", "plugin", "->", "setTitle", "(", "$", "data", "[", "'title'", "]", ")", "->", "setDescription", "(", "$", "data", "[", "'description'", "]", ")", ";", "if", "(", "$", "data", "[", "'logo'", "]", ")", "{", "$", "this", "->", "downloader", "->", "entity", "(", "$", "data", "[", "'logo'", "]", ",", "$", "plugin", ",", "true", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// is not a critical error", "}", "$", "this", "->", "em", "->", "persist", "(", "$", "plugin", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
Add plugin from package. @param ComposerPackage $package
[ "Add", "plugin", "from", "package", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L109-L133
17,245
anime-db/app-bundle
src/Event/Listener/Package.php
Package.onRemoved
public function onRemoved(RemovedEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $plugin = $this->rep->find($event->getPackage()->getName()); if ($plugin) { $this->em->remove($plugin); $this->em->flush(); } } }
php
public function onRemoved(RemovedEvent $event) { if ($event->getPackage()->getType() == self::PLUGIN_TYPE) { $plugin = $this->rep->find($event->getPackage()->getName()); if ($plugin) { $this->em->remove($plugin); $this->em->flush(); } } }
[ "public", "function", "onRemoved", "(", "RemovedEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getType", "(", ")", "==", "self", "::", "PLUGIN_TYPE", ")", "{", "$", "plugin", "=", "$", "this", "->", "rep", "->", "find", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "plugin", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "plugin", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "}", "}" ]
Unregistr plugin. @param RemovedEvent $event
[ "Unregistr", "plugin", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L140-L150
17,246
anime-db/app-bundle
src/Event/Listener/Package.php
Package.onInstalledConfigureShmop
public function onInstalledConfigureShmop(InstalledEvent $event) { // use Shmop as driver for Cache Time Keeper if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) { $this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.multi'); $this->parameters->set('cache_time_keeper.driver.multi.fast', 'cache_time_keeper.driver.shmop'); } }
php
public function onInstalledConfigureShmop(InstalledEvent $event) { // use Shmop as driver for Cache Time Keeper if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) { $this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.multi'); $this->parameters->set('cache_time_keeper.driver.multi.fast', 'cache_time_keeper.driver.shmop'); } }
[ "public", "function", "onInstalledConfigureShmop", "(", "InstalledEvent", "$", "event", ")", "{", "// use Shmop as driver for Cache Time Keeper", "if", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getName", "(", ")", "==", "self", "::", "PACKAGE_SHMOP", ")", "{", "$", "this", "->", "parameters", "->", "set", "(", "'cache_time_keeper.driver'", ",", "'cache_time_keeper.driver.multi'", ")", ";", "$", "this", "->", "parameters", "->", "set", "(", "'cache_time_keeper.driver.multi.fast'", ",", "'cache_time_keeper.driver.shmop'", ")", ";", "}", "}" ]
Configure shmop. @param InstalledEvent $event
[ "Configure", "shmop", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L157-L164
17,247
anime-db/app-bundle
src/Event/Listener/Package.php
Package.onRemovedShmop
public function onRemovedShmop(RemovedEvent $event) { if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) { $this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.file'); } }
php
public function onRemovedShmop(RemovedEvent $event) { if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) { $this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.file'); } }
[ "public", "function", "onRemovedShmop", "(", "RemovedEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getPackage", "(", ")", "->", "getName", "(", ")", "==", "self", "::", "PACKAGE_SHMOP", ")", "{", "$", "this", "->", "parameters", "->", "set", "(", "'cache_time_keeper.driver'", ",", "'cache_time_keeper.driver.file'", ")", ";", "}", "}" ]
Restore config on removed shmop. @param RemovedEvent $event
[ "Restore", "config", "on", "removed", "shmop", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Package.php#L171-L176
17,248
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/SimpleSemafor.php
SimpleSemafor.lock
public function lock() { if (!$this->isLocked()) { $file = fopen($this->getFilePath(), 'w'); if ($file) { fwrite($file, getmypid()); fclose($file); return true; } } return false; }
php
public function lock() { if (!$this->isLocked()) { $file = fopen($this->getFilePath(), 'w'); if ($file) { fwrite($file, getmypid()); fclose($file); return true; } } return false; }
[ "public", "function", "lock", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isLocked", "(", ")", ")", "{", "$", "file", "=", "fopen", "(", "$", "this", "->", "getFilePath", "(", ")", ",", "'w'", ")", ";", "if", "(", "$", "file", ")", "{", "fwrite", "(", "$", "file", ",", "getmypid", "(", ")", ")", ";", "fclose", "(", "$", "file", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Try create semafor file @return bool When successful locked
[ "Try", "create", "semafor", "file" ]
4e1769ab6411a584112df1151dcc90e6b82fe2bb
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/SimpleSemafor.php#L23-L34
17,249
mmieluch/laravel-serve-custom-ini
src/ServeCommand.php
ServeCommand.buildCommand
protected function buildCommand($binary, $host, $port, $base) { $binary = $this->handleCustomIni($binary); $base = str_replace("'", '', $base); $command = "{$binary} -S {$host}:{$port} {$base}/server.php"; return $command; }
php
protected function buildCommand($binary, $host, $port, $base) { $binary = $this->handleCustomIni($binary); $base = str_replace("'", '', $base); $command = "{$binary} -S {$host}:{$port} {$base}/server.php"; return $command; }
[ "protected", "function", "buildCommand", "(", "$", "binary", ",", "$", "host", ",", "$", "port", ",", "$", "base", ")", "{", "$", "binary", "=", "$", "this", "->", "handleCustomIni", "(", "$", "binary", ")", ";", "$", "base", "=", "str_replace", "(", "\"'\"", ",", "''", ",", "$", "base", ")", ";", "$", "command", "=", "\"{$binary} -S {$host}:{$port} {$base}/server.php\"", ";", "return", "$", "command", ";", "}" ]
Returns a command to pass through to shell. @param string $binary Usually full path to the PHP executable @param string $host Hostname @param int $port @param string $base Full path to Laravel project root @return string
[ "Returns", "a", "command", "to", "pass", "through", "to", "shell", "." ]
38e547b8496a6123fe63be0901a07fd798537ad7
https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L80-L89
17,250
mmieluch/laravel-serve-custom-ini
src/ServeCommand.php
ServeCommand.handleCustomIni
protected function handleCustomIni($command) { // If --ini parameter was not specified, just return the command // is at has been constructed. if (!$this->option('ini')) { return $command; } // Additional parameter will not work when escaped with single quotes. $command = str_replace("'", '', $command); // Determine the path $iniPath = ($this->option('ini-path') === $this->defaultIniPath) ? $this->laravel->basePath() . '/' . $this->defaultIniPath : $this->option('ini-path'); $iniPath = realpath($iniPath); $this->info('Loading custom configuration file: ' . $iniPath, 'v'); if (!file_exists($iniPath)) { $this->warn(sprintf( 'File %s does not exist. Custom configuration will not be loaded.', $iniPath )); } // Append PHP parameter with a path to the configuration file. $command .= ' -c ' . $iniPath; return $command; }
php
protected function handleCustomIni($command) { // If --ini parameter was not specified, just return the command // is at has been constructed. if (!$this->option('ini')) { return $command; } // Additional parameter will not work when escaped with single quotes. $command = str_replace("'", '', $command); // Determine the path $iniPath = ($this->option('ini-path') === $this->defaultIniPath) ? $this->laravel->basePath() . '/' . $this->defaultIniPath : $this->option('ini-path'); $iniPath = realpath($iniPath); $this->info('Loading custom configuration file: ' . $iniPath, 'v'); if (!file_exists($iniPath)) { $this->warn(sprintf( 'File %s does not exist. Custom configuration will not be loaded.', $iniPath )); } // Append PHP parameter with a path to the configuration file. $command .= ' -c ' . $iniPath; return $command; }
[ "protected", "function", "handleCustomIni", "(", "$", "command", ")", "{", "// If --ini parameter was not specified, just return the command", "// is at has been constructed.", "if", "(", "!", "$", "this", "->", "option", "(", "'ini'", ")", ")", "{", "return", "$", "command", ";", "}", "// Additional parameter will not work when escaped with single quotes.", "$", "command", "=", "str_replace", "(", "\"'\"", ",", "''", ",", "$", "command", ")", ";", "// Determine the path", "$", "iniPath", "=", "(", "$", "this", "->", "option", "(", "'ini-path'", ")", "===", "$", "this", "->", "defaultIniPath", ")", "?", "$", "this", "->", "laravel", "->", "basePath", "(", ")", ".", "'/'", ".", "$", "this", "->", "defaultIniPath", ":", "$", "this", "->", "option", "(", "'ini-path'", ")", ";", "$", "iniPath", "=", "realpath", "(", "$", "iniPath", ")", ";", "$", "this", "->", "info", "(", "'Loading custom configuration file: '", ".", "$", "iniPath", ",", "'v'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "iniPath", ")", ")", "{", "$", "this", "->", "warn", "(", "sprintf", "(", "'File %s does not exist. Custom configuration will not be loaded.'", ",", "$", "iniPath", ")", ")", ";", "}", "// Append PHP parameter with a path to the configuration file.", "$", "command", ".=", "' -c '", ".", "$", "iniPath", ";", "return", "$", "command", ";", "}" ]
Adds parameter telling PHP built-in server to respect a custom php.ini file. @param string $command Command built up to this point. @return string
[ "Adds", "parameter", "telling", "PHP", "built", "-", "in", "server", "to", "respect", "a", "custom", "php", ".", "ini", "file", "." ]
38e547b8496a6123fe63be0901a07fd798537ad7
https://github.com/mmieluch/laravel-serve-custom-ini/blob/38e547b8496a6123fe63be0901a07fd798537ad7/src/ServeCommand.php#L99-L130
17,251
webtown-php/KunstmaanExtensionBundle
src/User/UserEditService.php
UserEditService.getChoices
public function getChoices($username = null, $email = null, $or = false, $limit = null) { $qb = $this->getRepository()->createQueryBuilder('u'); $qb->orderBy('u.username'); $method = $or ? 'orWhere' : 'andWhere'; if ($username) { $qb->$method('u.username LIKE :username'); $qb->setParameter('username', '%' . $username . '%'); } if ($email) { $qb->$method('u.email LIKE :email'); $qb->setParameter('email', '%' . $email . '%'); } if ($limit) { $qb->setMaxResults($limit); } return $qb->getQuery()->getResult(); }
php
public function getChoices($username = null, $email = null, $or = false, $limit = null) { $qb = $this->getRepository()->createQueryBuilder('u'); $qb->orderBy('u.username'); $method = $or ? 'orWhere' : 'andWhere'; if ($username) { $qb->$method('u.username LIKE :username'); $qb->setParameter('username', '%' . $username . '%'); } if ($email) { $qb->$method('u.email LIKE :email'); $qb->setParameter('email', '%' . $email . '%'); } if ($limit) { $qb->setMaxResults($limit); } return $qb->getQuery()->getResult(); }
[ "public", "function", "getChoices", "(", "$", "username", "=", "null", ",", "$", "email", "=", "null", ",", "$", "or", "=", "false", ",", "$", "limit", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "getRepository", "(", ")", "->", "createQueryBuilder", "(", "'u'", ")", ";", "$", "qb", "->", "orderBy", "(", "'u.username'", ")", ";", "$", "method", "=", "$", "or", "?", "'orWhere'", ":", "'andWhere'", ";", "if", "(", "$", "username", ")", "{", "$", "qb", "->", "$", "method", "(", "'u.username LIKE :username'", ")", ";", "$", "qb", "->", "setParameter", "(", "'username'", ",", "'%'", ".", "$", "username", ".", "'%'", ")", ";", "}", "if", "(", "$", "email", ")", "{", "$", "qb", "->", "$", "method", "(", "'u.email LIKE :email'", ")", ";", "$", "qb", "->", "setParameter", "(", "'email'", ",", "'%'", ".", "$", "email", ".", "'%'", ")", ";", "}", "if", "(", "$", "limit", ")", "{", "$", "qb", "->", "setMaxResults", "(", "$", "limit", ")", ";", "}", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Find user choices @param string $username @param string $email @param bool $or combine search params with OR @param int $limit Limit the number of results @return array
[ "Find", "user", "choices" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L67-L85
17,252
webtown-php/KunstmaanExtensionBundle
src/User/UserEditService.php
UserEditService.getChoicesAsEmailUsername
public function getChoicesAsEmailUsername(array &$choices) { $ret = []; foreach ($choices as $item) { $ret[] = sprintf('%s (%s)', $item->getEmail(), $item->getUsername()); } return $ret; }
php
public function getChoicesAsEmailUsername(array &$choices) { $ret = []; foreach ($choices as $item) { $ret[] = sprintf('%s (%s)', $item->getEmail(), $item->getUsername()); } return $ret; }
[ "public", "function", "getChoicesAsEmailUsername", "(", "array", "&", "$", "choices", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "choices", "as", "$", "item", ")", "{", "$", "ret", "[", "]", "=", "sprintf", "(", "'%s (%s)'", ",", "$", "item", "->", "getEmail", "(", ")", ",", "$", "item", "->", "getUsername", "(", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Get selector choices as combined username+email @param User[] $choices @return string[]
[ "Get", "selector", "choices", "as", "combined", "username", "+", "email" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L94-L102
17,253
webtown-php/KunstmaanExtensionBundle
src/User/UserEditService.php
UserEditService.updateUser
public function updateUser(User $user, UserUpdater $up) { $up->updateUser($user, $this->getEncoder()); $em = $this->getRegistry()->getManager(); $em->persist($user); $em->flush(); }
php
public function updateUser(User $user, UserUpdater $up) { $up->updateUser($user, $this->getEncoder()); $em = $this->getRegistry()->getManager(); $em->persist($user); $em->flush(); }
[ "public", "function", "updateUser", "(", "User", "$", "user", ",", "UserUpdater", "$", "up", ")", "{", "$", "up", "->", "updateUser", "(", "$", "user", ",", "$", "this", "->", "getEncoder", "(", ")", ")", ";", "$", "em", "=", "$", "this", "->", "getRegistry", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "user", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Update user details @param User $user @param UserUpdater $up
[ "Update", "user", "details" ]
86c656c131295fe1f3f7694fd4da1e5e454076b9
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/User/UserEditService.php#L128-L134
17,254
Double-Opt-in/php-client-api
src/Guzzle/Plugin/AccessTokenCache.php
AccessTokenCache.get
public function get() { if ( ! file_exists($this->file)) return array(); $data = unserialize(base64_decode(file_get_contents($this->file))); return $data ?: array(); }
php
public function get() { if ( ! file_exists($this->file)) return array(); $data = unserialize(base64_decode(file_get_contents($this->file))); return $data ?: array(); }
[ "public", "function", "get", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "file", ")", ")", "return", "array", "(", ")", ";", "$", "data", "=", "unserialize", "(", "base64_decode", "(", "file_get_contents", "(", "$", "this", "->", "file", ")", ")", ")", ";", "return", "$", "data", "?", ":", "array", "(", ")", ";", "}" ]
returns the cached access token @return array
[ "returns", "the", "cached", "access", "token" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Guzzle/Plugin/AccessTokenCache.php#L32-L40
17,255
Double-Opt-in/php-client-api
src/Guzzle/Plugin/AccessTokenCache.php
AccessTokenCache.put
public function put($accessToken) { if ($accessToken === null) return unlink($this->file); file_put_contents($this->file, base64_encode(serialize($accessToken))); return file_exists($this->file); }
php
public function put($accessToken) { if ($accessToken === null) return unlink($this->file); file_put_contents($this->file, base64_encode(serialize($accessToken))); return file_exists($this->file); }
[ "public", "function", "put", "(", "$", "accessToken", ")", "{", "if", "(", "$", "accessToken", "===", "null", ")", "return", "unlink", "(", "$", "this", "->", "file", ")", ";", "file_put_contents", "(", "$", "this", "->", "file", ",", "base64_encode", "(", "serialize", "(", "$", "accessToken", ")", ")", ")", ";", "return", "file_exists", "(", "$", "this", "->", "file", ")", ";", "}" ]
store the access token @param array $accessToken @return bool
[ "store", "the", "access", "token" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Guzzle/Plugin/AccessTokenCache.php#L49-L57
17,256
ClanCats/Core
src/bundles/Database/Model.php
Model._fetch_handler
public static function _fetch_handler( &$query ) { // because the model is an object we force the fetch // arguments to obj so that we can still make use of // the group by and forward key functions $query->fetch_arguments = array( 'obj' ); // Run the query and assign the reults // here we force the fetch arguments to assoc // without this step model::assign will fail return static::assign( $query->handler->fetch( $query->build(), $query->handler->builder()->parameters, array( 'assoc' ) ) ); }
php
public static function _fetch_handler( &$query ) { // because the model is an object we force the fetch // arguments to obj so that we can still make use of // the group by and forward key functions $query->fetch_arguments = array( 'obj' ); // Run the query and assign the reults // here we force the fetch arguments to assoc // without this step model::assign will fail return static::assign( $query->handler->fetch( $query->build(), $query->handler->builder()->parameters, array( 'assoc' ) ) ); }
[ "public", "static", "function", "_fetch_handler", "(", "&", "$", "query", ")", "{", "// because the model is an object we force the fetch", "// arguments to obj so that we can still make use of", "// the group by and forward key functions", "$", "query", "->", "fetch_arguments", "=", "array", "(", "'obj'", ")", ";", "// Run the query and assign the reults", "// here we force the fetch arguments to assoc ", "// without this step model::assign will fail", "return", "static", "::", "assign", "(", "$", "query", "->", "handler", "->", "fetch", "(", "$", "query", "->", "build", "(", ")", ",", "$", "query", "->", "handler", "->", "builder", "(", ")", "->", "parameters", ",", "array", "(", "'assoc'", ")", ")", ")", ";", "}" ]
Fetch from the databse and created models out of the reults @param DB\Query_Select $query @return array
[ "Fetch", "from", "the", "databse", "and", "created", "models", "out", "of", "the", "reults" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L126-L137
17,257
ClanCats/Core
src/bundles/Database/Model.php
Model.find
public static function find( $param = null, $param2 = null ) { $settings = static::_model(); $query = DB::select( $settings['table'] ); // Do we have a find modifier? if ( !is_null( $settings['find_modifier'] ) ) { $callbacks = $settings['find_modifier']; if ( !\CCArr::is_collection( $callbacks ) ) { $callbacks = array( $callbacks ); } foreach( $callbacks as $call ) { if ( is_callable( $call ) ) { call_user_func_array( $call, array( &$query ) ); } else { throw new ModelException( "Invalid Callback given to find modifiers." ); } } } if ( !is_null( $param ) ) { // Check if paramert 1 is a valid callback and not a string. // Strings as function callback are not possible because // the user might want to search by key like: // Model::find( 'key', 'type' ); if ( is_callable( $param ) && !is_string( $param ) ) { call_user_func_array( $param, array( &$query ) ); } // When no param 2 isset we try to find the record by primary key elseif ( is_null( $param2 ) ) { $query->where( $settings['table'].'.'.$settings['primary_key'], $param ) ->limit(1); } // When param one and two isset we try to find the record by // the given key and value. elseif ( !is_null( $param2 ) ) { $query->where( $param, $param2 ) ->limit(1); } } // alway group the result $query->forward_key( $settings['primary_key'] ); // and we have to fetch assoc $query->fetch_arguments = array( 'assoc' ); // and assign return static::assign( $query->run() ); }
php
public static function find( $param = null, $param2 = null ) { $settings = static::_model(); $query = DB::select( $settings['table'] ); // Do we have a find modifier? if ( !is_null( $settings['find_modifier'] ) ) { $callbacks = $settings['find_modifier']; if ( !\CCArr::is_collection( $callbacks ) ) { $callbacks = array( $callbacks ); } foreach( $callbacks as $call ) { if ( is_callable( $call ) ) { call_user_func_array( $call, array( &$query ) ); } else { throw new ModelException( "Invalid Callback given to find modifiers." ); } } } if ( !is_null( $param ) ) { // Check if paramert 1 is a valid callback and not a string. // Strings as function callback are not possible because // the user might want to search by key like: // Model::find( 'key', 'type' ); if ( is_callable( $param ) && !is_string( $param ) ) { call_user_func_array( $param, array( &$query ) ); } // When no param 2 isset we try to find the record by primary key elseif ( is_null( $param2 ) ) { $query->where( $settings['table'].'.'.$settings['primary_key'], $param ) ->limit(1); } // When param one and two isset we try to find the record by // the given key and value. elseif ( !is_null( $param2 ) ) { $query->where( $param, $param2 ) ->limit(1); } } // alway group the result $query->forward_key( $settings['primary_key'] ); // and we have to fetch assoc $query->fetch_arguments = array( 'assoc' ); // and assign return static::assign( $query->run() ); }
[ "public", "static", "function", "find", "(", "$", "param", "=", "null", ",", "$", "param2", "=", "null", ")", "{", "$", "settings", "=", "static", "::", "_model", "(", ")", ";", "$", "query", "=", "DB", "::", "select", "(", "$", "settings", "[", "'table'", "]", ")", ";", "// Do we have a find modifier?", "if", "(", "!", "is_null", "(", "$", "settings", "[", "'find_modifier'", "]", ")", ")", "{", "$", "callbacks", "=", "$", "settings", "[", "'find_modifier'", "]", ";", "if", "(", "!", "\\", "CCArr", "::", "is_collection", "(", "$", "callbacks", ")", ")", "{", "$", "callbacks", "=", "array", "(", "$", "callbacks", ")", ";", "}", "foreach", "(", "$", "callbacks", "as", "$", "call", ")", "{", "if", "(", "is_callable", "(", "$", "call", ")", ")", "{", "call_user_func_array", "(", "$", "call", ",", "array", "(", "&", "$", "query", ")", ")", ";", "}", "else", "{", "throw", "new", "ModelException", "(", "\"Invalid Callback given to find modifiers.\"", ")", ";", "}", "}", "}", "if", "(", "!", "is_null", "(", "$", "param", ")", ")", "{", "// Check if paramert 1 is a valid callback and not a string.", "// Strings as function callback are not possible because", "// the user might want to search by key like:", "// Model::find( 'key', 'type' );", "if", "(", "is_callable", "(", "$", "param", ")", "&&", "!", "is_string", "(", "$", "param", ")", ")", "{", "call_user_func_array", "(", "$", "param", ",", "array", "(", "&", "$", "query", ")", ")", ";", "}", "// When no param 2 isset we try to find the record by primary key", "elseif", "(", "is_null", "(", "$", "param2", ")", ")", "{", "$", "query", "->", "where", "(", "$", "settings", "[", "'table'", "]", ".", "'.'", ".", "$", "settings", "[", "'primary_key'", "]", ",", "$", "param", ")", "->", "limit", "(", "1", ")", ";", "}", "// When param one and two isset we try to find the record by", "// the given key and value.", "elseif", "(", "!", "is_null", "(", "$", "param2", ")", ")", "{", "$", "query", "->", "where", "(", "$", "param", ",", "$", "param2", ")", "->", "limit", "(", "1", ")", ";", "}", "}", "// alway group the result", "$", "query", "->", "forward_key", "(", "$", "settings", "[", "'primary_key'", "]", ")", ";", "// and we have to fetch assoc", "$", "query", "->", "fetch_arguments", "=", "array", "(", "'assoc'", ")", ";", "// and assign", "return", "static", "::", "assign", "(", "$", "query", "->", "run", "(", ")", ")", ";", "}" ]
Model finder This function allows you direct access to your records. @param mixed $param @param mixed $param2 @return CCModel
[ "Model", "finder", "This", "function", "allows", "you", "direct", "access", "to", "your", "records", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L157-L219
17,258
ClanCats/Core
src/bundles/Database/Model.php
Model.__call_property
public function __call_property( $key ) { $result = parent::__call_property( $key ); // when we recive a relation we execute it and save it // to the data to avoid mutlitple queries if ( $result instanceof Model_Relation ) { return $this->_data_store[$key] = $result->run(); } return $result; }
php
public function __call_property( $key ) { $result = parent::__call_property( $key ); // when we recive a relation we execute it and save it // to the data to avoid mutlitple queries if ( $result instanceof Model_Relation ) { return $this->_data_store[$key] = $result->run(); } return $result; }
[ "public", "function", "__call_property", "(", "$", "key", ")", "{", "$", "result", "=", "parent", "::", "__call_property", "(", "$", "key", ")", ";", "// when we recive a relation we execute it and save it", "// to the data to avoid mutlitple queries", "if", "(", "$", "result", "instanceof", "Model_Relation", ")", "{", "return", "$", "this", "->", "_data_store", "[", "$", "key", "]", "=", "$", "result", "->", "run", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Call a function as a property @param string $key @return mixed
[ "Call", "a", "function", "as", "a", "property" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L227-L239
17,259
ClanCats/Core
src/bundles/Database/Model.php
Model.has_one
protected function has_one( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_HasOne( $this, $model, $foreign_key, $local_key ); }
php
protected function has_one( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_HasOne( $this, $model, $foreign_key, $local_key ); }
[ "protected", "function", "has_one", "(", "$", "model", ",", "$", "foreign_key", "=", "null", ",", "$", "local_key", "=", "null", ")", "{", "return", "new", "Model_Relation_HasOne", "(", "$", "this", ",", "$", "model", ",", "$", "foreign_key", ",", "$", "local_key", ")", ";", "}" ]
Has one releationships Model Car: function engine() { return $this->has_one( 'Car_Engine', 'car_id', 'id' ); } @param Model $model @param mixed $foreign_key @param mixed $key @return array
[ "Has", "one", "releationships" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L255-L258
17,260
ClanCats/Core
src/bundles/Database/Model.php
Model.has_many
protected function has_many( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_HasMany( $this, $model, $foreign_key, $local_key ); }
php
protected function has_many( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_HasMany( $this, $model, $foreign_key, $local_key ); }
[ "protected", "function", "has_many", "(", "$", "model", ",", "$", "foreign_key", "=", "null", ",", "$", "local_key", "=", "null", ")", "{", "return", "new", "Model_Relation_HasMany", "(", "$", "this", ",", "$", "model", ",", "$", "foreign_key", ",", "$", "local_key", ")", ";", "}" ]
Has many releationships Model Car: function wheels() { return $this->has_many( 'Car_Wheel', 'car_id', 'id' ); } @param Model $model @param mixed $foreign_key @param mixed $key @return array
[ "Has", "many", "releationships" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L274-L277
17,261
ClanCats/Core
src/bundles/Database/Model.php
Model.belongs_to
protected function belongs_to( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_BelongsTo( $this, $model, $foreign_key, $local_key ); }
php
protected function belongs_to( $model, $foreign_key = null, $local_key = null ) { return new Model_Relation_BelongsTo( $this, $model, $foreign_key, $local_key ); }
[ "protected", "function", "belongs_to", "(", "$", "model", ",", "$", "foreign_key", "=", "null", ",", "$", "local_key", "=", "null", ")", "{", "return", "new", "Model_Relation_BelongsTo", "(", "$", "this", ",", "$", "model", ",", "$", "foreign_key", ",", "$", "local_key", ")", ";", "}" ]
Belongs To releationships Model Car_Engine: function car() { return $this->belongs_to( 'Car', 'id', 'car_id' ); } @param Model $model @param mixed $foreign_key @param mixed $key @return array
[ "Belongs", "To", "releationships" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L293-L296
17,262
ClanCats/Core
src/bundles/Database/Model.php
Model.with
public static function with( $with, $callback = null ) { if ( !is_array( $with ) ) { $with = array( $with ); } $settings = static::_model(); $query = DB::select( $settings['table'] ); // run the callback if ( !is_null( $callback ) ) { call_user_func_array( $callback, array( &$query ) ); } // alway group the result and fetch assoc $query->forward_key( $settings['primary_key'] ); $query->fetch_arguments = array( 'assoc' ); // get the main result set $results = static::assign( $query->run() ); $singleton = false; if ( !is_array( $results ) ) { $results = array( $results ); $singleton = true; } $ref_object = reset( $results ); // we have to sort the relationships to make sure that // select the relations in the right order. asort( $with ); foreach( $with as $relation => $callback ) { if ( is_int( $relation ) && is_string( $callback ) ) { $relation = $callback; $callback = null; } if ( strpos( $relation, '.' ) !== false ) { $relation_layers = explode( '.', $relation ); $relation_name = array_pop( $relation_layers ); $relation_collection = array(); foreach( $results as $key => &$item ) { $curr_item = $item; foreach( $relation_layers as $layer ) { $curr_item = $curr_item->raw( $layer ); } $relation_collection[] = $curr_item; } $ref_object = reset( $relation_collection ); $relation_object = call_user_func( array( $ref_object, $relation_name ) ); if ( $relation_object instanceof Model_Relation ) { $relation_object->collection_assign( $relation_name, $relation_collection, $callback ); } } else { $relation_object = call_user_func( array( $ref_object, $relation ) ); if ( $relation_object instanceof Model_Relation ) { $relation_object->collection_assign( $relation, $results, $callback ); } } } if ( $singleton ) { return reset( $results ); } // and assign return $results; }
php
public static function with( $with, $callback = null ) { if ( !is_array( $with ) ) { $with = array( $with ); } $settings = static::_model(); $query = DB::select( $settings['table'] ); // run the callback if ( !is_null( $callback ) ) { call_user_func_array( $callback, array( &$query ) ); } // alway group the result and fetch assoc $query->forward_key( $settings['primary_key'] ); $query->fetch_arguments = array( 'assoc' ); // get the main result set $results = static::assign( $query->run() ); $singleton = false; if ( !is_array( $results ) ) { $results = array( $results ); $singleton = true; } $ref_object = reset( $results ); // we have to sort the relationships to make sure that // select the relations in the right order. asort( $with ); foreach( $with as $relation => $callback ) { if ( is_int( $relation ) && is_string( $callback ) ) { $relation = $callback; $callback = null; } if ( strpos( $relation, '.' ) !== false ) { $relation_layers = explode( '.', $relation ); $relation_name = array_pop( $relation_layers ); $relation_collection = array(); foreach( $results as $key => &$item ) { $curr_item = $item; foreach( $relation_layers as $layer ) { $curr_item = $curr_item->raw( $layer ); } $relation_collection[] = $curr_item; } $ref_object = reset( $relation_collection ); $relation_object = call_user_func( array( $ref_object, $relation_name ) ); if ( $relation_object instanceof Model_Relation ) { $relation_object->collection_assign( $relation_name, $relation_collection, $callback ); } } else { $relation_object = call_user_func( array( $ref_object, $relation ) ); if ( $relation_object instanceof Model_Relation ) { $relation_object->collection_assign( $relation, $results, $callback ); } } } if ( $singleton ) { return reset( $results ); } // and assign return $results; }
[ "public", "static", "function", "with", "(", "$", "with", ",", "$", "callback", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "with", ")", ")", "{", "$", "with", "=", "array", "(", "$", "with", ")", ";", "}", "$", "settings", "=", "static", "::", "_model", "(", ")", ";", "$", "query", "=", "DB", "::", "select", "(", "$", "settings", "[", "'table'", "]", ")", ";", "// run the callback", "if", "(", "!", "is_null", "(", "$", "callback", ")", ")", "{", "call_user_func_array", "(", "$", "callback", ",", "array", "(", "&", "$", "query", ")", ")", ";", "}", "// alway group the result and fetch assoc", "$", "query", "->", "forward_key", "(", "$", "settings", "[", "'primary_key'", "]", ")", ";", "$", "query", "->", "fetch_arguments", "=", "array", "(", "'assoc'", ")", ";", "// get the main result set", "$", "results", "=", "static", "::", "assign", "(", "$", "query", "->", "run", "(", ")", ")", ";", "$", "singleton", "=", "false", ";", "if", "(", "!", "is_array", "(", "$", "results", ")", ")", "{", "$", "results", "=", "array", "(", "$", "results", ")", ";", "$", "singleton", "=", "true", ";", "}", "$", "ref_object", "=", "reset", "(", "$", "results", ")", ";", "// we have to sort the relationships to make sure that", "// select the relations in the right order.\t", "asort", "(", "$", "with", ")", ";", "foreach", "(", "$", "with", "as", "$", "relation", "=>", "$", "callback", ")", "{", "if", "(", "is_int", "(", "$", "relation", ")", "&&", "is_string", "(", "$", "callback", ")", ")", "{", "$", "relation", "=", "$", "callback", ";", "$", "callback", "=", "null", ";", "}", "if", "(", "strpos", "(", "$", "relation", ",", "'.'", ")", "!==", "false", ")", "{", "$", "relation_layers", "=", "explode", "(", "'.'", ",", "$", "relation", ")", ";", "$", "relation_name", "=", "array_pop", "(", "$", "relation_layers", ")", ";", "$", "relation_collection", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "key", "=>", "&", "$", "item", ")", "{", "$", "curr_item", "=", "$", "item", ";", "foreach", "(", "$", "relation_layers", "as", "$", "layer", ")", "{", "$", "curr_item", "=", "$", "curr_item", "->", "raw", "(", "$", "layer", ")", ";", "}", "$", "relation_collection", "[", "]", "=", "$", "curr_item", ";", "}", "$", "ref_object", "=", "reset", "(", "$", "relation_collection", ")", ";", "$", "relation_object", "=", "call_user_func", "(", "array", "(", "$", "ref_object", ",", "$", "relation_name", ")", ")", ";", "if", "(", "$", "relation_object", "instanceof", "Model_Relation", ")", "{", "$", "relation_object", "->", "collection_assign", "(", "$", "relation_name", ",", "$", "relation_collection", ",", "$", "callback", ")", ";", "}", "}", "else", "{", "$", "relation_object", "=", "call_user_func", "(", "array", "(", "$", "ref_object", ",", "$", "relation", ")", ")", ";", "if", "(", "$", "relation_object", "instanceof", "Model_Relation", ")", "{", "$", "relation_object", "->", "collection_assign", "(", "$", "relation", ",", "$", "results", ",", "$", "callback", ")", ";", "}", "}", "}", "if", "(", "$", "singleton", ")", "{", "return", "reset", "(", "$", "results", ")", ";", "}", "// and assign", "return", "$", "results", ";", "}" ]
find with an relationship Person::with( 'cars' ); @param array|string $with @param callback $callback @return array
[ "find", "with", "an", "relationship" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L307-L398
17,263
ClanCats/Core
src/bundles/Database/Model.php
Model.save
public function save( $fields = null ) { $settings = static::_model(); // check if we should save just some fields if ( is_null( $fields ) ) { $fields = array_keys( $settings['defaults'] ); } elseif ( !is_array( $fields ) ) { $fields = array( $fields ); } $pkey = $this->_data_store[$settings['primary_key']]; $data = array(); // Now we have to filter the data to the save g foreach( $fields as $field ) { $data[$field] = $this->_data_store[$field]; } // We have to remove the primary key from our data if ( array_key_exists( $settings['primary_key'], $data ) ) { unset( $data[$settings['primary_key']] ); } // We pass the data trough the before save callback. // This is a local callback for performence reasons. $data = $this->_before_save( $data ); // after the before save event, // do we have to to something with the data type? foreach( $data as $key => $value ) { if ( array_key_exists( $key, $settings['types'] ) ) { $data[$key] = $this->_type_assignment_set( $settings['types'][$key], $value ); } } // check if we have to set the timestamps automatically if ( $settings['timestamps'] === true ) { if ( array_key_exists( 'created_at', $data ) ) { // check if created_at should be set if ( $data['created_at'] < 1 ) { $this->_data_store['created_at'] = $data['created_at'] = time(); } } if ( array_key_exists( 'modified_at', $data ) ) { $this->_data_store['modified_at'] =$data['modified_at'] = time(); } } // When we already have a primary key we are going to // update our record instead of inserting a new one. if ( !is_null( $pkey ) && $pkey > 0 ) { $query = DB::update( $settings['table'], $data ) ->where( $settings['primary_key'], $pkey ); } // No primary key? Smells like an insert query. else { $query = DB::insert( $settings['table'], $data ); } // We check the query type to handle the response right if ( $query instanceof Query_Insert ) { $this->_data_store[$settings['primary_key']] = $query->run(); } else { $query->run(); } // after save hookt $this->_after_save(); // return self return $this; }
php
public function save( $fields = null ) { $settings = static::_model(); // check if we should save just some fields if ( is_null( $fields ) ) { $fields = array_keys( $settings['defaults'] ); } elseif ( !is_array( $fields ) ) { $fields = array( $fields ); } $pkey = $this->_data_store[$settings['primary_key']]; $data = array(); // Now we have to filter the data to the save g foreach( $fields as $field ) { $data[$field] = $this->_data_store[$field]; } // We have to remove the primary key from our data if ( array_key_exists( $settings['primary_key'], $data ) ) { unset( $data[$settings['primary_key']] ); } // We pass the data trough the before save callback. // This is a local callback for performence reasons. $data = $this->_before_save( $data ); // after the before save event, // do we have to to something with the data type? foreach( $data as $key => $value ) { if ( array_key_exists( $key, $settings['types'] ) ) { $data[$key] = $this->_type_assignment_set( $settings['types'][$key], $value ); } } // check if we have to set the timestamps automatically if ( $settings['timestamps'] === true ) { if ( array_key_exists( 'created_at', $data ) ) { // check if created_at should be set if ( $data['created_at'] < 1 ) { $this->_data_store['created_at'] = $data['created_at'] = time(); } } if ( array_key_exists( 'modified_at', $data ) ) { $this->_data_store['modified_at'] =$data['modified_at'] = time(); } } // When we already have a primary key we are going to // update our record instead of inserting a new one. if ( !is_null( $pkey ) && $pkey > 0 ) { $query = DB::update( $settings['table'], $data ) ->where( $settings['primary_key'], $pkey ); } // No primary key? Smells like an insert query. else { $query = DB::insert( $settings['table'], $data ); } // We check the query type to handle the response right if ( $query instanceof Query_Insert ) { $this->_data_store[$settings['primary_key']] = $query->run(); } else { $query->run(); } // after save hookt $this->_after_save(); // return self return $this; }
[ "public", "function", "save", "(", "$", "fields", "=", "null", ")", "{", "$", "settings", "=", "static", "::", "_model", "(", ")", ";", "// check if we should save just some fields", "if", "(", "is_null", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "array_keys", "(", "$", "settings", "[", "'defaults'", "]", ")", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "array", "(", "$", "fields", ")", ";", "}", "$", "pkey", "=", "$", "this", "->", "_data_store", "[", "$", "settings", "[", "'primary_key'", "]", "]", ";", "$", "data", "=", "array", "(", ")", ";", "// Now we have to filter the data to the save g", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "data", "[", "$", "field", "]", "=", "$", "this", "->", "_data_store", "[", "$", "field", "]", ";", "}", "// We have to remove the primary key from our data", "if", "(", "array_key_exists", "(", "$", "settings", "[", "'primary_key'", "]", ",", "$", "data", ")", ")", "{", "unset", "(", "$", "data", "[", "$", "settings", "[", "'primary_key'", "]", "]", ")", ";", "}", "// We pass the data trough the before save callback.", "// This is a local callback for performence reasons.", "$", "data", "=", "$", "this", "->", "_before_save", "(", "$", "data", ")", ";", "// after the before save event,", "// do we have to to something with the data type?", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "settings", "[", "'types'", "]", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_type_assignment_set", "(", "$", "settings", "[", "'types'", "]", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "}", "// check if we have to set the timestamps automatically", "if", "(", "$", "settings", "[", "'timestamps'", "]", "===", "true", ")", "{", "if", "(", "array_key_exists", "(", "'created_at'", ",", "$", "data", ")", ")", "{", "// check if created_at should be set", "if", "(", "$", "data", "[", "'created_at'", "]", "<", "1", ")", "{", "$", "this", "->", "_data_store", "[", "'created_at'", "]", "=", "$", "data", "[", "'created_at'", "]", "=", "time", "(", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'modified_at'", ",", "$", "data", ")", ")", "{", "$", "this", "->", "_data_store", "[", "'modified_at'", "]", "=", "$", "data", "[", "'modified_at'", "]", "=", "time", "(", ")", ";", "}", "}", "// When we already have a primary key we are going to ", "// update our record instead of inserting a new one.", "if", "(", "!", "is_null", "(", "$", "pkey", ")", "&&", "$", "pkey", ">", "0", ")", "{", "$", "query", "=", "DB", "::", "update", "(", "$", "settings", "[", "'table'", "]", ",", "$", "data", ")", "->", "where", "(", "$", "settings", "[", "'primary_key'", "]", ",", "$", "pkey", ")", ";", "}", "// No primary key? Smells like an insert query. ", "else", "{", "$", "query", "=", "DB", "::", "insert", "(", "$", "settings", "[", "'table'", "]", ",", "$", "data", ")", ";", "}", "// We check the query type to handle the response right", "if", "(", "$", "query", "instanceof", "Query_Insert", ")", "{", "$", "this", "->", "_data_store", "[", "$", "settings", "[", "'primary_key'", "]", "]", "=", "$", "query", "->", "run", "(", ")", ";", "}", "else", "{", "$", "query", "->", "run", "(", ")", ";", "}", "// after save hookt", "$", "this", "->", "_after_save", "(", ")", ";", "// return self", "return", "$", "this", ";", "}" ]
save an model @param mixed $fields @return self
[ "save", "an", "model" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L406-L495
17,264
ClanCats/Core
src/bundles/Database/Model.php
Model.delete
public function delete() { $settings = static::_model(); $result = DB::delete( $settings['table'] ) ->where( $settings['primary_key'], $this->_data_store[$settings['primary_key']] ) ->limit(1) ->run( $settings['handler'] ); $this->_data_store[$cache['primary_key']] = null; return $result; }
php
public function delete() { $settings = static::_model(); $result = DB::delete( $settings['table'] ) ->where( $settings['primary_key'], $this->_data_store[$settings['primary_key']] ) ->limit(1) ->run( $settings['handler'] ); $this->_data_store[$cache['primary_key']] = null; return $result; }
[ "public", "function", "delete", "(", ")", "{", "$", "settings", "=", "static", "::", "_model", "(", ")", ";", "$", "result", "=", "DB", "::", "delete", "(", "$", "settings", "[", "'table'", "]", ")", "->", "where", "(", "$", "settings", "[", "'primary_key'", "]", ",", "$", "this", "->", "_data_store", "[", "$", "settings", "[", "'primary_key'", "]", "]", ")", "->", "limit", "(", "1", ")", "->", "run", "(", "$", "settings", "[", "'handler'", "]", ")", ";", "$", "this", "->", "_data_store", "[", "$", "cache", "[", "'primary_key'", "]", "]", "=", "null", ";", "return", "$", "result", ";", "}" ]
Delete the current model from the database @return DB\Model
[ "Delete", "the", "current", "model", "from", "the", "database" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model.php#L512-L524
17,265
GrahamDeprecated/CMS-Core
src/Providers/PageProvider.php
PageProvider.navigation
public function navigation() { // caching logic if ($this->validCache($this->nav)) { // get the value from the class cache $value = $this->nav; } else { // pull from the cache $value = $this->getCache(); // check if the value is valid if (!$this->validCache($value)) { // if is invalid, do the work $value = $this->sendGet(); // add the value from the work to the cache $this->setCache($value); } } // cache the value in the class $this->nav = $value; // spit out the value return $value; }
php
public function navigation() { // caching logic if ($this->validCache($this->nav)) { // get the value from the class cache $value = $this->nav; } else { // pull from the cache $value = $this->getCache(); // check if the value is valid if (!$this->validCache($value)) { // if is invalid, do the work $value = $this->sendGet(); // add the value from the work to the cache $this->setCache($value); } } // cache the value in the class $this->nav = $value; // spit out the value return $value; }
[ "public", "function", "navigation", "(", ")", "{", "// caching logic", "if", "(", "$", "this", "->", "validCache", "(", "$", "this", "->", "nav", ")", ")", "{", "// get the value from the class cache", "$", "value", "=", "$", "this", "->", "nav", ";", "}", "else", "{", "// pull from the cache", "$", "value", "=", "$", "this", "->", "getCache", "(", ")", ";", "// check if the value is valid", "if", "(", "!", "$", "this", "->", "validCache", "(", "$", "value", ")", ")", "{", "// if is invalid, do the work", "$", "value", "=", "$", "this", "->", "sendGet", "(", ")", ";", "// add the value from the work to the cache", "$", "this", "->", "setCache", "(", "$", "value", ")", ";", "}", "}", "// cache the value in the class", "$", "this", "->", "nav", "=", "$", "value", ";", "// spit out the value", "return", "$", "value", ";", "}" ]
Get the page navigation. @return array
[ "Get", "the", "page", "navigation", "." ]
5603e2bfa2fac6cf46ca3ed62d21518f2f653675
https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Providers/PageProvider.php#L51-L74
17,266
GrahamDeprecated/CMS-Core
src/Providers/PageProvider.php
PageProvider.validCache
protected function validCache($value) { if (is_null($value) || !is_array($value) || empty($value)) { return false; } return true; }
php
protected function validCache($value) { if (is_null($value) || !is_array($value) || empty($value)) { return false; } return true; }
[ "protected", "function", "validCache", "(", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "||", "!", "is_array", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check of the nav var is not corrupt. @param array $value @return bool
[ "Check", "of", "the", "nav", "var", "is", "not", "corrupt", "." ]
5603e2bfa2fac6cf46ca3ed62d21518f2f653675
https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Providers/PageProvider.php#L138-L145
17,267
neos/doctools
Classes/Command/CommandReferenceCommandController.php
CommandReferenceCommandController.renderCommand
public function renderCommand($reference = null) { $references = $reference !== null ? [$reference] : array_keys($this->settings['commandReferences']); $this->renderReferences($references); }
php
public function renderCommand($reference = null) { $references = $reference !== null ? [$reference] : array_keys($this->settings['commandReferences']); $this->renderReferences($references); }
[ "public", "function", "renderCommand", "(", "$", "reference", "=", "null", ")", "{", "$", "references", "=", "$", "reference", "!==", "null", "?", "[", "$", "reference", "]", ":", "array_keys", "(", "$", "this", "->", "settings", "[", "'commandReferences'", "]", ")", ";", "$", "this", "->", "renderReferences", "(", "$", "references", ")", ";", "}" ]
Renders command reference documentation from source code. @param string $reference to render. If not specified all configured references will be rendered @return void @throws \Neos\Flow\Mvc\Exception\StopActionException @throws \Neos\FluidAdaptor\Exception
[ "Renders", "command", "reference", "documentation", "from", "source", "code", "." ]
726981245a8d59319ee594a582f80a30256df98b
https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/CommandReferenceCommandController.php#L48-L52
17,268
neos/doctools
Classes/Command/CommandReferenceCommandController.php
CommandReferenceCommandController.renderReferences
protected function renderReferences($references) { foreach ($references as $reference) { $this->outputLine('Rendering Reference "%s"', [$reference]); $this->renderReference($reference); } }
php
protected function renderReferences($references) { foreach ($references as $reference) { $this->outputLine('Rendering Reference "%s"', [$reference]); $this->renderReference($reference); } }
[ "protected", "function", "renderReferences", "(", "$", "references", ")", "{", "foreach", "(", "$", "references", "as", "$", "reference", ")", "{", "$", "this", "->", "outputLine", "(", "'Rendering Reference \"%s\"'", ",", "[", "$", "reference", "]", ")", ";", "$", "this", "->", "renderReference", "(", "$", "reference", ")", ";", "}", "}" ]
Render a set of CLI command references to reStructuredText. @param array $references to render. @return void @throws \Neos\Flow\Mvc\Exception\StopActionException @throws \Neos\FluidAdaptor\Exception
[ "Render", "a", "set", "of", "CLI", "command", "references", "to", "reStructuredText", "." ]
726981245a8d59319ee594a582f80a30256df98b
https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Command/CommandReferenceCommandController.php#L84-L90
17,269
Chill-project/Main
Controller/ScopeController.php
ScopeController.createCreateForm
private function createCreateForm(Scope $scope) { $form = $this->createForm(new ScopeType(), $scope, array( 'action' => $this->generateUrl('admin_scope_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Scope $scope) { $form = $this->createForm(new ScopeType(), $scope, array( 'action' => $this->generateUrl('admin_scope_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Scope", "$", "scope", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ScopeType", "(", ")", ",", "$", "scope", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_scope_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a Scope entity. @param Scope $scope The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Scope", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ScopeController.php#L63-L73
17,270
Chill-project/Main
Controller/ScopeController.php
ScopeController.newAction
public function newAction() { $scope = new Scope(); $form = $this->createCreateForm($scope); return $this->render('ChillMainBundle:Scope:new.html.twig', array( 'entity' => $scope, 'form' => $form->createView(), )); }
php
public function newAction() { $scope = new Scope(); $form = $this->createCreateForm($scope); return $this->render('ChillMainBundle:Scope:new.html.twig', array( 'entity' => $scope, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", ")", "{", "$", "scope", "=", "new", "Scope", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "scope", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:Scope:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "scope", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to create a new Scope entity.
[ "Displays", "a", "form", "to", "create", "a", "new", "Scope", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ScopeController.php#L79-L88
17,271
Chill-project/Main
Controller/ScopeController.php
ScopeController.createEditForm
private function createEditForm(Scope $scope) { $form = $this->createForm(new ScopeType(), $scope, array( 'action' => $this->generateUrl('admin_scope_update', array('id' => $scope->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(Scope $scope) { $form = $this->createForm(new ScopeType(), $scope, array( 'action' => $this->generateUrl('admin_scope_update', array('id' => $scope->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "Scope", "$", "scope", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ScopeType", "(", ")", ",", "$", "scope", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_scope_update'", ",", "array", "(", "'id'", "=>", "$", "scope", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a Scope entity. @param Scope $scope The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "Scope", "entity", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/ScopeController.php#L138-L148
17,272
djgadd/themosis-illuminate
src/Config/ConfigFinder.php
ConfigFinder.fileMatchesMoreSpecificExtension
protected function fileMatchesMoreSpecificExtension(string $filename, string $extension) : bool { return array_reduce($this->extensions, function ($match, $compare) use ($filename, $extension) { if ($match || $compare === $extension || strlen($compare) < strlen($extension)) { return $match; } return $filename === basename($filename, ".{$compare}").".{$compare}"; }, false); }
php
protected function fileMatchesMoreSpecificExtension(string $filename, string $extension) : bool { return array_reduce($this->extensions, function ($match, $compare) use ($filename, $extension) { if ($match || $compare === $extension || strlen($compare) < strlen($extension)) { return $match; } return $filename === basename($filename, ".{$compare}").".{$compare}"; }, false); }
[ "protected", "function", "fileMatchesMoreSpecificExtension", "(", "string", "$", "filename", ",", "string", "$", "extension", ")", ":", "bool", "{", "return", "array_reduce", "(", "$", "this", "->", "extensions", ",", "function", "(", "$", "match", ",", "$", "compare", ")", "use", "(", "$", "filename", ",", "$", "extension", ")", "{", "if", "(", "$", "match", "||", "$", "compare", "===", "$", "extension", "||", "strlen", "(", "$", "compare", ")", "<", "strlen", "(", "$", "extension", ")", ")", "{", "return", "$", "match", ";", "}", "return", "$", "filename", "===", "basename", "(", "$", "filename", ",", "\".{$compare}\"", ")", ".", "\".{$compare}\"", ";", "}", ",", "false", ")", ";", "}" ]
Determines if a file matches another more specific extension @param string $filename @param string $extension @return bool
[ "Determines", "if", "a", "file", "matches", "another", "more", "specific", "extension" ]
13ee4c3413cddd85a2f262ac361f35c81da0c53c
https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Config/ConfigFinder.php#L67-L76
17,273
djgadd/themosis-illuminate
src/Config/ConfigFinder.php
ConfigFinder.mergeConfigs
protected function mergeConfigs(array $old, array $new) : array { foreach ($new as $key => $val) { if (!array_key_exists($key, $old) || !is_array($old[$key]) || !is_array($val)) { $old[$key] = $val; continue; } if (is_int($key)) { $old[] = $val; continue; } $old[$key] = $this->mergeConfigs($old[$key], $val); } return $old; }
php
protected function mergeConfigs(array $old, array $new) : array { foreach ($new as $key => $val) { if (!array_key_exists($key, $old) || !is_array($old[$key]) || !is_array($val)) { $old[$key] = $val; continue; } if (is_int($key)) { $old[] = $val; continue; } $old[$key] = $this->mergeConfigs($old[$key], $val); } return $old; }
[ "protected", "function", "mergeConfigs", "(", "array", "$", "old", ",", "array", "$", "new", ")", ":", "array", "{", "foreach", "(", "$", "new", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "old", ")", "||", "!", "is_array", "(", "$", "old", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "val", ")", ")", "{", "$", "old", "[", "$", "key", "]", "=", "$", "val", ";", "continue", ";", "}", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "old", "[", "]", "=", "$", "val", ";", "continue", ";", "}", "$", "old", "[", "$", "key", "]", "=", "$", "this", "->", "mergeConfigs", "(", "$", "old", "[", "$", "key", "]", ",", "$", "val", ")", ";", "}", "return", "$", "old", ";", "}" ]
Recusively merges configs together @param array $old @param array $new @return array
[ "Recusively", "merges", "configs", "together" ]
13ee4c3413cddd85a2f262ac361f35c81da0c53c
https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Config/ConfigFinder.php#L106-L123
17,274
lmammino/e-foundation
src/Common/Doctrine/MappingLocator.php
MappingLocator.getMappings
public static function getMappings() { $basePath = self::getBasePath(); return array( realpath($basePath.'Address/Resources/config/doctrine/model') => 'LMammino\EFoundation\Address\Model', realpath($basePath.'Attribute/Resources/config/doctrine/model') => 'LMammino\EFoundation\Attribute\Model', realpath($basePath.'Cart/Resources/config/doctrine/model') => 'LMammino\EFoundation\Cart\Model', realpath($basePath.'Order/Resources/config/doctrine/model') => 'LMammino\EFoundation\Order\Model', realpath($basePath.'Price/Resources/config/doctrine/model') => 'LMammino\EFoundation\Price\Model', realpath($basePath.'Product/Resources/config/doctrine/model') => 'LMammino\EFoundation\Product\Model', realpath($basePath.'Variation/Resources/config/doctrine/model') => 'LMammino\EFoundation\Variation\Model', ); }
php
public static function getMappings() { $basePath = self::getBasePath(); return array( realpath($basePath.'Address/Resources/config/doctrine/model') => 'LMammino\EFoundation\Address\Model', realpath($basePath.'Attribute/Resources/config/doctrine/model') => 'LMammino\EFoundation\Attribute\Model', realpath($basePath.'Cart/Resources/config/doctrine/model') => 'LMammino\EFoundation\Cart\Model', realpath($basePath.'Order/Resources/config/doctrine/model') => 'LMammino\EFoundation\Order\Model', realpath($basePath.'Price/Resources/config/doctrine/model') => 'LMammino\EFoundation\Price\Model', realpath($basePath.'Product/Resources/config/doctrine/model') => 'LMammino\EFoundation\Product\Model', realpath($basePath.'Variation/Resources/config/doctrine/model') => 'LMammino\EFoundation\Variation\Model', ); }
[ "public", "static", "function", "getMappings", "(", ")", "{", "$", "basePath", "=", "self", "::", "getBasePath", "(", ")", ";", "return", "array", "(", "realpath", "(", "$", "basePath", ".", "'Address/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Address\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Attribute/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Attribute\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Cart/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Cart\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Order/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Order\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Price/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Price\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Product/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Product\\Model'", ",", "realpath", "(", "$", "basePath", ".", "'Variation/Resources/config/doctrine/model'", ")", "=>", "'LMammino\\EFoundation\\Variation\\Model'", ",", ")", ";", "}" ]
Get the mapping @return array
[ "Get", "the", "mapping" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Common/Doctrine/MappingLocator.php#L17-L32
17,275
silvercommerce/catalogue-frontend
src/extensions/CategoryExtension.php
CategoryExtension.PrimaryImage
public function PrimaryImage() { // If we have associated an image, return it $image = $this->owner->Image(); if ($image->exists()) { return $image; } // Next try and get a child product image $product = $this->owner->AllProducts()->first(); if (!empty($product)) { return $product->PrimaryImage(); } // Finally generate our no product image return Helper::generate_no_image(); }
php
public function PrimaryImage() { // If we have associated an image, return it $image = $this->owner->Image(); if ($image->exists()) { return $image; } // Next try and get a child product image $product = $this->owner->AllProducts()->first(); if (!empty($product)) { return $product->PrimaryImage(); } // Finally generate our no product image return Helper::generate_no_image(); }
[ "public", "function", "PrimaryImage", "(", ")", "{", "// If we have associated an image, return it", "$", "image", "=", "$", "this", "->", "owner", "->", "Image", "(", ")", ";", "if", "(", "$", "image", "->", "exists", "(", ")", ")", "{", "return", "$", "image", ";", "}", "// Next try and get a child product image", "$", "product", "=", "$", "this", "->", "owner", "->", "AllProducts", "(", ")", "->", "first", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "product", ")", ")", "{", "return", "$", "product", "->", "PrimaryImage", "(", ")", ";", "}", "// Finally generate our no product image", "return", "Helper", "::", "generate_no_image", "(", ")", ";", "}" ]
Gets the main image to use for this category, this can either be the selected image, an image from the first product or the default "no-product" image. @return Image
[ "Gets", "the", "main", "image", "to", "use", "for", "this", "category", "this", "can", "either", "be", "the", "selected", "image", "an", "image", "from", "the", "first", "product", "or", "the", "default", "no", "-", "product", "image", "." ]
671f1e32bf6bc6eb193c6608ae904cd055540cc4
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/extensions/CategoryExtension.php#L35-L53
17,276
devmobgroup/postcodes
src/Util/Json.php
Json.decode
public static function decode(ResponseInterface $response): array { $contents = $response->getBody()->getContents(); $decoded = json_decode($contents, true); $response->getBody()->rewind(); if (json_last_error() !== JSON_ERROR_NONE || ! is_array($decoded)) { throw new JsonException(json_last_error_msg()); } return $decoded; }
php
public static function decode(ResponseInterface $response): array { $contents = $response->getBody()->getContents(); $decoded = json_decode($contents, true); $response->getBody()->rewind(); if (json_last_error() !== JSON_ERROR_NONE || ! is_array($decoded)) { throw new JsonException(json_last_error_msg()); } return $decoded; }
[ "public", "static", "function", "decode", "(", "ResponseInterface", "$", "response", ")", ":", "array", "{", "$", "contents", "=", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ";", "$", "decoded", "=", "json_decode", "(", "$", "contents", ",", "true", ")", ";", "$", "response", "->", "getBody", "(", ")", "->", "rewind", "(", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", "||", "!", "is_array", "(", "$", "decoded", ")", ")", "{", "throw", "new", "JsonException", "(", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "decoded", ";", "}" ]
Json decode an http response. @param \Psr\Http\Message\ResponseInterface $response @return array @throws \DevMob\Postcodes\Exceptions\JsonException
[ "Json", "decode", "an", "http", "response", "." ]
1a8438fd960a8f50ec28d61af94560892b529f12
https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Util/Json.php#L17-L28
17,277
Nozemi/SlickBoard-Library
lib/SBLib/Database/DBUtil.php
DBUtil.addQuery
public function addQuery(DBUtilQuery $query) { if($query->getName() !== null) { $this->_queryQueue[$query->getName()] = $query; } else { $this->_queryQueue[] = $query; } new Logger('Query added to the queue.', Logger::DEBUG, __CLASS__, __LINE__); return $this; }
php
public function addQuery(DBUtilQuery $query) { if($query->getName() !== null) { $this->_queryQueue[$query->getName()] = $query; } else { $this->_queryQueue[] = $query; } new Logger('Query added to the queue.', Logger::DEBUG, __CLASS__, __LINE__); return $this; }
[ "public", "function", "addQuery", "(", "DBUtilQuery", "$", "query", ")", "{", "if", "(", "$", "query", "->", "getName", "(", ")", "!==", "null", ")", "{", "$", "this", "->", "_queryQueue", "[", "$", "query", "->", "getName", "(", ")", "]", "=", "$", "query", ";", "}", "else", "{", "$", "this", "->", "_queryQueue", "[", "]", "=", "$", "query", ";", "}", "new", "Logger", "(", "'Query added to the queue.'", ",", "Logger", "::", "DEBUG", ",", "__CLASS__", ",", "__LINE__", ")", ";", "return", "$", "this", ";", "}" ]
Adds a query with it's parameters to the query queue. @param DBUtilQuery $query @return $this
[ "Adds", "a", "query", "with", "it", "s", "parameters", "to", "the", "query", "queue", "." ]
c9f0a26a30f8127c997f75d7232eac170972418d
https://github.com/Nozemi/SlickBoard-Library/blob/c9f0a26a30f8127c997f75d7232eac170972418d/lib/SBLib/Database/DBUtil.php#L123-L132
17,278
Nozemi/SlickBoard-Library
lib/SBLib/Database/DBUtil.php
DBUtil.addQueries
public function addQueries($queries) { if(is_array($queries)) { foreach($queries as $query) { $this->addQuery($query); } new Logger('Queries added to the queue.', Logger::DEBUG, __CLASS__, __LINE__); return $this; } new Logger('Failed to add to the queue.', Logger::ERROR, __CLASS__, __LINE__); return $this; }
php
public function addQueries($queries) { if(is_array($queries)) { foreach($queries as $query) { $this->addQuery($query); } new Logger('Queries added to the queue.', Logger::DEBUG, __CLASS__, __LINE__); return $this; } new Logger('Failed to add to the queue.', Logger::ERROR, __CLASS__, __LINE__); return $this; }
[ "public", "function", "addQueries", "(", "$", "queries", ")", "{", "if", "(", "is_array", "(", "$", "queries", ")", ")", "{", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "this", "->", "addQuery", "(", "$", "query", ")", ";", "}", "new", "Logger", "(", "'Queries added to the queue.'", ",", "Logger", "::", "DEBUG", ",", "__CLASS__", ",", "__LINE__", ")", ";", "return", "$", "this", ";", "}", "new", "Logger", "(", "'Failed to add to the queue.'", ",", "Logger", "::", "ERROR", ",", "__CLASS__", ",", "__LINE__", ")", ";", "return", "$", "this", ";", "}" ]
Add an array of "DBUtilQuery"s to the query_queue. @param $queries @return $this
[ "Add", "an", "array", "of", "DBUtilQuery", "s", "to", "the", "query_queue", "." ]
c9f0a26a30f8127c997f75d7232eac170972418d
https://github.com/Nozemi/SlickBoard-Library/blob/c9f0a26a30f8127c997f75d7232eac170972418d/lib/SBLib/Database/DBUtil.php#L140-L152
17,279
ClanCats/Core
src/classes/CCValidator.php
CCValidator.add_error
public function add_error( $key, $message ) { $this->success = false; $this->errors[$key][] = $message; }
php
public function add_error( $key, $message ) { $this->success = false; $this->errors[$key][] = $message; }
[ "public", "function", "add_error", "(", "$", "key", ",", "$", "message", ")", "{", "$", "this", "->", "success", "=", "false", ";", "$", "this", "->", "errors", "[", "$", "key", "]", "[", "]", "=", "$", "message", ";", "}" ]
Add an error to validator @param string $key @param string $message @return void
[ "Add", "an", "error", "to", "validator" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L165-L169
17,280
ClanCats/Core
src/classes/CCValidator.php
CCValidator.label
public function label( $data, $value = null ) { if ( !is_null( $value ) && !is_array( $data ) ) { $data = array( $data => $value ); } if ( !is_array( $data ) ) { throw new \InvalidArgumentException( 'CCValidator::label - invalid label data given' ); } $this->labels = array_merge( $this->labels, $data ); }
php
public function label( $data, $value = null ) { if ( !is_null( $value ) && !is_array( $data ) ) { $data = array( $data => $value ); } if ( !is_array( $data ) ) { throw new \InvalidArgumentException( 'CCValidator::label - invalid label data given' ); } $this->labels = array_merge( $this->labels, $data ); }
[ "public", "function", "label", "(", "$", "data", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "array", "(", "$", "data", "=>", "$", "value", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'CCValidator::label - invalid label data given'", ")", ";", "}", "$", "this", "->", "labels", "=", "array_merge", "(", "$", "this", "->", "labels", ",", "$", "data", ")", ";", "}" ]
Set a data value @param string $data @param mixed $value @return void
[ "Set", "a", "data", "value" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L190-L203
17,281
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rules
public function rules() { $args = func_get_args(); $key = array_shift( $args ); if ( !is_array( reset( $args ) ) ) { $rules = $args; } else { $rules = array_shift( $args ); } $success = true; foreach( $rules as $rule ) { $rule = explode( ':', $rule ); $params = array(); if ( array_key_exists( 1, $rule ) ) { $params = explode( ',', $rule[1] ); } $rule = reset( $rule ); array_unshift( $params, $key ); if ( !call_user_func_array( array( $this, $rule ), $params ) ) { $success = false; } } return $success; }
php
public function rules() { $args = func_get_args(); $key = array_shift( $args ); if ( !is_array( reset( $args ) ) ) { $rules = $args; } else { $rules = array_shift( $args ); } $success = true; foreach( $rules as $rule ) { $rule = explode( ':', $rule ); $params = array(); if ( array_key_exists( 1, $rule ) ) { $params = explode( ',', $rule[1] ); } $rule = reset( $rule ); array_unshift( $params, $key ); if ( !call_user_func_array( array( $this, $rule ), $params ) ) { $success = false; } } return $success; }
[ "public", "function", "rules", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "key", "=", "array_shift", "(", "$", "args", ")", ";", "if", "(", "!", "is_array", "(", "reset", "(", "$", "args", ")", ")", ")", "{", "$", "rules", "=", "$", "args", ";", "}", "else", "{", "$", "rules", "=", "array_shift", "(", "$", "args", ")", ";", "}", "$", "success", "=", "true", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "rule", "=", "explode", "(", "':'", ",", "$", "rule", ")", ";", "$", "params", "=", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "1", ",", "$", "rule", ")", ")", "{", "$", "params", "=", "explode", "(", "','", ",", "$", "rule", "[", "1", "]", ")", ";", "}", "$", "rule", "=", "reset", "(", "$", "rule", ")", ";", "array_unshift", "(", "$", "params", ",", "$", "key", ")", ";", "if", "(", "!", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "rule", ")", ",", "$", "params", ")", ")", "{", "$", "success", "=", "false", ";", "}", "}", "return", "$", "success", ";", "}" ]
Apply multiple rules to one attribute @param ...string @return bool
[ "Apply", "multiple", "rules", "to", "one", "attribute" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L231-L269
17,282
ClanCats/Core
src/classes/CCValidator.php
CCValidator.message
public function message() { $params = func_get_args(); $message = array_shift( $params ); $method = array_shift( $params ); if ( !$result = $this->validate( $method, $params ) ) { $key = array_shift( $params ); $params = $this->get_error_message_params( $key, $params ); // replace the params inside the line foreach ( $params as $param => $value ) { $message = str_replace( ':'.$param, $value, $message ); } $this->errors[$key][] = $message; } return $result; }
php
public function message() { $params = func_get_args(); $message = array_shift( $params ); $method = array_shift( $params ); if ( !$result = $this->validate( $method, $params ) ) { $key = array_shift( $params ); $params = $this->get_error_message_params( $key, $params ); // replace the params inside the line foreach ( $params as $param => $value ) { $message = str_replace( ':'.$param, $value, $message ); } $this->errors[$key][] = $message; } return $result; }
[ "public", "function", "message", "(", ")", "{", "$", "params", "=", "func_get_args", "(", ")", ";", "$", "message", "=", "array_shift", "(", "$", "params", ")", ";", "$", "method", "=", "array_shift", "(", "$", "params", ")", ";", "if", "(", "!", "$", "result", "=", "$", "this", "->", "validate", "(", "$", "method", ",", "$", "params", ")", ")", "{", "$", "key", "=", "array_shift", "(", "$", "params", ")", ";", "$", "params", "=", "$", "this", "->", "get_error_message_params", "(", "$", "key", ",", "$", "params", ")", ";", "// replace the params inside the line", "foreach", "(", "$", "params", "as", "$", "param", "=>", "$", "value", ")", "{", "$", "message", "=", "str_replace", "(", "':'", ".", "$", "param", ",", "$", "value", ",", "$", "message", ")", ";", "}", "$", "this", "->", "errors", "[", "$", "key", "]", "[", "]", "=", "$", "message", ";", "}", "return", "$", "result", ";", "}" ]
Run the validation with a custom message @param mixed... @return bool
[ "Run", "the", "validation", "with", "a", "custom", "message" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L296-L319
17,283
ClanCats/Core
src/classes/CCValidator.php
CCValidator.validate
protected function validate( $method, $params ) { $reverse = false; // when the method starts with not we assume that we // have to reverse the validation means only accepting the opposite if ( substr( $method, 0, 4 ) === 'not_' ) { $reverse = true; $method = substr( $method, 4 ); } if ( array_key_exists( $method, static::$rules ) ) { return $this->apply_rule( $method, static::$rules[$method], $params, $reverse ); } if ( method_exists( $this, 'rule_'.$method ) ) { return $this->apply_rule( $method, array( $this, 'rule_'.$method ), $params, $reverse ); } throw new \BadMethodCallException( "CCValidator - Invalid rule or method '".$method."'." ); }
php
protected function validate( $method, $params ) { $reverse = false; // when the method starts with not we assume that we // have to reverse the validation means only accepting the opposite if ( substr( $method, 0, 4 ) === 'not_' ) { $reverse = true; $method = substr( $method, 4 ); } if ( array_key_exists( $method, static::$rules ) ) { return $this->apply_rule( $method, static::$rules[$method], $params, $reverse ); } if ( method_exists( $this, 'rule_'.$method ) ) { return $this->apply_rule( $method, array( $this, 'rule_'.$method ), $params, $reverse ); } throw new \BadMethodCallException( "CCValidator - Invalid rule or method '".$method."'." ); }
[ "protected", "function", "validate", "(", "$", "method", ",", "$", "params", ")", "{", "$", "reverse", "=", "false", ";", "// when the method starts with not we assume that we ", "// have to reverse the validation means only accepting the opposite", "if", "(", "substr", "(", "$", "method", ",", "0", ",", "4", ")", "===", "'not_'", ")", "{", "$", "reverse", "=", "true", ";", "$", "method", "=", "substr", "(", "$", "method", ",", "4", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "method", ",", "static", "::", "$", "rules", ")", ")", "{", "return", "$", "this", "->", "apply_rule", "(", "$", "method", ",", "static", "::", "$", "rules", "[", "$", "method", "]", ",", "$", "params", ",", "$", "reverse", ")", ";", "}", "if", "(", "method_exists", "(", "$", "this", ",", "'rule_'", ".", "$", "method", ")", ")", "{", "return", "$", "this", "->", "apply_rule", "(", "$", "method", ",", "array", "(", "$", "this", ",", "'rule_'", ".", "$", "method", ")", ",", "$", "params", ",", "$", "reverse", ")", ";", "}", "throw", "new", "\\", "BadMethodCallException", "(", "\"CCValidator - Invalid rule or method '\"", ".", "$", "method", ".", "\"'.\"", ")", ";", "}" ]
Run an validation call @param string $rule @param array $params @return bool
[ "Run", "an", "validation", "call" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L328-L350
17,284
ClanCats/Core
src/classes/CCValidator.php
CCValidator.proof_result
protected function proof_result( $rule, $key, $result ) { if ( $result === false ) { $this->failed[$key][] = $rule; } if ( $this->success === true ) { return $this->success = $result; } return $result; }
php
protected function proof_result( $rule, $key, $result ) { if ( $result === false ) { $this->failed[$key][] = $rule; } if ( $this->success === true ) { return $this->success = $result; } return $result; }
[ "protected", "function", "proof_result", "(", "$", "rule", ",", "$", "key", ",", "$", "result", ")", "{", "if", "(", "$", "result", "===", "false", ")", "{", "$", "this", "->", "failed", "[", "$", "key", "]", "[", "]", "=", "$", "rule", ";", "}", "if", "(", "$", "this", "->", "success", "===", "true", ")", "{", "return", "$", "this", "->", "success", "=", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Proof a single result and update the success property @param string $rule @param string $key @param array $result @return bool
[ "Proof", "a", "single", "result", "and", "update", "the", "success", "property" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L360-L373
17,285
ClanCats/Core
src/classes/CCValidator.php
CCValidator.apply_rule
protected function apply_rule( $rule, $callback, $params, $reverse ) { $data_key = array_shift( $params ); // In case of that the requested data set does not exist // we always set the test as failure. if ( !array_key_exists( $data_key, $this->data ) ) { return $this->proof_result( $rule, $data_key, ( $reverse ? true : false ) ); } $call_arguments = array( $data_key, $this->data[$data_key] ); // add the other params to our call parameters $call_arguments = array_merge( $call_arguments, $params ); $result = (bool) call_user_func_array( $callback, $call_arguments ); if ( $reverse ) { $result = !$result; } return $this->proof_result( $rule, $data_key, $result ); }
php
protected function apply_rule( $rule, $callback, $params, $reverse ) { $data_key = array_shift( $params ); // In case of that the requested data set does not exist // we always set the test as failure. if ( !array_key_exists( $data_key, $this->data ) ) { return $this->proof_result( $rule, $data_key, ( $reverse ? true : false ) ); } $call_arguments = array( $data_key, $this->data[$data_key] ); // add the other params to our call parameters $call_arguments = array_merge( $call_arguments, $params ); $result = (bool) call_user_func_array( $callback, $call_arguments ); if ( $reverse ) { $result = !$result; } return $this->proof_result( $rule, $data_key, $result ); }
[ "protected", "function", "apply_rule", "(", "$", "rule", ",", "$", "callback", ",", "$", "params", ",", "$", "reverse", ")", "{", "$", "data_key", "=", "array_shift", "(", "$", "params", ")", ";", "// In case of that the requested data set does not exist", "// we always set the test as failure.", "if", "(", "!", "array_key_exists", "(", "$", "data_key", ",", "$", "this", "->", "data", ")", ")", "{", "return", "$", "this", "->", "proof_result", "(", "$", "rule", ",", "$", "data_key", ",", "(", "$", "reverse", "?", "true", ":", "false", ")", ")", ";", "}", "$", "call_arguments", "=", "array", "(", "$", "data_key", ",", "$", "this", "->", "data", "[", "$", "data_key", "]", ")", ";", "// add the other params to our call parameters", "$", "call_arguments", "=", "array_merge", "(", "$", "call_arguments", ",", "$", "params", ")", ";", "$", "result", "=", "(", "bool", ")", "call_user_func_array", "(", "$", "callback", ",", "$", "call_arguments", ")", ";", "if", "(", "$", "reverse", ")", "{", "$", "result", "=", "!", "$", "result", ";", "}", "return", "$", "this", "->", "proof_result", "(", "$", "rule", ",", "$", "data_key", ",", "$", "result", ")", ";", "}" ]
Apply an rule executes the rule and runs the result proof @param string $rule @param callback $callback @param array $params @return bool
[ "Apply", "an", "rule", "executes", "the", "rule", "and", "runs", "the", "result", "proof" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L383-L407
17,286
ClanCats/Core
src/classes/CCValidator.php
CCValidator.get_error_message_params
protected function get_error_message_params( $key, $params ) { // do we have a label to replace the key? if ( isset( $this->labels[$key] ) ) { $field = $this->labels[$key]; } else { $field = ucfirst( str_replace( array( '_', '-' ), ' ', $key ) ); } return array_merge( array( 'field' => $field ), $params ); }
php
protected function get_error_message_params( $key, $params ) { // do we have a label to replace the key? if ( isset( $this->labels[$key] ) ) { $field = $this->labels[$key]; } else { $field = ucfirst( str_replace( array( '_', '-' ), ' ', $key ) ); } return array_merge( array( 'field' => $field ), $params ); }
[ "protected", "function", "get_error_message_params", "(", "$", "key", ",", "$", "params", ")", "{", "// do we have a label to replace the key?", "if", "(", "isset", "(", "$", "this", "->", "labels", "[", "$", "key", "]", ")", ")", "{", "$", "field", "=", "$", "this", "->", "labels", "[", "$", "key", "]", ";", "}", "else", "{", "$", "field", "=", "ucfirst", "(", "str_replace", "(", "array", "(", "'_'", ",", "'-'", ")", ",", "' '", ",", "$", "key", ")", ")", ";", "}", "return", "array_merge", "(", "array", "(", "'field'", "=>", "$", "field", ")", ",", "$", "params", ")", ";", "}" ]
Get the parameter array for the error messages @param string $key @param array $params @return array
[ "Get", "the", "parameter", "array", "for", "the", "error", "messages" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L416-L427
17,287
ClanCats/Core
src/classes/CCValidator.php
CCValidator.generate_error_message
protected function generate_error_message( $rule, $key, $params ) { $params = $this->get_error_message_params( $key, $params ); return __( ClanCats::$config->get( 'validation.language_prefix' ).'.'.$rule, $params ); }
php
protected function generate_error_message( $rule, $key, $params ) { $params = $this->get_error_message_params( $key, $params ); return __( ClanCats::$config->get( 'validation.language_prefix' ).'.'.$rule, $params ); }
[ "protected", "function", "generate_error_message", "(", "$", "rule", ",", "$", "key", ",", "$", "params", ")", "{", "$", "params", "=", "$", "this", "->", "get_error_message_params", "(", "$", "key", ",", "$", "params", ")", ";", "return", "__", "(", "ClanCats", "::", "$", "config", "->", "get", "(", "'validation.language_prefix'", ")", ".", "'.'", ".", "$", "rule", ",", "$", "params", ")", ";", "}" ]
Generate the error message for an rule @param string $rule @param string $key @param array $params @return string
[ "Generate", "the", "error", "message", "for", "an", "rule" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L437-L441
17,288
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_required
public function rule_required( $key, $value ) { if ( is_null( $value ) ) { return false; } elseif ( is_string( $value ) && trim( $value ) == '' ) { return false; } return true; }
php
public function rule_required( $key, $value ) { if ( is_null( $value ) ) { return false; } elseif ( is_string( $value ) && trim( $value ) == '' ) { return false; } return true; }
[ "public", "function", "rule_required", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", "&&", "trim", "(", "$", "value", ")", "==", "''", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if the field is set an not empty @param string $key @param string $value @return bool
[ "Check", "if", "the", "field", "is", "set", "an", "not", "empty" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L454-L465
17,289
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_between_num
public function rule_between_num( $key, $value, $min, $max ) { if ( !$this->rule_min_num( $key, $value, $min ) ) { return false; } if ( !$this->rule_max_num( $key, $value, $max ) ) { return false; } return true; }
php
public function rule_between_num( $key, $value, $min, $max ) { if ( !$this->rule_min_num( $key, $value, $min ) ) { return false; } if ( !$this->rule_max_num( $key, $value, $max ) ) { return false; } return true; }
[ "public", "function", "rule_between_num", "(", "$", "key", ",", "$", "value", ",", "$", "min", ",", "$", "max", ")", "{", "if", "(", "!", "$", "this", "->", "rule_min_num", "(", "$", "key", ",", "$", "value", ",", "$", "min", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "rule_max_num", "(", "$", "key", ",", "$", "value", ",", "$", "max", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is the given number between min and max @param string $key @param string $value @return bool
[ "Is", "the", "given", "number", "between", "min", "and", "max" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L518-L529
17,290
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_min
public function rule_min( $key, $value, $min ) { return $this->rule_min_num( $key, strlen( $value ), $min ); }
php
public function rule_min( $key, $value, $min ) { return $this->rule_min_num( $key, strlen( $value ), $min ); }
[ "public", "function", "rule_min", "(", "$", "key", ",", "$", "value", ",", "$", "min", ")", "{", "return", "$", "this", "->", "rule_min_num", "(", "$", "key", ",", "strlen", "(", "$", "value", ")", ",", "$", "min", ")", ";", "}" ]
Is the given string at least some size @param string $key @param string $value @return bool
[ "Is", "the", "given", "string", "at", "least", "some", "size" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L538-L541
17,291
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_max
public function rule_max( $key, $value, $max ) { return $this->rule_max_num( $key, strlen( $value ), $max ); }
php
public function rule_max( $key, $value, $max ) { return $this->rule_max_num( $key, strlen( $value ), $max ); }
[ "public", "function", "rule_max", "(", "$", "key", ",", "$", "value", ",", "$", "max", ")", "{", "return", "$", "this", "->", "rule_max_num", "(", "$", "key", ",", "strlen", "(", "$", "value", ")", ",", "$", "max", ")", ";", "}" ]
Is the given string max some size @param string $key @param string $value @return bool
[ "Is", "the", "given", "string", "max", "some", "size" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L550-L553
17,292
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_between
public function rule_between( $key, $value, $min, $max ) { return $this->rule_between_num( $key, strlen( $value ), $min, $max ); }
php
public function rule_between( $key, $value, $min, $max ) { return $this->rule_between_num( $key, strlen( $value ), $min, $max ); }
[ "public", "function", "rule_between", "(", "$", "key", ",", "$", "value", ",", "$", "min", ",", "$", "max", ")", "{", "return", "$", "this", "->", "rule_between_num", "(", "$", "key", ",", "strlen", "(", "$", "value", ")", ",", "$", "min", ",", "$", "max", ")", ";", "}" ]
Is the given string between min and max @param string $key @param string $value @return bool
[ "Is", "the", "given", "string", "between", "min", "and", "max" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L562-L565
17,293
ClanCats/Core
src/classes/CCValidator.php
CCValidator.rule_date_format
public function rule_date_format( $key, $value, $format = 'd/m/Y' ) { return date( $format, strtotime( trim( $value ) ) ) == trim( $value ); }
php
public function rule_date_format( $key, $value, $format = 'd/m/Y' ) { return date( $format, strtotime( trim( $value ) ) ) == trim( $value ); }
[ "public", "function", "rule_date_format", "(", "$", "key", ",", "$", "value", ",", "$", "format", "=", "'d/m/Y'", ")", "{", "return", "date", "(", "$", "format", ",", "strtotime", "(", "trim", "(", "$", "value", ")", ")", ")", "==", "trim", "(", "$", "value", ")", ";", "}" ]
Check if valid date format @param string $key @param string $value @param string $format @param bool
[ "Check", "if", "valid", "date", "format" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCValidator.php#L711-L714
17,294
devmobgroup/postcodes
src/Traits/AccessesProperties.php
AccessesProperties.get
protected function get($data, string $key) { $dot = $data instanceof Dot ? $data : new Dot($data); if (isset($dot[$key])) { return $dot[$key]; } throw new UnexpectedResponseException(sprintf('Missing key \'%s\' in data')); }
php
protected function get($data, string $key) { $dot = $data instanceof Dot ? $data : new Dot($data); if (isset($dot[$key])) { return $dot[$key]; } throw new UnexpectedResponseException(sprintf('Missing key \'%s\' in data')); }
[ "protected", "function", "get", "(", "$", "data", ",", "string", "$", "key", ")", "{", "$", "dot", "=", "$", "data", "instanceof", "Dot", "?", "$", "data", ":", "new", "Dot", "(", "$", "data", ")", ";", "if", "(", "isset", "(", "$", "dot", "[", "$", "key", "]", ")", ")", "{", "return", "$", "dot", "[", "$", "key", "]", ";", "}", "throw", "new", "UnexpectedResponseException", "(", "sprintf", "(", "'Missing key \\'%s\\' in data'", ")", ")", ";", "}" ]
Extract data from an array using dot notation. Throws an exception when the provided key does not exist. @param array|\Adbar\Dot $data @param string $key Supports dot notation {@see https://github.com/adbario/php-dot-notation} @return mixed @throws \DevMob\Postcodes\Exceptions\UnexpectedResponseException
[ "Extract", "data", "from", "an", "array", "using", "dot", "notation", ".", "Throws", "an", "exception", "when", "the", "provided", "key", "does", "not", "exist", "." ]
1a8438fd960a8f50ec28d61af94560892b529f12
https://github.com/devmobgroup/postcodes/blob/1a8438fd960a8f50ec28d61af94560892b529f12/src/Traits/AccessesProperties.php#L19-L28
17,295
maximebf/events
src/Events/Notifier.php
Notifier.notify
public function notify($eventName, array $params = array()) { $this->dispatcher->notify($e = $this->createEvent($eventName, $params)); return $e; }
php
public function notify($eventName, array $params = array()) { $this->dispatcher->notify($e = $this->createEvent($eventName, $params)); return $e; }
[ "public", "function", "notify", "(", "$", "eventName", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "this", "->", "dispatcher", "->", "notify", "(", "$", "e", "=", "$", "this", "->", "createEvent", "(", "$", "eventName", ",", "$", "params", ")", ")", ";", "return", "$", "e", ";", "}" ]
Creates and dispatches an event @see EventDispatcher::notify() @param string $eventName @param array $params @return Event
[ "Creates", "and", "dispatches", "an", "event" ]
b9861c260ee9eaabb9aa986bab76a2e039eb871f
https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/Notifier.php#L139-L143
17,296
maximebf/events
src/Events/Notifier.php
Notifier.notifyUntil
public function notifyUntil($eventName, array $params = array(), $callback = null) { $this->dispatcher->notifyUntil($e = $this->createEvent($eventName, $params), $callback); return $e; }
php
public function notifyUntil($eventName, array $params = array(), $callback = null) { $this->dispatcher->notifyUntil($e = $this->createEvent($eventName, $params), $callback); return $e; }
[ "public", "function", "notifyUntil", "(", "$", "eventName", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "callback", "=", "null", ")", "{", "$", "this", "->", "dispatcher", "->", "notifyUntil", "(", "$", "e", "=", "$", "this", "->", "createEvent", "(", "$", "eventName", ",", "$", "params", ")", ",", "$", "callback", ")", ";", "return", "$", "e", ";", "}" ]
Creates and dispatches an event until it has been processed. @see EventDispatcher::notifyUntil() @param string $eventName @param array $params @param callback $callback @return Event
[ "Creates", "and", "dispatches", "an", "event", "until", "it", "has", "been", "processed", "." ]
b9861c260ee9eaabb9aa986bab76a2e039eb871f
https://github.com/maximebf/events/blob/b9861c260ee9eaabb9aa986bab76a2e039eb871f/src/Events/Notifier.php#L154-L158
17,297
crypto-markets/common
src/Common/Endpoint.php
Endpoint.make
public static function make(Client $httpClient, array $params = []) { $instance = new static($httpClient); $instance->configure($params); return $instance; }
php
public static function make(Client $httpClient, array $params = []) { $instance = new static($httpClient); $instance->configure($params); return $instance; }
[ "public", "static", "function", "make", "(", "Client", "$", "httpClient", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "instance", "=", "new", "static", "(", "$", "httpClient", ")", ";", "$", "instance", "->", "configure", "(", "$", "params", ")", ";", "return", "$", "instance", ";", "}" ]
Create a new resource instance. @param \CryptoMarkets\Common\Client $httpClient @param array $params @return static
[ "Create", "a", "new", "resource", "instance", "." ]
206b1d9b88502d3fb73cef1323cd086156d3e633
https://github.com/crypto-markets/common/blob/206b1d9b88502d3fb73cef1323cd086156d3e633/src/Common/Endpoint.php#L48-L55
17,298
crypto-markets/common
src/Common/Endpoint.php
Endpoint.send
public function send() { $request = $this->createRequest(); $response = $this->httpClient->sendRequest($request); return $this->mapResponse((array) $this->parseResponse($response)); }
php
public function send() { $request = $this->createRequest(); $response = $this->httpClient->sendRequest($request); return $this->mapResponse((array) $this->parseResponse($response)); }
[ "public", "function", "send", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequest", "(", ")", ";", "$", "response", "=", "$", "this", "->", "httpClient", "->", "sendRequest", "(", "$", "request", ")", ";", "return", "$", "this", "->", "mapResponse", "(", "(", "array", ")", "$", "this", "->", "parseResponse", "(", "$", "response", ")", ")", ";", "}" ]
Send a new request. @return array
[ "Send", "a", "new", "request", "." ]
206b1d9b88502d3fb73cef1323cd086156d3e633
https://github.com/crypto-markets/common/blob/206b1d9b88502d3fb73cef1323cd086156d3e633/src/Common/Endpoint.php#L75-L82
17,299
crypto-markets/common
src/Common/Endpoint.php
Endpoint.getPreparedData
public function getPreparedData() { $params = $this->getData(); if ($this->authorize) { $params = array_merge($params, $this->authenticationData($params)); } return $params; }
php
public function getPreparedData() { $params = $this->getData(); if ($this->authorize) { $params = array_merge($params, $this->authenticationData($params)); } return $params; }
[ "public", "function", "getPreparedData", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getData", "(", ")", ";", "if", "(", "$", "this", "->", "authorize", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "authenticationData", "(", "$", "params", ")", ")", ";", "}", "return", "$", "params", ";", "}" ]
Get the request data for authorized or not. @return string
[ "Get", "the", "request", "data", "for", "authorized", "or", "not", "." ]
206b1d9b88502d3fb73cef1323cd086156d3e633
https://github.com/crypto-markets/common/blob/206b1d9b88502d3fb73cef1323cd086156d3e633/src/Common/Endpoint.php#L141-L150