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
14,700
stubbles/stubbles-webapp-core
src/main/php/auth/token/TokenAuthenticator.php
TokenAuthenticator.login
private function login(Request $request) { $user = $this->loginProvider->authenticate($request); if (null !== $user) { try { $token = $user->createToken($this->tokenSalt); $this->tokenStore->store($request, $token, $user); return $user; } catch (\Exception $e) { throw new InternalAuthProviderException( 'Error while trying to store new token for user: ' . $e->getMessage(), $e ); } } return null; }
php
private function login(Request $request) { $user = $this->loginProvider->authenticate($request); if (null !== $user) { try { $token = $user->createToken($this->tokenSalt); $this->tokenStore->store($request, $token, $user); return $user; } catch (\Exception $e) { throw new InternalAuthProviderException( 'Error while trying to store new token for user: ' . $e->getMessage(), $e ); } } return null; }
[ "private", "function", "login", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "$", "this", "->", "loginProvider", "->", "authenticate", "(", "$", "request", ")", ";", "if", "(", "null", "!==", "$", "user", ")", "{", "try", "{", "$", "token", "=", "$", "user", "->", "createToken", "(", "$", "this", "->", "tokenSalt", ")", ";", "$", "this", "->", "tokenStore", "->", "store", "(", "$", "request", ",", "$", "token", ",", "$", "user", ")", ";", "return", "$", "user", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "InternalAuthProviderException", "(", "'Error while trying to store new token for user: '", ".", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", ")", ";", "}", "}", "return", "null", ";", "}" ]
performs login when token not found or invalid @param \stubbles\webapp\Request $request @return \stubbles\webapp\auth\User|null @throws \stubbles\webapp\auth\InternalAuthProviderException
[ "performs", "login", "when", "token", "not", "found", "or", "invalid" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/token/TokenAuthenticator.php#L92-L109
14,701
stubbles/stubbles-webapp-core
src/main/php/auth/token/TokenAuthenticator.php
TokenAuthenticator.readToken
private function readToken(Request $request) { if (!$request->hasRedirectHeader('HTTP_AUTHORIZATION')) { return null; } return $request->readRedirectHeader('HTTP_AUTHORIZATION') ->withFilter(TokenFilter::instance()); }
php
private function readToken(Request $request) { if (!$request->hasRedirectHeader('HTTP_AUTHORIZATION')) { return null; } return $request->readRedirectHeader('HTTP_AUTHORIZATION') ->withFilter(TokenFilter::instance()); }
[ "private", "function", "readToken", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "hasRedirectHeader", "(", "'HTTP_AUTHORIZATION'", ")", ")", "{", "return", "null", ";", "}", "return", "$", "request", "->", "readRedirectHeader", "(", "'HTTP_AUTHORIZATION'", ")", "->", "withFilter", "(", "TokenFilter", "::", "instance", "(", ")", ")", ";", "}" ]
reads token from authorization header @param \stubbles\webapp\Request $request current request @return \stubbles\webapp\auth\Token|null
[ "reads", "token", "from", "authorization", "header" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/token/TokenAuthenticator.php#L117-L125
14,702
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/Column.php
Column.getColumnAttr
public function getColumnAttr() { $attr = []; foreach ($this->column as $item) { if (is_array($item)) $attr = array_merge($attr, $item); else $attr[] = $item; } return array_unique(array_values($attr)); }
php
public function getColumnAttr() { $attr = []; foreach ($this->column as $item) { if (is_array($item)) $attr = array_merge($attr, $item); else $attr[] = $item; } return array_unique(array_values($attr)); }
[ "public", "function", "getColumnAttr", "(", ")", "{", "$", "attr", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "column", "as", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "$", "attr", "=", "array_merge", "(", "$", "attr", ",", "$", "item", ")", ";", "else", "$", "attr", "[", "]", "=", "$", "item", ";", "}", "return", "array_unique", "(", "array_values", "(", "$", "attr", ")", ")", ";", "}" ]
Gets all column attributes. @return array
[ "Gets", "all", "column", "attributes", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Column.php#L29-L41
14,703
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/Column.php
Column.hideColumn
public function hideColumn($column) { if (! is_array($column)) $column = [$column]; $newColumn = []; foreach ($this->column as $item) { if (is_array($item)) { $new = array_values(array_diff($item, $column)); if (! empty($new)) $newColumn[] = count($new) > 1 ? array_values($new) : $new[0]; } else if (! in_array($item, $column)) $newColumn[] = $item; } $this->column = $newColumn; return $this; }
php
public function hideColumn($column) { if (! is_array($column)) $column = [$column]; $newColumn = []; foreach ($this->column as $item) { if (is_array($item)) { $new = array_values(array_diff($item, $column)); if (! empty($new)) $newColumn[] = count($new) > 1 ? array_values($new) : $new[0]; } else if (! in_array($item, $column)) $newColumn[] = $item; } $this->column = $newColumn; return $this; }
[ "public", "function", "hideColumn", "(", "$", "column", ")", "{", "if", "(", "!", "is_array", "(", "$", "column", ")", ")", "$", "column", "=", "[", "$", "column", "]", ";", "$", "newColumn", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "column", "as", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "new", "=", "array_values", "(", "array_diff", "(", "$", "item", ",", "$", "column", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "new", ")", ")", "$", "newColumn", "[", "]", "=", "count", "(", "$", "new", ")", ">", "1", "?", "array_values", "(", "$", "new", ")", ":", "$", "new", "[", "0", "]", ";", "}", "else", "if", "(", "!", "in_array", "(", "$", "item", ",", "$", "column", ")", ")", "$", "newColumn", "[", "]", "=", "$", "item", ";", "}", "$", "this", "->", "column", "=", "$", "newColumn", ";", "return", "$", "this", ";", "}" ]
Remove one or more columns attributes @param string|array $column @return self
[ "Remove", "one", "or", "more", "columns", "attributes" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Column.php#L64-L85
14,704
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesKeyframe.php
KeyframesKeyframe.checkValue
public function checkValue(&$value) { if (parent::checkValue($value) === true) { if (!preg_match('/^(?:from|to|(?:\d{1,2}|100)%)$/D', $value)) { $this->setIsValid(false); $this->addValidationError("Invalid value '$value' for the keyframe selector."); return false; } return true; } return false; }
php
public function checkValue(&$value) { if (parent::checkValue($value) === true) { if (!preg_match('/^(?:from|to|(?:\d{1,2}|100)%)$/D', $value)) { $this->setIsValid(false); $this->addValidationError("Invalid value '$value' for the keyframe selector."); return false; } return true; } return false; }
[ "public", "function", "checkValue", "(", "&", "$", "value", ")", "{", "if", "(", "parent", "::", "checkValue", "(", "$", "value", ")", "===", "true", ")", "{", "if", "(", "!", "preg_match", "(", "'/^(?:from|to|(?:\\d{1,2}|100)%)$/D'", ",", "$", "value", ")", ")", "{", "$", "this", "->", "setIsValid", "(", "false", ")", ";", "$", "this", "->", "addValidationError", "(", "\"Invalid value '$value' for the keyframe selector.\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks the keyframes selector value. @param string $value @return bool
[ "Checks", "the", "keyframes", "selector", "value", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesKeyframe.php#L25-L38
14,705
discophp/framework
core/classes/DataModel.class.php
DataModel.verifyOnly
public final function verifyOnly($fields){ foreach($fields as $k){ $this->verifyData($k); }//foreach if(count($this->errors)){ return false; }//if return true; }
php
public final function verifyOnly($fields){ foreach($fields as $k){ $this->verifyData($k); }//foreach if(count($this->errors)){ return false; }//if return true; }
[ "public", "final", "function", "verifyOnly", "(", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "k", ")", "{", "$", "this", "->", "verifyData", "(", "$", "k", ")", ";", "}", "//foreach", "if", "(", "count", "(", "$", "this", "->", "errors", ")", ")", "{", "return", "false", ";", "}", "//if", "return", "true", ";", "}" ]
Verify only the passed fields data. This comes in handy when you only want to verify a subset of the data models definition. @param array $fields The field data keys to verify. @return boolean Whether the data in the passed fields passed verification.
[ "Verify", "only", "the", "passed", "fields", "data", ".", "This", "comes", "in", "handy", "when", "you", "only", "want", "to", "verify", "a", "subset", "of", "the", "data", "models", "definition", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L149-L161
14,706
discophp/framework
core/classes/DataModel.class.php
DataModel.verifySetData
public final function verifySetData(){ foreach($this->data as $k => $v){ $this->verifyData($k); }//foreach if(count($this->errors)){ return false; }//if return true; }
php
public final function verifySetData(){ foreach($this->data as $k => $v){ $this->verifyData($k); }//foreach if(count($this->errors)){ return false; }//if return true; }
[ "public", "final", "function", "verifySetData", "(", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "verifyData", "(", "$", "k", ")", ";", "}", "//foreach", "if", "(", "count", "(", "$", "this", "->", "errors", ")", ")", "{", "return", "false", ";", "}", "//if", "return", "true", ";", "}" ]
Verify only data that has been set in the data model and not all data defined by the definitions. @return boolean Whether the set data passed verification.
[ "Verify", "only", "data", "that", "has", "been", "set", "in", "the", "data", "model", "and", "not", "all", "data", "defined", "by", "the", "definitions", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L170-L182
14,707
discophp/framework
core/classes/DataModel.class.php
DataModel.setError
protected final function setError($key, $error = null){ if($e = $this->getDefinitionValue($key,'error')){ $error = $e; } else if($error === null){ $error = sprintf($this->defaultErrorMessage,$key); }//elif $this->errors[$key] = $error; return false; }
php
protected final function setError($key, $error = null){ if($e = $this->getDefinitionValue($key,'error')){ $error = $e; } else if($error === null){ $error = sprintf($this->defaultErrorMessage,$key); }//elif $this->errors[$key] = $error; return false; }
[ "protected", "final", "function", "setError", "(", "$", "key", ",", "$", "error", "=", "null", ")", "{", "if", "(", "$", "e", "=", "$", "this", "->", "getDefinitionValue", "(", "$", "key", ",", "'error'", ")", ")", "{", "$", "error", "=", "$", "e", ";", "}", "else", "if", "(", "$", "error", "===", "null", ")", "{", "$", "error", "=", "sprintf", "(", "$", "this", "->", "defaultErrorMessage", ",", "$", "key", ")", ";", "}", "//elif", "$", "this", "->", "errors", "[", "$", "key", "]", "=", "$", "error", ";", "return", "false", ";", "}" ]
Set an error. @param string $key The data key. @param null|string The error message to set, if null, the `defaultErrorMessage` will be used. @return boolean Always returns false, which eases chaining in the `verifyData` method.
[ "Set", "an", "error", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L396-L404
14,708
discophp/framework
core/classes/DataModel.class.php
DataModel.getError
public function getError($key){ if(!isset($this->errors[$key])){ return false; }//if return $this->errors[$key]; }
php
public function getError($key){ if(!isset($this->errors[$key])){ return false; }//if return $this->errors[$key]; }
[ "public", "function", "getError", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "errors", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "//if", "return", "$", "this", "->", "errors", "[", "$", "key", "]", ";", "}" ]
Get an error. @param string $key The data key. @return boolean|string False if no error for `$key`, otherwise the error string.
[ "Get", "an", "error", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L415-L423
14,709
discophp/framework
core/classes/DataModel.class.php
DataModel.setDefinition
public final function setDefinition($key, $value){ if(array_key_exists($key, $this->definition)){ throw new \Disco\exceptions\Exception("Cannot override frozen data model definition `{$key}`"); }//if $this->definition[$key] = $value; }
php
public final function setDefinition($key, $value){ if(array_key_exists($key, $this->definition)){ throw new \Disco\exceptions\Exception("Cannot override frozen data model definition `{$key}`"); }//if $this->definition[$key] = $value; }
[ "public", "final", "function", "setDefinition", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "definition", ")", ")", "{", "throw", "new", "\\", "Disco", "\\", "exceptions", "\\", "Exception", "(", "\"Cannot override frozen data model definition `{$key}`\"", ")", ";", "}", "//if", "$", "this", "->", "definition", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set a datums definition. Cannot overwrite previously defined definitions. @param string $key The definition key. @param array $value The definition. @throws \Disco\exceptions\Exception When setting the definition would override a frozen data model definition.
[ "Set", "a", "datums", "definition", ".", "Cannot", "overwrite", "previously", "defined", "definitions", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L480-L485
14,710
discophp/framework
core/classes/DataModel.class.php
DataModel.getDefinitionValue
public final function getDefinitionValue($key, $condition){ if(!array_key_exists($key, $this->definition) || !array_key_exists($condition, $this->definition[$key])){ return false; }//if return $this->definition[$key][$condition]; }
php
public final function getDefinitionValue($key, $condition){ if(!array_key_exists($key, $this->definition) || !array_key_exists($condition, $this->definition[$key])){ return false; }//if return $this->definition[$key][$condition]; }
[ "public", "final", "function", "getDefinitionValue", "(", "$", "key", ",", "$", "condition", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "definition", ")", "||", "!", "array_key_exists", "(", "$", "condition", ",", "$", "this", "->", "definition", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "//if ", "return", "$", "this", "->", "definition", "[", "$", "key", "]", "[", "$", "condition", "]", ";", "}" ]
Get a single value that resides within a single data definition. @param string $key The definition key. @param string $condition The definition key child key. @param mixed False when the condition is not set, otherwise the condition value. @return mixed
[ "Get", "a", "single", "value", "that", "resides", "within", "a", "single", "data", "definition", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L498-L503
14,711
discophp/framework
core/classes/DataModel.class.php
DataModel.offsetSet
public function offsetSet($key,$value){ if(!array_key_exists($key,$this->definition)){ throw new \Disco\exceptions\Exception("Field `{$key}` is not defined by this data model"); }//if $this->data[$key] = $value; }
php
public function offsetSet($key,$value){ if(!array_key_exists($key,$this->definition)){ throw new \Disco\exceptions\Exception("Field `{$key}` is not defined by this data model"); }//if $this->data[$key] = $value; }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "definition", ")", ")", "{", "throw", "new", "\\", "Disco", "\\", "exceptions", "\\", "Exception", "(", "\"Field `{$key}` is not defined by this data model\"", ")", ";", "}", "//if", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set a field of the data model using array access syntax. @param string $key The key. @param mixed $value The value. @throws \Disco\exceptions\Exception When the data model doesn't support that field.
[ "Set", "a", "field", "of", "the", "data", "model", "using", "array", "access", "syntax", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L601-L606
14,712
discophp/framework
core/classes/DataModel.class.php
DataModel._postMassage
protected final function _postMassage($key,$value){ //POSTMASSAGE if(($massage = $this->getDefinitionValue($key,'postmassage')) !== false){ $this->data[$key] = $this->{$massage}($value); }//if }
php
protected final function _postMassage($key,$value){ //POSTMASSAGE if(($massage = $this->getDefinitionValue($key,'postmassage')) !== false){ $this->data[$key] = $this->{$massage}($value); }//if }
[ "protected", "final", "function", "_postMassage", "(", "$", "key", ",", "$", "value", ")", "{", "//POSTMASSAGE", "if", "(", "(", "$", "massage", "=", "$", "this", "->", "getDefinitionValue", "(", "$", "key", ",", "'postmassage'", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "this", "->", "{", "$", "massage", "}", "(", "$", "value", ")", ";", "}", "//if", "}" ]
Apply a post massage function to a data value. @param string $key The data key. @param mixed $value The data value.
[ "Apply", "a", "post", "massage", "function", "to", "a", "data", "value", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L644-L651
14,713
discophp/framework
core/classes/DataModel.class.php
DataModel._isValidInt
protected final function _isValidInt($key,$value){ if(!is_numeric($value) || strpos($value,'.') !== false){ return $this->setError($key,"`{$key}` must be a integer"); }//if if(!$this->_isBetweenMinAndMax($key,$value)){ return false; }//if return true; }
php
protected final function _isValidInt($key,$value){ if(!is_numeric($value) || strpos($value,'.') !== false){ return $this->setError($key,"`{$key}` must be a integer"); }//if if(!$this->_isBetweenMinAndMax($key,$value)){ return false; }//if return true; }
[ "protected", "final", "function", "_isValidInt", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", "||", "strpos", "(", "$", "value", ",", "'.'", ")", "!==", "false", ")", "{", "return", "$", "this", "->", "setError", "(", "$", "key", ",", "\"`{$key}` must be a integer\"", ")", ";", "}", "//if", "if", "(", "!", "$", "this", "->", "_isBetweenMinAndMax", "(", "$", "key", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "//if", "return", "true", ";", "}" ]
Determine if the value is a valid int. @param string $key The data key. @param mixed $value The data value. @return boolean
[ "Determine", "if", "the", "value", "is", "a", "valid", "int", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L663-L675
14,714
discophp/framework
core/classes/DataModel.class.php
DataModel._isValidFloat
protected final function _isValidFloat($key,$value){ if(!is_numeric($value)){ return $this->setError($key,"`{$key}` must be numeric"); }//if if(!$this->_isBetweenMinAndMax($key,$value)){ return false; }//if return true; }
php
protected final function _isValidFloat($key,$value){ if(!is_numeric($value)){ return $this->setError($key,"`{$key}` must be numeric"); }//if if(!$this->_isBetweenMinAndMax($key,$value)){ return false; }//if return true; }
[ "protected", "final", "function", "_isValidFloat", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "setError", "(", "$", "key", ",", "\"`{$key}` must be numeric\"", ")", ";", "}", "//if", "if", "(", "!", "$", "this", "->", "_isBetweenMinAndMax", "(", "$", "key", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "//if", "return", "true", ";", "}" ]
Determine if the value is a valid float. @param string $key The data key. @param mixed $value The data value. @return boolean
[ "Determine", "if", "the", "value", "is", "a", "valid", "float", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L687-L699
14,715
discophp/framework
core/classes/DataModel.class.php
DataModel._isBetweenMinAndMax
protected final function _isBetweenMinAndMax($key,$value){ if(($min = $this->getDefinitionValue($key,'min')) !== false && $value < $min){ return $this->setError($key,"`{$key}` must be greater than {$min}"); }//if if(($max = $this->getDefinitionValue($key,'max')) !== false && $value > $max){ return $this->setError($key,"`{$key}` must be less than {$max}"); }//if return true; }
php
protected final function _isBetweenMinAndMax($key,$value){ if(($min = $this->getDefinitionValue($key,'min')) !== false && $value < $min){ return $this->setError($key,"`{$key}` must be greater than {$min}"); }//if if(($max = $this->getDefinitionValue($key,'max')) !== false && $value > $max){ return $this->setError($key,"`{$key}` must be less than {$max}"); }//if return true; }
[ "protected", "final", "function", "_isBetweenMinAndMax", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "(", "$", "min", "=", "$", "this", "->", "getDefinitionValue", "(", "$", "key", ",", "'min'", ")", ")", "!==", "false", "&&", "$", "value", "<", "$", "min", ")", "{", "return", "$", "this", "->", "setError", "(", "$", "key", ",", "\"`{$key}` must be greater than {$min}\"", ")", ";", "}", "//if", "if", "(", "(", "$", "max", "=", "$", "this", "->", "getDefinitionValue", "(", "$", "key", ",", "'max'", ")", ")", "!==", "false", "&&", "$", "value", ">", "$", "max", ")", "{", "return", "$", "this", "->", "setError", "(", "$", "key", ",", "\"`{$key}` must be less than {$max}\"", ")", ";", "}", "//if", "return", "true", ";", "}" ]
Determine if the value is greater than `min` if set, and less than `max` if set. @param string $key The data key. @param mixed $value The data value. @return boolean
[ "Determine", "if", "the", "value", "is", "greater", "than", "min", "if", "set", "and", "less", "than", "max", "if", "set", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/DataModel.class.php#L711-L723
14,716
bestit/commercetools-order-export-bundle
src/Command/ExportCommand.php
ExportCommand.getProgressBar
private function getProgressBar(OutputInterface $output, int $total): ProgressBar { return $this->getProgressBarFactory()->getProgressBar($output, $total); }
php
private function getProgressBar(OutputInterface $output, int $total): ProgressBar { return $this->getProgressBarFactory()->getProgressBar($output, $total); }
[ "private", "function", "getProgressBar", "(", "OutputInterface", "$", "output", ",", "int", "$", "total", ")", ":", "ProgressBar", "{", "return", "$", "this", "->", "getProgressBarFactory", "(", ")", "->", "getProgressBar", "(", "$", "output", ",", "$", "total", ")", ";", "}" ]
Returns the progress bar from the factory. @param OutputInterface $output @param int $total @return ProgressBar
[ "Returns", "the", "progress", "bar", "from", "the", "factory", "." ]
44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845
https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/Command/ExportCommand.php#L140-L143
14,717
huasituo/hstcms
src/Providers/ConsoleServiceProvider.php
ConsoleServiceProvider.registerInstallCommand
protected function registerInstallCommand() { $this->app->singleton('command.hstcms.install', function ($app) { return new \Huasituo\Hstcms\Console\Commands\HstcmsInstallCommand($app['hstcms']); }); $this->commands('command.hstcms.install'); }
php
protected function registerInstallCommand() { $this->app->singleton('command.hstcms.install', function ($app) { return new \Huasituo\Hstcms\Console\Commands\HstcmsInstallCommand($app['hstcms']); }); $this->commands('command.hstcms.install'); }
[ "protected", "function", "registerInstallCommand", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'command.hstcms.install'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Huasituo", "\\", "Hstcms", "\\", "Console", "\\", "Commands", "\\", "HstcmsInstallCommand", "(", "$", "app", "[", "'hstcms'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "'command.hstcms.install'", ")", ";", "}" ]
Register the hstcms.install command.
[ "Register", "the", "hstcms", ".", "install", "command", "." ]
12819979289e58ce38e3e92540aeeb16e205e525
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/ConsoleServiceProvider.php#L37-L43
14,718
huasituo/hstcms
src/Providers/ConsoleServiceProvider.php
ConsoleServiceProvider.registerInfoCommand
protected function registerInfoCommand() { $this->app->singleton('command.hstcms.info', function ($app) { return new \Huasituo\Hstcms\Console\Commands\HstcmsInfoCommand($app['hstcms']); }); $this->commands('command.hstcms.info'); }
php
protected function registerInfoCommand() { $this->app->singleton('command.hstcms.info', function ($app) { return new \Huasituo\Hstcms\Console\Commands\HstcmsInfoCommand($app['hstcms']); }); $this->commands('command.hstcms.info'); }
[ "protected", "function", "registerInfoCommand", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'command.hstcms.info'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Huasituo", "\\", "Hstcms", "\\", "Console", "\\", "Commands", "\\", "HstcmsInfoCommand", "(", "$", "app", "[", "'hstcms'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "'command.hstcms.info'", ")", ";", "}" ]
Register the hstcms.info command.
[ "Register", "the", "hstcms", ".", "info", "command", "." ]
12819979289e58ce38e3e92540aeeb16e205e525
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/ConsoleServiceProvider.php#L48-L54
14,719
datasift/datasift-php
lib/DataSift/StreamConsumer/HTTP.php
DataSift_StreamConsumer_HTTP.disconnect
private function disconnect() { if (is_resource($this->_conn)) { fclose($this->_conn); } $this->_auto_reconnect = false; $this->_conn = null; }
php
private function disconnect() { if (is_resource($this->_conn)) { fclose($this->_conn); } $this->_auto_reconnect = false; $this->_conn = null; }
[ "private", "function", "disconnect", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "_conn", ")", ")", "{", "fclose", "(", "$", "this", "->", "_conn", ")", ";", "}", "$", "this", "->", "_auto_reconnect", "=", "false", ";", "$", "this", "->", "_conn", "=", "null", ";", "}" ]
Disconnect from the DataSift stream @return void
[ "Disconnect", "from", "the", "DataSift", "stream" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer/HTTP.php#L300-L307
14,720
datasift/datasift-php
lib/DataSift/StreamConsumer/HTTP.php
DataSift_StreamConsumer_HTTP.reconnect
private function reconnect() { $auto = $this->_auto_reconnect; $this->disconnect(); $this->auto_reconnect = $auto; $this->connect(); }
php
private function reconnect() { $auto = $this->_auto_reconnect; $this->disconnect(); $this->auto_reconnect = $auto; $this->connect(); }
[ "private", "function", "reconnect", "(", ")", "{", "$", "auto", "=", "$", "this", "->", "_auto_reconnect", ";", "$", "this", "->", "disconnect", "(", ")", ";", "$", "this", "->", "auto_reconnect", "=", "$", "auto", ";", "$", "this", "->", "connect", "(", ")", ";", "}" ]
Reconnect to the DataSift stream @return void
[ "Reconnect", "to", "the", "DataSift", "stream" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer/HTTP.php#L314-L320
14,721
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/InterfaceTrans.php
InterfaceTrans.getInterfaceTrans
public function getInterfaceTrans() { $locale = config('app.locale'); $file = config('crude.defaultInterfaceTrans'); if ($file == 'CrudeCRUD::crude') { $available = ['en', 'pl']; $locale = in_array($locale, $available) ? $locale : 'en'; } $this->interfaceTrans = array_merge( \Lang::get($file, [], $locale), $this->interfaceTrans ); return $this->interfaceTrans; }
php
public function getInterfaceTrans() { $locale = config('app.locale'); $file = config('crude.defaultInterfaceTrans'); if ($file == 'CrudeCRUD::crude') { $available = ['en', 'pl']; $locale = in_array($locale, $available) ? $locale : 'en'; } $this->interfaceTrans = array_merge( \Lang::get($file, [], $locale), $this->interfaceTrans ); return $this->interfaceTrans; }
[ "public", "function", "getInterfaceTrans", "(", ")", "{", "$", "locale", "=", "config", "(", "'app.locale'", ")", ";", "$", "file", "=", "config", "(", "'crude.defaultInterfaceTrans'", ")", ";", "if", "(", "$", "file", "==", "'CrudeCRUD::crude'", ")", "{", "$", "available", "=", "[", "'en'", ",", "'pl'", "]", ";", "$", "locale", "=", "in_array", "(", "$", "locale", ",", "$", "available", ")", "?", "$", "locale", ":", "'en'", ";", "}", "$", "this", "->", "interfaceTrans", "=", "array_merge", "(", "\\", "Lang", "::", "get", "(", "$", "file", ",", "[", "]", ",", "$", "locale", ")", ",", "$", "this", "->", "interfaceTrans", ")", ";", "return", "$", "this", "->", "interfaceTrans", ";", "}" ]
Gets the interface and api labels and messages. @return array
[ "Gets", "the", "interface", "and", "api", "labels", "and", "messages", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InterfaceTrans.php#L19-L35
14,722
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/InterfaceTrans.php
InterfaceTrans.setInterfaceTrans
public function setInterfaceTrans($attr, $value = null) { if (is_array($attr)) $this->interfaceTrans = array_merge($this->interfaceTrans, $attr); else $this->interfaceTrans[$attr] = $value; return $this; }
php
public function setInterfaceTrans($attr, $value = null) { if (is_array($attr)) $this->interfaceTrans = array_merge($this->interfaceTrans, $attr); else $this->interfaceTrans[$attr] = $value; return $this; }
[ "public", "function", "setInterfaceTrans", "(", "$", "attr", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "attr", ")", ")", "$", "this", "->", "interfaceTrans", "=", "array_merge", "(", "$", "this", "->", "interfaceTrans", ",", "$", "attr", ")", ";", "else", "$", "this", "->", "interfaceTrans", "[", "$", "attr", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets the interface and api labels and messages. @param string|array $attr @param array $value @return self
[ "Sets", "the", "interface", "and", "api", "labels", "and", "messages", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InterfaceTrans.php#L52-L60
14,723
prooph/link-app-core
src/Service/AbstractRestController.php
AbstractRestController.location
protected function location($url) { /** @var $response Response */ $response = $this->getResponse(); $response->getHeaders() ->addHeaderLine( 'Location', $url ); $response->setStatusCode(201); return $response; }
php
protected function location($url) { /** @var $response Response */ $response = $this->getResponse(); $response->getHeaders() ->addHeaderLine( 'Location', $url ); $response->setStatusCode(201); return $response; }
[ "protected", "function", "location", "(", "$", "url", ")", "{", "/** @var $response Response */", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "$", "response", "->", "getHeaders", "(", ")", "->", "addHeaderLine", "(", "'Location'", ",", "$", "url", ")", ";", "$", "response", "->", "setStatusCode", "(", "201", ")", ";", "return", "$", "response", ";", "}" ]
Returns a 201 response with a Location header @param string $url @return Response
[ "Returns", "a", "201", "response", "with", "a", "Location", "header" ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Service/AbstractRestController.php#L205-L219
14,724
fuelphp/display
src/Parser/Smarty.php
Smarty.setupSmarty
protected function setupSmarty() { $this->smarty = new SmartyParser; if ($this->viewManager->cachePath) { $this->smarty->setCacheDir($this->viewManager->cachePath.'smarty/'); } }
php
protected function setupSmarty() { $this->smarty = new SmartyParser; if ($this->viewManager->cachePath) { $this->smarty->setCacheDir($this->viewManager->cachePath.'smarty/'); } }
[ "protected", "function", "setupSmarty", "(", ")", "{", "$", "this", "->", "smarty", "=", "new", "SmartyParser", ";", "if", "(", "$", "this", "->", "viewManager", "->", "cachePath", ")", "{", "$", "this", "->", "smarty", "->", "setCacheDir", "(", "$", "this", "->", "viewManager", "->", "cachePath", ".", "'smarty/'", ")", ";", "}", "}" ]
Sets Smarty up
[ "Sets", "Smarty", "up" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/Parser/Smarty.php#L51-L59
14,725
dragosprotung/stc-core
src/Workout/Dumper/JSON.php
JSON.writeTrackPoints
private function writeTrackPoints(array $trackPoints) { $points = array(); $previousPoint = null; foreach ($trackPoints as $trackPoint) { $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $distance = 0; if ($previousPoint !== null) { $distance = $trackPoint->distanceFromPoint($previousPoint); } $point = array( 'time' => $dateTime->format(\DateTime::W3C), 'latitude' => $trackPoint->latitude(), 'longitude' => $trackPoint->longitude(), 'elevation' => $trackPoint->elevation(), 'distance' => $distance, 'extensions' => $this->writeExtensions($trackPoint->extensions()) ); $previousPoint = $trackPoint; $points[] = $point; } return $points; }
php
private function writeTrackPoints(array $trackPoints) { $points = array(); $previousPoint = null; foreach ($trackPoints as $trackPoint) { $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $distance = 0; if ($previousPoint !== null) { $distance = $trackPoint->distanceFromPoint($previousPoint); } $point = array( 'time' => $dateTime->format(\DateTime::W3C), 'latitude' => $trackPoint->latitude(), 'longitude' => $trackPoint->longitude(), 'elevation' => $trackPoint->elevation(), 'distance' => $distance, 'extensions' => $this->writeExtensions($trackPoint->extensions()) ); $previousPoint = $trackPoint; $points[] = $point; } return $points; }
[ "private", "function", "writeTrackPoints", "(", "array", "$", "trackPoints", ")", "{", "$", "points", "=", "array", "(", ")", ";", "$", "previousPoint", "=", "null", ";", "foreach", "(", "$", "trackPoints", "as", "$", "trackPoint", ")", "{", "$", "dateTime", "=", "clone", "$", "trackPoint", "->", "dateTime", "(", ")", ";", "$", "dateTime", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "distance", "=", "0", ";", "if", "(", "$", "previousPoint", "!==", "null", ")", "{", "$", "distance", "=", "$", "trackPoint", "->", "distanceFromPoint", "(", "$", "previousPoint", ")", ";", "}", "$", "point", "=", "array", "(", "'time'", "=>", "$", "dateTime", "->", "format", "(", "\\", "DateTime", "::", "W3C", ")", ",", "'latitude'", "=>", "$", "trackPoint", "->", "latitude", "(", ")", ",", "'longitude'", "=>", "$", "trackPoint", "->", "longitude", "(", ")", ",", "'elevation'", "=>", "$", "trackPoint", "->", "elevation", "(", ")", ",", "'distance'", "=>", "$", "distance", ",", "'extensions'", "=>", "$", "this", "->", "writeExtensions", "(", "$", "trackPoint", "->", "extensions", "(", ")", ")", ")", ";", "$", "previousPoint", "=", "$", "trackPoint", ";", "$", "points", "[", "]", "=", "$", "point", ";", "}", "return", "$", "points", ";", "}" ]
Write the track points into an array. @param TrackPoint[] $trackPoints The track points to write. @return array
[ "Write", "the", "track", "points", "into", "an", "array", "." ]
9783e3414294f4ee555a1d538d2807269deeb9e7
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/JSON.php#L40-L67
14,726
tonicospinelli/class-generation
src/ClassGeneration/PhpClass.php
PhpClass.createMethodsFromInterface
protected function createMethodsFromInterface($interfaceName) { if (!interface_exists($interfaceName)) { return; } $refInterface = new \ReflectionClass($interfaceName); $methodsReflected = $refInterface->getMethods(); foreach ($methodsReflected as $methodReflected) { if ($this->getMethodCollection()->exists($methodReflected->getName())) { continue; } $method = Method::createFromReflection($methodReflected); $this->addMethod($method); } }
php
protected function createMethodsFromInterface($interfaceName) { if (!interface_exists($interfaceName)) { return; } $refInterface = new \ReflectionClass($interfaceName); $methodsReflected = $refInterface->getMethods(); foreach ($methodsReflected as $methodReflected) { if ($this->getMethodCollection()->exists($methodReflected->getName())) { continue; } $method = Method::createFromReflection($methodReflected); $this->addMethod($method); } }
[ "protected", "function", "createMethodsFromInterface", "(", "$", "interfaceName", ")", "{", "if", "(", "!", "interface_exists", "(", "$", "interfaceName", ")", ")", "{", "return", ";", "}", "$", "refInterface", "=", "new", "\\", "ReflectionClass", "(", "$", "interfaceName", ")", ";", "$", "methodsReflected", "=", "$", "refInterface", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methodsReflected", "as", "$", "methodReflected", ")", "{", "if", "(", "$", "this", "->", "getMethodCollection", "(", ")", "->", "exists", "(", "$", "methodReflected", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "method", "=", "Method", "::", "createFromReflection", "(", "$", "methodReflected", ")", ";", "$", "this", "->", "addMethod", "(", "$", "method", ")", ";", "}", "}" ]
Creates methods from Interface. @param string $interfaceName
[ "Creates", "methods", "from", "Interface", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/PhpClass.php#L348-L363
14,727
tonicospinelli/class-generation
src/ClassGeneration/PhpClass.php
PhpClass.createMethodsFromAbstractClass
protected function createMethodsFromAbstractClass($abstractClass) { if (!class_exists($abstractClass)) { return; } $refExtends = new \ReflectionClass($abstractClass); $methodsRef = $refExtends->getMethods(); foreach ($methodsRef as $methodRef) { if (!$methodRef->isAbstract() || $this->getMethodCollection()->exists($methodRef->getName())) { continue; } $method = Method::createFromReflection($methodRef); $this->addMethod($method); } }
php
protected function createMethodsFromAbstractClass($abstractClass) { if (!class_exists($abstractClass)) { return; } $refExtends = new \ReflectionClass($abstractClass); $methodsRef = $refExtends->getMethods(); foreach ($methodsRef as $methodRef) { if (!$methodRef->isAbstract() || $this->getMethodCollection()->exists($methodRef->getName())) { continue; } $method = Method::createFromReflection($methodRef); $this->addMethod($method); } }
[ "protected", "function", "createMethodsFromAbstractClass", "(", "$", "abstractClass", ")", "{", "if", "(", "!", "class_exists", "(", "$", "abstractClass", ")", ")", "{", "return", ";", "}", "$", "refExtends", "=", "new", "\\", "ReflectionClass", "(", "$", "abstractClass", ")", ";", "$", "methodsRef", "=", "$", "refExtends", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methodsRef", "as", "$", "methodRef", ")", "{", "if", "(", "!", "$", "methodRef", "->", "isAbstract", "(", ")", "||", "$", "this", "->", "getMethodCollection", "(", ")", "->", "exists", "(", "$", "methodRef", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "method", "=", "Method", "::", "createFromReflection", "(", "$", "methodRef", ")", ";", "$", "this", "->", "addMethod", "(", "$", "method", ")", ";", "}", "}" ]
Creates methods from Abstract. @param string $abstractClass @return void
[ "Creates", "methods", "from", "Abstract", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/PhpClass.php#L373-L389
14,728
tonicospinelli/class-generation
src/ClassGeneration/PhpClass.php
PhpClass.generateGettersAndSettersFromProperties
public function generateGettersAndSettersFromProperties() { $propertyIterator = $this->getPropertyCollection()->getIterator(); foreach ($propertyIterator as $property) { $this->getMethodCollection()->add(Method::createGetterFromProperty($property)); $this->getMethodCollection()->add(Method::createSetterFromProperty($property)); } }
php
public function generateGettersAndSettersFromProperties() { $propertyIterator = $this->getPropertyCollection()->getIterator(); foreach ($propertyIterator as $property) { $this->getMethodCollection()->add(Method::createGetterFromProperty($property)); $this->getMethodCollection()->add(Method::createSetterFromProperty($property)); } }
[ "public", "function", "generateGettersAndSettersFromProperties", "(", ")", "{", "$", "propertyIterator", "=", "$", "this", "->", "getPropertyCollection", "(", ")", "->", "getIterator", "(", ")", ";", "foreach", "(", "$", "propertyIterator", "as", "$", "property", ")", "{", "$", "this", "->", "getMethodCollection", "(", ")", "->", "add", "(", "Method", "::", "createGetterFromProperty", "(", "$", "property", ")", ")", ";", "$", "this", "->", "getMethodCollection", "(", ")", "->", "add", "(", "Method", "::", "createSetterFromProperty", "(", "$", "property", ")", ")", ";", "}", "}" ]
Create all getters and setters from Property Collection. @return void
[ "Create", "all", "getters", "and", "setters", "from", "Property", "Collection", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/PhpClass.php#L473-L480
14,729
tonicospinelli/class-generation
src/ClassGeneration/PhpClass.php
PhpClass.toStringType
protected function toStringType() { $type = 'class '; switch (true) { case $this->isInterface(): $type = 'interface '; break; case $this->isAbstract(): $type = 'abstract class '; break; case $this->isFinal(): $type = 'final class '; break; case $this->isTrait(): $type = 'trait '; } return $type; }
php
protected function toStringType() { $type = 'class '; switch (true) { case $this->isInterface(): $type = 'interface '; break; case $this->isAbstract(): $type = 'abstract class '; break; case $this->isFinal(): $type = 'final class '; break; case $this->isTrait(): $type = 'trait '; } return $type; }
[ "protected", "function", "toStringType", "(", ")", "{", "$", "type", "=", "'class '", ";", "switch", "(", "true", ")", "{", "case", "$", "this", "->", "isInterface", "(", ")", ":", "$", "type", "=", "'interface '", ";", "break", ";", "case", "$", "this", "->", "isAbstract", "(", ")", ":", "$", "type", "=", "'abstract class '", ";", "break", ";", "case", "$", "this", "->", "isFinal", "(", ")", ":", "$", "type", "=", "'final class '", ";", "break", ";", "case", "$", "this", "->", "isTrait", "(", ")", ":", "$", "type", "=", "'trait '", ";", "}", "return", "$", "type", ";", "}" ]
Get string based on type set. @return string
[ "Get", "string", "based", "on", "type", "set", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/PhpClass.php#L565-L584
14,730
okvpn/fixture-bundle
src/Event/DataFixturesEvent.php
DataFixturesEvent.log
public function log($message) { if (null !== $this->logger) { $logger = $this->logger; $logger($message); } }
php
public function log($message) { if (null !== $this->logger) { $logger = $this->logger; $logger($message); } }
[ "public", "function", "log", "(", "$", "message", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "logger", ")", "{", "$", "logger", "=", "$", "this", "->", "logger", ";", "$", "logger", "(", "$", "message", ")", ";", "}", "}" ]
Adds a message to the logger. @param string $message
[ "Adds", "a", "message", "to", "the", "logger", "." ]
243b5e4dff9773e97fa447280e929c936a5d66ae
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Event/DataFixturesEvent.php#L59-L65
14,731
stubbles/stubbles-webapp-core
src/main/php/auth/AuthConstraint.php
AuthConstraint.requiresLogin
private function requiresLogin(): bool { if ($this->requiresLogin) { return true; } $this->requiresLogin = $this->callbackAnnotatedWith->requiresLogin(); return $this->requiresLogin; }
php
private function requiresLogin(): bool { if ($this->requiresLogin) { return true; } $this->requiresLogin = $this->callbackAnnotatedWith->requiresLogin(); return $this->requiresLogin; }
[ "private", "function", "requiresLogin", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "requiresLogin", ")", "{", "return", "true", ";", "}", "$", "this", "->", "requiresLogin", "=", "$", "this", "->", "callbackAnnotatedWith", "->", "requiresLogin", "(", ")", ";", "return", "$", "this", "->", "requiresLogin", ";", "}" ]
checks whether login is required @return bool @XmlAttribute(attributeName='requiresLogin')
[ "checks", "whether", "login", "is", "required" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/AuthConstraint.php#L102-L110
14,732
stubbles/stubbles-webapp-core
src/main/php/auth/AuthConstraint.php
AuthConstraint.requiredRole
public function requiredRole() { if (null === $this->requiredRole) { $this->requiredRole = $this->callbackAnnotatedWith->requiredRole(); } return $this->requiredRole; }
php
public function requiredRole() { if (null === $this->requiredRole) { $this->requiredRole = $this->callbackAnnotatedWith->requiredRole(); } return $this->requiredRole; }
[ "public", "function", "requiredRole", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "requiredRole", ")", "{", "$", "this", "->", "requiredRole", "=", "$", "this", "->", "callbackAnnotatedWith", "->", "requiredRole", "(", ")", ";", "}", "return", "$", "this", "->", "requiredRole", ";", "}" ]
returns required role for this route @return string|null @XmlAttribute(attributeName='role', skipEmpty=true)
[ "returns", "required", "role", "for", "this", "route" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/AuthConstraint.php#L152-L159
14,733
stubbles/stubbles-webapp-core
src/main/php/auth/AuthConstraint.php
AuthConstraint.satisfiedByRoles
public function satisfiedByRoles(Roles $roles = null): bool { if (null === $roles) { return false; } if ($this->callbackAnnotatedWith->rolesAware()) { return true; } return $roles->contain($this->requiredRole()); }
php
public function satisfiedByRoles(Roles $roles = null): bool { if (null === $roles) { return false; } if ($this->callbackAnnotatedWith->rolesAware()) { return true; } return $roles->contain($this->requiredRole()); }
[ "public", "function", "satisfiedByRoles", "(", "Roles", "$", "roles", "=", "null", ")", ":", "bool", "{", "if", "(", "null", "===", "$", "roles", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "callbackAnnotatedWith", "->", "rolesAware", "(", ")", ")", "{", "return", "true", ";", "}", "return", "$", "roles", "->", "contain", "(", "$", "this", "->", "requiredRole", "(", ")", ")", ";", "}" ]
checks whether route is satisfied by the given roles @param \stubbles\webapp\auth\Roles $roles @return bool
[ "checks", "whether", "route", "is", "satisfied", "by", "the", "given", "roles" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/AuthConstraint.php#L167-L178
14,734
stubbles/stubbles-webapp-core
src/main/php/auth/AuthConstraint.php
AuthConstraint.jsonSerialize
public function jsonSerialize(): array { $data = ['required' => $this->requiresAuth()]; if ($this->requiresAuth()) { $data['requiresLogin'] = $this->requiresLogin(); } if ($this->requiresRoles()) { $data['requiresRoles'] = true; $data['requiredRole'] = $this->requiredRole(); } return $data; }
php
public function jsonSerialize(): array { $data = ['required' => $this->requiresAuth()]; if ($this->requiresAuth()) { $data['requiresLogin'] = $this->requiresLogin(); } if ($this->requiresRoles()) { $data['requiresRoles'] = true; $data['requiredRole'] = $this->requiredRole(); } return $data; }
[ "public", "function", "jsonSerialize", "(", ")", ":", "array", "{", "$", "data", "=", "[", "'required'", "=>", "$", "this", "->", "requiresAuth", "(", ")", "]", ";", "if", "(", "$", "this", "->", "requiresAuth", "(", ")", ")", "{", "$", "data", "[", "'requiresLogin'", "]", "=", "$", "this", "->", "requiresLogin", "(", ")", ";", "}", "if", "(", "$", "this", "->", "requiresRoles", "(", ")", ")", "{", "$", "data", "[", "'requiresRoles'", "]", "=", "true", ";", "$", "data", "[", "'requiredRole'", "]", "=", "$", "this", "->", "requiredRole", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
returns data suitable for encoding to JSON @return array @since 6.1.0 @XmlIgnore
[ "returns", "data", "suitable", "for", "encoding", "to", "JSON" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/AuthConstraint.php#L187-L200
14,735
slogsdon/staticwp
includes/staticwp.class.php
StaticWP.addComment
public function addComment($id, $status) { if ($status == 0) { return; } $comment = get_comment($id); $this->updateHtml($comment->comment_post_ID); wp_safe_redirect(get_permalink($comment->comment_post_ID)); exit(); }
php
public function addComment($id, $status) { if ($status == 0) { return; } $comment = get_comment($id); $this->updateHtml($comment->comment_post_ID); wp_safe_redirect(get_permalink($comment->comment_post_ID)); exit(); }
[ "public", "function", "addComment", "(", "$", "id", ",", "$", "status", ")", "{", "if", "(", "$", "status", "==", "0", ")", "{", "return", ";", "}", "$", "comment", "=", "get_comment", "(", "$", "id", ")", ";", "$", "this", "->", "updateHtml", "(", "$", "comment", "->", "comment_post_ID", ")", ";", "wp_safe_redirect", "(", "get_permalink", "(", "$", "comment", "->", "comment_post_ID", ")", ")", ";", "exit", "(", ")", ";", "}" ]
Updates static HTML after an approved comment is added. @param int $id @param int @status @return void
[ "Updates", "static", "HTML", "after", "an", "approved", "comment", "is", "added", "." ]
e96811e57c521b0dc28fc600647b89828cdba8c0
https://github.com/slogsdon/staticwp/blob/e96811e57c521b0dc28fc600647b89828cdba8c0/includes/staticwp.class.php#L47-L57
14,736
slogsdon/staticwp
includes/staticwp.class.php
StaticWP.load
public function load() { // We only care about GET requests at the moment if ($_SERVER['REQUEST_METHOD'] !== 'GET') { return; } $file = $_SERVER['REQUEST_URI'] . 'index.html'; if (is_file($this->destination . $file)) { $contents = file_get_contents($this->destination . $file); do_action('staticwp_pre_cache_hit', $_SERVER['REQUEST_URI']); echo apply_filters('staticwp_cache_hit_contents', $contents); do_action('staticwp_post_cache_hit', $_SERVER['REQUEST_URI']); exit(); } else { do_action('staticwp_cache_miss', $_SERVER['REQUEST_URI']); } }
php
public function load() { // We only care about GET requests at the moment if ($_SERVER['REQUEST_METHOD'] !== 'GET') { return; } $file = $_SERVER['REQUEST_URI'] . 'index.html'; if (is_file($this->destination . $file)) { $contents = file_get_contents($this->destination . $file); do_action('staticwp_pre_cache_hit', $_SERVER['REQUEST_URI']); echo apply_filters('staticwp_cache_hit_contents', $contents); do_action('staticwp_post_cache_hit', $_SERVER['REQUEST_URI']); exit(); } else { do_action('staticwp_cache_miss', $_SERVER['REQUEST_URI']); } }
[ "public", "function", "load", "(", ")", "{", "// We only care about GET requests at the moment", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!==", "'GET'", ")", "{", "return", ";", "}", "$", "file", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ".", "'index.html'", ";", "if", "(", "is_file", "(", "$", "this", "->", "destination", ".", "$", "file", ")", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "this", "->", "destination", ".", "$", "file", ")", ";", "do_action", "(", "'staticwp_pre_cache_hit'", ",", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ";", "echo", "apply_filters", "(", "'staticwp_cache_hit_contents'", ",", "$", "contents", ")", ";", "do_action", "(", "'staticwp_post_cache_hit'", ",", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ";", "exit", "(", ")", ";", "}", "else", "{", "do_action", "(", "'staticwp_cache_miss'", ",", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ";", "}", "}" ]
Presents a compiled static HTML file when present. @since 1.0.0 @return void
[ "Presents", "a", "compiled", "static", "HTML", "file", "when", "present", "." ]
e96811e57c521b0dc28fc600647b89828cdba8c0
https://github.com/slogsdon/staticwp/blob/e96811e57c521b0dc28fc600647b89828cdba8c0/includes/staticwp.class.php#L80-L97
14,737
slogsdon/staticwp
includes/staticwp.class.php
StaticWP.updateHtml
public function updateHtml($id, $post = null) { if ($post != null && $post->post_status != 'publish') { return; } $permalink = get_permalink($id); $uri = substr($permalink, strlen(get_option('home'))); $filename = $this->destination . $uri . 'index.html'; $dir = $this->destination . $uri; if (!is_dir($dir)) { wp_mkdir_p($dir); } if (is_file($filename)) { unlink($filename); } $curl = curl_init($permalink); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $data = null; if (($data = curl_exec($curl)) === false) { throw new Exception(sprintf('Curl error: %s', curl_error($curl))); } curl_close($curl); do_action('staticwp_pre_cache_update', $id); file_put_contents($filename, apply_filters('staticwp_cache_update_contents', $data, $id)); do_action('staticwp_post_cache_update', $id); }
php
public function updateHtml($id, $post = null) { if ($post != null && $post->post_status != 'publish') { return; } $permalink = get_permalink($id); $uri = substr($permalink, strlen(get_option('home'))); $filename = $this->destination . $uri . 'index.html'; $dir = $this->destination . $uri; if (!is_dir($dir)) { wp_mkdir_p($dir); } if (is_file($filename)) { unlink($filename); } $curl = curl_init($permalink); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $data = null; if (($data = curl_exec($curl)) === false) { throw new Exception(sprintf('Curl error: %s', curl_error($curl))); } curl_close($curl); do_action('staticwp_pre_cache_update', $id); file_put_contents($filename, apply_filters('staticwp_cache_update_contents', $data, $id)); do_action('staticwp_post_cache_update', $id); }
[ "public", "function", "updateHtml", "(", "$", "id", ",", "$", "post", "=", "null", ")", "{", "if", "(", "$", "post", "!=", "null", "&&", "$", "post", "->", "post_status", "!=", "'publish'", ")", "{", "return", ";", "}", "$", "permalink", "=", "get_permalink", "(", "$", "id", ")", ";", "$", "uri", "=", "substr", "(", "$", "permalink", ",", "strlen", "(", "get_option", "(", "'home'", ")", ")", ")", ";", "$", "filename", "=", "$", "this", "->", "destination", ".", "$", "uri", ".", "'index.html'", ";", "$", "dir", "=", "$", "this", "->", "destination", ".", "$", "uri", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "wp_mkdir_p", "(", "$", "dir", ")", ";", "}", "if", "(", "is_file", "(", "$", "filename", ")", ")", "{", "unlink", "(", "$", "filename", ")", ";", "}", "$", "curl", "=", "curl_init", "(", "$", "permalink", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HEADER", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "data", "=", "null", ";", "if", "(", "(", "$", "data", "=", "curl_exec", "(", "$", "curl", ")", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Curl error: %s'", ",", "curl_error", "(", "$", "curl", ")", ")", ")", ";", "}", "curl_close", "(", "$", "curl", ")", ";", "do_action", "(", "'staticwp_pre_cache_update'", ",", "$", "id", ")", ";", "file_put_contents", "(", "$", "filename", ",", "apply_filters", "(", "'staticwp_cache_update_contents'", ",", "$", "data", ",", "$", "id", ")", ")", ";", "do_action", "(", "'staticwp_post_cache_update'", ",", "$", "id", ")", ";", "}" ]
Updates the static HTML for a post. @since 1.0.0 @param int $id @param \WP_Post|null $post @return void
[ "Updates", "the", "static", "HTML", "for", "a", "post", "." ]
e96811e57c521b0dc28fc600647b89828cdba8c0
https://github.com/slogsdon/staticwp/blob/e96811e57c521b0dc28fc600647b89828cdba8c0/includes/staticwp.class.php#L108-L141
14,738
slogsdon/staticwp
includes/staticwp.class.php
StaticWP.resolveDestination
protected function resolveDestination() { $dir = ''; $uploads = wp_upload_dir(); if (isset($uploads['basedir'])) { $dir = $uploads['basedir'] . '/' . $this->plugin . '/_site'; } else { $dir = WP_CONTENT_DIR . '/uploads/' . $this->plugin . '/_site'; } return apply_filters('staticwp_cache_destination', $dir); }
php
protected function resolveDestination() { $dir = ''; $uploads = wp_upload_dir(); if (isset($uploads['basedir'])) { $dir = $uploads['basedir'] . '/' . $this->plugin . '/_site'; } else { $dir = WP_CONTENT_DIR . '/uploads/' . $this->plugin . '/_site'; } return apply_filters('staticwp_cache_destination', $dir); }
[ "protected", "function", "resolveDestination", "(", ")", "{", "$", "dir", "=", "''", ";", "$", "uploads", "=", "wp_upload_dir", "(", ")", ";", "if", "(", "isset", "(", "$", "uploads", "[", "'basedir'", "]", ")", ")", "{", "$", "dir", "=", "$", "uploads", "[", "'basedir'", "]", ".", "'/'", ".", "$", "this", "->", "plugin", ".", "'/_site'", ";", "}", "else", "{", "$", "dir", "=", "WP_CONTENT_DIR", ".", "'/uploads/'", ".", "$", "this", "->", "plugin", ".", "'/_site'", ";", "}", "return", "apply_filters", "(", "'staticwp_cache_destination'", ",", "$", "dir", ")", ";", "}" ]
Recursively deletes a directory and its contents. @since 1.2.0 @return string
[ "Recursively", "deletes", "a", "directory", "and", "its", "contents", "." ]
e96811e57c521b0dc28fc600647b89828cdba8c0
https://github.com/slogsdon/staticwp/blob/e96811e57c521b0dc28fc600647b89828cdba8c0/includes/staticwp.class.php#L150-L162
14,739
acasademont/wurfl
WURFL/Configuration/ArrayConfig.php
WURFL_Configuration_ArrayConfig.initialize
protected function initialize() { include parent::getConfigFilePath(); if (!isset($configuration) || !is_array($configuration)) { throw new WURFL_WURFLException("Configuration array must be defined in the configuraiton file"); } $this->init($configuration); }
php
protected function initialize() { include parent::getConfigFilePath(); if (!isset($configuration) || !is_array($configuration)) { throw new WURFL_WURFLException("Configuration array must be defined in the configuraiton file"); } $this->init($configuration); }
[ "protected", "function", "initialize", "(", ")", "{", "include", "parent", "::", "getConfigFilePath", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "configuration", ")", "||", "!", "is_array", "(", "$", "configuration", ")", ")", "{", "throw", "new", "WURFL_WURFLException", "(", "\"Configuration array must be defined in the configuraiton file\"", ")", ";", "}", "$", "this", "->", "init", "(", "$", "configuration", ")", ";", "}" ]
Initialize class - gets called from the parent constructor @throws WURFL_WURFLException configuration not present
[ "Initialize", "class", "-", "gets", "called", "from", "the", "parent", "constructor" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/ArrayConfig.php#L83-L91
14,740
JoffreyPoreeCoding/MongoDB-ODM
src/DocumentManager.php
DocumentManager.getRepository
public function getRepository($modelName, $collection = null) { return $this->repositoryFactory->getRepository($this, $modelName, $collection); }
php
public function getRepository($modelName, $collection = null) { return $this->repositoryFactory->getRepository($this, $modelName, $collection); }
[ "public", "function", "getRepository", "(", "$", "modelName", ",", "$", "collection", "=", "null", ")", "{", "return", "$", "this", "->", "repositoryFactory", "->", "getRepository", "(", "$", "this", ",", "$", "modelName", ",", "$", "collection", ")", ";", "}" ]
Allow to get repository for specified model @param string $modelName Name of the model @param string $collection Name of the collection (null for get collection from document annotation) @return Repository Repository for model
[ "Allow", "to", "get", "repository", "for", "specified", "model" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/DocumentManager.php#L97-L100
14,741
JoffreyPoreeCoding/MongoDB-ODM
src/DocumentManager.php
DocumentManager.persist
public function persist($object, $collection = null) { $repository = $this->getRepository(get_class($object), $collection); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_PERSIST, $object); $this->addObject($object, ObjectManager::OBJ_NEW, $repository); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_PERSIST, $object); return $this; }
php
public function persist($object, $collection = null) { $repository = $this->getRepository(get_class($object), $collection); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_PERSIST, $object); $this->addObject($object, ObjectManager::OBJ_NEW, $repository); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_PERSIST, $object); return $this; }
[ "public", "function", "persist", "(", "$", "object", ",", "$", "collection", "=", "null", ")", "{", "$", "repository", "=", "$", "this", "->", "getRepository", "(", "get_class", "(", "$", "object", ")", ",", "$", "collection", ")", ";", "$", "repository", "->", "getClassMetadata", "(", ")", "->", "getEventManager", "(", ")", "->", "execute", "(", "EventManager", "::", "EVENT_PRE_PERSIST", ",", "$", "object", ")", ";", "$", "this", "->", "addObject", "(", "$", "object", ",", "ObjectManager", "::", "OBJ_NEW", ",", "$", "repository", ")", ";", "$", "repository", "->", "getClassMetadata", "(", ")", "->", "getEventManager", "(", ")", "->", "execute", "(", "EventManager", "::", "EVENT_POST_PERSIST", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Persist object in document manager @param mixed $object Object to persist @param string $collection Collection where object is persisted @return void
[ "Persist", "object", "in", "document", "manager" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/DocumentManager.php#L109-L117
14,742
JoffreyPoreeCoding/MongoDB-ODM
src/DocumentManager.php
DocumentManager.refresh
public function refresh(&$object) { if (!isset($this->objectsRepository[spl_object_hash($object)])) { return; } $repository = $this->objectsRepository[spl_object_hash($object)]; $id = $repository->getHydrator()->unhydrate($object)["_id"]; $projection = $repository->getLastProjection($object); $collection = $repository->getCollection(); $hydrator = $repository->getHydrator(); if (null !== ($data = $collection->findOne(['_id' => $id], ['projection' => $projection]))) { $hydrator->hydrate($object, $data); $repository->cacheObject($object); } else { $object = null; } return $object; }
php
public function refresh(&$object) { if (!isset($this->objectsRepository[spl_object_hash($object)])) { return; } $repository = $this->objectsRepository[spl_object_hash($object)]; $id = $repository->getHydrator()->unhydrate($object)["_id"]; $projection = $repository->getLastProjection($object); $collection = $repository->getCollection(); $hydrator = $repository->getHydrator(); if (null !== ($data = $collection->findOne(['_id' => $id], ['projection' => $projection]))) { $hydrator->hydrate($object, $data); $repository->cacheObject($object); } else { $object = null; } return $object; }
[ "public", "function", "refresh", "(", "&", "$", "object", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "objectsRepository", "[", "spl_object_hash", "(", "$", "object", ")", "]", ")", ")", "{", "return", ";", "}", "$", "repository", "=", "$", "this", "->", "objectsRepository", "[", "spl_object_hash", "(", "$", "object", ")", "]", ";", "$", "id", "=", "$", "repository", "->", "getHydrator", "(", ")", "->", "unhydrate", "(", "$", "object", ")", "[", "\"_id\"", "]", ";", "$", "projection", "=", "$", "repository", "->", "getLastProjection", "(", "$", "object", ")", ";", "$", "collection", "=", "$", "repository", "->", "getCollection", "(", ")", ";", "$", "hydrator", "=", "$", "repository", "->", "getHydrator", "(", ")", ";", "if", "(", "null", "!==", "(", "$", "data", "=", "$", "collection", "->", "findOne", "(", "[", "'_id'", "=>", "$", "id", "]", ",", "[", "'projection'", "=>", "$", "projection", "]", ")", ")", ")", "{", "$", "hydrator", "->", "hydrate", "(", "$", "object", ",", "$", "data", ")", ";", "$", "repository", "->", "cacheObject", "(", "$", "object", ")", ";", "}", "else", "{", "$", "object", "=", "null", ";", "}", "return", "$", "object", ";", "}" ]
Refresh an object to last MongoDB values @param mixed $object Object to refresh
[ "Refresh", "an", "object", "to", "last", "MongoDB", "values" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/DocumentManager.php#L154-L172
14,743
JoffreyPoreeCoding/MongoDB-ODM
src/DocumentManager.php
DocumentManager.perfomOperations
private function perfomOperations($insert, $update, $remove) { $bulkOperations = []; foreach ($insert as $id => $document) { $repository = $this->getObjectRepository($document); if ($repository instanceof GridFSRepository) { $repository->insertOne($document); unset($insert[$id]); } else { $query = $repository->insertOne($document, ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = isset($bulkOperations[$repositoryId]) ? $bulkOperations[$repositoryId] : $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } } foreach ($update as $id => $document) { $repository = $this->getObjectRepository($document); $query = $repository->updateOne($document, [], ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = isset($bulkOperations[$repositoryId]) ? $bulkOperations[$repositoryId] : $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } foreach ($remove as $id => $document) { $repository = $this->getObjectRepository($document); if ($repository instanceof GridFSRepository) { $repository->deleteOne($document); unset($remove[$id]); } else { $query = $repository->deleteOne($document, ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = $bulkOperations[$repositoryId] ?? $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } } foreach (array_merge($insert, $update, $remove) as $id => $document) { $repository = $this->getObjectRepository($document); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_FLUSH, $document); } foreach ($bulkOperations as $bulkOperation) { $bulkOperation->execute(); } foreach (array_merge($insert, $update) as $id => $document) { $repository = $this->getObjectRepository($document); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_FLUSH, $document); $repository->cacheObject($document); } $this->flush(); }
php
private function perfomOperations($insert, $update, $remove) { $bulkOperations = []; foreach ($insert as $id => $document) { $repository = $this->getObjectRepository($document); if ($repository instanceof GridFSRepository) { $repository->insertOne($document); unset($insert[$id]); } else { $query = $repository->insertOne($document, ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = isset($bulkOperations[$repositoryId]) ? $bulkOperations[$repositoryId] : $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } } foreach ($update as $id => $document) { $repository = $this->getObjectRepository($document); $query = $repository->updateOne($document, [], ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = isset($bulkOperations[$repositoryId]) ? $bulkOperations[$repositoryId] : $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } foreach ($remove as $id => $document) { $repository = $this->getObjectRepository($document); if ($repository instanceof GridFSRepository) { $repository->deleteOne($document); unset($remove[$id]); } else { $query = $repository->deleteOne($document, ['getQuery' => true]); $repositoryId = spl_object_hash($repository); $bulkOperations[$repositoryId] = $bulkOperations[$repositoryId] ?? $repository->createBulkWriteQuery(); $bulkOperations[$repositoryId]->addQuery($query); } } foreach (array_merge($insert, $update, $remove) as $id => $document) { $repository = $this->getObjectRepository($document); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_PRE_FLUSH, $document); } foreach ($bulkOperations as $bulkOperation) { $bulkOperation->execute(); } foreach (array_merge($insert, $update) as $id => $document) { $repository = $this->getObjectRepository($document); $repository->getClassMetadata()->getEventManager()->execute(EventManager::EVENT_POST_FLUSH, $document); $repository->cacheObject($document); } $this->flush(); }
[ "private", "function", "perfomOperations", "(", "$", "insert", ",", "$", "update", ",", "$", "remove", ")", "{", "$", "bulkOperations", "=", "[", "]", ";", "foreach", "(", "$", "insert", "as", "$", "id", "=>", "$", "document", ")", "{", "$", "repository", "=", "$", "this", "->", "getObjectRepository", "(", "$", "document", ")", ";", "if", "(", "$", "repository", "instanceof", "GridFSRepository", ")", "{", "$", "repository", "->", "insertOne", "(", "$", "document", ")", ";", "unset", "(", "$", "insert", "[", "$", "id", "]", ")", ";", "}", "else", "{", "$", "query", "=", "$", "repository", "->", "insertOne", "(", "$", "document", ",", "[", "'getQuery'", "=>", "true", "]", ")", ";", "$", "repositoryId", "=", "spl_object_hash", "(", "$", "repository", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "=", "isset", "(", "$", "bulkOperations", "[", "$", "repositoryId", "]", ")", "?", "$", "bulkOperations", "[", "$", "repositoryId", "]", ":", "$", "repository", "->", "createBulkWriteQuery", "(", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "->", "addQuery", "(", "$", "query", ")", ";", "}", "}", "foreach", "(", "$", "update", "as", "$", "id", "=>", "$", "document", ")", "{", "$", "repository", "=", "$", "this", "->", "getObjectRepository", "(", "$", "document", ")", ";", "$", "query", "=", "$", "repository", "->", "updateOne", "(", "$", "document", ",", "[", "]", ",", "[", "'getQuery'", "=>", "true", "]", ")", ";", "$", "repositoryId", "=", "spl_object_hash", "(", "$", "repository", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "=", "isset", "(", "$", "bulkOperations", "[", "$", "repositoryId", "]", ")", "?", "$", "bulkOperations", "[", "$", "repositoryId", "]", ":", "$", "repository", "->", "createBulkWriteQuery", "(", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "->", "addQuery", "(", "$", "query", ")", ";", "}", "foreach", "(", "$", "remove", "as", "$", "id", "=>", "$", "document", ")", "{", "$", "repository", "=", "$", "this", "->", "getObjectRepository", "(", "$", "document", ")", ";", "if", "(", "$", "repository", "instanceof", "GridFSRepository", ")", "{", "$", "repository", "->", "deleteOne", "(", "$", "document", ")", ";", "unset", "(", "$", "remove", "[", "$", "id", "]", ")", ";", "}", "else", "{", "$", "query", "=", "$", "repository", "->", "deleteOne", "(", "$", "document", ",", "[", "'getQuery'", "=>", "true", "]", ")", ";", "$", "repositoryId", "=", "spl_object_hash", "(", "$", "repository", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "=", "$", "bulkOperations", "[", "$", "repositoryId", "]", "??", "$", "repository", "->", "createBulkWriteQuery", "(", ")", ";", "$", "bulkOperations", "[", "$", "repositoryId", "]", "->", "addQuery", "(", "$", "query", ")", ";", "}", "}", "foreach", "(", "array_merge", "(", "$", "insert", ",", "$", "update", ",", "$", "remove", ")", "as", "$", "id", "=>", "$", "document", ")", "{", "$", "repository", "=", "$", "this", "->", "getObjectRepository", "(", "$", "document", ")", ";", "$", "repository", "->", "getClassMetadata", "(", ")", "->", "getEventManager", "(", ")", "->", "execute", "(", "EventManager", "::", "EVENT_PRE_FLUSH", ",", "$", "document", ")", ";", "}", "foreach", "(", "$", "bulkOperations", "as", "$", "bulkOperation", ")", "{", "$", "bulkOperation", "->", "execute", "(", ")", ";", "}", "foreach", "(", "array_merge", "(", "$", "insert", ",", "$", "update", ")", "as", "$", "id", "=>", "$", "document", ")", "{", "$", "repository", "=", "$", "this", "->", "getObjectRepository", "(", "$", "document", ")", ";", "$", "repository", "->", "getClassMetadata", "(", ")", "->", "getEventManager", "(", ")", "->", "execute", "(", "EventManager", "::", "EVENT_POST_FLUSH", ",", "$", "document", ")", ";", "$", "repository", "->", "cacheObject", "(", "$", "document", ")", ";", "}", "$", "this", "->", "flush", "(", ")", ";", "}" ]
Perfom operation on collections @param array $insert Objects to insert @param array $update Objects to update @param array $remove Objects to remove @return void
[ "Perfom", "operation", "on", "collections" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/DocumentManager.php#L200-L253
14,744
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/Dropdown.php
Dropdown.generate
public function generate() { $toggle = clone $this->toggle; $toggle->addAttributes($this->attributes); $toggle->setLabel($toggle->getLabel() . ' ' . Bootstrap::getConfigVar('dropdown.toggle')); return sprintf( '%s<ul class="dropdown-menu">%s%s</ul>', $toggle, PHP_EOL, $this->generateChildren() ); }
php
public function generate() { $toggle = clone $this->toggle; $toggle->addAttributes($this->attributes); $toggle->setLabel($toggle->getLabel() . ' ' . Bootstrap::getConfigVar('dropdown.toggle')); return sprintf( '%s<ul class="dropdown-menu">%s%s</ul>', $toggle, PHP_EOL, $this->generateChildren() ); }
[ "public", "function", "generate", "(", ")", "{", "$", "toggle", "=", "clone", "$", "this", "->", "toggle", ";", "$", "toggle", "->", "addAttributes", "(", "$", "this", "->", "attributes", ")", ";", "$", "toggle", "->", "setLabel", "(", "$", "toggle", "->", "getLabel", "(", ")", ".", "' '", ".", "Bootstrap", "::", "getConfigVar", "(", "'dropdown.toggle'", ")", ")", ";", "return", "sprintf", "(", "'%s<ul class=\"dropdown-menu\">%s%s</ul>'", ",", "$", "toggle", ",", "PHP_EOL", ",", "$", "this", "->", "generateChildren", "(", ")", ")", ";", "}" ]
Generate the dropdown. @return string
[ "Generate", "the", "dropdown", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/Dropdown.php#L78-L90
14,745
withfatpanda/illuminate-wordpress
src/WordPress/Models/Post.php
Post.updateTimestamps
protected function updateTimestamps() { $time = $this->freshTimestamp(); $gmt = new Carbon; $gmt->timestamp = $time->timestamp - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); if (! $this->isDirty(static::UPDATED_AT)) { $this->setUpdatedAt($time); } if (! $this->exists && ! $this->isDirty(static::CREATED_AT)) { $this->setCreatedAt($time); } if (! $this->isDirty('post_modified_gmt')) { $this->post_modified_gmt = $gmt; } if (! $this->exists && ! $this->isDirty('post_gmt')) { $this->post_gmt = $gmt; } }
php
protected function updateTimestamps() { $time = $this->freshTimestamp(); $gmt = new Carbon; $gmt->timestamp = $time->timestamp - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); if (! $this->isDirty(static::UPDATED_AT)) { $this->setUpdatedAt($time); } if (! $this->exists && ! $this->isDirty(static::CREATED_AT)) { $this->setCreatedAt($time); } if (! $this->isDirty('post_modified_gmt')) { $this->post_modified_gmt = $gmt; } if (! $this->exists && ! $this->isDirty('post_gmt')) { $this->post_gmt = $gmt; } }
[ "protected", "function", "updateTimestamps", "(", ")", "{", "$", "time", "=", "$", "this", "->", "freshTimestamp", "(", ")", ";", "$", "gmt", "=", "new", "Carbon", ";", "$", "gmt", "->", "timestamp", "=", "$", "time", "->", "timestamp", "-", "(", "get_option", "(", "'gmt_offset'", ")", "*", "HOUR_IN_SECONDS", ")", ";", "if", "(", "!", "$", "this", "->", "isDirty", "(", "static", "::", "UPDATED_AT", ")", ")", "{", "$", "this", "->", "setUpdatedAt", "(", "$", "time", ")", ";", "}", "if", "(", "!", "$", "this", "->", "exists", "&&", "!", "$", "this", "->", "isDirty", "(", "static", "::", "CREATED_AT", ")", ")", "{", "$", "this", "->", "setCreatedAt", "(", "$", "time", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isDirty", "(", "'post_modified_gmt'", ")", ")", "{", "$", "this", "->", "post_modified_gmt", "=", "$", "gmt", ";", "}", "if", "(", "!", "$", "this", "->", "exists", "&&", "!", "$", "this", "->", "isDirty", "(", "'post_gmt'", ")", ")", "{", "$", "this", "->", "post_gmt", "=", "$", "gmt", ";", "}", "}" ]
Update the creation and update timestamps; WordPress has two timestamp fields, obviously. @return void
[ "Update", "the", "creation", "and", "update", "timestamps", ";", "WordPress", "has", "two", "timestamp", "fields", "obviously", "." ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Models/Post.php#L472-L494
14,746
wizbii/pipeline
Factory/PipelineFactory.php
PipelineFactory.buildName
public function buildName($pipeline, $configuration) { $name = is_array($configuration) && array_key_exists("name", $configuration) ? $configuration["name"] : null; if (empty($name)) { throw new InvalidConfigurationException("Missing pipeline name"); } $pipeline->setName($name); }
php
public function buildName($pipeline, $configuration) { $name = is_array($configuration) && array_key_exists("name", $configuration) ? $configuration["name"] : null; if (empty($name)) { throw new InvalidConfigurationException("Missing pipeline name"); } $pipeline->setName($name); }
[ "public", "function", "buildName", "(", "$", "pipeline", ",", "$", "configuration", ")", "{", "$", "name", "=", "is_array", "(", "$", "configuration", ")", "&&", "array_key_exists", "(", "\"name\"", ",", "$", "configuration", ")", "?", "$", "configuration", "[", "\"name\"", "]", ":", "null", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "\"Missing pipeline name\"", ")", ";", "}", "$", "pipeline", "->", "setName", "(", "$", "name", ")", ";", "}" ]
Set the pipeline name. Empty name will throw an exception @param Pipeline $pipeline @param array $configuration @throws InvalidConfigurationException
[ "Set", "the", "pipeline", "name", ".", "Empty", "name", "will", "throw", "an", "exception" ]
8d22b976a53bb52abf0333b62b308ec7127cf414
https://github.com/wizbii/pipeline/blob/8d22b976a53bb52abf0333b62b308ec7127cf414/Factory/PipelineFactory.php#L50-L57
14,747
wizbii/pipeline
Factory/PipelineFactory.php
PipelineFactory.buildAction
public function buildAction($pipeline, $actionName, $actionConfiguration = []) { $triggeredByEvents = is_array($actionConfiguration) && array_key_exists("triggered_by_events", $actionConfiguration) ? $actionConfiguration["triggered_by_events"] : []; if (empty($triggeredByEvents)) { // default behavior : auto-wiring action to the same event name $triggeredByEvents = [$actionName]; } // create the action and the action creator $action = new Action($actionName); $actionCreator = new ActionCreator($action); foreach ($triggeredByEvents as $triggeredByEvent) { $event = $pipeline->hasIncomingEvent($triggeredByEvent) ? $pipeline->getIncomingEvent($triggeredByEvent) : new Event($triggeredByEvent); $actionCreator->addTriggeredByEvent($event); $pipeline->addIncomingEvent($event); } $pipeline->addAction($action); $pipeline->addActionCreator($actionCreator); }
php
public function buildAction($pipeline, $actionName, $actionConfiguration = []) { $triggeredByEvents = is_array($actionConfiguration) && array_key_exists("triggered_by_events", $actionConfiguration) ? $actionConfiguration["triggered_by_events"] : []; if (empty($triggeredByEvents)) { // default behavior : auto-wiring action to the same event name $triggeredByEvents = [$actionName]; } // create the action and the action creator $action = new Action($actionName); $actionCreator = new ActionCreator($action); foreach ($triggeredByEvents as $triggeredByEvent) { $event = $pipeline->hasIncomingEvent($triggeredByEvent) ? $pipeline->getIncomingEvent($triggeredByEvent) : new Event($triggeredByEvent); $actionCreator->addTriggeredByEvent($event); $pipeline->addIncomingEvent($event); } $pipeline->addAction($action); $pipeline->addActionCreator($actionCreator); }
[ "public", "function", "buildAction", "(", "$", "pipeline", ",", "$", "actionName", ",", "$", "actionConfiguration", "=", "[", "]", ")", "{", "$", "triggeredByEvents", "=", "is_array", "(", "$", "actionConfiguration", ")", "&&", "array_key_exists", "(", "\"triggered_by_events\"", ",", "$", "actionConfiguration", ")", "?", "$", "actionConfiguration", "[", "\"triggered_by_events\"", "]", ":", "[", "]", ";", "if", "(", "empty", "(", "$", "triggeredByEvents", ")", ")", "{", "// default behavior : auto-wiring action to the same event name", "$", "triggeredByEvents", "=", "[", "$", "actionName", "]", ";", "}", "// create the action and the action creator", "$", "action", "=", "new", "Action", "(", "$", "actionName", ")", ";", "$", "actionCreator", "=", "new", "ActionCreator", "(", "$", "action", ")", ";", "foreach", "(", "$", "triggeredByEvents", "as", "$", "triggeredByEvent", ")", "{", "$", "event", "=", "$", "pipeline", "->", "hasIncomingEvent", "(", "$", "triggeredByEvent", ")", "?", "$", "pipeline", "->", "getIncomingEvent", "(", "$", "triggeredByEvent", ")", ":", "new", "Event", "(", "$", "triggeredByEvent", ")", ";", "$", "actionCreator", "->", "addTriggeredByEvent", "(", "$", "event", ")", ";", "$", "pipeline", "->", "addIncomingEvent", "(", "$", "event", ")", ";", "}", "$", "pipeline", "->", "addAction", "(", "$", "action", ")", ";", "$", "pipeline", "->", "addActionCreator", "(", "$", "actionCreator", ")", ";", "}" ]
Add actions inside Pipeline based on the configuration provided by Symfony Configuration @param Pipeline $pipeline @param string $actionName @param array $actionConfiguration
[ "Add", "actions", "inside", "Pipeline", "based", "on", "the", "configuration", "provided", "by", "Symfony", "Configuration" ]
8d22b976a53bb52abf0333b62b308ec7127cf414
https://github.com/wizbii/pipeline/blob/8d22b976a53bb52abf0333b62b308ec7127cf414/Factory/PipelineFactory.php#L65-L84
14,748
FrenchFrogs/framework
src/Ruler/Ruler/Permission.php
Permission.removePermission
public function removePermission($permission) { if ($this->hasPermission($permission)) { $index = array_search($permission, $this->permissions); unset($this->permissions[$index]); } return $this; }
php
public function removePermission($permission) { if ($this->hasPermission($permission)) { $index = array_search($permission, $this->permissions); unset($this->permissions[$index]); } return $this; }
[ "public", "function", "removePermission", "(", "$", "permission", ")", "{", "if", "(", "$", "this", "->", "hasPermission", "(", "$", "permission", ")", ")", "{", "$", "index", "=", "array_search", "(", "$", "permission", ",", "$", "this", "->", "permissions", ")", ";", "unset", "(", "$", "this", "->", "permissions", "[", "$", "index", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove permission from ermission container @param $permission @return $this
[ "Remove", "permission", "from", "ermission", "container" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Ruler/Ruler/Permission.php#L71-L79
14,749
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/ArrayQuery.php
ArrayQuery.select
public function select($select, $filters = array()) { if (false === is_array($select)) { $newSelect = [ $select => $filters ]; } else { $newSelect = []; foreach ($select as $key => $filters) { if (true === is_int($key) || '*' === $key) { $newSelect[$filters] = []; } else { $newSelect[$key] = $filters; } } } $this->select = $newSelect; return $this; }
php
public function select($select, $filters = array()) { if (false === is_array($select)) { $newSelect = [ $select => $filters ]; } else { $newSelect = []; foreach ($select as $key => $filters) { if (true === is_int($key) || '*' === $key) { $newSelect[$filters] = []; } else { $newSelect[$key] = $filters; } } } $this->select = $newSelect; return $this; }
[ "public", "function", "select", "(", "$", "select", ",", "$", "filters", "=", "array", "(", ")", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "select", ")", ")", "{", "$", "newSelect", "=", "[", "$", "select", "=>", "$", "filters", "]", ";", "}", "else", "{", "$", "newSelect", "=", "[", "]", ";", "foreach", "(", "$", "select", "as", "$", "key", "=>", "$", "filters", ")", "{", "if", "(", "true", "===", "is_int", "(", "$", "key", ")", "||", "'*'", "===", "$", "key", ")", "{", "$", "newSelect", "[", "$", "filters", "]", "=", "[", "]", ";", "}", "else", "{", "$", "newSelect", "[", "$", "key", "]", "=", "$", "filters", ";", "}", "}", "}", "$", "this", "->", "select", "=", "$", "newSelect", ";", "return", "$", "this", ";", "}" ]
The names of the fields that should be selected by the query. Example 1: **One field** `$query->select('name');` Example 2: **One field with filters** `$query->select('name', 'length')` Example 3: **Two fields as array** `$query->select([ 'name', 'age' ]);` Example 4: **Two fields with filters** `$query->select([ 'name' => [ 'replace 3,e', 'trim' ], 'bio' => 'trim' ]);` @param mixed $select Either an array of field names or each field name as parameter @return ArrayQuery
[ "The", "names", "of", "the", "fields", "that", "should", "be", "selected", "by", "the", "query", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/ArrayQuery.php#L73-L90
14,750
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/ArrayQuery.php
ArrayQuery.where
public function where($key, $value, $operator = '=', $filters = array()) { $this->where[] = [ 'key' => $key, 'value' => $value, 'operator' => $operator, 'filters' => $filters ]; return $this; }
php
public function where($key, $value, $operator = '=', $filters = array()) { $this->where[] = [ 'key' => $key, 'value' => $value, 'operator' => $operator, 'filters' => $filters ]; return $this; }
[ "public", "function", "where", "(", "$", "key", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "filters", "=", "array", "(", ")", ")", "{", "$", "this", "->", "where", "[", "]", "=", "[", "'key'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ",", "'operator'", "=>", "$", "operator", ",", "'filters'", "=>", "$", "filters", "]", ";", "return", "$", "this", ";", "}" ]
Add a clause that elements have to match to be returned. Example 1: **Simple where** `$select->where('name', 'Bilbo Baggings');` Example 2: **Different operator** `$select->where('age', 50, '>=');` Example 3: **Add filters** `$select->where('name', 5, '=', [ 'trim', 'count' ]);` @param mixed $key Key of the element to evaluate @param mixed $value Value the evaluated element has to match (occording to the operator) @param string $operator Operator used for the evluation @param array $filters Array of filters to be applied to a value before it is evaluated @return ArrayQuery
[ "Add", "a", "clause", "that", "elements", "have", "to", "match", "to", "be", "returned", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/ArrayQuery.php#L128-L138
14,751
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/ArrayQuery.php
ArrayQuery.evaluateWhere
protected function evaluateWhere(array $item) { $result = true; foreach ($this->where as $clause) { $result = $result && $this->whereEvaluation->evaluate($item, $clause); } return $result; }
php
protected function evaluateWhere(array $item) { $result = true; foreach ($this->where as $clause) { $result = $result && $this->whereEvaluation->evaluate($item, $clause); } return $result; }
[ "protected", "function", "evaluateWhere", "(", "array", "$", "item", ")", "{", "$", "result", "=", "true", ";", "foreach", "(", "$", "this", "->", "where", "as", "$", "clause", ")", "{", "$", "result", "=", "$", "result", "&&", "$", "this", "->", "whereEvaluation", "->", "evaluate", "(", "$", "item", ",", "$", "clause", ")", ";", "}", "return", "$", "result", ";", "}" ]
Evaluates the where clauses on the given item. @param array $item The item to evaluate @return boolean `true` if all where clauses evaluate to `true`, `false` otherwise
[ "Evaluates", "the", "where", "clauses", "on", "the", "given", "item", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/ArrayQuery.php#L222-L231
14,752
braincrafted/arrayquery
src/Braincrafted/ArrayQuery/ArrayQuery.php
ArrayQuery.evaluateSelect
protected function evaluateSelect(array $item, $scalar) { $resultItem = []; foreach ($item as $key => $value) { if (true === isset($this->select['*']) || true === isset($this->select[$key])) { if (true === isset($this->select[$key])) { $value = $this->selectEvaluation->evaluate($value, $this->select[$key]); } if (true === $scalar) { $resultItem = $value; } else { $resultItem[$key] = $value; } } } return $resultItem; }
php
protected function evaluateSelect(array $item, $scalar) { $resultItem = []; foreach ($item as $key => $value) { if (true === isset($this->select['*']) || true === isset($this->select[$key])) { if (true === isset($this->select[$key])) { $value = $this->selectEvaluation->evaluate($value, $this->select[$key]); } if (true === $scalar) { $resultItem = $value; } else { $resultItem[$key] = $value; } } } return $resultItem; }
[ "protected", "function", "evaluateSelect", "(", "array", "$", "item", ",", "$", "scalar", ")", "{", "$", "resultItem", "=", "[", "]", ";", "foreach", "(", "$", "item", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "select", "[", "'*'", "]", ")", "||", "true", "===", "isset", "(", "$", "this", "->", "select", "[", "$", "key", "]", ")", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "select", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "selectEvaluation", "->", "evaluate", "(", "$", "value", ",", "$", "this", "->", "select", "[", "$", "key", "]", ")", ";", "}", "if", "(", "true", "===", "$", "scalar", ")", "{", "$", "resultItem", "=", "$", "value", ";", "}", "else", "{", "$", "resultItem", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "resultItem", ";", "}" ]
Evaluates the select. @param array $item @param boolean $scalar @return mixed
[ "Evaluates", "the", "select", "." ]
8b0c44ee76cea796589422f52e2f7130676b9bd1
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/ArrayQuery.php#L241-L258
14,753
activecollab/databasestructure
src/Behaviour/IsArchivedInterface/Implementation.php
Implementation.moveToArchive
public function moveToArchive($bulk = false) { $this->connection->transact(function () use ($bulk) { $this->triggerEvent('on_before_move_to_archive', [$bulk]); if ($bulk && method_exists($this, 'setOriginalIsArchived')) { $this->setOriginalIsArchived($this->getIsArchived()); } $this->setIsArchived(true); $this->save(); $this->triggerEvent('on_after_move_to_archive', [$bulk]); }); }
php
public function moveToArchive($bulk = false) { $this->connection->transact(function () use ($bulk) { $this->triggerEvent('on_before_move_to_archive', [$bulk]); if ($bulk && method_exists($this, 'setOriginalIsArchived')) { $this->setOriginalIsArchived($this->getIsArchived()); } $this->setIsArchived(true); $this->save(); $this->triggerEvent('on_after_move_to_archive', [$bulk]); }); }
[ "public", "function", "moveToArchive", "(", "$", "bulk", "=", "false", ")", "{", "$", "this", "->", "connection", "->", "transact", "(", "function", "(", ")", "use", "(", "$", "bulk", ")", "{", "$", "this", "->", "triggerEvent", "(", "'on_before_move_to_archive'", ",", "[", "$", "bulk", "]", ")", ";", "if", "(", "$", "bulk", "&&", "method_exists", "(", "$", "this", ",", "'setOriginalIsArchived'", ")", ")", "{", "$", "this", "->", "setOriginalIsArchived", "(", "$", "this", "->", "getIsArchived", "(", ")", ")", ";", "}", "$", "this", "->", "setIsArchived", "(", "true", ")", ";", "$", "this", "->", "save", "(", ")", ";", "$", "this", "->", "triggerEvent", "(", "'on_after_move_to_archive'", ",", "[", "$", "bulk", "]", ")", ";", "}", ")", ";", "}" ]
Move to archive. @param bool $bulk
[ "Move", "to", "archive", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/IsArchivedInterface/Implementation.php#L32-L46
14,754
activecollab/databasestructure
src/Behaviour/IsArchivedInterface/Implementation.php
Implementation.restoreFromArchive
public function restoreFromArchive($bulk = false) { if ($this->getIsArchived()) { $this->connection->transact(function () use ($bulk) { $this->triggerEvent('on_before_restore_from_archive', [$bulk]); if ($bulk && method_exists($this, 'getOriginalIsArchived') && method_exists($this, 'setOriginalIsArchived')) { $this->setIsArchived($this->getOriginalIsArchived()); $this->setOriginalIsArchived(false); } else { $this->setIsArchived(false); } $this->save(); $this->triggerEvent('on_after_restore_from_archive', [$bulk]); }); } }
php
public function restoreFromArchive($bulk = false) { if ($this->getIsArchived()) { $this->connection->transact(function () use ($bulk) { $this->triggerEvent('on_before_restore_from_archive', [$bulk]); if ($bulk && method_exists($this, 'getOriginalIsArchived') && method_exists($this, 'setOriginalIsArchived')) { $this->setIsArchived($this->getOriginalIsArchived()); $this->setOriginalIsArchived(false); } else { $this->setIsArchived(false); } $this->save(); $this->triggerEvent('on_after_restore_from_archive', [$bulk]); }); } }
[ "public", "function", "restoreFromArchive", "(", "$", "bulk", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getIsArchived", "(", ")", ")", "{", "$", "this", "->", "connection", "->", "transact", "(", "function", "(", ")", "use", "(", "$", "bulk", ")", "{", "$", "this", "->", "triggerEvent", "(", "'on_before_restore_from_archive'", ",", "[", "$", "bulk", "]", ")", ";", "if", "(", "$", "bulk", "&&", "method_exists", "(", "$", "this", ",", "'getOriginalIsArchived'", ")", "&&", "method_exists", "(", "$", "this", ",", "'setOriginalIsArchived'", ")", ")", "{", "$", "this", "->", "setIsArchived", "(", "$", "this", "->", "getOriginalIsArchived", "(", ")", ")", ";", "$", "this", "->", "setOriginalIsArchived", "(", "false", ")", ";", "}", "else", "{", "$", "this", "->", "setIsArchived", "(", "false", ")", ";", "}", "$", "this", "->", "save", "(", ")", ";", "$", "this", "->", "triggerEvent", "(", "'on_after_restore_from_archive'", ",", "[", "$", "bulk", "]", ")", ";", "}", ")", ";", "}", "}" ]
Restore from archive. @param bool $bulk
[ "Restore", "from", "archive", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/IsArchivedInterface/Implementation.php#L53-L71
14,755
verschoof/bunq-api
src/Client.php
Client.requestAPI
private function requestAPI($method, $url, array $options = []) { try { return $this->sendRequest((string)$method, (string)$url, $options); } catch (SessionWasExpiredException $e) { return $this->sendRequest((string)$method, (string)$url, $options); } catch (ClientException $e) { throw new BunqException($e); } }
php
private function requestAPI($method, $url, array $options = []) { try { return $this->sendRequest((string)$method, (string)$url, $options); } catch (SessionWasExpiredException $e) { return $this->sendRequest((string)$method, (string)$url, $options); } catch (ClientException $e) { throw new BunqException($e); } }
[ "private", "function", "requestAPI", "(", "$", "method", ",", "$", "url", ",", "array", "$", "options", "=", "[", "]", ")", "{", "try", "{", "return", "$", "this", "->", "sendRequest", "(", "(", "string", ")", "$", "method", ",", "(", "string", ")", "$", "url", ",", "$", "options", ")", ";", "}", "catch", "(", "SessionWasExpiredException", "$", "e", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "(", "string", ")", "$", "method", ",", "(", "string", ")", "$", "url", ",", "$", "options", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "throw", "new", "BunqException", "(", "$", "e", ")", ";", "}", "}" ]
Handles the API Calling. @param string $method @param string $url @param array $options @return array @throws BunqException
[ "Handles", "the", "API", "Calling", "." ]
df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Client.php#L68-L77
14,756
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php
DummyArrayLog.logWarning
public function logWarning($message, $attachment = null) { $this->messages[] = "warning: " . $message . print_r($attachment, true); }
php
public function logWarning($message, $attachment = null) { $this->messages[] = "warning: " . $message . print_r($attachment, true); }
[ "public", "function", "logWarning", "(", "$", "message", ",", "$", "attachment", "=", "null", ")", "{", "$", "this", "->", "messages", "[", "]", "=", "\"warning: \"", ".", "$", "message", ".", "print_r", "(", "$", "attachment", ",", "true", ")", ";", "}" ]
Log message as warning level @param string $message @param mixed $attachment optional array or structure of data to be attached @return void
[ "Log", "message", "as", "warning", "level" ]
ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php#L48-L50
14,757
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php
DummyArrayLog.logError
public function logError($message, $attachment = null) { $this->messages[] = "error: " . $message . print_r($attachment, true); }
php
public function logError($message, $attachment = null) { $this->messages[] = "error: " . $message . print_r($attachment, true); }
[ "public", "function", "logError", "(", "$", "message", ",", "$", "attachment", "=", "null", ")", "{", "$", "this", "->", "messages", "[", "]", "=", "\"error: \"", ".", "$", "message", ".", "print_r", "(", "$", "attachment", ",", "true", ")", ";", "}" ]
Log message as error level @param string $message @param mixed $attachment optional array or structure of data to be attached @return void
[ "Log", "message", "as", "error", "level" ]
ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php#L59-L61
14,758
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php
DummyArrayLog.getLastMessage
public function getLastMessage() { $messagesClone = $this->messages; $keys = array_keys($messagesClone); $key = array_pop($keys); return $this->messages[$key]; }
php
public function getLastMessage() { $messagesClone = $this->messages; $keys = array_keys($messagesClone); $key = array_pop($keys); return $this->messages[$key]; }
[ "public", "function", "getLastMessage", "(", ")", "{", "$", "messagesClone", "=", "$", "this", "->", "messages", ";", "$", "keys", "=", "array_keys", "(", "$", "messagesClone", ")", ";", "$", "key", "=", "array_pop", "(", "$", "keys", ")", ";", "return", "$", "this", "->", "messages", "[", "$", "key", "]", ";", "}" ]
Get most recent log entry as string @return string
[ "Get", "most", "recent", "log", "entry", "as", "string" ]
ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Adapter/Log/DummyArrayLog.php#L75-L80
14,759
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php
RolePermissionQuery.filterByPermissionId
public function filterByPermissionId($permissionId = null, $comparison = null) { if (is_array($permissionId)) { $useMinMax = false; if (isset($permissionId['min'])) { $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($permissionId['max'])) { $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId, $comparison); }
php
public function filterByPermissionId($permissionId = null, $comparison = null) { if (is_array($permissionId)) { $useMinMax = false; if (isset($permissionId['min'])) { $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($permissionId['max'])) { $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permissionId, $comparison); }
[ "public", "function", "filterByPermissionId", "(", "$", "permissionId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "permissionId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "permissionId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RolePermissionTableMap", "::", "COL_PERMISSION_ID", ",", "$", "permissionId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "permissionId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RolePermissionTableMap", "::", "COL_PERMISSION_ID", ",", "$", "permissionId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RolePermissionTableMap", "::", "COL_PERMISSION_ID", ",", "$", "permissionId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the permission_id column Example usage: <code> $query->filterByPermissionId(1234); // WHERE permission_id = 1234 $query->filterByPermissionId(array(12, 34)); // WHERE permission_id IN (12, 34) $query->filterByPermissionId(array('min' => 12)); // WHERE permission_id > 12 </code> @see filterByPermission() @param mixed $permissionId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildRolePermissionQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "permission_id", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php#L306-L327
14,760
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php
RolePermissionQuery.filterByRole
public function filterByRole($role, $comparison = null) { if ($role instanceof \Alchemy\Component\Cerberus\Model\Role) { return $this ->addUsingAlias(RolePermissionTableMap::COL_ROLE_ID, $role->getId(), $comparison); } elseif ($role instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(RolePermissionTableMap::COL_ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRole() only accepts arguments of type \Alchemy\Component\Cerberus\Model\Role or Collection'); } }
php
public function filterByRole($role, $comparison = null) { if ($role instanceof \Alchemy\Component\Cerberus\Model\Role) { return $this ->addUsingAlias(RolePermissionTableMap::COL_ROLE_ID, $role->getId(), $comparison); } elseif ($role instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(RolePermissionTableMap::COL_ROLE_ID, $role->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRole() only accepts arguments of type \Alchemy\Component\Cerberus\Model\Role or Collection'); } }
[ "public", "function", "filterByRole", "(", "$", "role", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "role", "instanceof", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "Role", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "RolePermissionTableMap", "::", "COL_ROLE_ID", ",", "$", "role", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "role", "instanceof", "ObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RolePermissionTableMap", "::", "COL_ROLE_ID", ",", "$", "role", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByRole() only accepts arguments of type \\Alchemy\\Component\\Cerberus\\Model\\Role or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \Alchemy\Component\Cerberus\Model\Role object @param \Alchemy\Component\Cerberus\Model\Role|ObjectCollection $role The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildRolePermissionQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "Role", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php#L337-L352
14,761
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php
RolePermissionQuery.usePermissionQuery
public function usePermissionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPermission($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Permission', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
php
public function usePermissionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPermission($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Permission', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
[ "public", "function", "usePermissionQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinPermission", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Permission'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\PermissionQuery'", ")", ";", "}" ]
Use the Permission relation Permission object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\PermissionQuery A secondary query class using the current class as primary query
[ "Use", "the", "Permission", "relation", "Permission", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/RolePermissionQuery.php#L472-L477
14,762
delboy1978uk/form
src/Renderer/AbstractFormRenderer.php
AbstractFormRenderer.createNewDynamicContainerBlockIfNeeded
private function createNewDynamicContainerBlockIfNeeded($dynamicTriggerValue) { if (!isset($this->dynamicContainerBlock) && $dynamicTriggerValue !== null) { $this->dynamicContainerBlock = $this->createElement('div'); $this->dynamicContainerBlock->setAttribute('data-dynamic-form', $this->dynamicFormParentName); $this->dynamicContainerBlock->setAttribute('data-dynamic-form-trigger-value', $dynamicTriggerValue); $this->dynamicContainerBlock->setAttribute('class', 'dynamic-form-block trigger'.$this->dynamicFormParentName); $this->dynamicContainerBlock->setAttribute('id', $this->dynamicFormParentName.$dynamicTriggerValue); $this->dynamicFormVisible === false ? $this->dynamicContainerBlock->setAttribute('style', 'display: none;') : null; } }
php
private function createNewDynamicContainerBlockIfNeeded($dynamicTriggerValue) { if (!isset($this->dynamicContainerBlock) && $dynamicTriggerValue !== null) { $this->dynamicContainerBlock = $this->createElement('div'); $this->dynamicContainerBlock->setAttribute('data-dynamic-form', $this->dynamicFormParentName); $this->dynamicContainerBlock->setAttribute('data-dynamic-form-trigger-value', $dynamicTriggerValue); $this->dynamicContainerBlock->setAttribute('class', 'dynamic-form-block trigger'.$this->dynamicFormParentName); $this->dynamicContainerBlock->setAttribute('id', $this->dynamicFormParentName.$dynamicTriggerValue); $this->dynamicFormVisible === false ? $this->dynamicContainerBlock->setAttribute('style', 'display: none;') : null; } }
[ "private", "function", "createNewDynamicContainerBlockIfNeeded", "(", "$", "dynamicTriggerValue", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dynamicContainerBlock", ")", "&&", "$", "dynamicTriggerValue", "!==", "null", ")", "{", "$", "this", "->", "dynamicContainerBlock", "=", "$", "this", "->", "createElement", "(", "'div'", ")", ";", "$", "this", "->", "dynamicContainerBlock", "->", "setAttribute", "(", "'data-dynamic-form'", ",", "$", "this", "->", "dynamicFormParentName", ")", ";", "$", "this", "->", "dynamicContainerBlock", "->", "setAttribute", "(", "'data-dynamic-form-trigger-value'", ",", "$", "dynamicTriggerValue", ")", ";", "$", "this", "->", "dynamicContainerBlock", "->", "setAttribute", "(", "'class'", ",", "'dynamic-form-block trigger'", ".", "$", "this", "->", "dynamicFormParentName", ")", ";", "$", "this", "->", "dynamicContainerBlock", "->", "setAttribute", "(", "'id'", ",", "$", "this", "->", "dynamicFormParentName", ".", "$", "dynamicTriggerValue", ")", ";", "$", "this", "->", "dynamicFormVisible", "===", "false", "?", "$", "this", "->", "dynamicContainerBlock", "->", "setAttribute", "(", "'style'", ",", "'display: none;'", ")", ":", "null", ";", "}", "}" ]
This creates a containing div for dynamic fields which appear only on another fields value @param null|string $dynamicTriggerValue
[ "This", "creates", "a", "containing", "div", "for", "dynamic", "fields", "which", "appear", "only", "on", "another", "fields", "value" ]
fbbb042d95deef4603a19edf08c0497f720398a6
https://github.com/delboy1978uk/form/blob/fbbb042d95deef4603a19edf08c0497f720398a6/src/Renderer/AbstractFormRenderer.php#L177-L187
14,763
delboy1978uk/form
src/Renderer/AbstractFormRenderer.php
AbstractFormRenderer.dynamicFormCheck
private function dynamicFormCheck() { if ($this->field->hasDynamicForms()) { $this->dynamicFormParentName = $this->field->getName(); $value = $this->field->getValue(); $forms = $this->field->getDynamicForms(); $this->includeDynamicFormJavascript = true; foreach ($forms as $dynamicTriggerValue => $form) { $this->dynamicFormVisible = ($value == $dynamicTriggerValue); $dynamicFields = $form->getFields(); $this->processFields($dynamicFields, $dynamicTriggerValue); } unset($this->dynamicFormParentName); } }
php
private function dynamicFormCheck() { if ($this->field->hasDynamicForms()) { $this->dynamicFormParentName = $this->field->getName(); $value = $this->field->getValue(); $forms = $this->field->getDynamicForms(); $this->includeDynamicFormJavascript = true; foreach ($forms as $dynamicTriggerValue => $form) { $this->dynamicFormVisible = ($value == $dynamicTriggerValue); $dynamicFields = $form->getFields(); $this->processFields($dynamicFields, $dynamicTriggerValue); } unset($this->dynamicFormParentName); } }
[ "private", "function", "dynamicFormCheck", "(", ")", "{", "if", "(", "$", "this", "->", "field", "->", "hasDynamicForms", "(", ")", ")", "{", "$", "this", "->", "dynamicFormParentName", "=", "$", "this", "->", "field", "->", "getName", "(", ")", ";", "$", "value", "=", "$", "this", "->", "field", "->", "getValue", "(", ")", ";", "$", "forms", "=", "$", "this", "->", "field", "->", "getDynamicForms", "(", ")", ";", "$", "this", "->", "includeDynamicFormJavascript", "=", "true", ";", "foreach", "(", "$", "forms", "as", "$", "dynamicTriggerValue", "=>", "$", "form", ")", "{", "$", "this", "->", "dynamicFormVisible", "=", "(", "$", "value", "==", "$", "dynamicTriggerValue", ")", ";", "$", "dynamicFields", "=", "$", "form", "->", "getFields", "(", ")", ";", "$", "this", "->", "processFields", "(", "$", "dynamicFields", ",", "$", "dynamicTriggerValue", ")", ";", "}", "unset", "(", "$", "this", "->", "dynamicFormParentName", ")", ";", "}", "}" ]
Checks current field being processed for dynamic sub forms
[ "Checks", "current", "field", "being", "processed", "for", "dynamic", "sub", "forms" ]
fbbb042d95deef4603a19edf08c0497f720398a6
https://github.com/delboy1978uk/form/blob/fbbb042d95deef4603a19edf08c0497f720398a6/src/Renderer/AbstractFormRenderer.php#L192-L206
14,764
adminarchitect/contacts
src/Terranet/Contacts/Traits/HasContacts.php
HasContacts.prepareArrays
protected function prepareArrays(array $items = []) { $items = array_map(function ($item) { return trim($item); }, $items); return array_filter($items, function ($item) { return ! empty($item); }); }
php
protected function prepareArrays(array $items = []) { $items = array_map(function ($item) { return trim($item); }, $items); return array_filter($items, function ($item) { return ! empty($item); }); }
[ "protected", "function", "prepareArrays", "(", "array", "$", "items", "=", "[", "]", ")", "{", "$", "items", "=", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "trim", "(", "$", "item", ")", ";", "}", ",", "$", "items", ")", ";", "return", "array_filter", "(", "$", "items", ",", "function", "(", "$", "item", ")", "{", "return", "!", "empty", "(", "$", "item", ")", ";", "}", ")", ";", "}" ]
Prepare arrays before accepting @param array $items @return array
[ "Prepare", "arrays", "before", "accepting" ]
f46e6a13a2d5802ad32c446d5a7e0fbc878a4b5e
https://github.com/adminarchitect/contacts/blob/f46e6a13a2d5802ad32c446d5a7e0fbc878a4b5e/src/Terranet/Contacts/Traits/HasContacts.php#L65-L74
14,765
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/Handler/Save/UploadSaveHandler.php
UploadSaveHandler.parseWidget
public function parseWidget($widget) { /** * Check if file in session exists */ if(!isset($_SESSION['FILES'][$this->field->getColName()])){ return false; } /** * Rename the file (move) to the new location with the new name */ $ext = pathinfo($_SESSION['FILES'][$this->field->getColName()]['name'], PATHINFO_EXTENSION); $name = $this->field->uploadPath . '/' . $this->item->get('id') . '_' . $this->field->getColName() . '.' . $ext; if (move_uploaded_file($_SESSION['FILES'][$this->field->getColName()]['tmp_name'], TL_ROOT . '/' . $name)) { /** * Add File to the DBAFS */ $dbafsFile = \Dbafs::addResource($name); /** * Remove file from session */ unset($_SESSION['FILES'][$this->field->getColName()]); /** * Return UUID */ return $dbafsFile->uuid; } return false; }
php
public function parseWidget($widget) { /** * Check if file in session exists */ if(!isset($_SESSION['FILES'][$this->field->getColName()])){ return false; } /** * Rename the file (move) to the new location with the new name */ $ext = pathinfo($_SESSION['FILES'][$this->field->getColName()]['name'], PATHINFO_EXTENSION); $name = $this->field->uploadPath . '/' . $this->item->get('id') . '_' . $this->field->getColName() . '.' . $ext; if (move_uploaded_file($_SESSION['FILES'][$this->field->getColName()]['tmp_name'], TL_ROOT . '/' . $name)) { /** * Add File to the DBAFS */ $dbafsFile = \Dbafs::addResource($name); /** * Remove file from session */ unset($_SESSION['FILES'][$this->field->getColName()]); /** * Return UUID */ return $dbafsFile->uuid; } return false; }
[ "public", "function", "parseWidget", "(", "$", "widget", ")", "{", "/**\n * Check if file in session exists\n */", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "'FILES'", "]", "[", "$", "this", "->", "field", "->", "getColName", "(", ")", "]", ")", ")", "{", "return", "false", ";", "}", "/**\n * Rename the file (move) to the new location with the new name\n */", "$", "ext", "=", "pathinfo", "(", "$", "_SESSION", "[", "'FILES'", "]", "[", "$", "this", "->", "field", "->", "getColName", "(", ")", "]", "[", "'name'", "]", ",", "PATHINFO_EXTENSION", ")", ";", "$", "name", "=", "$", "this", "->", "field", "->", "uploadPath", ".", "'/'", ".", "$", "this", "->", "item", "->", "get", "(", "'id'", ")", ".", "'_'", ".", "$", "this", "->", "field", "->", "getColName", "(", ")", ".", "'.'", ".", "$", "ext", ";", "if", "(", "move_uploaded_file", "(", "$", "_SESSION", "[", "'FILES'", "]", "[", "$", "this", "->", "field", "->", "getColName", "(", ")", "]", "[", "'tmp_name'", "]", ",", "TL_ROOT", ".", "'/'", ".", "$", "name", ")", ")", "{", "/**\n * Add File to the DBAFS\n */", "$", "dbafsFile", "=", "\\", "Dbafs", "::", "addResource", "(", "$", "name", ")", ";", "/**\n * Remove file from session\n */", "unset", "(", "$", "_SESSION", "[", "'FILES'", "]", "[", "$", "this", "->", "field", "->", "getColName", "(", ")", "]", ")", ";", "/**\n * Return UUID\n */", "return", "$", "dbafsFile", "->", "uuid", ";", "}", "return", "false", ";", "}" ]
Parses the widget and returns either the uuid of the file or false if moving the file failed @param $widget @return mixed @throws \Exception
[ "Parses", "the", "widget", "and", "returns", "either", "the", "uuid", "of", "the", "file", "or", "false", "if", "moving", "the", "file", "failed" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/Handler/Save/UploadSaveHandler.php#L37-L75
14,766
FrenchFrogs/framework
src/Core/FrenchFrogsServiceProvider.php
FrenchFrogsServiceProvider.boot
public function boot() { $this->bootBlade(); $this->bootDatatable(); $this->bootModal(); $this->bootMail(); $this->bootValidator(); $this->publish(); }
php
public function boot() { $this->bootBlade(); $this->bootDatatable(); $this->bootModal(); $this->bootMail(); $this->bootValidator(); $this->publish(); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "bootBlade", "(", ")", ";", "$", "this", "->", "bootDatatable", "(", ")", ";", "$", "this", "->", "bootModal", "(", ")", ";", "$", "this", "->", "bootMail", "(", ")", ";", "$", "this", "->", "bootValidator", "(", ")", ";", "$", "this", "->", "publish", "(", ")", ";", "}" ]
Boot principale du service
[ "Boot", "principale", "du", "service" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/FrenchFrogsServiceProvider.php#L16-L24
14,767
FrenchFrogs/framework
src/Core/FrenchFrogsServiceProvider.php
FrenchFrogsServiceProvider.bootValidator
public function bootValidator() { // notExists (database) renvoie true si l'entrée n'existe pas \Validator::extend('not_exists', function($attribute, $value, $parameters) { $row = \DB::table($parameters[0])->where($parameters[1], '=', $value)->first(); return empty($row); }); }
php
public function bootValidator() { // notExists (database) renvoie true si l'entrée n'existe pas \Validator::extend('not_exists', function($attribute, $value, $parameters) { $row = \DB::table($parameters[0])->where($parameters[1], '=', $value)->first(); return empty($row); }); }
[ "public", "function", "bootValidator", "(", ")", "{", "// notExists (database) renvoie true si l'entrée n'existe pas", "\\", "Validator", "::", "extend", "(", "'not_exists'", ",", "function", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "$", "row", "=", "\\", "DB", "::", "table", "(", "$", "parameters", "[", "0", "]", ")", "->", "where", "(", "$", "parameters", "[", "1", "]", ",", "'='", ",", "$", "value", ")", "->", "first", "(", ")", ";", "return", "empty", "(", "$", "row", ")", ";", "}", ")", ";", "}" ]
Ajoute de nouveau validateur
[ "Ajoute", "de", "nouveau", "validateur" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/FrenchFrogsServiceProvider.php#L42-L51
14,768
FrenchFrogs/framework
src/Core/FrenchFrogsServiceProvider.php
FrenchFrogsServiceProvider.bootMail
public function bootMail() { /** * Mail manager * * @param string $view * @param array $data * @param array $from * @param array $to * @param string $subject * @param array $attach */ Response::macro('mail', function($view, $data = [], $from = [], $to = [], $subject = '', $attach = []) { if ($from instanceof Mail\Message) { \Mail::send($view, $data, function (Mail\Message $message) use ($from, $attach) { // Getting the generated message $swift = $from->getSwiftMessage(); // Setting the mandatory arguments $message->subject($swift->getSubject()); $message->from($swift->getFrom()); $message->to($swift->getTo()); // Getting the optional arguments if (!empty($swift->getSender())) { $message->sender($swift->getSender()); } if (!empty($swift->getCc())) { $message->cc($swift->getCc()); } if (!empty($swift->getBcc())) { $message->bcc($swift->getBcc()); } if (!empty($swift->getReplyTo())) { $message->replyTo($swift->getReplyTo()); } if (!empty($swift->getPriority())) { $message->priority($swift->getPriority()); } if (!empty($swift->getChildren())) { foreach($swift->getChildren() as $child){ $message->attachData($child->getBody(),$child->getHeaders()->get('content-type')->getParameter('name')); } } }); } else { \Mail::send($view, $data, function (Mail\Message $message) use ($from, $to, $subject, $attach) { // Setting the mandatory arguments $message->from(...$from)->subject($subject); // Managing multiple to foreach ($to as $mail) { $message->to(...$mail); } // Managing multiple attachment foreach ($attach as $file) { $message->attach($file); } }); } }); }
php
public function bootMail() { /** * Mail manager * * @param string $view * @param array $data * @param array $from * @param array $to * @param string $subject * @param array $attach */ Response::macro('mail', function($view, $data = [], $from = [], $to = [], $subject = '', $attach = []) { if ($from instanceof Mail\Message) { \Mail::send($view, $data, function (Mail\Message $message) use ($from, $attach) { // Getting the generated message $swift = $from->getSwiftMessage(); // Setting the mandatory arguments $message->subject($swift->getSubject()); $message->from($swift->getFrom()); $message->to($swift->getTo()); // Getting the optional arguments if (!empty($swift->getSender())) { $message->sender($swift->getSender()); } if (!empty($swift->getCc())) { $message->cc($swift->getCc()); } if (!empty($swift->getBcc())) { $message->bcc($swift->getBcc()); } if (!empty($swift->getReplyTo())) { $message->replyTo($swift->getReplyTo()); } if (!empty($swift->getPriority())) { $message->priority($swift->getPriority()); } if (!empty($swift->getChildren())) { foreach($swift->getChildren() as $child){ $message->attachData($child->getBody(),$child->getHeaders()->get('content-type')->getParameter('name')); } } }); } else { \Mail::send($view, $data, function (Mail\Message $message) use ($from, $to, $subject, $attach) { // Setting the mandatory arguments $message->from(...$from)->subject($subject); // Managing multiple to foreach ($to as $mail) { $message->to(...$mail); } // Managing multiple attachment foreach ($attach as $file) { $message->attach($file); } }); } }); }
[ "public", "function", "bootMail", "(", ")", "{", "/**\n * Mail manager\n *\n * @param string $view\n * @param array $data\n * @param array $from\n * @param array $to\n * @param string $subject\n * @param array $attach\n */", "Response", "::", "macro", "(", "'mail'", ",", "function", "(", "$", "view", ",", "$", "data", "=", "[", "]", ",", "$", "from", "=", "[", "]", ",", "$", "to", "=", "[", "]", ",", "$", "subject", "=", "''", ",", "$", "attach", "=", "[", "]", ")", "{", "if", "(", "$", "from", "instanceof", "Mail", "\\", "Message", ")", "{", "\\", "Mail", "::", "send", "(", "$", "view", ",", "$", "data", ",", "function", "(", "Mail", "\\", "Message", "$", "message", ")", "use", "(", "$", "from", ",", "$", "attach", ")", "{", "// Getting the generated message", "$", "swift", "=", "$", "from", "->", "getSwiftMessage", "(", ")", ";", "// Setting the mandatory arguments", "$", "message", "->", "subject", "(", "$", "swift", "->", "getSubject", "(", ")", ")", ";", "$", "message", "->", "from", "(", "$", "swift", "->", "getFrom", "(", ")", ")", ";", "$", "message", "->", "to", "(", "$", "swift", "->", "getTo", "(", ")", ")", ";", "// Getting the optional arguments", "if", "(", "!", "empty", "(", "$", "swift", "->", "getSender", "(", ")", ")", ")", "{", "$", "message", "->", "sender", "(", "$", "swift", "->", "getSender", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "swift", "->", "getCc", "(", ")", ")", ")", "{", "$", "message", "->", "cc", "(", "$", "swift", "->", "getCc", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "swift", "->", "getBcc", "(", ")", ")", ")", "{", "$", "message", "->", "bcc", "(", "$", "swift", "->", "getBcc", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "swift", "->", "getReplyTo", "(", ")", ")", ")", "{", "$", "message", "->", "replyTo", "(", "$", "swift", "->", "getReplyTo", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "swift", "->", "getPriority", "(", ")", ")", ")", "{", "$", "message", "->", "priority", "(", "$", "swift", "->", "getPriority", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "swift", "->", "getChildren", "(", ")", ")", ")", "{", "foreach", "(", "$", "swift", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "message", "->", "attachData", "(", "$", "child", "->", "getBody", "(", ")", ",", "$", "child", "->", "getHeaders", "(", ")", "->", "get", "(", "'content-type'", ")", "->", "getParameter", "(", "'name'", ")", ")", ";", "}", "}", "}", ")", ";", "}", "else", "{", "\\", "Mail", "::", "send", "(", "$", "view", ",", "$", "data", ",", "function", "(", "Mail", "\\", "Message", "$", "message", ")", "use", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "attach", ")", "{", "// Setting the mandatory arguments", "$", "message", "->", "from", "(", "...", "$", "from", ")", "->", "subject", "(", "$", "subject", ")", ";", "// Managing multiple to", "foreach", "(", "$", "to", "as", "$", "mail", ")", "{", "$", "message", "->", "to", "(", "...", "$", "mail", ")", ";", "}", "// Managing multiple attachment", "foreach", "(", "$", "attach", "as", "$", "file", ")", "{", "$", "message", "->", "attach", "(", "$", "file", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "}" ]
Permet d'utiliser la reponse pour envoyer un mail Cela permet de gere un email comme une page web.
[ "Permet", "d", "utiliser", "la", "reponse", "pour", "envoyer", "un", "mail" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/FrenchFrogsServiceProvider.php#L180-L230
14,769
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Aop/Advice/CircuitBreakerAdvice.php
CircuitBreakerAdvice.interceptMethodCall
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { if ($this->breaker->isAvailable($this->serviceName)) { try { $result = $jointPoint->proceed(); $this->breaker->reportSuccess($this->serviceName); return $result; } catch (Exception $e) { if ($this->isServiceFailureException($e)) { $this->breaker->reportFailure($this->serviceName); }else{ $this->breaker->reportSuccess($this->serviceName); } throw $e; } } else { throw $this->throwOnFailure; } }
php
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { if ($this->breaker->isAvailable($this->serviceName)) { try { $result = $jointPoint->proceed(); $this->breaker->reportSuccess($this->serviceName); return $result; } catch (Exception $e) { if ($this->isServiceFailureException($e)) { $this->breaker->reportFailure($this->serviceName); }else{ $this->breaker->reportSuccess($this->serviceName); } throw $e; } } else { throw $this->throwOnFailure; } }
[ "public", "function", "interceptMethodCall", "(", "ProceedingJoinPointInterface", "$", "jointPoint", ")", "{", "if", "(", "$", "this", "->", "breaker", "->", "isAvailable", "(", "$", "this", "->", "serviceName", ")", ")", "{", "try", "{", "$", "result", "=", "$", "jointPoint", "->", "proceed", "(", ")", ";", "$", "this", "->", "breaker", "->", "reportSuccess", "(", "$", "this", "->", "serviceName", ")", ";", "return", "$", "result", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "isServiceFailureException", "(", "$", "e", ")", ")", "{", "$", "this", "->", "breaker", "->", "reportFailure", "(", "$", "this", "->", "serviceName", ")", ";", "}", "else", "{", "$", "this", "->", "breaker", "->", "reportSuccess", "(", "$", "this", "->", "serviceName", ")", ";", "}", "throw", "$", "e", ";", "}", "}", "else", "{", "throw", "$", "this", "->", "throwOnFailure", ";", "}", "}" ]
In this implementation we ask CircuitBreaker implementation if it is safe to proceed with the service call. @param ProceedingJoinPointInterface $jointPoint @throws ServiceUnavailableException|Exception @return mixed
[ "In", "this", "implementation", "we", "ask", "CircuitBreaker", "implementation", "if", "it", "is", "safe", "to", "proceed", "with", "the", "service", "call", "." ]
ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Aop/Advice/CircuitBreakerAdvice.php#L103-L121
14,770
belgattitude/soluble-metadata
src/Soluble/Metadata/ColumnsMetadata.php
ColumnsMetadata.getColumn
public function getColumn(string $name): AbstractColumnDefinition { if (!$this->offsetExists($name)) { throw new Exception\UnexistentColumnException("Column '$name' does not exists in metadata"); } return $this->offsetGet($name); }
php
public function getColumn(string $name): AbstractColumnDefinition { if (!$this->offsetExists($name)) { throw new Exception\UnexistentColumnException("Column '$name' does not exists in metadata"); } return $this->offsetGet($name); }
[ "public", "function", "getColumn", "(", "string", "$", "name", ")", ":", "AbstractColumnDefinition", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "$", "name", ")", ")", "{", "throw", "new", "Exception", "\\", "UnexistentColumnException", "(", "\"Column '$name' does not exists in metadata\"", ")", ";", "}", "return", "$", "this", "->", "offsetGet", "(", "$", "name", ")", ";", "}" ]
Return specific column metadata. @throws Exception\UnexistentColumnException
[ "Return", "specific", "column", "metadata", "." ]
6285461c40a619070f601184d58e6c772b769d5c
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/ColumnsMetadata.php#L17-L24
14,771
dantleech/glob
lib/DTL/Glob/Parser/SelectorParser.php
SelectorParser.parse
public function parse($selector) { if ('/' === $selector) { return array(); } if ('/' !== substr($selector, 0, 1)) { throw new \InvalidArgumentException(sprintf( 'Path "%s" must be absolute', $selector )); } $selector = substr($selector, 1); $segments = array(); $elements = explode('/', $selector); foreach ($elements as $index => $element) { if ($this->processWildcard($element)) { $flags = self::T_PATTERN; } else { $flags = self::T_STATIC; } if ($index === (count($elements) - 1)) { $flags = $flags | self::T_LAST; } $segments[] = array($element, $flags); } return $segments; }
php
public function parse($selector) { if ('/' === $selector) { return array(); } if ('/' !== substr($selector, 0, 1)) { throw new \InvalidArgumentException(sprintf( 'Path "%s" must be absolute', $selector )); } $selector = substr($selector, 1); $segments = array(); $elements = explode('/', $selector); foreach ($elements as $index => $element) { if ($this->processWildcard($element)) { $flags = self::T_PATTERN; } else { $flags = self::T_STATIC; } if ($index === (count($elements) - 1)) { $flags = $flags | self::T_LAST; } $segments[] = array($element, $flags); } return $segments; }
[ "public", "function", "parse", "(", "$", "selector", ")", "{", "if", "(", "'/'", "===", "$", "selector", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "'/'", "!==", "substr", "(", "$", "selector", ",", "0", ",", "1", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Path \"%s\" must be absolute'", ",", "$", "selector", ")", ")", ";", "}", "$", "selector", "=", "substr", "(", "$", "selector", ",", "1", ")", ";", "$", "segments", "=", "array", "(", ")", ";", "$", "elements", "=", "explode", "(", "'/'", ",", "$", "selector", ")", ";", "foreach", "(", "$", "elements", "as", "$", "index", "=>", "$", "element", ")", "{", "if", "(", "$", "this", "->", "processWildcard", "(", "$", "element", ")", ")", "{", "$", "flags", "=", "self", "::", "T_PATTERN", ";", "}", "else", "{", "$", "flags", "=", "self", "::", "T_STATIC", ";", "}", "if", "(", "$", "index", "===", "(", "count", "(", "$", "elements", ")", "-", "1", ")", ")", "{", "$", "flags", "=", "$", "flags", "|", "self", "::", "T_LAST", ";", "}", "$", "segments", "[", "]", "=", "array", "(", "$", "element", ",", "$", "flags", ")", ";", "}", "return", "$", "segments", ";", "}" ]
Parse the given selector. Returns an associative array of path elements to bitmasks. @return array
[ "Parse", "the", "given", "selector", "." ]
1f618e6b77a5de4c6b0538d82572fe19cbb1c446
https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/Parser/SelectorParser.php#L31-L64
14,772
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/EndpointGateway.php
EndpointGateway.makeAuthenticatedApiRequest
public function makeAuthenticatedApiRequest($resource, array $params = array(), $method = 'GET') { $this->assertHasActiveUser(); $params['oauth_token'] = $this->token; return $this->makeApiRequest($resource, $params, $method); }
php
public function makeAuthenticatedApiRequest($resource, array $params = array(), $method = 'GET') { $this->assertHasActiveUser(); $params['oauth_token'] = $this->token; return $this->makeApiRequest($resource, $params, $method); }
[ "public", "function", "makeAuthenticatedApiRequest", "(", "$", "resource", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "method", "=", "'GET'", ")", "{", "$", "this", "->", "assertHasActiveUser", "(", ")", ";", "$", "params", "[", "'oauth_token'", "]", "=", "$", "this", "->", "token", ";", "return", "$", "this", "->", "makeApiRequest", "(", "$", "resource", ",", "$", "params", ",", "$", "method", ")", ";", "}" ]
make an authenticated request to the api @param string $resource @param array $params @param string $method @return stdClass
[ "make", "an", "authenticated", "request", "to", "the", "api" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/EndpointGateway.php#L94-L101
14,773
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/EndpointGateway.php
EndpointGateway.makeApiRequest
public function makeApiRequest($resource, array $params = array(), $method = 'GET') { $uri = $this->requestUri . '/' . ltrim($resource, '/'); if ($this->hasValidToken()) { $params['oauth_token'] = $this->token; } else { $params['client_id'] = $this->clientId; $params['client_secret'] = $this->clientSecret; } // apply a dated "version" $params['v'] = $this->dateVerified->format('Ymd'); switch ($method) { case 'GET': $response = json_decode($this->httpClient->get($uri, $params)); break; case 'POST': $response = json_decode($this->httpClient->post($uri, $params)); break; default: throw new \RuntimeException('Currently only HTTP methods "GET" and "POST" are supported.'); } //TODO check headers for api request limit if (isset($response->meta)) { if (isset($response->meta->code) && $response->meta->code != 200 ) { //TODO handle case } if (isset($response->meta->notifications) && is_array($response->meta->notifications) && count($response->meta->notifications) ) { //TODO handle notifications } } return $response->response; }
php
public function makeApiRequest($resource, array $params = array(), $method = 'GET') { $uri = $this->requestUri . '/' . ltrim($resource, '/'); if ($this->hasValidToken()) { $params['oauth_token'] = $this->token; } else { $params['client_id'] = $this->clientId; $params['client_secret'] = $this->clientSecret; } // apply a dated "version" $params['v'] = $this->dateVerified->format('Ymd'); switch ($method) { case 'GET': $response = json_decode($this->httpClient->get($uri, $params)); break; case 'POST': $response = json_decode($this->httpClient->post($uri, $params)); break; default: throw new \RuntimeException('Currently only HTTP methods "GET" and "POST" are supported.'); } //TODO check headers for api request limit if (isset($response->meta)) { if (isset($response->meta->code) && $response->meta->code != 200 ) { //TODO handle case } if (isset($response->meta->notifications) && is_array($response->meta->notifications) && count($response->meta->notifications) ) { //TODO handle notifications } } return $response->response; }
[ "public", "function", "makeApiRequest", "(", "$", "resource", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "method", "=", "'GET'", ")", "{", "$", "uri", "=", "$", "this", "->", "requestUri", ".", "'/'", ".", "ltrim", "(", "$", "resource", ",", "'/'", ")", ";", "if", "(", "$", "this", "->", "hasValidToken", "(", ")", ")", "{", "$", "params", "[", "'oauth_token'", "]", "=", "$", "this", "->", "token", ";", "}", "else", "{", "$", "params", "[", "'client_id'", "]", "=", "$", "this", "->", "clientId", ";", "$", "params", "[", "'client_secret'", "]", "=", "$", "this", "->", "clientSecret", ";", "}", "// apply a dated \"version\"", "$", "params", "[", "'v'", "]", "=", "$", "this", "->", "dateVerified", "->", "format", "(", "'Ymd'", ")", ";", "switch", "(", "$", "method", ")", "{", "case", "'GET'", ":", "$", "response", "=", "json_decode", "(", "$", "this", "->", "httpClient", "->", "get", "(", "$", "uri", ",", "$", "params", ")", ")", ";", "break", ";", "case", "'POST'", ":", "$", "response", "=", "json_decode", "(", "$", "this", "->", "httpClient", "->", "post", "(", "$", "uri", ",", "$", "params", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "'Currently only HTTP methods \"GET\" and \"POST\" are supported.'", ")", ";", "}", "//TODO check headers for api request limit", "if", "(", "isset", "(", "$", "response", "->", "meta", ")", ")", "{", "if", "(", "isset", "(", "$", "response", "->", "meta", "->", "code", ")", "&&", "$", "response", "->", "meta", "->", "code", "!=", "200", ")", "{", "//TODO handle case", "}", "if", "(", "isset", "(", "$", "response", "->", "meta", "->", "notifications", ")", "&&", "is_array", "(", "$", "response", "->", "meta", "->", "notifications", ")", "&&", "count", "(", "$", "response", "->", "meta", "->", "notifications", ")", ")", "{", "//TODO handle notifications", "}", "}", "return", "$", "response", "->", "response", ";", "}" ]
make a generic request to the api @param string $resource @param array $params @param string $method @return \stdClass
[ "make", "a", "generic", "request", "to", "the", "api" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/EndpointGateway.php#L110-L159
14,774
crossjoin/Css
src/Crossjoin/Css/Reader/HtmlFile.php
HtmlFile.getCssContent
protected function getCssContent() { $styleString = ""; if (class_exists("\\DOMDocument")) { $doc = new \DOMDocument(); $doc->loadHTMLFile($this->getFilename()); // Extract styles from the HTML file foreach($doc->getElementsByTagName('style') as $styleNode) { $styleString .= $styleNode->nodeValue . "\r\n"; } } else { throw new \RuntimeException("Required extension 'dom' seems to be missing."); } return $styleString; }
php
protected function getCssContent() { $styleString = ""; if (class_exists("\\DOMDocument")) { $doc = new \DOMDocument(); $doc->loadHTMLFile($this->getFilename()); // Extract styles from the HTML file foreach($doc->getElementsByTagName('style') as $styleNode) { $styleString .= $styleNode->nodeValue . "\r\n"; } } else { throw new \RuntimeException("Required extension 'dom' seems to be missing."); } return $styleString; }
[ "protected", "function", "getCssContent", "(", ")", "{", "$", "styleString", "=", "\"\"", ";", "if", "(", "class_exists", "(", "\"\\\\DOMDocument\"", ")", ")", "{", "$", "doc", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "doc", "->", "loadHTMLFile", "(", "$", "this", "->", "getFilename", "(", ")", ")", ";", "// Extract styles from the HTML file", "foreach", "(", "$", "doc", "->", "getElementsByTagName", "(", "'style'", ")", "as", "$", "styleNode", ")", "{", "$", "styleString", ".=", "$", "styleNode", "->", "nodeValue", ".", "\"\\r\\n\"", ";", "}", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Required extension 'dom' seems to be missing.\"", ")", ";", "}", "return", "$", "styleString", ";", "}" ]
Gets the CSS content from the HTML source. @return string
[ "Gets", "the", "CSS", "content", "from", "the", "HTML", "source", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Reader/HtmlFile.php#L12-L29
14,775
sulu/SuluPricingBundle
Manager/PriceCalculationManager.php
PriceCalculationManager.retrieveItemPrices
public function retrieveItemPrices($itemsData, $currency, $locale) { $items = []; $previousItem = null; // Prepare item data. foreach ($itemsData as $itemData) { $useProductsPrice = false; if (isset($itemData['useProductsPrice']) && $itemData['useProductsPrice'] == true) { $useProductsPrice = $itemData['useProductsPrice']; } // Add and remove necessary data for calculation. $itemData = $this->setDefaultData($itemData); $itemData = $this->unsetUneccesaryData($itemData); // Generate item. /** @var ItemInterface $item */ $item = $this->getItemManager()->save($itemData, $locale, null, null, null, null, $previousItem); $item->setUseProductsPrice($useProductsPrice); // Calculate total net price of item. $itemPrice = $this->itemPriceCalculator->calculateItemNetPrice( $item, $currency, $useProductsPrice, $this->isItemGrossPrice($itemData) ); $itemTotalNetPrice = $this->itemPriceCalculator->calculateItemTotalNetPrice( $item, $currency, $useProductsPrice, $this->isItemGrossPrice($itemData) ); $item->setPrice($itemPrice); $item->setTotalNetPrice($itemTotalNetPrice); // Save the last processed product item to calculate addon prices. if (Item::TYPE_ADDON !== $item->getType()) { $previousItem = $item->getEntity(); } $items[] = $item; } return [ 'items' => $items, ]; }
php
public function retrieveItemPrices($itemsData, $currency, $locale) { $items = []; $previousItem = null; // Prepare item data. foreach ($itemsData as $itemData) { $useProductsPrice = false; if (isset($itemData['useProductsPrice']) && $itemData['useProductsPrice'] == true) { $useProductsPrice = $itemData['useProductsPrice']; } // Add and remove necessary data for calculation. $itemData = $this->setDefaultData($itemData); $itemData = $this->unsetUneccesaryData($itemData); // Generate item. /** @var ItemInterface $item */ $item = $this->getItemManager()->save($itemData, $locale, null, null, null, null, $previousItem); $item->setUseProductsPrice($useProductsPrice); // Calculate total net price of item. $itemPrice = $this->itemPriceCalculator->calculateItemNetPrice( $item, $currency, $useProductsPrice, $this->isItemGrossPrice($itemData) ); $itemTotalNetPrice = $this->itemPriceCalculator->calculateItemTotalNetPrice( $item, $currency, $useProductsPrice, $this->isItemGrossPrice($itemData) ); $item->setPrice($itemPrice); $item->setTotalNetPrice($itemTotalNetPrice); // Save the last processed product item to calculate addon prices. if (Item::TYPE_ADDON !== $item->getType()) { $previousItem = $item->getEntity(); } $items[] = $item; } return [ 'items' => $items, ]; }
[ "public", "function", "retrieveItemPrices", "(", "$", "itemsData", ",", "$", "currency", ",", "$", "locale", ")", "{", "$", "items", "=", "[", "]", ";", "$", "previousItem", "=", "null", ";", "// Prepare item data.", "foreach", "(", "$", "itemsData", "as", "$", "itemData", ")", "{", "$", "useProductsPrice", "=", "false", ";", "if", "(", "isset", "(", "$", "itemData", "[", "'useProductsPrice'", "]", ")", "&&", "$", "itemData", "[", "'useProductsPrice'", "]", "==", "true", ")", "{", "$", "useProductsPrice", "=", "$", "itemData", "[", "'useProductsPrice'", "]", ";", "}", "// Add and remove necessary data for calculation.", "$", "itemData", "=", "$", "this", "->", "setDefaultData", "(", "$", "itemData", ")", ";", "$", "itemData", "=", "$", "this", "->", "unsetUneccesaryData", "(", "$", "itemData", ")", ";", "// Generate item.", "/** @var ItemInterface $item */", "$", "item", "=", "$", "this", "->", "getItemManager", "(", ")", "->", "save", "(", "$", "itemData", ",", "$", "locale", ",", "null", ",", "null", ",", "null", ",", "null", ",", "$", "previousItem", ")", ";", "$", "item", "->", "setUseProductsPrice", "(", "$", "useProductsPrice", ")", ";", "// Calculate total net price of item.", "$", "itemPrice", "=", "$", "this", "->", "itemPriceCalculator", "->", "calculateItemNetPrice", "(", "$", "item", ",", "$", "currency", ",", "$", "useProductsPrice", ",", "$", "this", "->", "isItemGrossPrice", "(", "$", "itemData", ")", ")", ";", "$", "itemTotalNetPrice", "=", "$", "this", "->", "itemPriceCalculator", "->", "calculateItemTotalNetPrice", "(", "$", "item", ",", "$", "currency", ",", "$", "useProductsPrice", ",", "$", "this", "->", "isItemGrossPrice", "(", "$", "itemData", ")", ")", ";", "$", "item", "->", "setPrice", "(", "$", "itemPrice", ")", ";", "$", "item", "->", "setTotalNetPrice", "(", "$", "itemTotalNetPrice", ")", ";", "// Save the last processed product item to calculate addon prices.", "if", "(", "Item", "::", "TYPE_ADDON", "!==", "$", "item", "->", "getType", "(", ")", ")", "{", "$", "previousItem", "=", "$", "item", "->", "getEntity", "(", ")", ";", "}", "$", "items", "[", "]", "=", "$", "item", ";", "}", "return", "[", "'items'", "=>", "$", "items", ",", "]", ";", "}" ]
Calculates total prices of all items given in data array. @param array $itemsData @param string $currency @param string $locale @return array
[ "Calculates", "total", "prices", "of", "all", "items", "given", "in", "data", "array", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Manager/PriceCalculationManager.php#L56-L104
14,776
JoffreyPoreeCoding/MongoDB-ODM
src/Factory/ClassMetadataFactory.php
ClassMetadataFactory.getMetadataForClass
public function getMetadataForClass($className) { if (!class_exists($className)) { throw new \Exception("Class $className does not exist!"); } if (isset($this->loadedMetadatas[$className])) { return $this->loadedMetadatas[$className]; } return $this->loadedMetadatas[$className] = $this->loadMetadataForClass($className, $this->annotationReader); }
php
public function getMetadataForClass($className) { if (!class_exists($className)) { throw new \Exception("Class $className does not exist!"); } if (isset($this->loadedMetadatas[$className])) { return $this->loadedMetadatas[$className]; } return $this->loadedMetadatas[$className] = $this->loadMetadataForClass($className, $this->annotationReader); }
[ "public", "function", "getMetadataForClass", "(", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Class $className does not exist!\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "loadedMetadatas", "[", "$", "className", "]", ")", ")", "{", "return", "$", "this", "->", "loadedMetadatas", "[", "$", "className", "]", ";", "}", "return", "$", "this", "->", "loadedMetadatas", "[", "$", "className", "]", "=", "$", "this", "->", "loadMetadataForClass", "(", "$", "className", ",", "$", "this", "->", "annotationReader", ")", ";", "}" ]
Allow to get class metadata for specified class @param string $className Name of the class to get metadatas @return ClassMetadata Class metadatas
[ "Allow", "to", "get", "class", "metadata", "for", "specified", "class" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Factory/ClassMetadataFactory.php#L57-L67
14,777
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtCharset/CharsetRule.php
CharsetRule.setValue
protected function setValue($value) { if (is_string($value)) { $value = trim($value); if ($value !== "") { $this->value = $value; } else { throw new \InvalidArgumentException("Invalid value for argument 'value' given."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for argument 'value' given. String expected." ); } return $this; }
php
protected function setValue($value) { if (is_string($value)) { $value = trim($value); if ($value !== "") { $this->value = $value; } else { throw new \InvalidArgumentException("Invalid value for argument 'value' given."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for argument 'value' given. String expected." ); } return $this; }
[ "protected", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "$", "value", "!==", "\"\"", ")", "{", "$", "this", "->", "value", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value for argument 'value' given.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for argument 'value' given. String expected.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the value for the charset rule. @param string $value @return $this
[ "Sets", "the", "value", "for", "the", "charset", "rule", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtCharset/CharsetRule.php#L39-L55
14,778
weavephp/weave
src/Weave.php
Weave.start
public function start($environment = null, $configLocation = null) { $config = $this->loadConfig($environment, $configLocation); $this->loadErrorHandler($config, $environment); $instantiator = $this->loadContainer($config, $environment); $middleware = $instantiator(Middleware\Middleware::class); $response = $middleware->execute(); $middleware->emit($response); }
php
public function start($environment = null, $configLocation = null) { $config = $this->loadConfig($environment, $configLocation); $this->loadErrorHandler($config, $environment); $instantiator = $this->loadContainer($config, $environment); $middleware = $instantiator(Middleware\Middleware::class); $response = $middleware->execute(); $middleware->emit($response); }
[ "public", "function", "start", "(", "$", "environment", "=", "null", ",", "$", "configLocation", "=", "null", ")", "{", "$", "config", "=", "$", "this", "->", "loadConfig", "(", "$", "environment", ",", "$", "configLocation", ")", ";", "$", "this", "->", "loadErrorHandler", "(", "$", "config", ",", "$", "environment", ")", ";", "$", "instantiator", "=", "$", "this", "->", "loadContainer", "(", "$", "config", ",", "$", "environment", ")", ";", "$", "middleware", "=", "$", "instantiator", "(", "Middleware", "\\", "Middleware", "::", "class", ")", ";", "$", "response", "=", "$", "middleware", "->", "execute", "(", ")", ";", "$", "middleware", "->", "emit", "(", "$", "response", ")", ";", "}" ]
The starting point for any Weave App. Environment and config location details are passed on to the config adaptor and environment is also passed to the error adaptor and the container adaptor. @param string $environment Optional indication of the runtime environment. @param string $configLocation Optional location from which to load config. @return null
[ "The", "starting", "point", "for", "any", "Weave", "App", "." ]
44183a5bcb9e3ed3754cc76aa9e0724d718caeec
https://github.com/weavephp/weave/blob/44183a5bcb9e3ed3754cc76aa9e0724d718caeec/src/Weave.php#L24-L34
14,779
opis/utils
lib/Punycode.php
Punycode.encodePart
protected static function encodePart(&$input) { $codePoints = &static::codePoints($input); $n = static::INITIAL_N; $bias = static::INITIAL_BIAS; $delta = 0; $h = $b = count($codePoints['basic']); $output = static::getString($codePoints['basic']); if ($input === $output) { return $output; } if ($b > 0) { $output .= static::DELIMITER; } $codePoints['nonBasic'] = array_unique($codePoints['nonBasic']); sort($codePoints['nonBasic']); $i = 0; $length = $codePoints['length']; while ($h < $length) { $m = $codePoints['nonBasic'][$i++]; $delta = $delta + ($m - $n) * ($h + 1); $n = $m; foreach ($codePoints['all'] as $c) { if ($c < $n || $c < static::INITIAL_N) { $delta++; } if ($c === $n) { $q = $delta; for ($k = static::BASE;; $k += static::BASE) { $t = static::calculateThreshold($k, $bias); if ($q < $t) { break; } $code = $t + (($q - $t) % (static::BASE - $t)); $output .= static::$encodeTable[$code]; $q = ($q - $t) / (static::BASE - $t); } $output .= static::$encodeTable[$q]; $bias = static::adapt($delta, $h + 1, ($h === $b)); $delta = 0; $h++; } } $delta++; $n++; } return static::PREFIX . $output; }
php
protected static function encodePart(&$input) { $codePoints = &static::codePoints($input); $n = static::INITIAL_N; $bias = static::INITIAL_BIAS; $delta = 0; $h = $b = count($codePoints['basic']); $output = static::getString($codePoints['basic']); if ($input === $output) { return $output; } if ($b > 0) { $output .= static::DELIMITER; } $codePoints['nonBasic'] = array_unique($codePoints['nonBasic']); sort($codePoints['nonBasic']); $i = 0; $length = $codePoints['length']; while ($h < $length) { $m = $codePoints['nonBasic'][$i++]; $delta = $delta + ($m - $n) * ($h + 1); $n = $m; foreach ($codePoints['all'] as $c) { if ($c < $n || $c < static::INITIAL_N) { $delta++; } if ($c === $n) { $q = $delta; for ($k = static::BASE;; $k += static::BASE) { $t = static::calculateThreshold($k, $bias); if ($q < $t) { break; } $code = $t + (($q - $t) % (static::BASE - $t)); $output .= static::$encodeTable[$code]; $q = ($q - $t) / (static::BASE - $t); } $output .= static::$encodeTable[$q]; $bias = static::adapt($delta, $h + 1, ($h === $b)); $delta = 0; $h++; } } $delta++; $n++; } return static::PREFIX . $output; }
[ "protected", "static", "function", "encodePart", "(", "&", "$", "input", ")", "{", "$", "codePoints", "=", "&", "static", "::", "codePoints", "(", "$", "input", ")", ";", "$", "n", "=", "static", "::", "INITIAL_N", ";", "$", "bias", "=", "static", "::", "INITIAL_BIAS", ";", "$", "delta", "=", "0", ";", "$", "h", "=", "$", "b", "=", "count", "(", "$", "codePoints", "[", "'basic'", "]", ")", ";", "$", "output", "=", "static", "::", "getString", "(", "$", "codePoints", "[", "'basic'", "]", ")", ";", "if", "(", "$", "input", "===", "$", "output", ")", "{", "return", "$", "output", ";", "}", "if", "(", "$", "b", ">", "0", ")", "{", "$", "output", ".=", "static", "::", "DELIMITER", ";", "}", "$", "codePoints", "[", "'nonBasic'", "]", "=", "array_unique", "(", "$", "codePoints", "[", "'nonBasic'", "]", ")", ";", "sort", "(", "$", "codePoints", "[", "'nonBasic'", "]", ")", ";", "$", "i", "=", "0", ";", "$", "length", "=", "$", "codePoints", "[", "'length'", "]", ";", "while", "(", "$", "h", "<", "$", "length", ")", "{", "$", "m", "=", "$", "codePoints", "[", "'nonBasic'", "]", "[", "$", "i", "++", "]", ";", "$", "delta", "=", "$", "delta", "+", "(", "$", "m", "-", "$", "n", ")", "*", "(", "$", "h", "+", "1", ")", ";", "$", "n", "=", "$", "m", ";", "foreach", "(", "$", "codePoints", "[", "'all'", "]", "as", "$", "c", ")", "{", "if", "(", "$", "c", "<", "$", "n", "||", "$", "c", "<", "static", "::", "INITIAL_N", ")", "{", "$", "delta", "++", ";", "}", "if", "(", "$", "c", "===", "$", "n", ")", "{", "$", "q", "=", "$", "delta", ";", "for", "(", "$", "k", "=", "static", "::", "BASE", ";", ";", "$", "k", "+=", "static", "::", "BASE", ")", "{", "$", "t", "=", "static", "::", "calculateThreshold", "(", "$", "k", ",", "$", "bias", ")", ";", "if", "(", "$", "q", "<", "$", "t", ")", "{", "break", ";", "}", "$", "code", "=", "$", "t", "+", "(", "(", "$", "q", "-", "$", "t", ")", "%", "(", "static", "::", "BASE", "-", "$", "t", ")", ")", ";", "$", "output", ".=", "static", "::", "$", "encodeTable", "[", "$", "code", "]", ";", "$", "q", "=", "(", "$", "q", "-", "$", "t", ")", "/", "(", "static", "::", "BASE", "-", "$", "t", ")", ";", "}", "$", "output", ".=", "static", "::", "$", "encodeTable", "[", "$", "q", "]", ";", "$", "bias", "=", "static", "::", "adapt", "(", "$", "delta", ",", "$", "h", "+", "1", ",", "(", "$", "h", "===", "$", "b", ")", ")", ";", "$", "delta", "=", "0", ";", "$", "h", "++", ";", "}", "}", "$", "delta", "++", ";", "$", "n", "++", ";", "}", "return", "static", "::", "PREFIX", ".", "$", "output", ";", "}" ]
Encode a part of a domain name, such as tld, to its Punycode version @param string $input Part of a domain name @return string Punycode representation of a domain part
[ "Encode", "a", "part", "of", "a", "domain", "name", "such", "as", "tld", "to", "its", "Punycode", "version" ]
239cd3dc3760eb746838011e712592700fe5d58c
https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/Punycode.php#L89-L150
14,780
ARCANEDEV/SpamBlocker
src/Entities/SpammerCollection.php
SpammerCollection.blockOne
public function blockOne($host) { return $this->exists($host) ? $this->updateOne($host) : $this->addOne($host); }
php
public function blockOne($host) { return $this->exists($host) ? $this->updateOne($host) : $this->addOne($host); }
[ "public", "function", "blockOne", "(", "$", "host", ")", "{", "return", "$", "this", "->", "exists", "(", "$", "host", ")", "?", "$", "this", "->", "updateOne", "(", "$", "host", ")", ":", "$", "this", "->", "addOne", "(", "$", "host", ")", ";", "}" ]
Add a host to a blacklist collection. @param string $host @return self
[ "Add", "a", "host", "to", "a", "blacklist", "collection", "." ]
708c9d5363616e0b257451256c4ca9fb9a9ff55f
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/Entities/SpammerCollection.php#L69-L74
14,781
ARCANEDEV/SpamBlocker
src/Entities/SpammerCollection.php
SpammerCollection.allowOne
public function allowOne($host) { return $this->exists($host) ? $this->updateOne($host, false) : $this->addOne($host, false); }
php
public function allowOne($host) { return $this->exists($host) ? $this->updateOne($host, false) : $this->addOne($host, false); }
[ "public", "function", "allowOne", "(", "$", "host", ")", "{", "return", "$", "this", "->", "exists", "(", "$", "host", ")", "?", "$", "this", "->", "updateOne", "(", "$", "host", ",", "false", ")", ":", "$", "this", "->", "addOne", "(", "$", "host", ",", "false", ")", ";", "}" ]
Add a host to a whitelist collection. @param string $host @return self
[ "Add", "a", "host", "to", "a", "whitelist", "collection", "." ]
708c9d5363616e0b257451256c4ca9fb9a9ff55f
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/Entities/SpammerCollection.php#L83-L88
14,782
ARCANEDEV/SpamBlocker
src/Entities/SpammerCollection.php
SpammerCollection.addOne
private function addOne($host, $blocked = true) { $spammer = Spammer::make($host, $blocked); return $this->put($spammer->host(), $spammer); }
php
private function addOne($host, $blocked = true) { $spammer = Spammer::make($host, $blocked); return $this->put($spammer->host(), $spammer); }
[ "private", "function", "addOne", "(", "$", "host", ",", "$", "blocked", "=", "true", ")", "{", "$", "spammer", "=", "Spammer", "::", "make", "(", "$", "host", ",", "$", "blocked", ")", ";", "return", "$", "this", "->", "put", "(", "$", "spammer", "->", "host", "(", ")", ",", "$", "spammer", ")", ";", "}" ]
Add a host to the collection. @param string $host @param bool $blocked @return self
[ "Add", "a", "host", "to", "the", "collection", "." ]
708c9d5363616e0b257451256c4ca9fb9a9ff55f
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/Entities/SpammerCollection.php#L98-L103
14,783
ARCANEDEV/SpamBlocker
src/Entities/SpammerCollection.php
SpammerCollection.whereHostIn
public function whereHostIn(array $hosts, $strict = false) { $values = $this->getArrayableItems($hosts); return $this->filter(function (Spammer $spammer) use ($values, $strict) { return in_array($spammer->host(), $values, $strict); }); }
php
public function whereHostIn(array $hosts, $strict = false) { $values = $this->getArrayableItems($hosts); return $this->filter(function (Spammer $spammer) use ($values, $strict) { return in_array($spammer->host(), $values, $strict); }); }
[ "public", "function", "whereHostIn", "(", "array", "$", "hosts", ",", "$", "strict", "=", "false", ")", "{", "$", "values", "=", "$", "this", "->", "getArrayableItems", "(", "$", "hosts", ")", ";", "return", "$", "this", "->", "filter", "(", "function", "(", "Spammer", "$", "spammer", ")", "use", "(", "$", "values", ",", "$", "strict", ")", "{", "return", "in_array", "(", "$", "spammer", "->", "host", "(", ")", ",", "$", "values", ",", "$", "strict", ")", ";", "}", ")", ";", "}" ]
Filter the spammer by the given hosts. @param array $hosts @param bool $strict @return self
[ "Filter", "the", "spammer", "by", "the", "given", "hosts", "." ]
708c9d5363616e0b257451256c4ca9fb9a9ff55f
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/Entities/SpammerCollection.php#L148-L155
14,784
Laralum/Roles
src/Controllers/RoleController.php
RoleController.updatePermissions
public function updatePermissions(Request $request, Role $role) { $this->authorize('manage_permissions', Role::class); $permissions = Permission::all(); foreach ($permissions as $permission) { if (array_key_exists($permission->id, $request->all())) { $role->addPermission($permission); } else { $role->deletePermission($permission); } } return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_permissions_updated', ['id' => $role->id])); }
php
public function updatePermissions(Request $request, Role $role) { $this->authorize('manage_permissions', Role::class); $permissions = Permission::all(); foreach ($permissions as $permission) { if (array_key_exists($permission->id, $request->all())) { $role->addPermission($permission); } else { $role->deletePermission($permission); } } return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_permissions_updated', ['id' => $role->id])); }
[ "public", "function", "updatePermissions", "(", "Request", "$", "request", ",", "Role", "$", "role", ")", "{", "$", "this", "->", "authorize", "(", "'manage_permissions'", ",", "Role", "::", "class", ")", ";", "$", "permissions", "=", "Permission", "::", "all", "(", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "if", "(", "array_key_exists", "(", "$", "permission", "->", "id", ",", "$", "request", "->", "all", "(", ")", ")", ")", "{", "$", "role", "->", "addPermission", "(", "$", "permission", ")", ";", "}", "else", "{", "$", "role", "->", "deletePermission", "(", "$", "permission", ")", ";", "}", "}", "return", "redirect", "(", ")", "->", "route", "(", "'laralum::roles.index'", ")", "->", "with", "(", "'success'", ",", "__", "(", "'laralum_roles::general.role_permissions_updated'", ",", "[", "'id'", "=>", "$", "role", "->", "id", "]", ")", ")", ";", "}" ]
Update the role permissions. @param \Illuminate\Http\Request $request @param \Laralum\Roles\Models\Role $role @return \Illuminate\Http\Response
[ "Update", "the", "role", "permissions", "." ]
f934967a5dcebebf81915dd50fccdbcb7e23c113
https://github.com/Laralum/Roles/blob/f934967a5dcebebf81915dd50fccdbcb7e23c113/src/Controllers/RoleController.php#L111-L125
14,785
shawnsandy/ui-pages
src/Controllers/PageKitController.php
PageKitController.contactUs
public function contactUs(Request $request) { $this->validate($request, [ 'full_name' => 'required', 'email' => 'required', 'subject' => 'required', 'message' => 'required' ] ); Mail::send( 'page::emails.contact-info', ['data' => $request->all()], function (Message $message) use ($request) { $message->from(config("mail.username"), ': Contact request'); $message->to($this->config("mail.username"), 'CTSFLA') ->subject('Contact request'); } ); return back()->with('success', config('pagekit.contact_us_response', 'Your message has been sent. Thank you!')); }
php
public function contactUs(Request $request) { $this->validate($request, [ 'full_name' => 'required', 'email' => 'required', 'subject' => 'required', 'message' => 'required' ] ); Mail::send( 'page::emails.contact-info', ['data' => $request->all()], function (Message $message) use ($request) { $message->from(config("mail.username"), ': Contact request'); $message->to($this->config("mail.username"), 'CTSFLA') ->subject('Contact request'); } ); return back()->with('success', config('pagekit.contact_us_response', 'Your message has been sent. Thank you!')); }
[ "public", "function", "contactUs", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'full_name'", "=>", "'required'", ",", "'email'", "=>", "'required'", ",", "'subject'", "=>", "'required'", ",", "'message'", "=>", "'required'", "]", ")", ";", "Mail", "::", "send", "(", "'page::emails.contact-info'", ",", "[", "'data'", "=>", "$", "request", "->", "all", "(", ")", "]", ",", "function", "(", "Message", "$", "message", ")", "use", "(", "$", "request", ")", "{", "$", "message", "->", "from", "(", "config", "(", "\"mail.username\"", ")", ",", "': Contact request'", ")", ";", "$", "message", "->", "to", "(", "$", "this", "->", "config", "(", "\"mail.username\"", ")", ",", "'CTSFLA'", ")", "->", "subject", "(", "'Contact request'", ")", ";", "}", ")", ";", "return", "back", "(", ")", "->", "with", "(", "'success'", ",", "config", "(", "'pagekit.contact_us_response'", ",", "'Your message has been sent. Thank you!'", ")", ")", ";", "}" ]
Process the contact form name. @return Response
[ "Process", "the", "contact", "form", "name", "." ]
11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8
https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Controllers/PageKitController.php#L21-L38
14,786
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/CoreBundle/Manager/EmailManager.php
EmailManager.writeLog
protected function writeLog($message) { $fileName = 'app/logs/mail/error.log'; $log = sprintf("[%s]: %s\n", date_format(new \DateTime(), 'Y-m-d H:i:s'), $message); file_put_contents($fileName, $log, FILE_APPEND); }
php
protected function writeLog($message) { $fileName = 'app/logs/mail/error.log'; $log = sprintf("[%s]: %s\n", date_format(new \DateTime(), 'Y-m-d H:i:s'), $message); file_put_contents($fileName, $log, FILE_APPEND); }
[ "protected", "function", "writeLog", "(", "$", "message", ")", "{", "$", "fileName", "=", "'app/logs/mail/error.log'", ";", "$", "log", "=", "sprintf", "(", "\"[%s]: %s\\n\"", ",", "date_format", "(", "new", "\\", "DateTime", "(", ")", ",", "'Y-m-d H:i:s'", ")", ",", "$", "message", ")", ";", "file_put_contents", "(", "$", "fileName", ",", "$", "log", ",", "FILE_APPEND", ")", ";", "}" ]
Writes a new line to mail error log @param string $message
[ "Writes", "a", "new", "line", "to", "mail", "error", "log" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Manager/EmailManager.php#L193-L199
14,787
CalderaWP/magic-tags
src/two/magictag.php
magictag.author_traversal
protected function author_traversal( $field, $post ) { $parts = explode( '.', $field ); $author = get_user_by( 'id', $post->post_author ); $parts = explode( '.', $field ); $author = get_user_by( 'id', $post->post_author ); if( is_object( $author ) && isset( $parts[1] ) && 'posts_url' == $parts[1] ) { $link = get_author_posts_url( $author->ID ); return $link; } if( is_object( $author ) && isset( $parts[1] ) && isset( $author->$parts[1] ) ) { return $author->$parts[1]; } }
php
protected function author_traversal( $field, $post ) { $parts = explode( '.', $field ); $author = get_user_by( 'id', $post->post_author ); $parts = explode( '.', $field ); $author = get_user_by( 'id', $post->post_author ); if( is_object( $author ) && isset( $parts[1] ) && 'posts_url' == $parts[1] ) { $link = get_author_posts_url( $author->ID ); return $link; } if( is_object( $author ) && isset( $parts[1] ) && isset( $author->$parts[1] ) ) { return $author->$parts[1]; } }
[ "protected", "function", "author_traversal", "(", "$", "field", ",", "$", "post", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "$", "author", "=", "get_user_by", "(", "'id'", ",", "$", "post", "->", "post_author", ")", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "$", "author", "=", "get_user_by", "(", "'id'", ",", "$", "post", "->", "post_author", ")", ";", "if", "(", "is_object", "(", "$", "author", ")", "&&", "isset", "(", "$", "parts", "[", "1", "]", ")", "&&", "'posts_url'", "==", "$", "parts", "[", "1", "]", ")", "{", "$", "link", "=", "get_author_posts_url", "(", "$", "author", "->", "ID", ")", ";", "return", "$", "link", ";", "}", "if", "(", "is_object", "(", "$", "author", ")", "&&", "isset", "(", "$", "parts", "[", "1", "]", ")", "&&", "isset", "(", "$", "author", "->", "$", "parts", "[", "1", "]", ")", ")", "{", "return", "$", "author", "->", "$", "parts", "[", "1", "]", ";", "}", "}" ]
Handle author.field traversals @since 2.0.0 @param string $field Field @param \WP_Post $post Current post @return mixed
[ "Handle", "author", ".", "field", "traversals" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L153-L169
14,788
CalderaWP/magic-tags
src/two/magictag.php
magictag.filter_post
public function filter_post( $in_params ){ // check if there is a third $params = explode( ':', $in_params ); if( isset( $params[1] ) ){ // a third e.g {post:24:post_title} indicates post ID 24 value post_title $post = get_post( $params[0] ); $field = $params[1]; }else{ // stic to current post global $post; $field = $params[0]; } // try object return $this->get_post_value( $field, $in_params, $post ); }
php
public function filter_post( $in_params ){ // check if there is a third $params = explode( ':', $in_params ); if( isset( $params[1] ) ){ // a third e.g {post:24:post_title} indicates post ID 24 value post_title $post = get_post( $params[0] ); $field = $params[1]; }else{ // stic to current post global $post; $field = $params[0]; } // try object return $this->get_post_value( $field, $in_params, $post ); }
[ "public", "function", "filter_post", "(", "$", "in_params", ")", "{", "// check if there is a third", "$", "params", "=", "explode", "(", "':'", ",", "$", "in_params", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "1", "]", ")", ")", "{", "// a third e.g {post:24:post_title} indicates post ID 24 value post_title", "$", "post", "=", "get_post", "(", "$", "params", "[", "0", "]", ")", ";", "$", "field", "=", "$", "params", "[", "1", "]", ";", "}", "else", "{", "// stic to current post", "global", "$", "post", ";", "$", "field", "=", "$", "params", "[", "0", "]", ";", "}", "// try object", "return", "$", "this", "->", "get_post_value", "(", "$", "field", ",", "$", "in_params", ",", "$", "post", ")", ";", "}" ]
Filters a post magic tag @since 0.0.1 @return string converted tag value
[ "Filters", "a", "post", "magic", "tag" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L178-L198
14,789
CalderaWP/magic-tags
src/two/magictag.php
magictag.filter_get_var
public function filter_get_var( $params ){ if( isset($_GET[$params])){ return wp_slash( $_GET[$params] ); }elseif( !empty( $_SERVER['HTTP_REFERER'] ) ){ return $this->filter_get_referr_var( $params ); } return $params; }
php
public function filter_get_var( $params ){ if( isset($_GET[$params])){ return wp_slash( $_GET[$params] ); }elseif( !empty( $_SERVER['HTTP_REFERER'] ) ){ return $this->filter_get_referr_var( $params ); } return $params; }
[ "public", "function", "filter_get_var", "(", "$", "params", ")", "{", "if", "(", "isset", "(", "$", "_GET", "[", "$", "params", "]", ")", ")", "{", "return", "wp_slash", "(", "$", "_GET", "[", "$", "params", "]", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", ")", "{", "return", "$", "this", "->", "filter_get_referr_var", "(", "$", "params", ")", ";", "}", "return", "$", "params", ";", "}" ]
Filters a GET magic tag @since 0.0.1 @return string converted tag value
[ "Filters", "a", "GET", "magic", "tag" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L206-L215
14,790
CalderaWP/magic-tags
src/two/magictag.php
magictag.filter_get_referr_var
private function filter_get_referr_var( $params ){ $referer = parse_url( $_SERVER['HTTP_REFERER'] ); if( !empty( $referer['query'] ) ){ parse_str( $referer['query'], $get_vars ); if( isset( $get_vars[$params] ) ){ return wp_slash( $get_vars[$params] ); } } return $params; }
php
private function filter_get_referr_var( $params ){ $referer = parse_url( $_SERVER['HTTP_REFERER'] ); if( !empty( $referer['query'] ) ){ parse_str( $referer['query'], $get_vars ); if( isset( $get_vars[$params] ) ){ return wp_slash( $get_vars[$params] ); } } return $params; }
[ "private", "function", "filter_get_referr_var", "(", "$", "params", ")", "{", "$", "referer", "=", "parse_url", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "referer", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "referer", "[", "'query'", "]", ",", "$", "get_vars", ")", ";", "if", "(", "isset", "(", "$", "get_vars", "[", "$", "params", "]", ")", ")", "{", "return", "wp_slash", "(", "$", "get_vars", "[", "$", "params", "]", ")", ";", "}", "}", "return", "$", "params", ";", "}" ]
Filters a GET from a referrer @since 0.0.1 @return string converted tag value
[ "Filters", "a", "GET", "from", "a", "referrer" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L224-L234
14,791
CalderaWP/magic-tags
src/two/magictag.php
magictag.filter_user
public function filter_user( $params ){ if(!is_user_logged_in() ){ return $params; } $user = get_userdata( get_current_user_id() ); if(isset( $user->data->{$params} )){ $params = $user->data->{$params}; } $is_meta = get_user_meta( $user->ID, $params, true ); if( !empty( $is_meta ) ){ $params = implode( ', ', (array) $is_meta ); } return $params; }
php
public function filter_user( $params ){ if(!is_user_logged_in() ){ return $params; } $user = get_userdata( get_current_user_id() ); if(isset( $user->data->{$params} )){ $params = $user->data->{$params}; } $is_meta = get_user_meta( $user->ID, $params, true ); if( !empty( $is_meta ) ){ $params = implode( ', ', (array) $is_meta ); } return $params; }
[ "public", "function", "filter_user", "(", "$", "params", ")", "{", "if", "(", "!", "is_user_logged_in", "(", ")", ")", "{", "return", "$", "params", ";", "}", "$", "user", "=", "get_userdata", "(", "get_current_user_id", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "user", "->", "data", "->", "{", "$", "params", "}", ")", ")", "{", "$", "params", "=", "$", "user", "->", "data", "->", "{", "$", "params", "}", ";", "}", "$", "is_meta", "=", "get_user_meta", "(", "$", "user", "->", "ID", ",", "$", "params", ",", "true", ")", ";", "if", "(", "!", "empty", "(", "$", "is_meta", ")", ")", "{", "$", "params", "=", "implode", "(", "', '", ",", "(", "array", ")", "$", "is_meta", ")", ";", "}", "return", "$", "params", ";", "}" ]
Filters a user magic tag @since 0.0.1 @return string converted tag value
[ "Filters", "a", "user", "magic", "tag" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L275-L291
14,792
CalderaWP/magic-tags
src/two/magictag.php
magictag.filter_ip
public function filter_ip( ){ // get IP $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } return $ip; }
php
public function filter_ip( ){ // get IP $ip = $_SERVER['REMOTE_ADDR']; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } return $ip; }
[ "public", "function", "filter_ip", "(", ")", "{", "// get IP", "$", "ip", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ")", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ")", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ";", "}", "return", "$", "ip", ";", "}" ]
Filters a ip magic tag @since 0.0.1 @return string converted tag value
[ "Filters", "a", "ip", "magic", "tag" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L313-L325
14,793
CalderaWP/magic-tags
src/two/magictag.php
magictag.maybe_do_post_thumbnail
private function maybe_do_post_thumbnail( $field, $post ) { if ( 'post_thumbnail' == $field || false !== strpos( $field, 'post_thumbnail.' ) ) { $size = 'thumbnail'; if ( false !== ( $pos = strpos( $field, '.' ) ) ) { $size = substr( $field, $pos + 1); } $id = get_post_thumbnail_id( $post->ID ); if ( 0 < absint( $id ) ) { $img = wp_get_attachment_image_src( $id, $size); if ( is_array( $img ) ) { return $img[0]; } } return 0; } return false; }
php
private function maybe_do_post_thumbnail( $field, $post ) { if ( 'post_thumbnail' == $field || false !== strpos( $field, 'post_thumbnail.' ) ) { $size = 'thumbnail'; if ( false !== ( $pos = strpos( $field, '.' ) ) ) { $size = substr( $field, $pos + 1); } $id = get_post_thumbnail_id( $post->ID ); if ( 0 < absint( $id ) ) { $img = wp_get_attachment_image_src( $id, $size); if ( is_array( $img ) ) { return $img[0]; } } return 0; } return false; }
[ "private", "function", "maybe_do_post_thumbnail", "(", "$", "field", ",", "$", "post", ")", "{", "if", "(", "'post_thumbnail'", "==", "$", "field", "||", "false", "!==", "strpos", "(", "$", "field", ",", "'post_thumbnail.'", ")", ")", "{", "$", "size", "=", "'thumbnail'", ";", "if", "(", "false", "!==", "(", "$", "pos", "=", "strpos", "(", "$", "field", ",", "'.'", ")", ")", ")", "{", "$", "size", "=", "substr", "(", "$", "field", ",", "$", "pos", "+", "1", ")", ";", "}", "$", "id", "=", "get_post_thumbnail_id", "(", "$", "post", "->", "ID", ")", ";", "if", "(", "0", "<", "absint", "(", "$", "id", ")", ")", "{", "$", "img", "=", "wp_get_attachment_image_src", "(", "$", "id", ",", "$", "size", ")", ";", "if", "(", "is_array", "(", "$", "img", ")", ")", "{", "return", "$", "img", "[", "0", "]", ";", "}", "}", "return", "0", ";", "}", "return", "false", ";", "}" ]
If field is "post_thumbnail" return image source URL Supports .size traversal @param string $field @param \WP_Post|object $post Post object @since 1.1.0 @return bool
[ "If", "field", "is", "post_thumbnail", "return", "image", "source", "URL" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L339-L364
14,794
CalderaWP/magic-tags
src/two/magictag.php
magictag.maybe_do_featured
private function maybe_do_featured( $field, $post ){ if ( 'post_featured' == $field ) { $id = get_post_thumbnail_id( $post->ID ); if ( 0 < absint( $id ) ) { return wp_get_attachment_image( $id, 'large' ); } return ''; } }
php
private function maybe_do_featured( $field, $post ){ if ( 'post_featured' == $field ) { $id = get_post_thumbnail_id( $post->ID ); if ( 0 < absint( $id ) ) { return wp_get_attachment_image( $id, 'large' ); } return ''; } }
[ "private", "function", "maybe_do_featured", "(", "$", "field", ",", "$", "post", ")", "{", "if", "(", "'post_featured'", "==", "$", "field", ")", "{", "$", "id", "=", "get_post_thumbnail_id", "(", "$", "post", "->", "ID", ")", ";", "if", "(", "0", "<", "absint", "(", "$", "id", ")", ")", "{", "return", "wp_get_attachment_image", "(", "$", "id", ",", "'large'", ")", ";", "}", "return", "''", ";", "}", "}" ]
Handle 'post_featured' tags @since 2.1.0 @param string $field @param \WP_Post|object $post Post object @return string|void
[ "Handle", "post_featured", "tags" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/two/magictag.php#L376-L391
14,795
repli2dev/nette-mailpanel
src/SessionMailer.php
SessionMailer.send
public function send(Message $mail) { $mails = array(); if($this->sessionSection->offsetExists('sentMessages')) { $mails = $this->sessionSection->sentMessages; } if (count($mails) === $this->limit) { array_pop($mails); } // get message with generated html instead of set FileTemplate etc $reflectionMethod = $mail->getReflection()->getMethod('build'); $reflectionMethod->setAccessible(TRUE); $builtMail = $reflectionMethod->invoke($mail); array_unshift($mails, $builtMail); $this->sessionSection->sentMessages = $mails; }
php
public function send(Message $mail) { $mails = array(); if($this->sessionSection->offsetExists('sentMessages')) { $mails = $this->sessionSection->sentMessages; } if (count($mails) === $this->limit) { array_pop($mails); } // get message with generated html instead of set FileTemplate etc $reflectionMethod = $mail->getReflection()->getMethod('build'); $reflectionMethod->setAccessible(TRUE); $builtMail = $reflectionMethod->invoke($mail); array_unshift($mails, $builtMail); $this->sessionSection->sentMessages = $mails; }
[ "public", "function", "send", "(", "Message", "$", "mail", ")", "{", "$", "mails", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "sessionSection", "->", "offsetExists", "(", "'sentMessages'", ")", ")", "{", "$", "mails", "=", "$", "this", "->", "sessionSection", "->", "sentMessages", ";", "}", "if", "(", "count", "(", "$", "mails", ")", "===", "$", "this", "->", "limit", ")", "{", "array_pop", "(", "$", "mails", ")", ";", "}", "// get message with generated html instead of set FileTemplate etc", "$", "reflectionMethod", "=", "$", "mail", "->", "getReflection", "(", ")", "->", "getMethod", "(", "'build'", ")", ";", "$", "reflectionMethod", "->", "setAccessible", "(", "TRUE", ")", ";", "$", "builtMail", "=", "$", "reflectionMethod", "->", "invoke", "(", "$", "mail", ")", ";", "array_unshift", "(", "$", "mails", ",", "$", "builtMail", ")", ";", "$", "this", "->", "sessionSection", "->", "sentMessages", "=", "$", "mails", ";", "}" ]
Sends given message via this mailer @param Message $mail
[ "Sends", "given", "message", "via", "this", "mailer" ]
608e6967098b6a27aae2fbc5637b00f3723cbbff
https://github.com/repli2dev/nette-mailpanel/blob/608e6967098b6a27aae2fbc5637b00f3723cbbff/src/SessionMailer.php#L44-L62
14,796
gregorybesson/PlaygroundCore
src/Filter/Sanitize.php
Sanitize.removeNotReplacedChar
public function removeNotReplacedChar($notReplaced) { if (empty($notReplaced)) { throw new \Exception('Not replaced character cannot be null.'); } if (is_array($notReplaced)) { foreach ($notReplaced as $n) { $this->removeNotReplacedChar($n); } } else { if (! in_array($notReplaced, $this->getNotReplacedChars())) { throw new \Exception("Not replaced character '$notReplaced' is not in array."); } $newArray = array(); foreach ($this->_notReplacedChars as $n) { if ($n != $notReplaced) { $newArray[] = $n; } $this->_notReplacedChars = $newArray; } } return $this; }
php
public function removeNotReplacedChar($notReplaced) { if (empty($notReplaced)) { throw new \Exception('Not replaced character cannot be null.'); } if (is_array($notReplaced)) { foreach ($notReplaced as $n) { $this->removeNotReplacedChar($n); } } else { if (! in_array($notReplaced, $this->getNotReplacedChars())) { throw new \Exception("Not replaced character '$notReplaced' is not in array."); } $newArray = array(); foreach ($this->_notReplacedChars as $n) { if ($n != $notReplaced) { $newArray[] = $n; } $this->_notReplacedChars = $newArray; } } return $this; }
[ "public", "function", "removeNotReplacedChar", "(", "$", "notReplaced", ")", "{", "if", "(", "empty", "(", "$", "notReplaced", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Not replaced character cannot be null.'", ")", ";", "}", "if", "(", "is_array", "(", "$", "notReplaced", ")", ")", "{", "foreach", "(", "$", "notReplaced", "as", "$", "n", ")", "{", "$", "this", "->", "removeNotReplacedChar", "(", "$", "n", ")", ";", "}", "}", "else", "{", "if", "(", "!", "in_array", "(", "$", "notReplaced", ",", "$", "this", "->", "getNotReplacedChars", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Not replaced character '$notReplaced' is not in array.\"", ")", ";", "}", "$", "newArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_notReplacedChars", "as", "$", "n", ")", "{", "if", "(", "$", "n", "!=", "$", "notReplaced", ")", "{", "$", "newArray", "[", "]", "=", "$", "n", ";", "}", "$", "this", "->", "_notReplacedChars", "=", "$", "newArray", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove not replaced character @param string|array $notReplaced @return Zend_Filter_Sanitize
[ "Remove", "not", "replaced", "character" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Filter/Sanitize.php#L142-L164
14,797
gregorybesson/PlaygroundCore
src/Filter/Sanitize.php
Sanitize.addWordDelimiter
public function addWordDelimiter($delimiter) { if (in_array($delimiter, $this->getWordDelimiters())) { throw new \Exception("Word delimiter '$delimiter' is already there."); } if (empty($delimiter)) { throw new \Exception('Word delimiter cannot be null.'); } if (is_array($delimiter)) { $this->_wordDelimiters = array_merge($this->getWordDelimiters(), $delimiter); } else { $this->_wordDelimiters[] = $delimiter; } return $this; }
php
public function addWordDelimiter($delimiter) { if (in_array($delimiter, $this->getWordDelimiters())) { throw new \Exception("Word delimiter '$delimiter' is already there."); } if (empty($delimiter)) { throw new \Exception('Word delimiter cannot be null.'); } if (is_array($delimiter)) { $this->_wordDelimiters = array_merge($this->getWordDelimiters(), $delimiter); } else { $this->_wordDelimiters[] = $delimiter; } return $this; }
[ "public", "function", "addWordDelimiter", "(", "$", "delimiter", ")", "{", "if", "(", "in_array", "(", "$", "delimiter", ",", "$", "this", "->", "getWordDelimiters", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Word delimiter '$delimiter' is already there.\"", ")", ";", "}", "if", "(", "empty", "(", "$", "delimiter", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Word delimiter cannot be null.'", ")", ";", "}", "if", "(", "is_array", "(", "$", "delimiter", ")", ")", "{", "$", "this", "->", "_wordDelimiters", "=", "array_merge", "(", "$", "this", "->", "getWordDelimiters", "(", ")", ",", "$", "delimiter", ")", ";", "}", "else", "{", "$", "this", "->", "_wordDelimiters", "[", "]", "=", "$", "delimiter", ";", "}", "return", "$", "this", ";", "}" ]
Add word delimiter @param string|array $delimiter @return Zend_Filter_Sanitize
[ "Add", "word", "delimiter" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Filter/Sanitize.php#L204-L218
14,798
activecollab/databasestructure
src/Behaviour/PositionInterface/Implementation.php
Implementation.ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation() { $this->registerEventHandler('on_before_save', function () { if (!$this->getPosition()) { $table_name = $this->connection->escapeTableName($this->getTableName()); $conditions = $this->getPositionContextConditions(); if ($this->getPositionMode() == PositionInterface::POSITION_MODE_HEAD) { $this->setPosition(1); if ($ids = $this->connection->executeFirstColumn("SELECT `id` FROM $table_name $conditions")) { $this->connection->execute("UPDATE $table_name SET `position` = `position` + 1 $conditions"); } } else { $this->setPosition($this->connection->executeFirstCell("SELECT MAX(`position`) FROM $table_name $conditions") + 1); } } }); }
php
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation() { $this->registerEventHandler('on_before_save', function () { if (!$this->getPosition()) { $table_name = $this->connection->escapeTableName($this->getTableName()); $conditions = $this->getPositionContextConditions(); if ($this->getPositionMode() == PositionInterface::POSITION_MODE_HEAD) { $this->setPosition(1); if ($ids = $this->connection->executeFirstColumn("SELECT `id` FROM $table_name $conditions")) { $this->connection->execute("UPDATE $table_name SET `position` = `position` + 1 $conditions"); } } else { $this->setPosition($this->connection->executeFirstCell("SELECT MAX(`position`) FROM $table_name $conditions") + 1); } } }); }
[ "public", "function", "ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation", "(", ")", "{", "$", "this", "->", "registerEventHandler", "(", "'on_before_save'", ",", "function", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getPosition", "(", ")", ")", "{", "$", "table_name", "=", "$", "this", "->", "connection", "->", "escapeTableName", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "$", "conditions", "=", "$", "this", "->", "getPositionContextConditions", "(", ")", ";", "if", "(", "$", "this", "->", "getPositionMode", "(", ")", "==", "PositionInterface", "::", "POSITION_MODE_HEAD", ")", "{", "$", "this", "->", "setPosition", "(", "1", ")", ";", "if", "(", "$", "ids", "=", "$", "this", "->", "connection", "->", "executeFirstColumn", "(", "\"SELECT `id` FROM $table_name $conditions\"", ")", ")", "{", "$", "this", "->", "connection", "->", "execute", "(", "\"UPDATE $table_name SET `position` = `position` + 1 $conditions\"", ")", ";", "}", "}", "else", "{", "$", "this", "->", "setPosition", "(", "$", "this", "->", "connection", "->", "executeFirstCell", "(", "\"SELECT MAX(`position`) FROM $table_name $conditions\"", ")", "+", "1", ")", ";", "}", "}", "}", ")", ";", "}" ]
Say hello to the parent class.
[ "Say", "hello", "to", "the", "parent", "class", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/PositionInterface/Implementation.php#L23-L41
14,799
activecollab/databasestructure
src/Behaviour/PositionInterface/Implementation.php
Implementation.getPositionContextConditions
private function getPositionContextConditions() { $pattern = $this->pool->getTypeProperty(get_class($this), 'position_context_conditions_pattern', function () { $conditions = []; foreach ($this->getPositionContext() as $field_name) { $conditions[] = $this->connection->escapeFieldName($field_name) . ' = ?'; } return count($conditions) ? implode(' AND ', $conditions) : ''; }); if ($pattern) { $to_prepare = [$pattern]; foreach ($this->getPositionContext() as $field_name) { $to_prepare[] = $this->getFieldValue($field_name); } return 'WHERE ' . call_user_func_array([&$this->connection, 'prepare'], $to_prepare); } return ''; }
php
private function getPositionContextConditions() { $pattern = $this->pool->getTypeProperty(get_class($this), 'position_context_conditions_pattern', function () { $conditions = []; foreach ($this->getPositionContext() as $field_name) { $conditions[] = $this->connection->escapeFieldName($field_name) . ' = ?'; } return count($conditions) ? implode(' AND ', $conditions) : ''; }); if ($pattern) { $to_prepare = [$pattern]; foreach ($this->getPositionContext() as $field_name) { $to_prepare[] = $this->getFieldValue($field_name); } return 'WHERE ' . call_user_func_array([&$this->connection, 'prepare'], $to_prepare); } return ''; }
[ "private", "function", "getPositionContextConditions", "(", ")", "{", "$", "pattern", "=", "$", "this", "->", "pool", "->", "getTypeProperty", "(", "get_class", "(", "$", "this", ")", ",", "'position_context_conditions_pattern'", ",", "function", "(", ")", "{", "$", "conditions", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getPositionContext", "(", ")", "as", "$", "field_name", ")", "{", "$", "conditions", "[", "]", "=", "$", "this", "->", "connection", "->", "escapeFieldName", "(", "$", "field_name", ")", ".", "' = ?'", ";", "}", "return", "count", "(", "$", "conditions", ")", "?", "implode", "(", "' AND '", ",", "$", "conditions", ")", ":", "''", ";", "}", ")", ";", "if", "(", "$", "pattern", ")", "{", "$", "to_prepare", "=", "[", "$", "pattern", "]", ";", "foreach", "(", "$", "this", "->", "getPositionContext", "(", ")", "as", "$", "field_name", ")", "{", "$", "to_prepare", "[", "]", "=", "$", "this", "->", "getFieldValue", "(", "$", "field_name", ")", ";", "}", "return", "'WHERE '", ".", "call_user_func_array", "(", "[", "&", "$", "this", "->", "connection", ",", "'prepare'", "]", ",", "$", "to_prepare", ")", ";", "}", "return", "''", ";", "}" ]
Return position context conditions. @return string
[ "Return", "position", "context", "conditions", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/PositionInterface/Implementation.php#L48-L71