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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
5,300
gossi/trixionary
src/model/Base/SportQuery.php
SportQuery.useObjectQuery
public function useObjectQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinObject($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Object', '\gossi\trixionary\model\ObjectQuery'); }
php
public function useObjectQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinObject($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Object', '\gossi\trixionary\model\ObjectQuery'); }
[ "public", "function", "useObjectQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinObject", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Object'", ",", "'\\gossi\\trixionary\\model\\ObjectQuery'", ")", ";", "}" ]
Use the Object relation Object 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 \gossi\trixionary\model\ObjectQuery A secondary query class using the current class as primary query
[ "Use", "the", "Object", "relation", "Object", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SportQuery.php#L1058-L1063
5,301
gossi/trixionary
src/model/Base/SportQuery.php
SportQuery.usePositionQuery
public function usePositionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPosition($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Position', '\gossi\trixionary\model\PositionQuery'); }
php
public function usePositionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinPosition($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Position', '\gossi\trixionary\model\PositionQuery'); }
[ "public", "function", "usePositionQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinPosition", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Position'", ",", "'\\gossi\\trixionary\\model\\PositionQuery'", ")", ";", "}" ]
Use the Position relation Position 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 \gossi\trixionary\model\PositionQuery A secondary query class using the current class as primary query
[ "Use", "the", "Position", "relation", "Position", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SportQuery.php#L1131-L1136
5,302
gossi/trixionary
src/model/Base/SportQuery.php
SportQuery.useGroupQuery
public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Group', '\gossi\trixionary\model\GroupQuery'); }
php
public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Group', '\gossi\trixionary\model\GroupQuery'); }
[ "public", "function", "useGroupQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinGroup", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Group'", ",", "'\\gossi\\trixionary\\model\\GroupQuery'", ")", ";", "}" ]
Use the Group relation Group 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 \gossi\trixionary\model\GroupQuery A secondary query class using the current class as primary query
[ "Use", "the", "Group", "relation", "Group", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SportQuery.php#L1277-L1282
5,303
veridu/idos-sdk-php
src/idOS/Auth/CredentialToken.php
CredentialToken.getToken
public function getToken() : string { if (($this->token === null) || ($this->token->isExpired())) { $jwtBuilder = new Builder(); $jwtBuilder->set('iss', $this->handlerPublicKey); $jwtBuilder->set('sub', $this->credentialPublicKey); $this->token = $jwtBuilder ->sign(new Sha256(), $this->handlerPrivateKey) ->getToken(); } return (string) $this->token; }
php
public function getToken() : string { if (($this->token === null) || ($this->token->isExpired())) { $jwtBuilder = new Builder(); $jwtBuilder->set('iss', $this->handlerPublicKey); $jwtBuilder->set('sub', $this->credentialPublicKey); $this->token = $jwtBuilder ->sign(new Sha256(), $this->handlerPrivateKey) ->getToken(); } return (string) $this->token; }
[ "public", "function", "getToken", "(", ")", ":", "string", "{", "if", "(", "(", "$", "this", "->", "token", "===", "null", ")", "||", "(", "$", "this", "->", "token", "->", "isExpired", "(", ")", ")", ")", "{", "$", "jwtBuilder", "=", "new", "Builder", "(", ")", ";", "$", "jwtBuilder", "->", "set", "(", "'iss'", ",", "$", "this", "->", "handlerPublicKey", ")", ";", "$", "jwtBuilder", "->", "set", "(", "'sub'", ",", "$", "this", "->", "credentialPublicKey", ")", ";", "$", "this", "->", "token", "=", "$", "jwtBuilder", "->", "sign", "(", "new", "Sha256", "(", ")", ",", "$", "this", "->", "handlerPrivateKey", ")", "->", "getToken", "(", ")", ";", "}", "return", "(", "string", ")", "$", "this", "->", "token", ";", "}" ]
Generates the credential token and returns it. @return string credentialToken
[ "Generates", "the", "credential", "token", "and", "returns", "it", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Auth/CredentialToken.php#L53-L65
5,304
ddehart/dilmun
src/Anshar/Utils/StringHelper.php
StringHelper.affectChunks
public function affectChunks(callable $function, ...$delimiters) { $delimiter_string = ""; $replace_callback = function ($matches) use ($function) { $callback_string = $function($matches[0]); return $callback_string; }; foreach ($delimiters as $delimiter) { $delimiter_string .= preg_quote($delimiter, "/"); } $pattern = "/[^{$delimiter_string}]+/"; $affected_string = preg_replace_callback($pattern, $replace_callback, $this->string); return $affected_string; }
php
public function affectChunks(callable $function, ...$delimiters) { $delimiter_string = ""; $replace_callback = function ($matches) use ($function) { $callback_string = $function($matches[0]); return $callback_string; }; foreach ($delimiters as $delimiter) { $delimiter_string .= preg_quote($delimiter, "/"); } $pattern = "/[^{$delimiter_string}]+/"; $affected_string = preg_replace_callback($pattern, $replace_callback, $this->string); return $affected_string; }
[ "public", "function", "affectChunks", "(", "callable", "$", "function", ",", "...", "$", "delimiters", ")", "{", "$", "delimiter_string", "=", "\"\"", ";", "$", "replace_callback", "=", "function", "(", "$", "matches", ")", "use", "(", "$", "function", ")", "{", "$", "callback_string", "=", "$", "function", "(", "$", "matches", "[", "0", "]", ")", ";", "return", "$", "callback_string", ";", "}", ";", "foreach", "(", "$", "delimiters", "as", "$", "delimiter", ")", "{", "$", "delimiter_string", ".=", "preg_quote", "(", "$", "delimiter", ",", "\"/\"", ")", ";", "}", "$", "pattern", "=", "\"/[^{$delimiter_string}]+/\"", ";", "$", "affected_string", "=", "preg_replace_callback", "(", "$", "pattern", ",", "$", "replace_callback", ",", "$", "this", "->", "string", ")", ";", "return", "$", "affected_string", ";", "}" ]
Given a delimited string, returns a copy of the string with chunks defined by the delimiter affected by a given function. The supplied function must be callable and must accept a string as its only required parameter @param callable $function The function to be called against the delimited chunks; must be callable and must accept a string as its only parameter @param string[] $delimiters One or more strings delimiting the chunks @return string A delimited string with chunks affected by the supplied function
[ "Given", "a", "delimited", "string", "returns", "a", "copy", "of", "the", "string", "with", "chunks", "defined", "by", "the", "delimiter", "affected", "by", "a", "given", "function", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Utils/StringHelper.php#L41-L60
5,305
ddehart/dilmun
src/Anshar/Utils/StringHelper.php
StringHelper.startsWith
public function startsWith($string) { $pattern = "/^" . preg_quote($string, "/") . "/"; $starts_with_string = preg_match($pattern, $this->string); return (bool) $starts_with_string; }
php
public function startsWith($string) { $pattern = "/^" . preg_quote($string, "/") . "/"; $starts_with_string = preg_match($pattern, $this->string); return (bool) $starts_with_string; }
[ "public", "function", "startsWith", "(", "$", "string", ")", "{", "$", "pattern", "=", "\"/^\"", ".", "preg_quote", "(", "$", "string", ",", "\"/\"", ")", ".", "\"/\"", ";", "$", "starts_with_string", "=", "preg_match", "(", "$", "pattern", ",", "$", "this", "->", "string", ")", ";", "return", "(", "bool", ")", "$", "starts_with_string", ";", "}" ]
Determines whether the string starts with a given string. @param string $string A string the string may or may not start with @return bool Returns true if the string starts with the given string Returns false if the string does not start with the given string
[ "Determines", "whether", "the", "string", "starts", "with", "a", "given", "string", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Utils/StringHelper.php#L70-L77
5,306
ddehart/dilmun
src/Anshar/Utils/StringHelper.php
StringHelper.collapseStartingRepetition
public function collapseStartingRepetition($string) { $matches = array(); $pattern = "/^[" . preg_quote($string, "/") . "]+(?P<remainder>.*)/"; $starts_with_string = preg_match($pattern, $this->string, $matches); if ($starts_with_string) { $collapsed_string = $string . $matches["remainder"]; return $collapsed_string; } else { return $this->string; } }
php
public function collapseStartingRepetition($string) { $matches = array(); $pattern = "/^[" . preg_quote($string, "/") . "]+(?P<remainder>.*)/"; $starts_with_string = preg_match($pattern, $this->string, $matches); if ($starts_with_string) { $collapsed_string = $string . $matches["remainder"]; return $collapsed_string; } else { return $this->string; } }
[ "public", "function", "collapseStartingRepetition", "(", "$", "string", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "$", "pattern", "=", "\"/^[\"", ".", "preg_quote", "(", "$", "string", ",", "\"/\"", ")", ".", "\"]+(?P<remainder>.*)/\"", ";", "$", "starts_with_string", "=", "preg_match", "(", "$", "pattern", ",", "$", "this", "->", "string", ",", "$", "matches", ")", ";", "if", "(", "$", "starts_with_string", ")", "{", "$", "collapsed_string", "=", "$", "string", ".", "$", "matches", "[", "\"remainder\"", "]", ";", "return", "$", "collapsed_string", ";", "}", "else", "{", "return", "$", "this", "->", "string", ";", "}", "}" ]
Given a string, collapses any repetition at the start of the string into a single instance of the given string. If the given string does not exist at the start of the string, returns an unmodified string. For example, if the StringHelper was constructed with "ffoo", StringHelper::collapseStartingRepetition("f") will return "foo". If the StringHelper was constructed with "foo", StringHelper::collapseStartingRepetition("b") will also return "foo". @param string $string A string the string may or may not start with, with or without repetition @return string Returns a potentially modified string with a repeating, starting string collapsed into a single instance of the string
[ "Given", "a", "string", "collapses", "any", "repetition", "at", "the", "start", "of", "the", "string", "into", "a", "single", "instance", "of", "the", "given", "string", ".", "If", "the", "given", "string", "does", "not", "exist", "at", "the", "start", "of", "the", "string", "returns", "an", "unmodified", "string", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Utils/StringHelper.php#L92-L106
5,307
teamelf/core
src/Core/Extension.php
Extension.uninstall
public function uninstall() { $this->deactivate(); app('migration')->revert( $this->getPath() . '/migrations', $this->getPackage() ); return $this; }
php
public function uninstall() { $this->deactivate(); app('migration')->revert( $this->getPath() . '/migrations', $this->getPackage() ); return $this; }
[ "public", "function", "uninstall", "(", ")", "{", "$", "this", "->", "deactivate", "(", ")", ";", "app", "(", "'migration'", ")", "->", "revert", "(", "$", "this", "->", "getPath", "(", ")", ".", "'/migrations'", ",", "$", "this", "->", "getPackage", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
uninstall the extension @return $this
[ "uninstall", "the", "extension" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Core/Extension.php#L231-L239
5,308
sndatabase/core
src/ParameterizedStatement.php
ParameterizedStatement.doBind
protected function doBind() { $parsed = self::$parser->parse($this->statement); $index = 0; $params = $this->getParameters(); $this->walk($parsed, $index, $params); return self::$creator->create($parsed); }
php
protected function doBind() { $parsed = self::$parser->parse($this->statement); $index = 0; $params = $this->getParameters(); $this->walk($parsed, $index, $params); return self::$creator->create($parsed); }
[ "protected", "function", "doBind", "(", ")", "{", "$", "parsed", "=", "self", "::", "$", "parser", "->", "parse", "(", "$", "this", "->", "statement", ")", ";", "$", "index", "=", "0", ";", "$", "params", "=", "$", "this", "->", "getParameters", "(", ")", ";", "$", "this", "->", "walk", "(", "$", "parsed", ",", "$", "index", ",", "$", "params", ")", ";", "return", "self", "::", "$", "creator", "->", "create", "(", "$", "parsed", ")", ";", "}" ]
Binds parameters into statement to create a new statement ready to execute @return string final statement @throws InvalidParameterNumberException
[ "Binds", "parameters", "into", "statement", "to", "create", "a", "new", "statement", "ready", "to", "execute" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/ParameterizedStatement.php#L120-L126
5,309
makinacorpus/drupal-udate
lib/Udate/ViewsDateHelper.php
Udate_ViewsDateHelper.getBounds
static public function getBounds(DateTime $date, $granularity = UDATE_GRANULARITY_SECOND) { $bounds = array(clone $date, clone $date); switch ($granularity) { case UDATE_GRANULARITY_SECOND: return array($date, $date); case UDATE_GRANULARITY_MINUTE: $bounds[0]->setDate($date->get, $month, $day); return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:i:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:i:59")), ); case UDATE_GRANULARITY_HOUR: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:59:59")), ); case UDATE_GRANULARITY_DAY: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d 23:59:59")), ); case UDATE_GRANULARITY_MONTH: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-01 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-31 23:59:59")), ); case UDATE_GRANULARITY_YEAR: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-01-01 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-12-31 23:59:59")), ); default: return null; } }
php
static public function getBounds(DateTime $date, $granularity = UDATE_GRANULARITY_SECOND) { $bounds = array(clone $date, clone $date); switch ($granularity) { case UDATE_GRANULARITY_SECOND: return array($date, $date); case UDATE_GRANULARITY_MINUTE: $bounds[0]->setDate($date->get, $month, $day); return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:i:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:i:59")), ); case UDATE_GRANULARITY_HOUR: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d H:59:59")), ); case UDATE_GRANULARITY_DAY: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-d 23:59:59")), ); case UDATE_GRANULARITY_MONTH: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-01 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-m-31 23:59:59")), ); case UDATE_GRANULARITY_YEAR: return array( DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-01-01 00:00:00")), DateTime::createFromFormat(UDATE_PHP_DATETIME, $date->format("Y-12-31 23:59:59")), ); default: return null; } }
[ "static", "public", "function", "getBounds", "(", "DateTime", "$", "date", ",", "$", "granularity", "=", "UDATE_GRANULARITY_SECOND", ")", "{", "$", "bounds", "=", "array", "(", "clone", "$", "date", ",", "clone", "$", "date", ")", ";", "switch", "(", "$", "granularity", ")", "{", "case", "UDATE_GRANULARITY_SECOND", ":", "return", "array", "(", "$", "date", ",", "$", "date", ")", ";", "case", "UDATE_GRANULARITY_MINUTE", ":", "$", "bounds", "[", "0", "]", "->", "setDate", "(", "$", "date", "->", "get", ",", "$", "month", ",", "$", "day", ")", ";", "return", "array", "(", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d H:i:00\"", ")", ")", ",", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d H:i:59\"", ")", ")", ",", ")", ";", "case", "UDATE_GRANULARITY_HOUR", ":", "return", "array", "(", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d H:00:00\"", ")", ")", ",", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d H:59:59\"", ")", ")", ",", ")", ";", "case", "UDATE_GRANULARITY_DAY", ":", "return", "array", "(", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d 00:00:00\"", ")", ")", ",", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-d 23:59:59\"", ")", ")", ",", ")", ";", "case", "UDATE_GRANULARITY_MONTH", ":", "return", "array", "(", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-01 00:00:00\"", ")", ")", ",", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-m-31 23:59:59\"", ")", ")", ",", ")", ";", "case", "UDATE_GRANULARITY_YEAR", ":", "return", "array", "(", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-01-01 00:00:00\"", ")", ")", ",", "DateTime", "::", "createFromFormat", "(", "UDATE_PHP_DATETIME", ",", "$", "date", "->", "format", "(", "\"Y-12-31 23:59:59\"", ")", ")", ",", ")", ";", "default", ":", "return", "null", ";", "}", "}" ]
Build SQL formula @param DateTime $date @param int $granularity
[ "Build", "SQL", "formula" ]
75f296acd7ba230b2d0a28c1fb906f4f1da863cf
https://github.com/makinacorpus/drupal-udate/blob/75f296acd7ba230b2d0a28c1fb906f4f1da863cf/lib/Udate/ViewsDateHelper.php#L14-L57
5,310
antwebes/ChateaClientBundle
EventListener/AuthTokenUpdaterListener.php
AuthTokenUpdaterListener.assertUserIsLoggedIn
private function assertUserIsLoggedIn() { $token = $this->securityContext->getToken(); $isAuthenticated = $token !== null && $token->isAuthenticated() && $token->getUser() instanceof User && $token->getUser()->isCredentialsNonExpired(); if(!$isAuthenticated){ throw new AccessDeniedException(); } }
php
private function assertUserIsLoggedIn() { $token = $this->securityContext->getToken(); $isAuthenticated = $token !== null && $token->isAuthenticated() && $token->getUser() instanceof User && $token->getUser()->isCredentialsNonExpired(); if(!$isAuthenticated){ throw new AccessDeniedException(); } }
[ "private", "function", "assertUserIsLoggedIn", "(", ")", "{", "$", "token", "=", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", ";", "$", "isAuthenticated", "=", "$", "token", "!==", "null", "&&", "$", "token", "->", "isAuthenticated", "(", ")", "&&", "$", "token", "->", "getUser", "(", ")", "instanceof", "User", "&&", "$", "token", "->", "getUser", "(", ")", "->", "isCredentialsNonExpired", "(", ")", ";", "if", "(", "!", "$", "isAuthenticated", ")", "{", "throw", "new", "AccessDeniedException", "(", ")", ";", "}", "}" ]
Asserts that a user is logged in
[ "Asserts", "that", "a", "user", "is", "logged", "in" ]
a4deb5f966b6ddcf817068e859787e32d399acf6
https://github.com/antwebes/ChateaClientBundle/blob/a4deb5f966b6ddcf817068e859787e32d399acf6/EventListener/AuthTokenUpdaterListener.php#L53-L65
5,311
antwebes/ChateaClientBundle
EventListener/AuthTokenUpdaterListener.php
AuthTokenUpdaterListener.updateClientAccessToken
private function updateClientAccessToken() { $user = $this->securityContext->getToken()->getUser(); $this->client->updateAccessToken($user->getAccessToken()); }
php
private function updateClientAccessToken() { $user = $this->securityContext->getToken()->getUser(); $this->client->updateAccessToken($user->getAccessToken()); }
[ "private", "function", "updateClientAccessToken", "(", ")", "{", "$", "user", "=", "$", "this", "->", "securityContext", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "this", "->", "client", "->", "updateAccessToken", "(", "$", "user", "->", "getAccessToken", "(", ")", ")", ";", "}" ]
Updates the access token of the HTTP client with the access token of the current user
[ "Updates", "the", "access", "token", "of", "the", "HTTP", "client", "with", "the", "access", "token", "of", "the", "current", "user" ]
a4deb5f966b6ddcf817068e859787e32d399acf6
https://github.com/antwebes/ChateaClientBundle/blob/a4deb5f966b6ddcf817068e859787e32d399acf6/EventListener/AuthTokenUpdaterListener.php#L84-L88
5,312
ionutmilica/ionix-framework
src/Validation/Rules/BetweenRule.php
BetweenRule.validateNumeric
public function validateNumeric() { $val = $this->getValue() + 0; return $val >= $this->getArg(0) && $val <= $this->getArg(1); }
php
public function validateNumeric() { $val = $this->getValue() + 0; return $val >= $this->getArg(0) && $val <= $this->getArg(1); }
[ "public", "function", "validateNumeric", "(", ")", "{", "$", "val", "=", "$", "this", "->", "getValue", "(", ")", "+", "0", ";", "return", "$", "val", ">=", "$", "this", "->", "getArg", "(", "0", ")", "&&", "$", "val", "<=", "$", "this", "->", "getArg", "(", "1", ")", ";", "}" ]
Validate number as is it numeric
[ "Validate", "number", "as", "is", "it", "numeric" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Validation/Rules/BetweenRule.php#L12-L17
5,313
ionutmilica/ionix-framework
src/Validation/Rules/BetweenRule.php
BetweenRule.validateString
public function validateString() { $len = function_exists('mb_strlen') ? mb_strlen($this->getValue()) : strlen($this->getValue()); return $len >= $this->getArg(0) && $len <= $this->getArg(1); }
php
public function validateString() { $len = function_exists('mb_strlen') ? mb_strlen($this->getValue()) : strlen($this->getValue()); return $len >= $this->getArg(0) && $len <= $this->getArg(1); }
[ "public", "function", "validateString", "(", ")", "{", "$", "len", "=", "function_exists", "(", "'mb_strlen'", ")", "?", "mb_strlen", "(", "$", "this", "->", "getValue", "(", ")", ")", ":", "strlen", "(", "$", "this", "->", "getValue", "(", ")", ")", ";", "return", "$", "len", ">=", "$", "this", "->", "getArg", "(", "0", ")", "&&", "$", "len", "<=", "$", "this", "->", "getArg", "(", "1", ")", ";", "}" ]
Validate string by min length
[ "Validate", "string", "by", "min", "length" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Validation/Rules/BetweenRule.php#L22-L27
5,314
ionutmilica/ionix-framework
src/Validation/Rules/BetweenRule.php
BetweenRule.getMessage
public function getMessage() { return sprintf('The field `%s` length should be between %d and %d. (%d given) !', $this->inputName, $this->getArg(0), $this->getArg(1), $this->getValue()); }
php
public function getMessage() { return sprintf('The field `%s` length should be between %d and %d. (%d given) !', $this->inputName, $this->getArg(0), $this->getArg(1), $this->getValue()); }
[ "public", "function", "getMessage", "(", ")", "{", "return", "sprintf", "(", "'The field `%s` length should be between %d and %d. (%d given) !'", ",", "$", "this", "->", "inputName", ",", "$", "this", "->", "getArg", "(", "0", ")", ",", "$", "this", "->", "getArg", "(", "1", ")", ",", "$", "this", "->", "getValue", "(", ")", ")", ";", "}" ]
Get error message in case of fail @return string
[ "Get", "error", "message", "in", "case", "of", "fail" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Validation/Rules/BetweenRule.php#L49-L53
5,315
diasbruno/stc-pages
lib/stc/PageWriter.php
PageWriter.make_slug
private function make_slug($file, &$tmpl) { return $this->is_index($file['file']) ? '' : $this->slugify->slugify($file['title']); }
php
private function make_slug($file, &$tmpl) { return $this->is_index($file['file']) ? '' : $this->slugify->slugify($file['title']); }
[ "private", "function", "make_slug", "(", "$", "file", ",", "&", "$", "tmpl", ")", "{", "return", "$", "this", "->", "is_index", "(", "$", "file", "[", "'file'", "]", ")", "?", "''", ":", "$", "this", "->", "slugify", "->", "slugify", "(", "$", "file", "[", "'title'", "]", ")", ";", "}" ]
Make the page slug. @param $file array | Raw file data. @param $tmpl array | Reference to the new file data. @return void
[ "Make", "the", "page", "slug", "." ]
7f13fab79759303bdf823036f7f5a5d7687bdd8b
https://github.com/diasbruno/stc-pages/blob/7f13fab79759303bdf823036f7f5a5d7687bdd8b/lib/stc/PageWriter.php#L40-L45
5,316
diasbruno/stc-pages
lib/stc/PageWriter.php
PageWriter.make_data
private function make_data($file) { if (!array_key_exists('template', $file)) { throw new Exception('x> Current page: ' . $file['title'] . ' does not have a template.'); } $t = Application::templates()->template($file['template']); $tmpl = $file; $tmpl['slug'] = $this->make_slug($file, $tmpl); $data_folder = Application::data_folder(); $template_name = $data_folder . '/templates/' . $t; $content_template = $data_folder . '/' . $file['content']; $render_content_with = Application::renders()->select($content_template); $render_with = Application::renders()->select($template_name); $tmpl['html'] = $render_with->render($template_name, [ 'content' => $render_content_with->render($content_template, [ 'post'=> $file, ]), 'post'=> $file, ]); if ($this->is_index($file['file'])) { $this->log_current_page('index', ''); } else { $this->log_current_page($file['title'], $tmpl['slug']); } return $tmpl; }
php
private function make_data($file) { if (!array_key_exists('template', $file)) { throw new Exception('x> Current page: ' . $file['title'] . ' does not have a template.'); } $t = Application::templates()->template($file['template']); $tmpl = $file; $tmpl['slug'] = $this->make_slug($file, $tmpl); $data_folder = Application::data_folder(); $template_name = $data_folder . '/templates/' . $t; $content_template = $data_folder . '/' . $file['content']; $render_content_with = Application::renders()->select($content_template); $render_with = Application::renders()->select($template_name); $tmpl['html'] = $render_with->render($template_name, [ 'content' => $render_content_with->render($content_template, [ 'post'=> $file, ]), 'post'=> $file, ]); if ($this->is_index($file['file'])) { $this->log_current_page('index', ''); } else { $this->log_current_page($file['title'], $tmpl['slug']); } return $tmpl; }
[ "private", "function", "make_data", "(", "$", "file", ")", "{", "if", "(", "!", "array_key_exists", "(", "'template'", ",", "$", "file", ")", ")", "{", "throw", "new", "Exception", "(", "'x> Current page: '", ".", "$", "file", "[", "'title'", "]", ".", "' does not have a template.'", ")", ";", "}", "$", "t", "=", "Application", "::", "templates", "(", ")", "->", "template", "(", "$", "file", "[", "'template'", "]", ")", ";", "$", "tmpl", "=", "$", "file", ";", "$", "tmpl", "[", "'slug'", "]", "=", "$", "this", "->", "make_slug", "(", "$", "file", ",", "$", "tmpl", ")", ";", "$", "data_folder", "=", "Application", "::", "data_folder", "(", ")", ";", "$", "template_name", "=", "$", "data_folder", ".", "'/templates/'", ".", "$", "t", ";", "$", "content_template", "=", "$", "data_folder", ".", "'/'", ".", "$", "file", "[", "'content'", "]", ";", "$", "render_content_with", "=", "Application", "::", "renders", "(", ")", "->", "select", "(", "$", "content_template", ")", ";", "$", "render_with", "=", "Application", "::", "renders", "(", ")", "->", "select", "(", "$", "template_name", ")", ";", "$", "tmpl", "[", "'html'", "]", "=", "$", "render_with", "->", "render", "(", "$", "template_name", ",", "[", "'content'", "=>", "$", "render_content_with", "->", "render", "(", "$", "content_template", ",", "[", "'post'", "=>", "$", "file", ",", "]", ")", ",", "'post'", "=>", "$", "file", ",", "]", ")", ";", "if", "(", "$", "this", "->", "is_index", "(", "$", "file", "[", "'file'", "]", ")", ")", "{", "$", "this", "->", "log_current_page", "(", "'index'", ",", "''", ")", ";", "}", "else", "{", "$", "this", "->", "log_current_page", "(", "$", "file", "[", "'title'", "]", ",", "$", "tmpl", "[", "'slug'", "]", ")", ";", "}", "return", "$", "tmpl", ";", "}" ]
Format a file to be rendered. @param $template Template | A Template. @param $file array | Json file as array. @return array
[ "Format", "a", "file", "to", "be", "rendered", "." ]
7f13fab79759303bdf823036f7f5a5d7687bdd8b
https://github.com/diasbruno/stc-pages/blob/7f13fab79759303bdf823036f7f5a5d7687bdd8b/lib/stc/PageWriter.php#L53-L85
5,317
romeOz/rock-request
src/Request.php
Request.getScheme
public function getScheme() { if ($this->_schema === null) { $this->_schema = $this->isSecureConnection() ? 'https' : 'http'; } return $this->_schema; }
php
public function getScheme() { if ($this->_schema === null) { $this->_schema = $this->isSecureConnection() ? 'https' : 'http'; } return $this->_schema; }
[ "public", "function", "getScheme", "(", ")", "{", "if", "(", "$", "this", "->", "_schema", "===", "null", ")", "{", "$", "this", "->", "_schema", "=", "$", "this", "->", "isSecureConnection", "(", ")", "?", "'https'", ":", "'http'", ";", "}", "return", "$", "this", "->", "_schema", ";", "}" ]
Returns schema. @return string
[ "Returns", "schema", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L163-L170
5,318
romeOz/rock-request
src/Request.php
Request.getAbsoluteUrl
public function getAbsoluteUrl($strip = true) { $url = $this->getHostInfo() . $this->getUrl(); return $strip === true ? strip_tags($url) : $url; }
php
public function getAbsoluteUrl($strip = true) { $url = $this->getHostInfo() . $this->getUrl(); return $strip === true ? strip_tags($url) : $url; }
[ "public", "function", "getAbsoluteUrl", "(", "$", "strip", "=", "true", ")", "{", "$", "url", "=", "$", "this", "->", "getHostInfo", "(", ")", ".", "$", "this", "->", "getUrl", "(", ")", ";", "return", "$", "strip", "===", "true", "?", "strip_tags", "(", "$", "url", ")", ":", "$", "url", ";", "}" ]
Returns the currently requested absolute URL. This is a shortcut to the concatenation of {@see \rock\request\Request::getHostInfo()} and {@see \rock\request\Request::getUrl()}. @param bool $strip @return string the currently requested absolute URL.
[ "Returns", "the", "currently", "requested", "absolute", "URL", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L277-L281
5,319
romeOz/rock-request
src/Request.php
Request.getUrlWithoutArgs
public function getUrlWithoutArgs() { $url = $this->getUrl(); if (($pos = strpos($url, '?')) !== false) { $url = substr($url, 0, $pos); } return $url; }
php
public function getUrlWithoutArgs() { $url = $this->getUrl(); if (($pos = strpos($url, '?')) !== false) { $url = substr($url, 0, $pos); } return $url; }
[ "public", "function", "getUrlWithoutArgs", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getUrl", "(", ")", ";", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "url", ",", "'?'", ")", ")", "!==", "false", ")", "{", "$", "url", "=", "substr", "(", "$", "url", ",", "0", ",", "$", "pos", ")", ";", "}", "return", "$", "url", ";", "}" ]
Returns path. ``` http://site.com/foo/ ``` @return string
[ "Returns", "path", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L292-L299
5,320
romeOz/rock-request
src/Request.php
Request.getPort
public function getPort() { if ($this->_port === null) { $this->_port = !$this->isSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 80; } return $this->_port; }
php
public function getPort() { if ($this->_port === null) { $this->_port = !$this->isSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 80; } return $this->_port; }
[ "public", "function", "getPort", "(", ")", "{", "if", "(", "$", "this", "->", "_port", "===", "null", ")", "{", "$", "this", "->", "_port", "=", "!", "$", "this", "->", "isSecureConnection", "(", ")", "&&", "isset", "(", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ")", "?", "(", "int", ")", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ":", "80", ";", "}", "return", "$", "this", "->", "_port", ";", "}" ]
Returns the port to use for insecure requests. Defaults to 80, or the port specified by the server if the current request is insecure. @return integer port number for insecure requests. @see setPort()
[ "Returns", "the", "port", "to", "use", "for", "insecure", "requests", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L432-L438
5,321
romeOz/rock-request
src/Request.php
Request.setPort
public function setPort($port) { if ($port != $this->_port) { $this->_port = (int)$port; $this->_hostInfo = null; } return $this; }
php
public function setPort($port) { if ($port != $this->_port) { $this->_port = (int)$port; $this->_hostInfo = null; } return $this; }
[ "public", "function", "setPort", "(", "$", "port", ")", "{", "if", "(", "$", "port", "!=", "$", "this", "->", "_port", ")", "{", "$", "this", "->", "_port", "=", "(", "int", ")", "$", "port", ";", "$", "this", "->", "_hostInfo", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Sets the port to use for insecure requests. This setter is provided in case a custom port is necessary for certain server configurations. @param integer $port port number. @return $this
[ "Sets", "the", "port", "to", "use", "for", "insecure", "requests", ".", "This", "setter", "is", "provided", "in", "case", "a", "custom", "port", "is", "necessary", "for", "certain", "server", "configurations", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L447-L454
5,322
romeOz/rock-request
src/Request.php
Request.getSecurePort
public function getSecurePort() { if ($this->_securePort === null) { $this->_securePort = $this->isSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 443; } return $this->_securePort; }
php
public function getSecurePort() { if ($this->_securePort === null) { $this->_securePort = $this->isSecureConnection() && isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : 443; } return $this->_securePort; }
[ "public", "function", "getSecurePort", "(", ")", "{", "if", "(", "$", "this", "->", "_securePort", "===", "null", ")", "{", "$", "this", "->", "_securePort", "=", "$", "this", "->", "isSecureConnection", "(", ")", "&&", "isset", "(", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ")", "?", "(", "int", ")", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ":", "443", ";", "}", "return", "$", "this", "->", "_securePort", ";", "}" ]
Returns the port to use for secure requests. Defaults to 443, or the port specified by the server if the current request is secure. @return integer port number for secure requests. @see setSecurePort()
[ "Returns", "the", "port", "to", "use", "for", "secure", "requests", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L466-L472
5,323
romeOz/rock-request
src/Request.php
Request.getQueryString
public function getQueryString() { if (isset($this->_queryString)) { return $this->_queryString; } return $this->_queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; }
php
public function getQueryString() { if (isset($this->_queryString)) { return $this->_queryString; } return $this->_queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; }
[ "public", "function", "getQueryString", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_queryString", ")", ")", "{", "return", "$", "this", "->", "_queryString", ";", "}", "return", "$", "this", "->", "_queryString", "=", "isset", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ")", "?", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ":", "''", ";", "}" ]
Returns part of the request URL that is after the question mark. @return string part of the request URL that is after the question mark
[ "Returns", "part", "of", "the", "request", "URL", "that", "is", "after", "the", "question", "mark", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L551-L557
5,324
romeOz/rock-request
src/Request.php
Request.getContentType
public function getContentType() { if (isset($this->_contentType)) { return $this->_contentType; } if (isset($_SERVER["CONTENT_TYPE"])) { return $this->_contentType = $_SERVER["CONTENT_TYPE"]; } elseif (isset($_SERVER["HTTP_CONTENT_TYPE"])) { //fix bug https://bugs.php.net/bug.php?id=66606 return $this->_contentType = $_SERVER["HTTP_CONTENT_TYPE"]; } return null; }
php
public function getContentType() { if (isset($this->_contentType)) { return $this->_contentType; } if (isset($_SERVER["CONTENT_TYPE"])) { return $this->_contentType = $_SERVER["CONTENT_TYPE"]; } elseif (isset($_SERVER["HTTP_CONTENT_TYPE"])) { //fix bug https://bugs.php.net/bug.php?id=66606 return $this->_contentType = $_SERVER["HTTP_CONTENT_TYPE"]; } return null; }
[ "public", "function", "getContentType", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_contentType", ")", ")", "{", "return", "$", "this", "->", "_contentType", ";", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"CONTENT_TYPE\"", "]", ")", ")", "{", "return", "$", "this", "->", "_contentType", "=", "$", "_SERVER", "[", "\"CONTENT_TYPE\"", "]", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "\"HTTP_CONTENT_TYPE\"", "]", ")", ")", "{", "//fix bug https://bugs.php.net/bug.php?id=66606", "return", "$", "this", "->", "_contentType", "=", "$", "_SERVER", "[", "\"HTTP_CONTENT_TYPE\"", "]", ";", "}", "return", "null", ";", "}" ]
Returns request content-type. The Content-Type header field indicates the MIME type of the data contained in the case of the HEAD method, the media type that would have been sent had the request been a GET. For the MIME-types the user expects in response, see {@see \rock\request\Request::getAcceptableContentTypes()} . @return string request content-type. Null is returned if this information is not available. @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 HTTP 1.1 header field definitions
[ "Returns", "request", "content", "-", "type", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L726-L739
5,325
romeOz/rock-request
src/Request.php
Request.isSelfDomain
public function isSelfDomain($throw = false) { if (!$domains = $this->allowDomains) { return true; } if (!in_array(strtolower($_SERVER['SERVER_NAME']), $domains, true) || !in_array(strtolower($_SERVER['HTTP_HOST']), $domains, true) ) { if ($throw === true) { throw new RequestException("Invalid domain: {$_SERVER['HTTP_HOST']}"); } else { if (class_exists('\rock\log\Log')) { $message = BaseException::convertExceptionToString(new RequestException("Invalid domain: {$_SERVER['HTTP_HOST']}")); Log::err($message); } } return false; } return true; }
php
public function isSelfDomain($throw = false) { if (!$domains = $this->allowDomains) { return true; } if (!in_array(strtolower($_SERVER['SERVER_NAME']), $domains, true) || !in_array(strtolower($_SERVER['HTTP_HOST']), $domains, true) ) { if ($throw === true) { throw new RequestException("Invalid domain: {$_SERVER['HTTP_HOST']}"); } else { if (class_exists('\rock\log\Log')) { $message = BaseException::convertExceptionToString(new RequestException("Invalid domain: {$_SERVER['HTTP_HOST']}")); Log::err($message); } } return false; } return true; }
[ "public", "function", "isSelfDomain", "(", "$", "throw", "=", "false", ")", "{", "if", "(", "!", "$", "domains", "=", "$", "this", "->", "allowDomains", ")", "{", "return", "true", ";", "}", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ",", "$", "domains", ",", "true", ")", "||", "!", "in_array", "(", "strtolower", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ",", "$", "domains", ",", "true", ")", ")", "{", "if", "(", "$", "throw", "===", "true", ")", "{", "throw", "new", "RequestException", "(", "\"Invalid domain: {$_SERVER['HTTP_HOST']}\"", ")", ";", "}", "else", "{", "if", "(", "class_exists", "(", "'\\rock\\log\\Log'", ")", ")", "{", "$", "message", "=", "BaseException", "::", "convertExceptionToString", "(", "new", "RequestException", "(", "\"Invalid domain: {$_SERVER['HTTP_HOST']}\"", ")", ")", ";", "Log", "::", "err", "(", "$", "message", ")", ";", "}", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is self domain. @param bool $throw throw an exception (default: false) @throws RequestException @return bool
[ "Is", "self", "domain", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1009-L1031
5,326
romeOz/rock-request
src/Request.php
Request.resolveRequestUri
protected function resolveRequestUri() { if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // IIS $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; } elseif (isset($_SERVER['REQUEST_URI'])) { $requestUri = $_SERVER['REQUEST_URI']; if ($requestUri !== '' && $requestUri[0] !== '/') { $requestUri = preg_replace('/^(http|https):\/\/[^\/]+/i', '', $requestUri); } } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0 CGI $requestUri = $_SERVER['ORIG_PATH_INFO']; if ($query = $this->getQueryString()) { $requestUri .= '?' . $query; } } else { throw new RequestException('Unable to determine the request URI.'); } return $requestUri; }
php
protected function resolveRequestUri() { if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // IIS $requestUri = $_SERVER['HTTP_X_REWRITE_URL']; } elseif (isset($_SERVER['REQUEST_URI'])) { $requestUri = $_SERVER['REQUEST_URI']; if ($requestUri !== '' && $requestUri[0] !== '/') { $requestUri = preg_replace('/^(http|https):\/\/[^\/]+/i', '', $requestUri); } } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0 CGI $requestUri = $_SERVER['ORIG_PATH_INFO']; if ($query = $this->getQueryString()) { $requestUri .= '?' . $query; } } else { throw new RequestException('Unable to determine the request URI.'); } return $requestUri; }
[ "protected", "function", "resolveRequestUri", "(", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_X_REWRITE_URL'", "]", ")", ")", "{", "// IIS", "$", "requestUri", "=", "$", "_SERVER", "[", "'HTTP_X_REWRITE_URL'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "$", "requestUri", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "if", "(", "$", "requestUri", "!==", "''", "&&", "$", "requestUri", "[", "0", "]", "!==", "'/'", ")", "{", "$", "requestUri", "=", "preg_replace", "(", "'/^(http|https):\\/\\/[^\\/]+/i'", ",", "''", ",", "$", "requestUri", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'ORIG_PATH_INFO'", "]", ")", ")", "{", "// IIS 5.0 CGI", "$", "requestUri", "=", "$", "_SERVER", "[", "'ORIG_PATH_INFO'", "]", ";", "if", "(", "$", "query", "=", "$", "this", "->", "getQueryString", "(", ")", ")", "{", "$", "requestUri", ".=", "'?'", ".", "$", "query", ";", "}", "}", "else", "{", "throw", "new", "RequestException", "(", "'Unable to determine the request URI.'", ")", ";", "}", "return", "$", "requestUri", ";", "}" ]
Resolves the request URI portion for the currently requested URL. This refers to the portion that is after the {@see \rock\request\Request::$hostInfo} part. It includes the @see queryString part if any. The implementation of this method referenced Zend_Controller_Request_Http in Zend Framework. @return string|boolean the request URI portion for the currently requested URL. Note that the URI returned is URL-encoded. @throws RequestException if the request URI cannot be determined due to unusual server configuration
[ "Resolves", "the", "request", "URI", "portion", "for", "the", "currently", "requested", "URL", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1044-L1062
5,327
romeOz/rock-request
src/Request.php
Request.getReferrer
public function getReferrer() { if (isset($this->_referrer)) { return $this->_referrer; } return $this->_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; }
php
public function getReferrer() { if (isset($this->_referrer)) { return $this->_referrer; } return $this->_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; }
[ "public", "function", "getReferrer", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_referrer", ")", ")", "{", "return", "$", "this", "->", "_referrer", ";", "}", "return", "$", "this", "->", "_referrer", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ":", "null", ";", "}" ]
Returns the URL referrer, null if not present. @return string URL referrer, null if not present
[ "Returns", "the", "URL", "referrer", "null", "if", "not", "present", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1102-L1108
5,328
romeOz/rock-request
src/Request.php
Request.getUserAgent
public function getUserAgent() { if (isset($this->_userAgent)) { return $this->_userAgent; } return $this->_userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; }
php
public function getUserAgent() { if (isset($this->_userAgent)) { return $this->_userAgent; } return $this->_userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; }
[ "public", "function", "getUserAgent", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_userAgent", ")", ")", "{", "return", "$", "this", "->", "_userAgent", ";", "}", "return", "$", "this", "->", "_userAgent", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "null", ";", "}" ]
Returns the user agent, null if not present. @return string user agent, null if not present
[ "Returns", "the", "user", "agent", "null", "if", "not", "present", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1128-L1134
5,329
romeOz/rock-request
src/Request.php
Request.getUserHost
public function getUserHost() { if (isset($this->_userHost)) { return $this->_userHost; } return $this->_userHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; }
php
public function getUserHost() { if (isset($this->_userHost)) { return $this->_userHost; } return $this->_userHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : null; }
[ "public", "function", "getUserHost", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_userHost", ")", ")", "{", "return", "$", "this", "->", "_userHost", ";", "}", "return", "$", "this", "->", "_userHost", "=", "isset", "(", "$", "_SERVER", "[", "'REMOTE_HOST'", "]", ")", "?", "$", "_SERVER", "[", "'REMOTE_HOST'", "]", ":", "null", ";", "}" ]
Returns the user host name, null if it cannot be determined. @return string user host name, null if cannot be determined
[ "Returns", "the", "user", "host", "name", "null", "if", "it", "cannot", "be", "determined", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1187-L1193
5,330
romeOz/rock-request
src/Request.php
Request.isPjax
public function isPjax() { if (isset($this->_isPjax)) { return $this->_isPjax; } return $this->_isPjax = $this->isAjax() && !empty($_SERVER['HTTP_X_PJAX']); }
php
public function isPjax() { if (isset($this->_isPjax)) { return $this->_isPjax; } return $this->_isPjax = $this->isAjax() && !empty($_SERVER['HTTP_X_PJAX']); }
[ "public", "function", "isPjax", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_isPjax", ")", ")", "{", "return", "$", "this", "->", "_isPjax", ";", "}", "return", "$", "this", "->", "_isPjax", "=", "$", "this", "->", "isAjax", "(", ")", "&&", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_X_PJAX'", "]", ")", ";", "}" ]
Returns whether this is a PJAX request. @return boolean whether this is a PJAX request
[ "Returns", "whether", "this", "is", "a", "PJAX", "request", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1335-L1341
5,331
romeOz/rock-request
src/Request.php
Request.isCORS
public function isCORS() { if (isset($this->_isCORS)) { return $this->_isCORS; } return $this->_isCORS = !empty($_SERVER['HTTP_ORIGIN']); }
php
public function isCORS() { if (isset($this->_isCORS)) { return $this->_isCORS; } return $this->_isCORS = !empty($_SERVER['HTTP_ORIGIN']); }
[ "public", "function", "isCORS", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_isCORS", ")", ")", "{", "return", "$", "this", "->", "_isCORS", ";", "}", "return", "$", "this", "->", "_isCORS", "=", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_ORIGIN'", "]", ")", ";", "}" ]
Returns whether this is a CORS request. @return boolean whether this is a CORS request
[ "Returns", "whether", "this", "is", "a", "CORS", "request", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1389-L1395
5,332
romeOz/rock-request
src/Request.php
Request.getInternal
protected function getInternal($name = null, $default = null, Sanitize $sanitize = null) { return $this->sanitizeValue($this->rawGetInternal($name, $default), $sanitize); }
php
protected function getInternal($name = null, $default = null, Sanitize $sanitize = null) { return $this->sanitizeValue($this->rawGetInternal($name, $default), $sanitize); }
[ "protected", "function", "getInternal", "(", "$", "name", "=", "null", ",", "$", "default", "=", "null", ",", "Sanitize", "$", "sanitize", "=", "null", ")", "{", "return", "$", "this", "->", "sanitizeValue", "(", "$", "this", "->", "rawGetInternal", "(", "$", "name", ",", "$", "default", ")", ",", "$", "sanitize", ")", ";", "}" ]
Sanitize GET request-value. @param string $name name of request-value. @param mixed $default @param Sanitize $sanitize @return mixed
[ "Sanitize", "GET", "request", "-", "value", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1447-L1450
5,333
romeOz/rock-request
src/Request.php
Request.postInternal
protected function postInternal($name = null, $default = null, Sanitize $sanitize = null) { return $this->sanitizeValue($this->rawPostInternal($name, $default), $sanitize); }
php
protected function postInternal($name = null, $default = null, Sanitize $sanitize = null) { return $this->sanitizeValue($this->rawPostInternal($name, $default), $sanitize); }
[ "protected", "function", "postInternal", "(", "$", "name", "=", "null", ",", "$", "default", "=", "null", ",", "Sanitize", "$", "sanitize", "=", "null", ")", "{", "return", "$", "this", "->", "sanitizeValue", "(", "$", "this", "->", "rawPostInternal", "(", "$", "name", ",", "$", "default", ")", ",", "$", "sanitize", ")", ";", "}" ]
Sanitize POST request-value. @param string $name name of request-value. @param mixed $default @param Sanitize $sanitize @return mixed
[ "Sanitize", "POST", "request", "-", "value", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1459-L1462
5,334
romeOz/rock-request
src/Request.php
Request.sanitizeValue
protected function sanitizeValue($input, Sanitize $sanitize = null) { if (!isset($sanitize)) { $sanitize = $this->sanitize ?: Sanitize::removeTags()->trim()->toType(); } if (is_array($input)) { $rawRule = $sanitize->getRawRules(); $rawRule = current($rawRule); if ($rawRule instanceof Attributes) { return $sanitize->sanitize($input); } return Sanitize::attributes($sanitize)->sanitize($input); } return $sanitize->sanitize($input); }
php
protected function sanitizeValue($input, Sanitize $sanitize = null) { if (!isset($sanitize)) { $sanitize = $this->sanitize ?: Sanitize::removeTags()->trim()->toType(); } if (is_array($input)) { $rawRule = $sanitize->getRawRules(); $rawRule = current($rawRule); if ($rawRule instanceof Attributes) { return $sanitize->sanitize($input); } return Sanitize::attributes($sanitize)->sanitize($input); } return $sanitize->sanitize($input); }
[ "protected", "function", "sanitizeValue", "(", "$", "input", ",", "Sanitize", "$", "sanitize", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "sanitize", ")", ")", "{", "$", "sanitize", "=", "$", "this", "->", "sanitize", "?", ":", "Sanitize", "::", "removeTags", "(", ")", "->", "trim", "(", ")", "->", "toType", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "input", ")", ")", "{", "$", "rawRule", "=", "$", "sanitize", "->", "getRawRules", "(", ")", ";", "$", "rawRule", "=", "current", "(", "$", "rawRule", ")", ";", "if", "(", "$", "rawRule", "instanceof", "Attributes", ")", "{", "return", "$", "sanitize", "->", "sanitize", "(", "$", "input", ")", ";", "}", "return", "Sanitize", "::", "attributes", "(", "$", "sanitize", ")", "->", "sanitize", "(", "$", "input", ")", ";", "}", "return", "$", "sanitize", "->", "sanitize", "(", "$", "input", ")", ";", "}" ]
Sanitize request-value. @param mixed $input @param Sanitize $sanitize @return null
[ "Sanitize", "request", "-", "value", "." ]
06182c3c0d1f4a5348b52767912335dda3bffc8e
https://github.com/romeOz/rock-request/blob/06182c3c0d1f4a5348b52767912335dda3bffc8e/src/Request.php#L1471-L1487
5,335
jmpantoja/planb-utils
src/Utils/Loop/Loop.php
Loop.seed
private function seed() { foreach ($this->input as $key => $value) { if (!$this->call($this->before, $value, $key)) { return; } yield $key => $value; if (!$this->call($this->after, $value, $key)) { return; } } }
php
private function seed() { foreach ($this->input as $key => $value) { if (!$this->call($this->before, $value, $key)) { return; } yield $key => $value; if (!$this->call($this->after, $value, $key)) { return; } } }
[ "private", "function", "seed", "(", ")", "{", "foreach", "(", "$", "this", "->", "input", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "call", "(", "$", "this", "->", "before", ",", "$", "value", ",", "$", "key", ")", ")", "{", "return", ";", "}", "yield", "$", "key", "=>", "$", "value", ";", "if", "(", "!", "$", "this", "->", "call", "(", "$", "this", "->", "after", ",", "$", "value", ",", "$", "key", ")", ")", "{", "return", ";", "}", "}", "}" ]
Crea un generador @return \Generator|void
[ "Crea", "un", "generador" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Utils/Loop/Loop.php#L116-L129
5,336
vincenttouzet/BaseBundle
Generator/TranslationsGenerator.php
TranslationsGenerator.toText
protected function toText($fieldName) { $fieldName = $this->camelize($fieldName); $fieldName = str_replace('_', ' ', $fieldName); return ucfirst($fieldName); }
php
protected function toText($fieldName) { $fieldName = $this->camelize($fieldName); $fieldName = str_replace('_', ' ', $fieldName); return ucfirst($fieldName); }
[ "protected", "function", "toText", "(", "$", "fieldName", ")", "{", "$", "fieldName", "=", "$", "this", "->", "camelize", "(", "$", "fieldName", ")", ";", "$", "fieldName", "=", "str_replace", "(", "'_'", ",", "' '", ",", "$", "fieldName", ")", ";", "return", "ucfirst", "(", "$", "fieldName", ")", ";", "}" ]
Transform a fieldName to a text. @param string $fieldName [description] @return string
[ "Transform", "a", "fieldName", "to", "a", "text", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Generator/TranslationsGenerator.php#L198-L204
5,337
vincenttouzet/BaseBundle
Generator/TranslationsGenerator.php
TranslationsGenerator.getTrans
protected function getTrans($filename) { if (is_file($filename)) { $trans = Yaml::parse(file_get_contents($filename)); } else { $trans = array(); } $keys = array('breadcrumb', 'list', 'filter', 'show', 'form'); foreach ($keys as $key) { if (!array_key_exists($key, $trans)) { $trans[$key] = array(); } } return $trans; }
php
protected function getTrans($filename) { if (is_file($filename)) { $trans = Yaml::parse(file_get_contents($filename)); } else { $trans = array(); } $keys = array('breadcrumb', 'list', 'filter', 'show', 'form'); foreach ($keys as $key) { if (!array_key_exists($key, $trans)) { $trans[$key] = array(); } } return $trans; }
[ "protected", "function", "getTrans", "(", "$", "filename", ")", "{", "if", "(", "is_file", "(", "$", "filename", ")", ")", "{", "$", "trans", "=", "Yaml", "::", "parse", "(", "file_get_contents", "(", "$", "filename", ")", ")", ";", "}", "else", "{", "$", "trans", "=", "array", "(", ")", ";", "}", "$", "keys", "=", "array", "(", "'breadcrumb'", ",", "'list'", ",", "'filter'", ",", "'show'", ",", "'form'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "trans", ")", ")", "{", "$", "trans", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "}", "return", "$", "trans", ";", "}" ]
Load translation file. @param string $filename Filename @return array
[ "Load", "translation", "file", "." ]
04faac91884ac5ae270a32ba3d63dca8892aa1dd
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Generator/TranslationsGenerator.php#L213-L229
5,338
bestit/hipchat-api
src/HipChatLumenServiceProvider.php
HipChatLumenServiceProvider.register
public function register() { $this->app->singleton('hipchat', function ($app) { return new Client(config('hipchat.api_token'), config('hipchat.server_url')); }); $this->app->alias(Bestit\HipChat\Facade\HipChat::class, 'HipChat'); }
php
public function register() { $this->app->singleton('hipchat', function ($app) { return new Client(config('hipchat.api_token'), config('hipchat.server_url')); }); $this->app->alias(Bestit\HipChat\Facade\HipChat::class, 'HipChat'); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'hipchat'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Client", "(", "config", "(", "'hipchat.api_token'", ")", ",", "config", "(", "'hipchat.server_url'", ")", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "Bestit", "\\", "HipChat", "\\", "Facade", "\\", "HipChat", "::", "class", ",", "'HipChat'", ")", ";", "}" ]
Register the service provider and alias
[ "Register", "the", "service", "provider", "and", "alias" ]
2ad37856da53c17ac52e6e1c04392f6e0665d402
https://github.com/bestit/hipchat-api/blob/2ad37856da53c17ac52e6e1c04392f6e0665d402/src/HipChatLumenServiceProvider.php#L15-L22
5,339
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/debug.php
Debug.backtrace
public static function backtrace($trace = null) { $trace or $trace = debug_backtrace(); if (\Fuel::$is_cli) { // Special case for CLI since the var_dump of a backtrace is of little use. $str = ''; foreach ($trace as $i => $frame) { $line = "#$i\t"; if ( ! isset($frame['file'])) { $line .= "[internal function]"; } else { $line .= $frame['file'] . ":" . $frame['line']; } $line .= "\t"; if (isset($frame['function'])) { if (isset($frame['class'])) { $line .= $frame['class'] . '::'; } $line .= $frame['function'] . "()"; } $str .= $line . "\n"; } return $str; } else { return static::dump($trace); } }
php
public static function backtrace($trace = null) { $trace or $trace = debug_backtrace(); if (\Fuel::$is_cli) { // Special case for CLI since the var_dump of a backtrace is of little use. $str = ''; foreach ($trace as $i => $frame) { $line = "#$i\t"; if ( ! isset($frame['file'])) { $line .= "[internal function]"; } else { $line .= $frame['file'] . ":" . $frame['line']; } $line .= "\t"; if (isset($frame['function'])) { if (isset($frame['class'])) { $line .= $frame['class'] . '::'; } $line .= $frame['function'] . "()"; } $str .= $line . "\n"; } return $str; } else { return static::dump($trace); } }
[ "public", "static", "function", "backtrace", "(", "$", "trace", "=", "null", ")", "{", "$", "trace", "or", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "if", "(", "\\", "Fuel", "::", "$", "is_cli", ")", "{", "// Special case for CLI since the var_dump of a backtrace is of little use.", "$", "str", "=", "''", ";", "foreach", "(", "$", "trace", "as", "$", "i", "=>", "$", "frame", ")", "{", "$", "line", "=", "\"#$i\\t\"", ";", "if", "(", "!", "isset", "(", "$", "frame", "[", "'file'", "]", ")", ")", "{", "$", "line", ".=", "\"[internal function]\"", ";", "}", "else", "{", "$", "line", ".=", "$", "frame", "[", "'file'", "]", ".", "\":\"", ".", "$", "frame", "[", "'line'", "]", ";", "}", "$", "line", ".=", "\"\\t\"", ";", "if", "(", "isset", "(", "$", "frame", "[", "'function'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "frame", "[", "'class'", "]", ")", ")", "{", "$", "line", ".=", "$", "frame", "[", "'class'", "]", ".", "'::'", ";", "}", "$", "line", ".=", "$", "frame", "[", "'function'", "]", ".", "\"()\"", ";", "}", "$", "str", ".=", "$", "line", ".", "\"\\n\"", ";", "}", "return", "$", "str", ";", "}", "else", "{", "return", "static", "::", "dump", "(", "$", "trace", ")", ";", "}", "}" ]
Output the call stack from here, or the supplied one. @param array (optional) A backtrace to output @return string Formatted backtrace
[ "Output", "the", "call", "stack", "from", "here", "or", "the", "supplied", "one", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/debug.php#L363-L405
5,340
jfortunato/fortune
src/Output/BaseOutput.php
BaseOutput.index
public function index($identifiers = null) { $parents = func_get_args(); if ($this->failsSecurity()) { return $this->responseDenied(); } if ($this->failsParentMatch($parents)) { return $this->responseNotFound(); } $entities = $parents ? $this->resource->allByParent(end($parents)):$this->resource->all(); return $this->response($entities, 200); }
php
public function index($identifiers = null) { $parents = func_get_args(); if ($this->failsSecurity()) { return $this->responseDenied(); } if ($this->failsParentMatch($parents)) { return $this->responseNotFound(); } $entities = $parents ? $this->resource->allByParent(end($parents)):$this->resource->all(); return $this->response($entities, 200); }
[ "public", "function", "index", "(", "$", "identifiers", "=", "null", ")", "{", "$", "parents", "=", "func_get_args", "(", ")", ";", "if", "(", "$", "this", "->", "failsSecurity", "(", ")", ")", "{", "return", "$", "this", "->", "responseDenied", "(", ")", ";", "}", "if", "(", "$", "this", "->", "failsParentMatch", "(", "$", "parents", ")", ")", "{", "return", "$", "this", "->", "responseNotFound", "(", ")", ";", "}", "$", "entities", "=", "$", "parents", "?", "$", "this", "->", "resource", "->", "allByParent", "(", "end", "(", "$", "parents", ")", ")", ":", "$", "this", "->", "resource", "->", "all", "(", ")", ";", "return", "$", "this", "->", "response", "(", "$", "entities", ",", "200", ")", ";", "}" ]
Shows all of a resource. @param mixed $identifiers,... all the resource identifiers starting with the parents if applicable down to the requested resource @return string
[ "Shows", "all", "of", "a", "resource", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Output/BaseOutput.php#L174-L189
5,341
jfortunato/fortune
src/Output/BaseOutput.php
BaseOutput.update
public function update($identifiers) { $parents = func_get_args(); $id = array_pop($parents); $entity = $parents ? $this->resource->singleByParent(end($parents), $id) : $this->resource->single($id); if ($this->failsSecurity($entity)) { return $this->responseDenied(); } if (!$entity || $this->failsParentMatch($parents)) { return $this->responseNotFound(); } $input = $this->getInput(); if ($this->failsValidation($input)) { return $this->responseBadInput(); } $this->resource->update($id, $input); return $this->response(null, 204); }
php
public function update($identifiers) { $parents = func_get_args(); $id = array_pop($parents); $entity = $parents ? $this->resource->singleByParent(end($parents), $id) : $this->resource->single($id); if ($this->failsSecurity($entity)) { return $this->responseDenied(); } if (!$entity || $this->failsParentMatch($parents)) { return $this->responseNotFound(); } $input = $this->getInput(); if ($this->failsValidation($input)) { return $this->responseBadInput(); } $this->resource->update($id, $input); return $this->response(null, 204); }
[ "public", "function", "update", "(", "$", "identifiers", ")", "{", "$", "parents", "=", "func_get_args", "(", ")", ";", "$", "id", "=", "array_pop", "(", "$", "parents", ")", ";", "$", "entity", "=", "$", "parents", "?", "$", "this", "->", "resource", "->", "singleByParent", "(", "end", "(", "$", "parents", ")", ",", "$", "id", ")", ":", "$", "this", "->", "resource", "->", "single", "(", "$", "id", ")", ";", "if", "(", "$", "this", "->", "failsSecurity", "(", "$", "entity", ")", ")", "{", "return", "$", "this", "->", "responseDenied", "(", ")", ";", "}", "if", "(", "!", "$", "entity", "||", "$", "this", "->", "failsParentMatch", "(", "$", "parents", ")", ")", "{", "return", "$", "this", "->", "responseNotFound", "(", ")", ";", "}", "$", "input", "=", "$", "this", "->", "getInput", "(", ")", ";", "if", "(", "$", "this", "->", "failsValidation", "(", "$", "input", ")", ")", "{", "return", "$", "this", "->", "responseBadInput", "(", ")", ";", "}", "$", "this", "->", "resource", "->", "update", "(", "$", "id", ",", "$", "input", ")", ";", "return", "$", "this", "->", "response", "(", "null", ",", "204", ")", ";", "}" ]
Updates and existing resource. @param mixed $identifiers,... all the resource identifiers starting with the parents if applicable down to the requested resource @return string
[ "Updates", "and", "existing", "resource", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Output/BaseOutput.php#L254-L279
5,342
jfortunato/fortune
src/Output/BaseOutput.php
BaseOutput.delete
public function delete($identifiers) { $parents = func_get_args(); $id = array_pop($parents); $entity = $parents ? $this->resource->singleByParent(end($parents), $id) : $this->resource->single($id); if ($this->failsSecurity($entity)) { return $this->responseDenied(); } if (!$entity || $this->failsParentMatch($parents)) { return $this->responseNotFound(); } $this->resource->delete($id); return $this->response(null, 204); }
php
public function delete($identifiers) { $parents = func_get_args(); $id = array_pop($parents); $entity = $parents ? $this->resource->singleByParent(end($parents), $id) : $this->resource->single($id); if ($this->failsSecurity($entity)) { return $this->responseDenied(); } if (!$entity || $this->failsParentMatch($parents)) { return $this->responseNotFound(); } $this->resource->delete($id); return $this->response(null, 204); }
[ "public", "function", "delete", "(", "$", "identifiers", ")", "{", "$", "parents", "=", "func_get_args", "(", ")", ";", "$", "id", "=", "array_pop", "(", "$", "parents", ")", ";", "$", "entity", "=", "$", "parents", "?", "$", "this", "->", "resource", "->", "singleByParent", "(", "end", "(", "$", "parents", ")", ",", "$", "id", ")", ":", "$", "this", "->", "resource", "->", "single", "(", "$", "id", ")", ";", "if", "(", "$", "this", "->", "failsSecurity", "(", "$", "entity", ")", ")", "{", "return", "$", "this", "->", "responseDenied", "(", ")", ";", "}", "if", "(", "!", "$", "entity", "||", "$", "this", "->", "failsParentMatch", "(", "$", "parents", ")", ")", "{", "return", "$", "this", "->", "responseNotFound", "(", ")", ";", "}", "$", "this", "->", "resource", "->", "delete", "(", "$", "id", ")", ";", "return", "$", "this", "->", "response", "(", "null", ",", "204", ")", ";", "}" ]
Deletes an existing resource. @param mixed $identifiers,... all the resource identifiers starting with the parents if applicable down to the requested resource @return string
[ "Deletes", "an", "existing", "resource", "." ]
3bbf66a85304070562e54a66c99145f58f32877e
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Output/BaseOutput.php#L288-L307
5,343
fusible/fusible.view-provider
src/Config.php
Config.define
public function define(Container $di) { foreach ($this->params as $key => $value) { if (! isset($di->values[$key])) { $di->values[$key] = $value; } } $this->defineView($di); $this->defineHelpers($di); }
php
public function define(Container $di) { foreach ($this->params as $key => $value) { if (! isset($di->values[$key])) { $di->values[$key] = $value; } } $this->defineView($di); $this->defineHelpers($di); }
[ "public", "function", "define", "(", "Container", "$", "di", ")", "{", "foreach", "(", "$", "this", "->", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "di", "->", "values", "[", "$", "key", "]", ")", ")", "{", "$", "di", "->", "values", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "this", "->", "defineView", "(", "$", "di", ")", ";", "$", "this", "->", "defineHelpers", "(", "$", "di", ")", ";", "}" ]
Define Aura\View and Aura\Html factories and services @param Container $di DI Container @return void @access public @SuppressWarnings(PHPMD.ShortVariable)
[ "Define", "Aura", "\\", "View", "and", "Aura", "\\", "Html", "factories", "and", "services" ]
8c9c6bdafa713f3c5bea6cd465d74c50536b6e55
https://github.com/fusible/fusible.view-provider/blob/8c9c6bdafa713f3c5bea6cd465d74c50536b6e55/src/Config.php#L82-L92
5,344
fusible/fusible.view-provider
src/Config.php
Config.defineHelpers
protected function defineHelpers(Container $di) { $di->set( self::HELPER_FACTORY, $di->lazyNew(Html\HelperLocatorFactory::class) ); $di->set( self::HELPER_LOCATOR, $di->lazyGetCall(self::HELPER_FACTORY, 'newInstance') ); $di->set( self::ESCAPER_FACTORY, $di->lazyNew(Html\EscaperFactory::class) ); $di->set( self::ESCAPER, $di->lazyGetCall(self::ESCAPER_FACTORY, 'newInstance') ); $di->params[Html\Helper\AbstractHelper::class] = [ 'escaper' => $di->lazyGet(self::ESCAPER) ]; }
php
protected function defineHelpers(Container $di) { $di->set( self::HELPER_FACTORY, $di->lazyNew(Html\HelperLocatorFactory::class) ); $di->set( self::HELPER_LOCATOR, $di->lazyGetCall(self::HELPER_FACTORY, 'newInstance') ); $di->set( self::ESCAPER_FACTORY, $di->lazyNew(Html\EscaperFactory::class) ); $di->set( self::ESCAPER, $di->lazyGetCall(self::ESCAPER_FACTORY, 'newInstance') ); $di->params[Html\Helper\AbstractHelper::class] = [ 'escaper' => $di->lazyGet(self::ESCAPER) ]; }
[ "protected", "function", "defineHelpers", "(", "Container", "$", "di", ")", "{", "$", "di", "->", "set", "(", "self", "::", "HELPER_FACTORY", ",", "$", "di", "->", "lazyNew", "(", "Html", "\\", "HelperLocatorFactory", "::", "class", ")", ")", ";", "$", "di", "->", "set", "(", "self", "::", "HELPER_LOCATOR", ",", "$", "di", "->", "lazyGetCall", "(", "self", "::", "HELPER_FACTORY", ",", "'newInstance'", ")", ")", ";", "$", "di", "->", "set", "(", "self", "::", "ESCAPER_FACTORY", ",", "$", "di", "->", "lazyNew", "(", "Html", "\\", "EscaperFactory", "::", "class", ")", ")", ";", "$", "di", "->", "set", "(", "self", "::", "ESCAPER", ",", "$", "di", "->", "lazyGetCall", "(", "self", "::", "ESCAPER_FACTORY", ",", "'newInstance'", ")", ")", ";", "$", "di", "->", "params", "[", "Html", "\\", "Helper", "\\", "AbstractHelper", "::", "class", "]", "=", "[", "'escaper'", "=>", "$", "di", "->", "lazyGet", "(", "self", "::", "ESCAPER", ")", "]", ";", "}" ]
Define Aura\Html factories and services @param Container $di DI Container @return void @access public @SuppressWarnings(PHPMD.ShortVariable)
[ "Define", "Aura", "\\", "Html", "factories", "and", "services" ]
8c9c6bdafa713f3c5bea6cd465d74c50536b6e55
https://github.com/fusible/fusible.view-provider/blob/8c9c6bdafa713f3c5bea6cd465d74c50536b6e55/src/Config.php#L105-L130
5,345
fusible/fusible.view-provider
src/Config.php
Config.defineView
protected function defineView(Container $di) { $di->set( self::VIEW_FACTORY, $di->lazyNew(View\ViewFactory::class) ); $di->set( self::VIEW, $di->lazyGetCall( View\ViewFactory::class, 'newInstance', $di->lazyGet(self::HELPER_LOCATOR), $di->lazyValue(self::VIEW_MAP), $di->lazyValue(self::VIEW_PATHS), $di->lazyValue(self::LAYOUT_MAP), $di->lazyValue(self::LAYOUT_PATHS) ) ); }
php
protected function defineView(Container $di) { $di->set( self::VIEW_FACTORY, $di->lazyNew(View\ViewFactory::class) ); $di->set( self::VIEW, $di->lazyGetCall( View\ViewFactory::class, 'newInstance', $di->lazyGet(self::HELPER_LOCATOR), $di->lazyValue(self::VIEW_MAP), $di->lazyValue(self::VIEW_PATHS), $di->lazyValue(self::LAYOUT_MAP), $di->lazyValue(self::LAYOUT_PATHS) ) ); }
[ "protected", "function", "defineView", "(", "Container", "$", "di", ")", "{", "$", "di", "->", "set", "(", "self", "::", "VIEW_FACTORY", ",", "$", "di", "->", "lazyNew", "(", "View", "\\", "ViewFactory", "::", "class", ")", ")", ";", "$", "di", "->", "set", "(", "self", "::", "VIEW", ",", "$", "di", "->", "lazyGetCall", "(", "View", "\\", "ViewFactory", "::", "class", ",", "'newInstance'", ",", "$", "di", "->", "lazyGet", "(", "self", "::", "HELPER_LOCATOR", ")", ",", "$", "di", "->", "lazyValue", "(", "self", "::", "VIEW_MAP", ")", ",", "$", "di", "->", "lazyValue", "(", "self", "::", "VIEW_PATHS", ")", ",", "$", "di", "->", "lazyValue", "(", "self", "::", "LAYOUT_MAP", ")", ",", "$", "di", "->", "lazyValue", "(", "self", "::", "LAYOUT_PATHS", ")", ")", ")", ";", "}" ]
Define Aura\View factories and services @param Container $di DI Container @return void @access public @SuppressWarnings(PHPMD.ShortVariable)
[ "Define", "Aura", "\\", "View", "factories", "and", "services" ]
8c9c6bdafa713f3c5bea6cd465d74c50536b6e55
https://github.com/fusible/fusible.view-provider/blob/8c9c6bdafa713f3c5bea6cd465d74c50536b6e55/src/Config.php#L143-L162
5,346
fusible/fusible.view-provider
src/Config.php
Config.modify
public function modify(Container $di) { $specs = $di->lazyValue(self::HELPER_SPECS); $specs = $specs(); if (! $specs) { return; } $helpers = $di->get(self::HELPER_LOCATOR); $resolve = $di->newResolutionHelper(); foreach ($specs as $key => $spec) { $factory = function () use ($resolve, $spec) { return $resolve($spec); }; $helpers->set($key, $factory); } }
php
public function modify(Container $di) { $specs = $di->lazyValue(self::HELPER_SPECS); $specs = $specs(); if (! $specs) { return; } $helpers = $di->get(self::HELPER_LOCATOR); $resolve = $di->newResolutionHelper(); foreach ($specs as $key => $spec) { $factory = function () use ($resolve, $spec) { return $resolve($spec); }; $helpers->set($key, $factory); } }
[ "public", "function", "modify", "(", "Container", "$", "di", ")", "{", "$", "specs", "=", "$", "di", "->", "lazyValue", "(", "self", "::", "HELPER_SPECS", ")", ";", "$", "specs", "=", "$", "specs", "(", ")", ";", "if", "(", "!", "$", "specs", ")", "{", "return", ";", "}", "$", "helpers", "=", "$", "di", "->", "get", "(", "self", "::", "HELPER_LOCATOR", ")", ";", "$", "resolve", "=", "$", "di", "->", "newResolutionHelper", "(", ")", ";", "foreach", "(", "$", "specs", "as", "$", "key", "=>", "$", "spec", ")", "{", "$", "factory", "=", "function", "(", ")", "use", "(", "$", "resolve", ",", "$", "spec", ")", "{", "return", "$", "resolve", "(", "$", "spec", ")", ";", "}", ";", "$", "helpers", "->", "set", "(", "$", "key", ",", "$", "factory", ")", ";", "}", "}" ]
Define Add helpers @param Container $di DI Container @return void @access public @SuppressWarnings(PHPMD.ShortVariable)
[ "Define", "Add", "helpers" ]
8c9c6bdafa713f3c5bea6cd465d74c50536b6e55
https://github.com/fusible/fusible.view-provider/blob/8c9c6bdafa713f3c5bea6cd465d74c50536b6e55/src/Config.php#L175-L194
5,347
monolyth-php/formulaic
src/Number.php
Number.setMin
public function setMin(float $min) : Number { $this->attributes['min'] = $min; return $this->addTest('min', function ($value) use ($min) { return $value >= $min; }); }
php
public function setMin(float $min) : Number { $this->attributes['min'] = $min; return $this->addTest('min', function ($value) use ($min) { return $value >= $min; }); }
[ "public", "function", "setMin", "(", "float", "$", "min", ")", ":", "Number", "{", "$", "this", "->", "attributes", "[", "'min'", "]", "=", "$", "min", ";", "return", "$", "this", "->", "addTest", "(", "'min'", ",", "function", "(", "$", "value", ")", "use", "(", "$", "min", ")", "{", "return", "$", "value", ">=", "$", "min", ";", "}", ")", ";", "}" ]
Set the minimum value. @param float $min @return self
[ "Set", "the", "minimum", "value", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Number.php#L27-L33
5,348
monolyth-php/formulaic
src/Number.php
Number.setMax
public function setMax(float $max) : Number { $this->attributes['max'] = $max; return $this->addTest('max', function ($value) use ($max) { return $value <= $max; }); }
php
public function setMax(float $max) : Number { $this->attributes['max'] = $max; return $this->addTest('max', function ($value) use ($max) { return $value <= $max; }); }
[ "public", "function", "setMax", "(", "float", "$", "max", ")", ":", "Number", "{", "$", "this", "->", "attributes", "[", "'max'", "]", "=", "$", "max", ";", "return", "$", "this", "->", "addTest", "(", "'max'", ",", "function", "(", "$", "value", ")", "use", "(", "$", "max", ")", "{", "return", "$", "value", "<=", "$", "max", ";", "}", ")", ";", "}" ]
Set the maximum value. @param float $max @return self
[ "Set", "the", "maximum", "value", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Number.php#L41-L47
5,349
monolyth-php/formulaic
src/Number.php
Number.setStep
public function setStep(float $step) : Number { $this->attributes['step'] = $step; $offset = isset($this->attributes['min']) ? $this->attributes['min'] : 0; return $this->addTest('step', function ($value) use ($step, $offset) { if (!is_numeric($value)) { return false; } return !fmod($value - $offset, $step); }); }
php
public function setStep(float $step) : Number { $this->attributes['step'] = $step; $offset = isset($this->attributes['min']) ? $this->attributes['min'] : 0; return $this->addTest('step', function ($value) use ($step, $offset) { if (!is_numeric($value)) { return false; } return !fmod($value - $offset, $step); }); }
[ "public", "function", "setStep", "(", "float", "$", "step", ")", ":", "Number", "{", "$", "this", "->", "attributes", "[", "'step'", "]", "=", "$", "step", ";", "$", "offset", "=", "isset", "(", "$", "this", "->", "attributes", "[", "'min'", "]", ")", "?", "$", "this", "->", "attributes", "[", "'min'", "]", ":", "0", ";", "return", "$", "this", "->", "addTest", "(", "'step'", ",", "function", "(", "$", "value", ")", "use", "(", "$", "step", ",", "$", "offset", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "!", "fmod", "(", "$", "value", "-", "$", "offset", ",", "$", "step", ")", ";", "}", ")", ";", "}" ]
Set the allowed step interval. @param float $step @return self
[ "Set", "the", "allowed", "step", "interval", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Number.php#L55-L67
5,350
digbang/font-awesome
src/FontAwesome.php
FontAwesome.icon
public function icon($name, $options = []) { $options = $this->parseOptions($options); $options['class'] = $this->getClasses($name, Arr::pull($options, 'class')); return new HtmlString( $this->openTag($this->attributes($options)) . $this->closeTag() ); }
php
public function icon($name, $options = []) { $options = $this->parseOptions($options); $options['class'] = $this->getClasses($name, Arr::pull($options, 'class')); return new HtmlString( $this->openTag($this->attributes($options)) . $this->closeTag() ); }
[ "public", "function", "icon", "(", "$", "name", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "parseOptions", "(", "$", "options", ")", ";", "$", "options", "[", "'class'", "]", "=", "$", "this", "->", "getClasses", "(", "$", "name", ",", "Arr", "::", "pull", "(", "$", "options", ",", "'class'", ")", ")", ";", "return", "new", "HtmlString", "(", "$", "this", "->", "openTag", "(", "$", "this", "->", "attributes", "(", "$", "options", ")", ")", ".", "$", "this", "->", "closeTag", "(", ")", ")", ";", "}" ]
Builds a FontAwesome icon HTML. @param string $name The icon name, as indicated in the FA documentation. @param array $options Extra class/es to add to the icon @return string
[ "Builds", "a", "FontAwesome", "icon", "HTML", "." ]
04e18271b56c4677a8ca371842f05ab779059049
https://github.com/digbang/font-awesome/blob/04e18271b56c4677a8ca371842f05ab779059049/src/FontAwesome.php#L22-L31
5,351
vinala/kernel
src/MVC/Relations/OneToOne.php
OneToOne.ini
public function ini($related, $model, $local = null, $remote = null) { $this->checkModels($related, $model); // $relationVal = $this->relationValue($related, $model, $local); $relationColumn = $this->relationColumn($related, $model, $remote); // $mod = $this->first($related, $relationColumn, $relationVal); // return $this->prepare($mod, $related); }
php
public function ini($related, $model, $local = null, $remote = null) { $this->checkModels($related, $model); // $relationVal = $this->relationValue($related, $model, $local); $relationColumn = $this->relationColumn($related, $model, $remote); // $mod = $this->first($related, $relationColumn, $relationVal); // return $this->prepare($mod, $related); }
[ "public", "function", "ini", "(", "$", "related", ",", "$", "model", ",", "$", "local", "=", "null", ",", "$", "remote", "=", "null", ")", "{", "$", "this", "->", "checkModels", "(", "$", "related", ",", "$", "model", ")", ";", "//", "$", "relationVal", "=", "$", "this", "->", "relationValue", "(", "$", "related", ",", "$", "model", ",", "$", "local", ")", ";", "$", "relationColumn", "=", "$", "this", "->", "relationColumn", "(", "$", "related", ",", "$", "model", ",", "$", "remote", ")", ";", "//", "$", "mod", "=", "$", "this", "->", "first", "(", "$", "related", ",", "$", "relationColumn", ",", "$", "relationVal", ")", ";", "//", "return", "$", "this", "->", "prepare", "(", "$", "mod", ",", "$", "related", ")", ";", "}" ]
The one to one relation. @param $model : the model wanted to be related to the current model @param $local : if not null would be the local column of the relation @param $remote : if not null would be the $remote column of the relation
[ "The", "one", "to", "one", "relation", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Relations/OneToOne.php#L25-L35
5,352
vinala/kernel
src/MVC/Relations/OneToOne.php
OneToOne.relationColumn
protected function relationColumn($related, $model, $column = null) { $table = $related::$table; // return !is_null($column) ? $column : $this->idKey($table); }
php
protected function relationColumn($related, $model, $column = null) { $table = $related::$table; // return !is_null($column) ? $column : $this->idKey($table); }
[ "protected", "function", "relationColumn", "(", "$", "related", ",", "$", "model", ",", "$", "column", "=", "null", ")", "{", "$", "table", "=", "$", "related", "::", "$", "table", ";", "//", "return", "!", "is_null", "(", "$", "column", ")", "?", "$", "column", ":", "$", "this", "->", "idKey", "(", "$", "table", ")", ";", "}" ]
get the name of the column of the relation. @param $column : name of the column @param $model : name of the model
[ "get", "the", "name", "of", "the", "column", "of", "the", "relation", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Relations/OneToOne.php#L56-L61
5,353
vinala/kernel
src/MVC/Relations/OneToOne.php
OneToOne.first
protected function first($model, $column, $value) { $data = $model::where($column, '=', $value); if (!is_null($data)) { if (count($data) > 0) { return $data[0]; } } }
php
protected function first($model, $column, $value) { $data = $model::where($column, '=', $value); if (!is_null($data)) { if (count($data) > 0) { return $data[0]; } } }
[ "protected", "function", "first", "(", "$", "model", ",", "$", "column", ",", "$", "value", ")", "{", "$", "data", "=", "$", "model", "::", "where", "(", "$", "column", ",", "'='", ",", "$", "value", ")", ";", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "if", "(", "count", "(", "$", "data", ")", ">", "0", ")", "{", "return", "$", "data", "[", "0", "]", ";", "}", "}", "}" ]
Get the object for the relation one to one. @param $model : the model where to get data from @param $column : the column where to get data from @param $value : the value to get
[ "Get", "the", "object", "for", "the", "relation", "one", "to", "one", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/MVC/Relations/OneToOne.php#L70-L79
5,354
titon/g11n
src/Titon/G11n/Route/LocaleRoute.php
LocaleRoute.compile
public function compile() { if ($this->isCompiled()) { return $this->_compiled; } $g11n = G11n::registry(); if ($g11n->isEnabled()) { if (mb_substr($this->getPath(), 0, 9) !== '/<locale>') { $this->prepend('/<locale>'); } $this->setConfig('patterns.locale', self::LOCALE); $this->setConfig('locale', G11n::canonicalize($g11n->getFallback()->getCode())); } return parent::compile(); }
php
public function compile() { if ($this->isCompiled()) { return $this->_compiled; } $g11n = G11n::registry(); if ($g11n->isEnabled()) { if (mb_substr($this->getPath(), 0, 9) !== '/<locale>') { $this->prepend('/<locale>'); } $this->setConfig('patterns.locale', self::LOCALE); $this->setConfig('locale', G11n::canonicalize($g11n->getFallback()->getCode())); } return parent::compile(); }
[ "public", "function", "compile", "(", ")", "{", "if", "(", "$", "this", "->", "isCompiled", "(", ")", ")", "{", "return", "$", "this", "->", "_compiled", ";", "}", "$", "g11n", "=", "G11n", "::", "registry", "(", ")", ";", "if", "(", "$", "g11n", "->", "isEnabled", "(", ")", ")", "{", "if", "(", "mb_substr", "(", "$", "this", "->", "getPath", "(", ")", ",", "0", ",", "9", ")", "!==", "'/<locale>'", ")", "{", "$", "this", "->", "prepend", "(", "'/<locale>'", ")", ";", "}", "$", "this", "->", "setConfig", "(", "'patterns.locale'", ",", "self", "::", "LOCALE", ")", ";", "$", "this", "->", "setConfig", "(", "'locale'", ",", "G11n", "::", "canonicalize", "(", "$", "g11n", "->", "getFallback", "(", ")", "->", "getCode", "(", ")", ")", ")", ";", "}", "return", "parent", "::", "compile", "(", ")", ";", "}" ]
Prepend the locale to the front of the route before compilation. @return string
[ "Prepend", "the", "locale", "to", "the", "front", "of", "the", "route", "before", "compilation", "." ]
4b3192055c868167f557b7fb58c37ea620de8df3
https://github.com/titon/g11n/blob/4b3192055c868167f557b7fb58c37ea620de8df3/src/Titon/G11n/Route/LocaleRoute.php#L26-L43
5,355
edunola13/utils
lib/Validation/Validation.php
Validation.add_rule
public function add_rule($name, $value, $rules){ $this->fieldsState[$name] = array( 'name' => $name, 'value' => $value, 'rules' => explode('|', $rules), 'valid' => TRUE, 'message' => NULL ); }
php
public function add_rule($name, $value, $rules){ $this->fieldsState[$name] = array( 'name' => $name, 'value' => $value, 'rules' => explode('|', $rules), 'valid' => TRUE, 'message' => NULL ); }
[ "public", "function", "add_rule", "(", "$", "name", ",", "$", "value", ",", "$", "rules", ")", "{", "$", "this", "->", "fieldsState", "[", "$", "name", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'value'", "=>", "$", "value", ",", "'rules'", "=>", "explode", "(", "'|'", ",", "$", "rules", ")", ",", "'valid'", "=>", "TRUE", ",", "'message'", "=>", "NULL", ")", ";", "}" ]
Agregar una regla de validacion que luego sera validada @param string $name @param type $value @param array[string] $rules
[ "Agregar", "una", "regla", "de", "validacion", "que", "luego", "sera", "validada" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L54-L62
5,356
edunola13/utils
lib/Validation/Validation.php
Validation.validate
public function validate(){ if(count($this->fieldsState) == 0){ //Si no hay datos devuelve TRUE return TRUE; } else{ //Si hay datos valida sus reglas //El formulario empieza siendo valido $form_valid= TRUE; //Recorro todos los datos y sus reglas foreach ($this->fieldsState as $fieldState) { $valid= TRUE; //Recorro cada regla del dato foreach ($fieldState['rules'] as $rule) { //Ve el tipo de regla, con o sin parametros if (count(explode('[', $rule)) > 1){ //Si hay reglas con parametros, separa la regla y su parametro $vars= explode('[', $rule); $rule= $vars[0]; $var= explode(']', $vars[1]); $var= $var[0]; //Realiza el llamado a la funcion correspondiente $valid= call_user_func_array(array($this, $rule), array($fieldState['name'], $fieldState['value'], $var)); } else{ //Regla sin parametros //Realiza el llamado a la funcion correspondiente $valid= call_user_func_array(array($this, $rule), array($fieldState['name'], $fieldState['value'])); } //Si una regla ya no es valida, no reviso las demas if(!$valid){ //Asigno al campo Valido del dato FALSE $name= $fieldState['name']; $this->fieldsState["$name"]['valid']= FALSE; break; } } //Actualizo el valor de formulario_valido de manera que si ya es falso se mantiene en falso $form_valid= $form_valid && $valid; } return $form_valid; } }
php
public function validate(){ if(count($this->fieldsState) == 0){ //Si no hay datos devuelve TRUE return TRUE; } else{ //Si hay datos valida sus reglas //El formulario empieza siendo valido $form_valid= TRUE; //Recorro todos los datos y sus reglas foreach ($this->fieldsState as $fieldState) { $valid= TRUE; //Recorro cada regla del dato foreach ($fieldState['rules'] as $rule) { //Ve el tipo de regla, con o sin parametros if (count(explode('[', $rule)) > 1){ //Si hay reglas con parametros, separa la regla y su parametro $vars= explode('[', $rule); $rule= $vars[0]; $var= explode(']', $vars[1]); $var= $var[0]; //Realiza el llamado a la funcion correspondiente $valid= call_user_func_array(array($this, $rule), array($fieldState['name'], $fieldState['value'], $var)); } else{ //Regla sin parametros //Realiza el llamado a la funcion correspondiente $valid= call_user_func_array(array($this, $rule), array($fieldState['name'], $fieldState['value'])); } //Si una regla ya no es valida, no reviso las demas if(!$valid){ //Asigno al campo Valido del dato FALSE $name= $fieldState['name']; $this->fieldsState["$name"]['valid']= FALSE; break; } } //Actualizo el valor de formulario_valido de manera que si ya es falso se mantiene en falso $form_valid= $form_valid && $valid; } return $form_valid; } }
[ "public", "function", "validate", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "fieldsState", ")", "==", "0", ")", "{", "//Si no hay datos devuelve TRUE", "return", "TRUE", ";", "}", "else", "{", "//Si hay datos valida sus reglas ", "//El formulario empieza siendo valido", "$", "form_valid", "=", "TRUE", ";", "//Recorro todos los datos y sus reglas", "foreach", "(", "$", "this", "->", "fieldsState", "as", "$", "fieldState", ")", "{", "$", "valid", "=", "TRUE", ";", "//Recorro cada regla del dato", "foreach", "(", "$", "fieldState", "[", "'rules'", "]", "as", "$", "rule", ")", "{", "//Ve el tipo de regla, con o sin parametros", "if", "(", "count", "(", "explode", "(", "'['", ",", "$", "rule", ")", ")", ">", "1", ")", "{", "//Si hay reglas con parametros, separa la regla y su parametro ", "$", "vars", "=", "explode", "(", "'['", ",", "$", "rule", ")", ";", "$", "rule", "=", "$", "vars", "[", "0", "]", ";", "$", "var", "=", "explode", "(", "']'", ",", "$", "vars", "[", "1", "]", ")", ";", "$", "var", "=", "$", "var", "[", "0", "]", ";", "//Realiza el llamado a la funcion correspondiente", "$", "valid", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "rule", ")", ",", "array", "(", "$", "fieldState", "[", "'name'", "]", ",", "$", "fieldState", "[", "'value'", "]", ",", "$", "var", ")", ")", ";", "}", "else", "{", "//Regla sin parametros", "//Realiza el llamado a la funcion correspondiente", "$", "valid", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "rule", ")", ",", "array", "(", "$", "fieldState", "[", "'name'", "]", ",", "$", "fieldState", "[", "'value'", "]", ")", ")", ";", "}", "//Si una regla ya no es valida, no reviso las demas", "if", "(", "!", "$", "valid", ")", "{", "//Asigno al campo Valido del dato FALSE", "$", "name", "=", "$", "fieldState", "[", "'name'", "]", ";", "$", "this", "->", "fieldsState", "[", "\"$name\"", "]", "[", "'valid'", "]", "=", "FALSE", ";", "break", ";", "}", "}", "//Actualizo el valor de formulario_valido de manera que si ya es falso se mantiene en falso", "$", "form_valid", "=", "$", "form_valid", "&&", "$", "valid", ";", "}", "return", "$", "form_valid", ";", "}", "}" ]
Ejecuta todas las reglas de validacion que se hayan cargado. Devuelve TRUE si todas las reglas pasan y FALSE en caso contrario @return boolean
[ "Ejecuta", "todas", "las", "reglas", "de", "validacion", "que", "se", "hayan", "cargado", ".", "Devuelve", "TRUE", "si", "todas", "las", "reglas", "pasan", "y", "FALSE", "en", "caso", "contrario" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L68-L111
5,357
edunola13/utils
lib/Validation/Validation.php
Validation.error_messages
public function error_messages(){ $messages= array(); foreach ($this->fieldsState as $fieldState) { //Si no es valido agrego el mensaje de error if(! $fieldState['valid']){ $name= $fieldState['name']; $messages["$name"]= $fieldState['message']; } } return $messages; }
php
public function error_messages(){ $messages= array(); foreach ($this->fieldsState as $fieldState) { //Si no es valido agrego el mensaje de error if(! $fieldState['valid']){ $name= $fieldState['name']; $messages["$name"]= $fieldState['message']; } } return $messages; }
[ "public", "function", "error_messages", "(", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fieldsState", "as", "$", "fieldState", ")", "{", "//Si no es valido agrego el mensaje de error", "if", "(", "!", "$", "fieldState", "[", "'valid'", "]", ")", "{", "$", "name", "=", "$", "fieldState", "[", "'name'", "]", ";", "$", "messages", "[", "\"$name\"", "]", "=", "$", "fieldState", "[", "'message'", "]", ";", "}", "}", "return", "$", "messages", ";", "}" ]
Devuelve los mensajes de error para cada campo que no haya pasado la validacion. Es un array asociativo con el nombre del campo pasado @return array[string]
[ "Devuelve", "los", "mensajes", "de", "error", "para", "cada", "campo", "que", "no", "haya", "pasado", "la", "validacion", ".", "Es", "un", "array", "asociativo", "con", "el", "nombre", "del", "campo", "pasado" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L117-L127
5,358
edunola13/utils
lib/Validation/Validation.php
Validation.add_message
protected function add_message($name, $message, $parametros = array()){ //Carga el archivo si es la primer llamada $this->load_messages(); //Consigue el mensaje $message= $this->messages[$message]; //Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes foreach ($parametros as $key => $valor) { $message= str_replace(":$key", $valor, $message); } //Guarda el mensaje en el campo correspondiente $this->fieldsState["$name"]['message']= $message; }
php
protected function add_message($name, $message, $parametros = array()){ //Carga el archivo si es la primer llamada $this->load_messages(); //Consigue el mensaje $message= $this->messages[$message]; //Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes foreach ($parametros as $key => $valor) { $message= str_replace(":$key", $valor, $message); } //Guarda el mensaje en el campo correspondiente $this->fieldsState["$name"]['message']= $message; }
[ "protected", "function", "add_message", "(", "$", "name", ",", "$", "message", ",", "$", "parametros", "=", "array", "(", ")", ")", "{", "//Carga el archivo si es la primer llamada", "$", "this", "->", "load_messages", "(", ")", ";", "//Consigue el mensaje", "$", "message", "=", "$", "this", "->", "messages", "[", "$", "message", "]", ";", "//Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes", "foreach", "(", "$", "parametros", "as", "$", "key", "=>", "$", "valor", ")", "{", "$", "message", "=", "str_replace", "(", "\":$key\"", ",", "$", "valor", ",", "$", "message", ")", ";", "}", "//Guarda el mensaje en el campo correspondiente", "$", "this", "->", "fieldsState", "[", "\"$name\"", "]", "[", "'message'", "]", "=", "$", "message", ";", "}" ]
Funcion utilizada internamente para agregar mensajes de error a los campos @param string $name @param string $message
[ "Funcion", "utilizada", "internamente", "para", "agregar", "mensajes", "de", "error", "a", "los", "campos" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L133-L144
5,359
edunola13/utils
lib/Validation/Validation.php
Validation.load_messages
protected function load_messages(){ if($this->messages == NULL || $this->locale != $this->messagesLocale){ if($this->locale != NULL){ if(file_exists($this->dir_content . "_$this->locale" . '.txt')){ $this->messages= file($this->dir_content . "_$this->locale" . '.txt'); $this->messages= $this->parse_properties($this->messages); $this->messagesLocale= $this->locale; } } if($this->messages == NULL){ $this->messages= file($this->dir_content . '.txt'); $this->messages= $this->parse_properties($this->messages); $this->messagesLocale= NULL; } } }
php
protected function load_messages(){ if($this->messages == NULL || $this->locale != $this->messagesLocale){ if($this->locale != NULL){ if(file_exists($this->dir_content . "_$this->locale" . '.txt')){ $this->messages= file($this->dir_content . "_$this->locale" . '.txt'); $this->messages= $this->parse_properties($this->messages); $this->messagesLocale= $this->locale; } } if($this->messages == NULL){ $this->messages= file($this->dir_content . '.txt'); $this->messages= $this->parse_properties($this->messages); $this->messagesLocale= NULL; } } }
[ "protected", "function", "load_messages", "(", ")", "{", "if", "(", "$", "this", "->", "messages", "==", "NULL", "||", "$", "this", "->", "locale", "!=", "$", "this", "->", "messagesLocale", ")", "{", "if", "(", "$", "this", "->", "locale", "!=", "NULL", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "dir_content", ".", "\"_$this->locale\"", ".", "'.txt'", ")", ")", "{", "$", "this", "->", "messages", "=", "file", "(", "$", "this", "->", "dir_content", ".", "\"_$this->locale\"", ".", "'.txt'", ")", ";", "$", "this", "->", "messages", "=", "$", "this", "->", "parse_properties", "(", "$", "this", "->", "messages", ")", ";", "$", "this", "->", "messagesLocale", "=", "$", "this", "->", "locale", ";", "}", "}", "if", "(", "$", "this", "->", "messages", "==", "NULL", ")", "{", "$", "this", "->", "messages", "=", "file", "(", "$", "this", "->", "dir_content", ".", "'.txt'", ")", ";", "$", "this", "->", "messages", "=", "$", "this", "->", "parse_properties", "(", "$", "this", "->", "messages", ")", ";", "$", "this", "->", "messagesLocale", "=", "NULL", ";", "}", "}", "}" ]
Carga el archivo de mensajes en la primer llamada
[ "Carga", "el", "archivo", "de", "mensajes", "en", "la", "primer", "llamada" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L148-L163
5,360
edunola13/utils
lib/Validation/Validation.php
Validation.parse_properties
protected function parse_properties($lines) { $result= NULL; foreach($lines as $i=>$line) { if(empty($line) || !isset($line) || strpos($line,"#") === 0){ continue; } $key = substr($line,0,strpos($line,'=')); $value = substr($line,strpos($line,'=') + 1, strlen($line)); $result[$key] = $value; } return $result; }
php
protected function parse_properties($lines) { $result= NULL; foreach($lines as $i=>$line) { if(empty($line) || !isset($line) || strpos($line,"#") === 0){ continue; } $key = substr($line,0,strpos($line,'=')); $value = substr($line,strpos($line,'=') + 1, strlen($line)); $result[$key] = $value; } return $result; }
[ "protected", "function", "parse_properties", "(", "$", "lines", ")", "{", "$", "result", "=", "NULL", ";", "foreach", "(", "$", "lines", "as", "$", "i", "=>", "$", "line", ")", "{", "if", "(", "empty", "(", "$", "line", ")", "||", "!", "isset", "(", "$", "line", ")", "||", "strpos", "(", "$", "line", ",", "\"#\"", ")", "===", "0", ")", "{", "continue", ";", "}", "$", "key", "=", "substr", "(", "$", "line", ",", "0", ",", "strpos", "(", "$", "line", ",", "'='", ")", ")", ";", "$", "value", "=", "substr", "(", "$", "line", ",", "strpos", "(", "$", "line", ",", "'='", ")", "+", "1", ",", "strlen", "(", "$", "line", ")", ")", ";", "$", "result", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "result", ";", "}" ]
Este proceso analiza de a una las lineas del archivo de mensajes usado. En este caso txt y me arma lo que seria un array asociativo clave valor en base a la linea. @param array $lines @return array
[ "Este", "proceso", "analiza", "de", "a", "una", "las", "lineas", "del", "archivo", "de", "mensajes", "usado", ".", "En", "este", "caso", "txt", "y", "me", "arma", "lo", "que", "seria", "un", "array", "asociativo", "clave", "valor", "en", "base", "a", "la", "linea", "." ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/lib/Validation/Validation.php#L170-L181
5,361
XTAIN/JoomlaBundle
Joomla/Joomla.php
Joomla.encapsulate
protected function encapsulate() { $this->encapsulated = true; $args = func_get_args(); $function = array_shift($args); $content = ''; ob_start( function ($buffer) use (&$content) { $content .= $buffer; return ''; } ); $level = ob_get_level(); $applicationClosed = null; $statusCodeBefore = http_response_code(); $this->encapsulatedException = null; try { call_user_func_array($function, $args); } catch (ApplicationClosedException $e) { // nothing } catch (\Exception $e) { $this->encapsulatedException = $e; } $this->restoreBufferLevel($level); ob_end_clean(); $newStatusCode = http_response_code(); $this->response->setStatusCode($newStatusCode); if ($statusCodeBefore != $newStatusCode) { http_response_code($statusCodeBefore); } $headers = $this->cleanHeaders(); foreach ($headers as $name => $value) { $this->response->headers->set($name, $value); } $this->encapsulated = false; if ($this->encapsulatedException != null) { throw new JoomlaRequestException( "Encapsulated request to joomla failed", 0, $this->encapsulatedException ); } return $content; }
php
protected function encapsulate() { $this->encapsulated = true; $args = func_get_args(); $function = array_shift($args); $content = ''; ob_start( function ($buffer) use (&$content) { $content .= $buffer; return ''; } ); $level = ob_get_level(); $applicationClosed = null; $statusCodeBefore = http_response_code(); $this->encapsulatedException = null; try { call_user_func_array($function, $args); } catch (ApplicationClosedException $e) { // nothing } catch (\Exception $e) { $this->encapsulatedException = $e; } $this->restoreBufferLevel($level); ob_end_clean(); $newStatusCode = http_response_code(); $this->response->setStatusCode($newStatusCode); if ($statusCodeBefore != $newStatusCode) { http_response_code($statusCodeBefore); } $headers = $this->cleanHeaders(); foreach ($headers as $name => $value) { $this->response->headers->set($name, $value); } $this->encapsulated = false; if ($this->encapsulatedException != null) { throw new JoomlaRequestException( "Encapsulated request to joomla failed", 0, $this->encapsulatedException ); } return $content; }
[ "protected", "function", "encapsulate", "(", ")", "{", "$", "this", "->", "encapsulated", "=", "true", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "function", "=", "array_shift", "(", "$", "args", ")", ";", "$", "content", "=", "''", ";", "ob_start", "(", "function", "(", "$", "buffer", ")", "use", "(", "&", "$", "content", ")", "{", "$", "content", ".=", "$", "buffer", ";", "return", "''", ";", "}", ")", ";", "$", "level", "=", "ob_get_level", "(", ")", ";", "$", "applicationClosed", "=", "null", ";", "$", "statusCodeBefore", "=", "http_response_code", "(", ")", ";", "$", "this", "->", "encapsulatedException", "=", "null", ";", "try", "{", "call_user_func_array", "(", "$", "function", ",", "$", "args", ")", ";", "}", "catch", "(", "ApplicationClosedException", "$", "e", ")", "{", "// nothing", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "encapsulatedException", "=", "$", "e", ";", "}", "$", "this", "->", "restoreBufferLevel", "(", "$", "level", ")", ";", "ob_end_clean", "(", ")", ";", "$", "newStatusCode", "=", "http_response_code", "(", ")", ";", "$", "this", "->", "response", "->", "setStatusCode", "(", "$", "newStatusCode", ")", ";", "if", "(", "$", "statusCodeBefore", "!=", "$", "newStatusCode", ")", "{", "http_response_code", "(", "$", "statusCodeBefore", ")", ";", "}", "$", "headers", "=", "$", "this", "->", "cleanHeaders", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "response", "->", "headers", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}", "$", "this", "->", "encapsulated", "=", "false", ";", "if", "(", "$", "this", "->", "encapsulatedException", "!=", "null", ")", "{", "throw", "new", "JoomlaRequestException", "(", "\"Encapsulated request to joomla failed\"", ",", "0", ",", "$", "this", "->", "encapsulatedException", ")", ";", "}", "return", "$", "content", ";", "}" ]
This method executes code related to the Joomla code, and builds a correct response if required @return string @throws JoomlaRequestException If exception occurs in Jommla execution @author Maximilian Ruta <[email protected]>
[ "This", "method", "executes", "code", "related", "to", "the", "Joomla", "code", "and", "builds", "a", "correct", "response", "if", "required" ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Joomla/Joomla.php#L541-L601
5,362
kherge-abandoned/php-silex-wise
src/lib/Herrera/Wise/WiseServiceProvider.php
WiseServiceProvider.registerRoutes
public static function registerRoutes(Application $app) { $file = $app['wise.options']['config']['routes']; if ('prod' !== $app['wise.options']['mode']) { $file .= '_' . $app['wise.options']['mode']; } $file .= '.' . $app['wise.options']['type']; /** @var $wise Wise */ $wise = $app['wise']; $routes = $wise->load($file); $collection = new RouteCollection(); unset($routes['parameters']); unset($routes['imports']); foreach ($routes as $name => $route) { if (null === $route) { continue; } if (isset($route['pattern'])) { if (isset($route['path'])) { throw InvalidArgumentException::format( 'The "%s" route must not specify both "path" and "pattern".', $name ); } $route['path'] = $route['pattern']; } $unsupportedKeys = array_diff( array_keys($route), array_keys(self::$supportedKeys) ); if (!empty($unsupportedKeys)) { throw InvalidArgumentException::format( 'The "%s" route used unsupported keys (%s). Expected: %s', $name, join(', ', $unsupportedKeys), join(', ', array_keys(self::$supportedKeys)) ); } foreach (self::$supportedKeys as $key => $value) { if (!isset($route[$key])) { $route[$key] = $value; } } $collection->add( $name, new Route( $route['path'], $route['defaults'], $route['requirements'], $route['options'], $route['host'], $route['schemes'], $route['methods'] ) ); } /** @var $routes \Symfony\Component\Routing\RouteCollection */ $routes = $app['routes']; $routes->addCollection($collection); }
php
public static function registerRoutes(Application $app) { $file = $app['wise.options']['config']['routes']; if ('prod' !== $app['wise.options']['mode']) { $file .= '_' . $app['wise.options']['mode']; } $file .= '.' . $app['wise.options']['type']; /** @var $wise Wise */ $wise = $app['wise']; $routes = $wise->load($file); $collection = new RouteCollection(); unset($routes['parameters']); unset($routes['imports']); foreach ($routes as $name => $route) { if (null === $route) { continue; } if (isset($route['pattern'])) { if (isset($route['path'])) { throw InvalidArgumentException::format( 'The "%s" route must not specify both "path" and "pattern".', $name ); } $route['path'] = $route['pattern']; } $unsupportedKeys = array_diff( array_keys($route), array_keys(self::$supportedKeys) ); if (!empty($unsupportedKeys)) { throw InvalidArgumentException::format( 'The "%s" route used unsupported keys (%s). Expected: %s', $name, join(', ', $unsupportedKeys), join(', ', array_keys(self::$supportedKeys)) ); } foreach (self::$supportedKeys as $key => $value) { if (!isset($route[$key])) { $route[$key] = $value; } } $collection->add( $name, new Route( $route['path'], $route['defaults'], $route['requirements'], $route['options'], $route['host'], $route['schemes'], $route['methods'] ) ); } /** @var $routes \Symfony\Component\Routing\RouteCollection */ $routes = $app['routes']; $routes->addCollection($collection); }
[ "public", "static", "function", "registerRoutes", "(", "Application", "$", "app", ")", "{", "$", "file", "=", "$", "app", "[", "'wise.options'", "]", "[", "'config'", "]", "[", "'routes'", "]", ";", "if", "(", "'prod'", "!==", "$", "app", "[", "'wise.options'", "]", "[", "'mode'", "]", ")", "{", "$", "file", ".=", "'_'", ".", "$", "app", "[", "'wise.options'", "]", "[", "'mode'", "]", ";", "}", "$", "file", ".=", "'.'", ".", "$", "app", "[", "'wise.options'", "]", "[", "'type'", "]", ";", "/** @var $wise Wise */", "$", "wise", "=", "$", "app", "[", "'wise'", "]", ";", "$", "routes", "=", "$", "wise", "->", "load", "(", "$", "file", ")", ";", "$", "collection", "=", "new", "RouteCollection", "(", ")", ";", "unset", "(", "$", "routes", "[", "'parameters'", "]", ")", ";", "unset", "(", "$", "routes", "[", "'imports'", "]", ")", ";", "foreach", "(", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "if", "(", "null", "===", "$", "route", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "route", "[", "'pattern'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "route", "[", "'path'", "]", ")", ")", "{", "throw", "InvalidArgumentException", "::", "format", "(", "'The \"%s\" route must not specify both \"path\" and \"pattern\".'", ",", "$", "name", ")", ";", "}", "$", "route", "[", "'path'", "]", "=", "$", "route", "[", "'pattern'", "]", ";", "}", "$", "unsupportedKeys", "=", "array_diff", "(", "array_keys", "(", "$", "route", ")", ",", "array_keys", "(", "self", "::", "$", "supportedKeys", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "unsupportedKeys", ")", ")", "{", "throw", "InvalidArgumentException", "::", "format", "(", "'The \"%s\" route used unsupported keys (%s). Expected: %s'", ",", "$", "name", ",", "join", "(", "', '", ",", "$", "unsupportedKeys", ")", ",", "join", "(", "', '", ",", "array_keys", "(", "self", "::", "$", "supportedKeys", ")", ")", ")", ";", "}", "foreach", "(", "self", "::", "$", "supportedKeys", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "route", "[", "$", "key", "]", ")", ")", "{", "$", "route", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "collection", "->", "add", "(", "$", "name", ",", "new", "Route", "(", "$", "route", "[", "'path'", "]", ",", "$", "route", "[", "'defaults'", "]", ",", "$", "route", "[", "'requirements'", "]", ",", "$", "route", "[", "'options'", "]", ",", "$", "route", "[", "'host'", "]", ",", "$", "route", "[", "'schemes'", "]", ",", "$", "route", "[", "'methods'", "]", ")", ")", ";", "}", "/** @var $routes \\Symfony\\Component\\Routing\\RouteCollection */", "$", "routes", "=", "$", "app", "[", "'routes'", "]", ";", "$", "routes", "->", "addCollection", "(", "$", "collection", ")", ";", "}" ]
Registers the configured routes. @param Application $app The application. @throws InvalidArgumentException If a route definition is invalid.
[ "Registers", "the", "configured", "routes", "." ]
d1181e1dca2939eac8bb5687bcea548478b0db50
https://github.com/kherge-abandoned/php-silex-wise/blob/d1181e1dca2939eac8bb5687bcea548478b0db50/src/lib/Herrera/Wise/WiseServiceProvider.php#L165-L236
5,363
kherge-abandoned/php-silex-wise
src/lib/Herrera/Wise/WiseServiceProvider.php
WiseServiceProvider.registerServices
public static function registerServices(Application $app) { $file = $app['wise.options']['config']['services']; if ('prod' !== $app['wise.options']['mode']) { $file .= '_' . $app['wise.options']['mode']; } $file .= '.' . $app['wise.options']['type']; /** @var $wise Wise */ $wise = $app['wise']; $services = $wise->load($file); unset($services['parameters']); unset($services['imports']); foreach ($services as $name => $service) { if (null === $service) { continue; } if (!isset($service['class'])) { throw InvalidArgumentException::format( 'The service "%s" did not specify its "class".', $name ); } if (!isset($service['parameters'])) { $service['parameters'] = array(); } $app->register(new $service['class'](), $service['parameters']); } }
php
public static function registerServices(Application $app) { $file = $app['wise.options']['config']['services']; if ('prod' !== $app['wise.options']['mode']) { $file .= '_' . $app['wise.options']['mode']; } $file .= '.' . $app['wise.options']['type']; /** @var $wise Wise */ $wise = $app['wise']; $services = $wise->load($file); unset($services['parameters']); unset($services['imports']); foreach ($services as $name => $service) { if (null === $service) { continue; } if (!isset($service['class'])) { throw InvalidArgumentException::format( 'The service "%s" did not specify its "class".', $name ); } if (!isset($service['parameters'])) { $service['parameters'] = array(); } $app->register(new $service['class'](), $service['parameters']); } }
[ "public", "static", "function", "registerServices", "(", "Application", "$", "app", ")", "{", "$", "file", "=", "$", "app", "[", "'wise.options'", "]", "[", "'config'", "]", "[", "'services'", "]", ";", "if", "(", "'prod'", "!==", "$", "app", "[", "'wise.options'", "]", "[", "'mode'", "]", ")", "{", "$", "file", ".=", "'_'", ".", "$", "app", "[", "'wise.options'", "]", "[", "'mode'", "]", ";", "}", "$", "file", ".=", "'.'", ".", "$", "app", "[", "'wise.options'", "]", "[", "'type'", "]", ";", "/** @var $wise Wise */", "$", "wise", "=", "$", "app", "[", "'wise'", "]", ";", "$", "services", "=", "$", "wise", "->", "load", "(", "$", "file", ")", ";", "unset", "(", "$", "services", "[", "'parameters'", "]", ")", ";", "unset", "(", "$", "services", "[", "'imports'", "]", ")", ";", "foreach", "(", "$", "services", "as", "$", "name", "=>", "$", "service", ")", "{", "if", "(", "null", "===", "$", "service", ")", "{", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "service", "[", "'class'", "]", ")", ")", "{", "throw", "InvalidArgumentException", "::", "format", "(", "'The service \"%s\" did not specify its \"class\".'", ",", "$", "name", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "service", "[", "'parameters'", "]", ")", ")", "{", "$", "service", "[", "'parameters'", "]", "=", "array", "(", ")", ";", "}", "$", "app", "->", "register", "(", "new", "$", "service", "[", "'class'", "]", "(", ")", ",", "$", "service", "[", "'parameters'", "]", ")", ";", "}", "}" ]
Registers the configured services. @param Application $app The application. @throws InvalidArgumentException If a service definition is invalid.
[ "Registers", "the", "configured", "services", "." ]
d1181e1dca2939eac8bb5687bcea548478b0db50
https://github.com/kherge-abandoned/php-silex-wise/blob/d1181e1dca2939eac8bb5687bcea548478b0db50/src/lib/Herrera/Wise/WiseServiceProvider.php#L245-L280
5,364
novuso/common
src/Domain/EventSourcing/EventSourcedEntity.php
EventSourcedEntity.registerAggregateRoot
public function registerAggregateRoot(EventSourcedAggregateRoot $aggregateRoot): void { if ($this->aggregateRoot !== null && $this->aggregateRoot !== $aggregateRoot) { throw new DomainException('Aggregate root already registered'); } $this->aggregateRoot = $aggregateRoot; }
php
public function registerAggregateRoot(EventSourcedAggregateRoot $aggregateRoot): void { if ($this->aggregateRoot !== null && $this->aggregateRoot !== $aggregateRoot) { throw new DomainException('Aggregate root already registered'); } $this->aggregateRoot = $aggregateRoot; }
[ "public", "function", "registerAggregateRoot", "(", "EventSourcedAggregateRoot", "$", "aggregateRoot", ")", ":", "void", "{", "if", "(", "$", "this", "->", "aggregateRoot", "!==", "null", "&&", "$", "this", "->", "aggregateRoot", "!==", "$", "aggregateRoot", ")", "{", "throw", "new", "DomainException", "(", "'Aggregate root already registered'", ")", ";", "}", "$", "this", "->", "aggregateRoot", "=", "$", "aggregateRoot", ";", "}" ]
Registers the aggregate root @internal @param EventSourcedAggregateRoot $aggregateRoot The aggregate root @return void @throws DomainException
[ "Registers", "the", "aggregate", "root" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/EventSourcing/EventSourcedEntity.php#L38-L45
5,365
novuso/common
src/Domain/EventSourcing/EventSourcedEntity.php
EventSourcedEntity.handleRecursively
public function handleRecursively(Event $event): void { $this->handle($event); foreach ($this->childEntities() as $entity) { $entity->registerAggregateRoot($this->getAggregateRoot()); $entity->handleRecursively($event); } }
php
public function handleRecursively(Event $event): void { $this->handle($event); foreach ($this->childEntities() as $entity) { $entity->registerAggregateRoot($this->getAggregateRoot()); $entity->handleRecursively($event); } }
[ "public", "function", "handleRecursively", "(", "Event", "$", "event", ")", ":", "void", "{", "$", "this", "->", "handle", "(", "$", "event", ")", ";", "foreach", "(", "$", "this", "->", "childEntities", "(", ")", "as", "$", "entity", ")", "{", "$", "entity", "->", "registerAggregateRoot", "(", "$", "this", "->", "getAggregateRoot", "(", ")", ")", ";", "$", "entity", "->", "handleRecursively", "(", "$", "event", ")", ";", "}", "}" ]
Handles the domain event recursively @internal @param Event $event The domain event @return void
[ "Handles", "the", "domain", "event", "recursively" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/EventSourcing/EventSourcedEntity.php#L56-L64
5,366
novuso/common
src/Domain/EventSourcing/EventSourcedEntity.php
EventSourcedEntity.handle
protected function handle(Event $event): void { $method = 'apply'.ClassName::short($event); if (!method_exists($this, $method)) { return; } $this->$method($event); }
php
protected function handle(Event $event): void { $method = 'apply'.ClassName::short($event); if (!method_exists($this, $method)) { return; } $this->$method($event); }
[ "protected", "function", "handle", "(", "Event", "$", "event", ")", ":", "void", "{", "$", "method", "=", "'apply'", ".", "ClassName", "::", "short", "(", "$", "event", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", ";", "}", "$", "this", "->", "$", "method", "(", "$", "event", ")", ";", "}" ]
Handles event if the apply method is available This method delegates to a protected method based on the domain event class name: 'apply'.$className @param Event $event The domain event @return void
[ "Handles", "event", "if", "the", "apply", "method", "is", "available" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/EventSourcing/EventSourcedEntity.php#L76-L85
5,367
Solve/Inflector
Inflector.php
Inflector.transliterate
public static function transliterate($text, $direction = "en") { if ($direction == "en") { $text = str_replace(self::$_cyrillicTranslit, self::$_latinTranslit, $text); } else { $text = str_replace(self::$_latinTranslit, self::$_cyrillicTranslit, $text); } $text = preg_replace("#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e#", "\${1}e", $text); $text = preg_replace("#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]#", "\${1}'", $text); $text = preg_replace("#([ eyuioaEYUIOA-]+)[Kk]h#", "\${1}h", $text); $text = preg_replace("#^kh#", "h", $text); $text = preg_replace("#^Kh#", "H", $text); return $text; }
php
public static function transliterate($text, $direction = "en") { if ($direction == "en") { $text = str_replace(self::$_cyrillicTranslit, self::$_latinTranslit, $text); } else { $text = str_replace(self::$_latinTranslit, self::$_cyrillicTranslit, $text); } $text = preg_replace("#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e#", "\${1}e", $text); $text = preg_replace("#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]#", "\${1}'", $text); $text = preg_replace("#([ eyuioaEYUIOA-]+)[Kk]h#", "\${1}h", $text); $text = preg_replace("#^kh#", "h", $text); $text = preg_replace("#^Kh#", "H", $text); return $text; }
[ "public", "static", "function", "transliterate", "(", "$", "text", ",", "$", "direction", "=", "\"en\"", ")", "{", "if", "(", "$", "direction", "==", "\"en\"", ")", "{", "$", "text", "=", "str_replace", "(", "self", "::", "$", "_cyrillicTranslit", ",", "self", "::", "$", "_latinTranslit", ",", "$", "text", ")", ";", "}", "else", "{", "$", "text", "=", "str_replace", "(", "self", "::", "$", "_latinTranslit", ",", "self", "::", "$", "_cyrillicTranslit", ",", "$", "text", ")", ";", "}", "$", "text", "=", "preg_replace", "(", "\"#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]e#\"", ",", "\"\\${1}e\"", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "\"#([qwrtpsdfghklzxcvbnmQWRTPSDFGHKLZXCVBNM]+)[jJ]#\"", ",", "\"\\${1}'\"", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "\"#([ eyuioaEYUIOA-]+)[Kk]h#\"", ",", "\"\\${1}h\"", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "\"#^kh#\"", ",", "\"h\"", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "\"#^Kh#\"", ",", "\"H\"", ",", "$", "text", ")", ";", "return", "$", "text", ";", "}" ]
Do text transliteration @static @param string $text Text to transliteration @param string $direction "en" or "ru" @return string transliterated text
[ "Do", "text", "transliteration" ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L118-L132
5,368
Solve/Inflector
Inflector.php
Inflector.underscore
public static function underscore($text) { $pregRule = '#[A-Z]+#'; $text = preg_replace_callback($pregRule, function($match) { return "_" . strtolower($match[0]); }, $text); return self::slugify($text, '_'); }
php
public static function underscore($text) { $pregRule = '#[A-Z]+#'; $text = preg_replace_callback($pregRule, function($match) { return "_" . strtolower($match[0]); }, $text); return self::slugify($text, '_'); }
[ "public", "static", "function", "underscore", "(", "$", "text", ")", "{", "$", "pregRule", "=", "'#[A-Z]+#'", ";", "$", "text", "=", "preg_replace_callback", "(", "$", "pregRule", ",", "function", "(", "$", "match", ")", "{", "return", "\"_\"", ".", "strtolower", "(", "$", "match", "[", "0", "]", ")", ";", "}", ",", "$", "text", ")", ";", "return", "self", "::", "slugify", "(", "$", "text", ",", "'_'", ")", ";", "}" ]
Convert to underscored text @param $text @return string
[ "Convert", "to", "underscored", "text" ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L162-L167
5,369
Solve/Inflector
Inflector.php
Inflector.priceToStringLong
public static function priceToStringLong($price, $keepFloat = true, $currency = "uah", $language = null) { if ($language == null) $language = self::$_defaultLanguage; if (empty(self::$_numbersScript[$language]) || empty(self::$_numbersScript[$language]['sign'][$currency])) { trigger_error('You do not have a "'.$language.'/'.$currency.'" version for price labels. Add it via Inflector::addNumberLocalization'); } $segments = array_merge(self::$_numbersScript[$language]['sign'][$currency], self::$_numbersScript[$language]['segments']); return self::_numberToString($price, self::$_numbersScript[$language]['forms'], self::$_numbersScript[$language]['sex'], $segments, $keepFloat); }
php
public static function priceToStringLong($price, $keepFloat = true, $currency = "uah", $language = null) { if ($language == null) $language = self::$_defaultLanguage; if (empty(self::$_numbersScript[$language]) || empty(self::$_numbersScript[$language]['sign'][$currency])) { trigger_error('You do not have a "'.$language.'/'.$currency.'" version for price labels. Add it via Inflector::addNumberLocalization'); } $segments = array_merge(self::$_numbersScript[$language]['sign'][$currency], self::$_numbersScript[$language]['segments']); return self::_numberToString($price, self::$_numbersScript[$language]['forms'], self::$_numbersScript[$language]['sex'], $segments, $keepFloat); }
[ "public", "static", "function", "priceToStringLong", "(", "$", "price", ",", "$", "keepFloat", "=", "true", ",", "$", "currency", "=", "\"uah\"", ",", "$", "language", "=", "null", ")", "{", "if", "(", "$", "language", "==", "null", ")", "$", "language", "=", "self", "::", "$", "_defaultLanguage", ";", "if", "(", "empty", "(", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", ")", "||", "empty", "(", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", "[", "'sign'", "]", "[", "$", "currency", "]", ")", ")", "{", "trigger_error", "(", "'You do not have a \"'", ".", "$", "language", ".", "'/'", ".", "$", "currency", ".", "'\" version for price labels. Add it via Inflector::addNumberLocalization'", ")", ";", "}", "$", "segments", "=", "array_merge", "(", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", "[", "'sign'", "]", "[", "$", "currency", "]", ",", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", "[", "'segments'", "]", ")", ";", "return", "self", "::", "_numberToString", "(", "$", "price", ",", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", "[", "'forms'", "]", ",", "self", "::", "$", "_numbersScript", "[", "$", "language", "]", "[", "'sex'", "]", ",", "$", "segments", ",", "$", "keepFloat", ")", ";", "}" ]
Convert price to string and add localized money label @param $price @param bool $keepFloat @param string $currency @param string $language by default overwritten by Inflector's default language @return mixed
[ "Convert", "price", "to", "string", "and", "add", "localized", "money", "label" ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L401-L410
5,370
Solve/Inflector
Inflector.php
Inflector.dumpAsString
public static function dumpAsString($variable, $indentLevel = 0) { if (is_bool($variable)) { $result = $variable ? "true" : "false"; } elseif (is_null($variable)) { $result = "null"; } elseif (is_array($variable)) { $result = 'array ('; foreach($variable as $key=>$item) { $result .= "\n". str_repeat(" ", ($indentLevel+1)*4); $result .= self::dumpAsString($key, $indentLevel+1); $result .= ' => '; $result .= self::dumpAsString($item, $indentLevel+1).','; } $result .= "\n".str_repeat(" ", ($indentLevel)*4).')'; } elseif(is_string($variable) && (isset($variable[0]) && $variable[0] != '$')) { $result = '"'. (strpos($variable, '$__lv') === false ? str_replace('"', '\"', $variable) : $variable) .'"'; } else { $result = $variable; } return $result; }
php
public static function dumpAsString($variable, $indentLevel = 0) { if (is_bool($variable)) { $result = $variable ? "true" : "false"; } elseif (is_null($variable)) { $result = "null"; } elseif (is_array($variable)) { $result = 'array ('; foreach($variable as $key=>$item) { $result .= "\n". str_repeat(" ", ($indentLevel+1)*4); $result .= self::dumpAsString($key, $indentLevel+1); $result .= ' => '; $result .= self::dumpAsString($item, $indentLevel+1).','; } $result .= "\n".str_repeat(" ", ($indentLevel)*4).')'; } elseif(is_string($variable) && (isset($variable[0]) && $variable[0] != '$')) { $result = '"'. (strpos($variable, '$__lv') === false ? str_replace('"', '\"', $variable) : $variable) .'"'; } else { $result = $variable; } return $result; }
[ "public", "static", "function", "dumpAsString", "(", "$", "variable", ",", "$", "indentLevel", "=", "0", ")", "{", "if", "(", "is_bool", "(", "$", "variable", ")", ")", "{", "$", "result", "=", "$", "variable", "?", "\"true\"", ":", "\"false\"", ";", "}", "elseif", "(", "is_null", "(", "$", "variable", ")", ")", "{", "$", "result", "=", "\"null\"", ";", "}", "elseif", "(", "is_array", "(", "$", "variable", ")", ")", "{", "$", "result", "=", "'array ('", ";", "foreach", "(", "$", "variable", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "result", ".=", "\"\\n\"", ".", "str_repeat", "(", "\" \"", ",", "(", "$", "indentLevel", "+", "1", ")", "*", "4", ")", ";", "$", "result", ".=", "self", "::", "dumpAsString", "(", "$", "key", ",", "$", "indentLevel", "+", "1", ")", ";", "$", "result", ".=", "' => '", ";", "$", "result", ".=", "self", "::", "dumpAsString", "(", "$", "item", ",", "$", "indentLevel", "+", "1", ")", ".", "','", ";", "}", "$", "result", ".=", "\"\\n\"", ".", "str_repeat", "(", "\" \"", ",", "(", "$", "indentLevel", ")", "*", "4", ")", ".", "')'", ";", "}", "elseif", "(", "is_string", "(", "$", "variable", ")", "&&", "(", "isset", "(", "$", "variable", "[", "0", "]", ")", "&&", "$", "variable", "[", "0", "]", "!=", "'$'", ")", ")", "{", "$", "result", "=", "'\"'", ".", "(", "strpos", "(", "$", "variable", ",", "'$__lv'", ")", "===", "false", "?", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "$", "variable", ")", ":", "$", "variable", ")", ".", "'\"'", ";", "}", "else", "{", "$", "result", "=", "$", "variable", ";", "}", "return", "$", "result", ";", "}" ]
Return PHP-style variable dump @param $variable @param int $indentLevel @return string
[ "Return", "PHP", "-", "style", "variable", "dump" ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L439-L462
5,371
Solve/Inflector
Inflector.php
Inflector.dumperGet
public static function dumperGet(&$variable, $spacing = "") { if (is_array($variable)) { $type = "Array[" . count( $variable ) . "]"; } elseif( is_object( $variable ) ) { ob_start(); print_r($variable); return ob_get_clean(); } elseif( gettype( $variable ) == "boolean" ) { return $variable ? "true" : "false"; } elseif( is_null( $variable ) ) { return "NULL"; } else { ob_start(); var_dump($variable); return ob_get_clean(); } $buf = $type; $spacing .= " "; for (reset( $variable ); list ( $k, $v ) = each( $variable );) { if ($k === "GLOBALS" ) continue; $buf .= "\n".$spacing.'['.$k.'] => ' . self::dumperGet( $v, $spacing); } return $buf; }
php
public static function dumperGet(&$variable, $spacing = "") { if (is_array($variable)) { $type = "Array[" . count( $variable ) . "]"; } elseif( is_object( $variable ) ) { ob_start(); print_r($variable); return ob_get_clean(); } elseif( gettype( $variable ) == "boolean" ) { return $variable ? "true" : "false"; } elseif( is_null( $variable ) ) { return "NULL"; } else { ob_start(); var_dump($variable); return ob_get_clean(); } $buf = $type; $spacing .= " "; for (reset( $variable ); list ( $k, $v ) = each( $variable );) { if ($k === "GLOBALS" ) continue; $buf .= "\n".$spacing.'['.$k.'] => ' . self::dumperGet( $v, $spacing); } return $buf; }
[ "public", "static", "function", "dumperGet", "(", "&", "$", "variable", ",", "$", "spacing", "=", "\"\"", ")", "{", "if", "(", "is_array", "(", "$", "variable", ")", ")", "{", "$", "type", "=", "\"Array[\"", ".", "count", "(", "$", "variable", ")", ".", "\"]\"", ";", "}", "elseif", "(", "is_object", "(", "$", "variable", ")", ")", "{", "ob_start", "(", ")", ";", "print_r", "(", "$", "variable", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}", "elseif", "(", "gettype", "(", "$", "variable", ")", "==", "\"boolean\"", ")", "{", "return", "$", "variable", "?", "\"true\"", ":", "\"false\"", ";", "}", "elseif", "(", "is_null", "(", "$", "variable", ")", ")", "{", "return", "\"NULL\"", ";", "}", "else", "{", "ob_start", "(", ")", ";", "var_dump", "(", "$", "variable", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}", "$", "buf", "=", "$", "type", ";", "$", "spacing", ".=", "\" \"", ";", "for", "(", "reset", "(", "$", "variable", ")", ";", "list", "(", "$", "k", ",", "$", "v", ")", "=", "each", "(", "$", "variable", ")", ";", ")", "{", "if", "(", "$", "k", "===", "\"GLOBALS\"", ")", "continue", ";", "$", "buf", ".=", "\"\\n\"", ".", "$", "spacing", ".", "'['", ".", "$", "k", ".", "'] => '", ".", "self", "::", "dumperGet", "(", "$", "v", ",", "$", "spacing", ")", ";", "}", "return", "$", "buf", ";", "}" ]
Using for beautify output @param $variable @param string $spacing @return string
[ "Using", "for", "beautify", "output" ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L470-L496
5,372
Solve/Inflector
Inflector.php
Inflector._getMorphed
private static function _getMorphed($n, $f1, $f2, $f5) { $n = abs($n) % 100; $n1 = $n % 10; if ($n > 10 && $n < 20) return $f5; if ($n1 > 1 && $n1 < 5) return $f2; if ($n1 == 1) return $f1; return $f5; }
php
private static function _getMorphed($n, $f1, $f2, $f5) { $n = abs($n) % 100; $n1 = $n % 10; if ($n > 10 && $n < 20) return $f5; if ($n1 > 1 && $n1 < 5) return $f2; if ($n1 == 1) return $f1; return $f5; }
[ "private", "static", "function", "_getMorphed", "(", "$", "n", ",", "$", "f1", ",", "$", "f2", ",", "$", "f5", ")", "{", "$", "n", "=", "abs", "(", "$", "n", ")", "%", "100", ";", "$", "n1", "=", "$", "n", "%", "10", ";", "if", "(", "$", "n", ">", "10", "&&", "$", "n", "<", "20", ")", "return", "$", "f5", ";", "if", "(", "$", "n1", ">", "1", "&&", "$", "n1", "<", "5", ")", "return", "$", "f2", ";", "if", "(", "$", "n1", "==", "1", ")", "return", "$", "f1", ";", "return", "$", "f5", ";", "}" ]
For internal use. Morphing words. @static @param $n @param $f1 @param $f2 @param $f5 @return mixed
[ "For", "internal", "use", ".", "Morphing", "words", "." ]
0d588ae68116d93f7dcf17a3f35235b2881d5f69
https://github.com/Solve/Inflector/blob/0d588ae68116d93f7dcf17a3f35235b2881d5f69/Inflector.php#L573-L581
5,373
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.getConnectedAccount
public function getConnectedAccount($qualifier = null) { if (!$qualifier) $qualifier = $this->getConnectionQualifier(); if (!$qualifier) return null; return $this->getDocument()->getGraph()->getNode($this->getAAUID().':account:'.$qualifier); }
php
public function getConnectedAccount($qualifier = null) { if (!$qualifier) $qualifier = $this->getConnectionQualifier(); if (!$qualifier) return null; return $this->getDocument()->getGraph()->getNode($this->getAAUID().':account:'.$qualifier); }
[ "public", "function", "getConnectedAccount", "(", "$", "qualifier", "=", "null", ")", "{", "if", "(", "!", "$", "qualifier", ")", "$", "qualifier", "=", "$", "this", "->", "getConnectionQualifier", "(", ")", ";", "if", "(", "!", "$", "qualifier", ")", "return", "null", ";", "return", "$", "this", "->", "getDocument", "(", ")", "->", "getGraph", "(", ")", "->", "getNode", "(", "$", "this", "->", "getAAUID", "(", ")", ".", "':account:'", ".", "$", "qualifier", ")", ";", "}" ]
Get a connected account. @param $qualifier The qualifier for the account connection. If not specified, uses the connection qualifier.
[ "Get", "a", "connected", "account", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L213-L217
5,374
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.getConnectedAccountForService
public function getConnectedAccountForService($service) { $accounts = $this->getDocument()->getGraph()->getNodesByType('coid://accountgateways.cloudobjects.io/Account'); foreach ($accounts as $a) { if ($a->getProperty('coid://accountgateways.cloudobjects.io/isForService') && $a->getProperty('coid://accountgateways.cloudobjects.io/isForService')->getId()==$service) return $a; } return null; }
php
public function getConnectedAccountForService($service) { $accounts = $this->getDocument()->getGraph()->getNodesByType('coid://accountgateways.cloudobjects.io/Account'); foreach ($accounts as $a) { if ($a->getProperty('coid://accountgateways.cloudobjects.io/isForService') && $a->getProperty('coid://accountgateways.cloudobjects.io/isForService')->getId()==$service) return $a; } return null; }
[ "public", "function", "getConnectedAccountForService", "(", "$", "service", ")", "{", "$", "accounts", "=", "$", "this", "->", "getDocument", "(", ")", "->", "getGraph", "(", ")", "->", "getNodesByType", "(", "'coid://accountgateways.cloudobjects.io/Account'", ")", ";", "foreach", "(", "$", "accounts", "as", "$", "a", ")", "{", "if", "(", "$", "a", "->", "getProperty", "(", "'coid://accountgateways.cloudobjects.io/isForService'", ")", "&&", "$", "a", "->", "getProperty", "(", "'coid://accountgateways.cloudobjects.io/isForService'", ")", "->", "getId", "(", ")", "==", "$", "service", ")", "return", "$", "a", ";", "}", "return", "null", ";", "}" ]
Get the connected account for a service. @param $service COID of the service
[ "Get", "the", "connected", "account", "for", "a", "service", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L233-L240
5,375
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.getAllAccountConnections
public function getAllAccountConnections() { $connections = $this->getAccount()->getProperty('coid://accountgateways.cloudobjects.io/hasConnection'); if (!is_array($connections)) $connections = array($connections); return $connections; }
php
public function getAllAccountConnections() { $connections = $this->getAccount()->getProperty('coid://accountgateways.cloudobjects.io/hasConnection'); if (!is_array($connections)) $connections = array($connections); return $connections; }
[ "public", "function", "getAllAccountConnections", "(", ")", "{", "$", "connections", "=", "$", "this", "->", "getAccount", "(", ")", "->", "getProperty", "(", "'coid://accountgateways.cloudobjects.io/hasConnection'", ")", ";", "if", "(", "!", "is_array", "(", "$", "connections", ")", ")", "$", "connections", "=", "array", "(", "$", "connections", ")", ";", "return", "$", "connections", ";", "}" ]
Get all account connections.
[ "Get", "all", "account", "connections", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L245-L249
5,376
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.getAllConnectedAccounts
public function getAllConnectedAccounts() { $accounts = array(); foreach ($this->getAllAccountConnections() as $ac) { $accounts[] = $ac->getProperty('coid://accountgateways.cloudobjects.io/connectsTo'); } return $accounts; }
php
public function getAllConnectedAccounts() { $accounts = array(); foreach ($this->getAllAccountConnections() as $ac) { $accounts[] = $ac->getProperty('coid://accountgateways.cloudobjects.io/connectsTo'); } return $accounts; }
[ "public", "function", "getAllConnectedAccounts", "(", ")", "{", "$", "accounts", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAllAccountConnections", "(", ")", "as", "$", "ac", ")", "{", "$", "accounts", "[", "]", "=", "$", "ac", "->", "getProperty", "(", "'coid://accountgateways.cloudobjects.io/connectsTo'", ")", ";", "}", "return", "$", "accounts", ";", "}" ]
Get all connected accounts.
[ "Get", "all", "connected", "accounts", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L254-L260
5,377
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.getClient
public function getClient() { if (!$this->client) { // Create custom handler stack with middlewares $stack = HandlerStack::create(); $context = $this; $stack->push(Middleware::mapResponse(function (ResponseInterface $response) use ($context) { // If a new version of this accessor is available, store its COID if ($response->hasHeader('C-Accessor-Latest-Version')) $context->setLatestAccessorVersionCOID( new IRI($response->getHeaderLine('C-Accessor-Latest-Version'))); return $response; })); // Prepare client options $options = [ 'base_uri' => str_replace('{aauid}', AAUIDParser::getAAUID($this->getAAUID()), $this->agwBaseUrl), 'headers' => [ 'Authorization' => 'Bearer '.$this->getAccessToken() ], 'handler' => $stack ]; if (isset($this->request) && $this->request->hasHeader('X-Forwarded-For')) { $options['headers']['X-Forwarded-For'] = $this->request->getHeaderLine('X-Forwarded-For'); } // Create client $this->client = new Client($options); } return $this->client; }
php
public function getClient() { if (!$this->client) { // Create custom handler stack with middlewares $stack = HandlerStack::create(); $context = $this; $stack->push(Middleware::mapResponse(function (ResponseInterface $response) use ($context) { // If a new version of this accessor is available, store its COID if ($response->hasHeader('C-Accessor-Latest-Version')) $context->setLatestAccessorVersionCOID( new IRI($response->getHeaderLine('C-Accessor-Latest-Version'))); return $response; })); // Prepare client options $options = [ 'base_uri' => str_replace('{aauid}', AAUIDParser::getAAUID($this->getAAUID()), $this->agwBaseUrl), 'headers' => [ 'Authorization' => 'Bearer '.$this->getAccessToken() ], 'handler' => $stack ]; if (isset($this->request) && $this->request->hasHeader('X-Forwarded-For')) { $options['headers']['X-Forwarded-For'] = $this->request->getHeaderLine('X-Forwarded-For'); } // Create client $this->client = new Client($options); } return $this->client; }
[ "public", "function", "getClient", "(", ")", "{", "if", "(", "!", "$", "this", "->", "client", ")", "{", "// Create custom handler stack with middlewares", "$", "stack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "context", "=", "$", "this", ";", "$", "stack", "->", "push", "(", "Middleware", "::", "mapResponse", "(", "function", "(", "ResponseInterface", "$", "response", ")", "use", "(", "$", "context", ")", "{", "// If a new version of this accessor is available, store its COID", "if", "(", "$", "response", "->", "hasHeader", "(", "'C-Accessor-Latest-Version'", ")", ")", "$", "context", "->", "setLatestAccessorVersionCOID", "(", "new", "IRI", "(", "$", "response", "->", "getHeaderLine", "(", "'C-Accessor-Latest-Version'", ")", ")", ")", ";", "return", "$", "response", ";", "}", ")", ")", ";", "// Prepare client options", "$", "options", "=", "[", "'base_uri'", "=>", "str_replace", "(", "'{aauid}'", ",", "AAUIDParser", "::", "getAAUID", "(", "$", "this", "->", "getAAUID", "(", ")", ")", ",", "$", "this", "->", "agwBaseUrl", ")", ",", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "getAccessToken", "(", ")", "]", ",", "'handler'", "=>", "$", "stack", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "request", ")", "&&", "$", "this", "->", "request", "->", "hasHeader", "(", "'X-Forwarded-For'", ")", ")", "{", "$", "options", "[", "'headers'", "]", "[", "'X-Forwarded-For'", "]", "=", "$", "this", "->", "request", "->", "getHeaderLine", "(", "'X-Forwarded-For'", ")", ";", "}", "// Create client", "$", "this", "->", "client", "=", "new", "Client", "(", "$", "options", ")", ";", "}", "return", "$", "this", "->", "client", ";", "}" ]
Get a preconfigured Guzzle client to access the Account Gateway. @return Client
[ "Get", "a", "preconfigured", "Guzzle", "client", "to", "access", "the", "Account", "Gateway", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L286-L316
5,378
CloudObjects/CloudObjects-PHP-SDK
CloudObjects/SDK/AccountGateway/AccountContext.php
AccountContext.processResponse
public function processResponse(Response $response) { if ($this->logCode) { $response->headers->set('C-Code-For-Logger', $this->logCode); } }
php
public function processResponse(Response $response) { if ($this->logCode) { $response->headers->set('C-Code-For-Logger', $this->logCode); } }
[ "public", "function", "processResponse", "(", "Response", "$", "response", ")", "{", "if", "(", "$", "this", "->", "logCode", ")", "{", "$", "response", "->", "headers", "->", "set", "(", "'C-Code-For-Logger'", ",", "$", "this", "->", "logCode", ")", ";", "}", "}" ]
Process a response and add headers if applicable.
[ "Process", "a", "response", "and", "add", "headers", "if", "applicable", "." ]
4f97f523cdab7501728ad0505e51435f727f6785
https://github.com/CloudObjects/CloudObjects-PHP-SDK/blob/4f97f523cdab7501728ad0505e51435f727f6785/CloudObjects/SDK/AccountGateway/AccountContext.php#L331-L335
5,379
Celarius/nofuzz-framework
src/Http/Client.php
Client.createClient
protected function createClient(array $opts=[]) { if ( !$this->guzzleClient ) { $this->guzzleClient = new \GuzzleHttp\Client(); $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar(); } return $this->guzzleClient; }
php
protected function createClient(array $opts=[]) { if ( !$this->guzzleClient ) { $this->guzzleClient = new \GuzzleHttp\Client(); $this->cookieJar = new \GuzzleHttp\Cookie\CookieJar(); } return $this->guzzleClient; }
[ "protected", "function", "createClient", "(", "array", "$", "opts", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "guzzleClient", ")", "{", "$", "this", "->", "guzzleClient", "=", "new", "\\", "GuzzleHttp", "\\", "Client", "(", ")", ";", "$", "this", "->", "cookieJar", "=", "new", "\\", "GuzzleHttp", "\\", "Cookie", "\\", "CookieJar", "(", ")", ";", "}", "return", "$", "this", "->", "guzzleClient", ";", "}" ]
Create the internal GuzzleHttp\Client @param array $opts [description] @return object
[ "Create", "the", "internal", "GuzzleHttp", "\\", "Client" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Http/Client.php#L57-L65
5,380
Celarius/nofuzz-framework
src/Http/Client.php
Client.createRequest
public function createRequest(string $method, string $url, $body=null, array $headers=[]) { # Merge Default Headers with user provided headers $headers = array_merge( [ 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, deflate' ], $headers ); # Create the httpRequest $this->httpRequest = new \GuzzleHttp\Psr7\Request( $method, $url, $headers, $body ); return $this->httpRequest; }
php
public function createRequest(string $method, string $url, $body=null, array $headers=[]) { # Merge Default Headers with user provided headers $headers = array_merge( [ 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, deflate' ], $headers ); # Create the httpRequest $this->httpRequest = new \GuzzleHttp\Psr7\Request( $method, $url, $headers, $body ); return $this->httpRequest; }
[ "public", "function", "createRequest", "(", "string", "$", "method", ",", "string", "$", "url", ",", "$", "body", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "# Merge Default Headers with user provided headers", "$", "headers", "=", "array_merge", "(", "[", "'Accept'", "=>", "'*/*'", ",", "'Accept-Encoding'", "=>", "'gzip, deflate'", "]", ",", "$", "headers", ")", ";", "# Create the httpRequest", "$", "this", "->", "httpRequest", "=", "new", "\\", "GuzzleHttp", "\\", "Psr7", "\\", "Request", "(", "$", "method", ",", "$", "url", ",", "$", "headers", ",", "$", "body", ")", ";", "return", "$", "this", "->", "httpRequest", ";", "}" ]
Creates & returns a GuzzleHttp\Request @param string $method [description] @param string $url [description] @param mixed $body [description] @param array $headers [description] @return object
[ "Creates", "&", "returns", "a", "GuzzleHttp", "\\", "Request" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Http/Client.php#L76-L91
5,381
Celarius/nofuzz-framework
src/Http/Client.php
Client.sendRequest
public function sendRequest(\GuzzleHttp\Psr7\Request $request, array $opts=[]) { # Set params $retriesLeft = $this->retries; $this->lastErrorStr = ''; # Retry loop while ( $retriesLeft>0 ) { # Decrease retry count $retriesLeft--; $this->timeStart = 0; $this->timeHeaders = 0; $this->timeResponse = 0; try { # Make sure we have a GuzzleHttp\Client $this->createClient($this->opts); $this->timeStart = microtime(true); # Request Options $opts = array_merge( [ 'http_errors' => true, // Exceptions on 4xx response codes 'connect_timeout' => $this->getTimeoutConnect(), // Connect Timeout (seconds) 'timeout' => $this->getTimeoutReceive(), // Receive Timeout (seconds) 'verify' => false // Disable SSL verification (handle self generated SSL certs) ] ,$this->getRequestOptions() ); $sendOpts = array_merge([ 'on_headers' => function (\GuzzleHttp\Psr7\Response $response) { $this->timeHeaders = microtime(true)-$this->timeStart; }, 'synchronous' => true, 'cookies' => $this->cookieJar, 'debug' => false // 'on_headers' => function ( \Psr\Http\Message\ResponseInterface $response ) { // error_log( print_r($response->getHeaders(), true) ); // }, // 'on_stats' => function ( \GuzzleHttp\TransferStats $status ) { // error_log( $status->getTransferTime().' - '.print_r($status->getHandlerStats(),true) ); // } ],$opts ); # Send the Request $this->httpResponse = $this->guzzleClient->send($request, $sendOpts); # Successful response, break the loop $retriesLeft = 0; } catch (\GuzzleHttp\Exception\ConnectException $e) { # Network errors # # Note: For "Host not found", "DNS failure", "Network errors" etc. # we might not have a Response Object! # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # No point in retrying $retriesLeft = 0; } catch (\GuzzleHttp\Exception\BadResponseException $e) { # 4xx (ClientException) # 5xx (ServerException) # # Note: We have a response object available, meaning the target service responded # so no retry needed (and it exists so no SDR reporting) # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # Break the while loop (no retries for this error) $retriesLeft = 0; } catch (\GuzzleHttp\Exception\RequestException $e) { # Also Catches # TooManyRedirectsException # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # Should we do a retry? if ($retriesLeft>0) { $_sec = 0.1; // 0.1 seconds = 100 ms usleep($_sec * 1000000); unset($_sec); } } catch (\Exception $e) { # General exception # # Set error String $this->lastErrorStr = $e->getMessage(); # Break the while loop (no retries for this error) $retriesLeft = 0; } finally { $this->timeResponse = microtime(true) - $this->timeStart; } } // while return $this->httpResponse; }
php
public function sendRequest(\GuzzleHttp\Psr7\Request $request, array $opts=[]) { # Set params $retriesLeft = $this->retries; $this->lastErrorStr = ''; # Retry loop while ( $retriesLeft>0 ) { # Decrease retry count $retriesLeft--; $this->timeStart = 0; $this->timeHeaders = 0; $this->timeResponse = 0; try { # Make sure we have a GuzzleHttp\Client $this->createClient($this->opts); $this->timeStart = microtime(true); # Request Options $opts = array_merge( [ 'http_errors' => true, // Exceptions on 4xx response codes 'connect_timeout' => $this->getTimeoutConnect(), // Connect Timeout (seconds) 'timeout' => $this->getTimeoutReceive(), // Receive Timeout (seconds) 'verify' => false // Disable SSL verification (handle self generated SSL certs) ] ,$this->getRequestOptions() ); $sendOpts = array_merge([ 'on_headers' => function (\GuzzleHttp\Psr7\Response $response) { $this->timeHeaders = microtime(true)-$this->timeStart; }, 'synchronous' => true, 'cookies' => $this->cookieJar, 'debug' => false // 'on_headers' => function ( \Psr\Http\Message\ResponseInterface $response ) { // error_log( print_r($response->getHeaders(), true) ); // }, // 'on_stats' => function ( \GuzzleHttp\TransferStats $status ) { // error_log( $status->getTransferTime().' - '.print_r($status->getHandlerStats(),true) ); // } ],$opts ); # Send the Request $this->httpResponse = $this->guzzleClient->send($request, $sendOpts); # Successful response, break the loop $retriesLeft = 0; } catch (\GuzzleHttp\Exception\ConnectException $e) { # Network errors # # Note: For "Host not found", "DNS failure", "Network errors" etc. # we might not have a Response Object! # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # No point in retrying $retriesLeft = 0; } catch (\GuzzleHttp\Exception\BadResponseException $e) { # 4xx (ClientException) # 5xx (ServerException) # # Note: We have a response object available, meaning the target service responded # so no retry needed (and it exists so no SDR reporting) # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # Break the while loop (no retries for this error) $retriesLeft = 0; } catch (\GuzzleHttp\Exception\RequestException $e) { # Also Catches # TooManyRedirectsException # Set error String $this->lastErrorStr = $e->getMessage(); # Get the Response Object from the Exception if ( $e->hasResponse() ) { $this->httpResponse = $e->getResponse(); } # Should we do a retry? if ($retriesLeft>0) { $_sec = 0.1; // 0.1 seconds = 100 ms usleep($_sec * 1000000); unset($_sec); } } catch (\Exception $e) { # General exception # # Set error String $this->lastErrorStr = $e->getMessage(); # Break the while loop (no retries for this error) $retriesLeft = 0; } finally { $this->timeResponse = microtime(true) - $this->timeStart; } } // while return $this->httpResponse; }
[ "public", "function", "sendRequest", "(", "\\", "GuzzleHttp", "\\", "Psr7", "\\", "Request", "$", "request", ",", "array", "$", "opts", "=", "[", "]", ")", "{", "# Set params", "$", "retriesLeft", "=", "$", "this", "->", "retries", ";", "$", "this", "->", "lastErrorStr", "=", "''", ";", "# Retry loop", "while", "(", "$", "retriesLeft", ">", "0", ")", "{", "# Decrease retry count", "$", "retriesLeft", "--", ";", "$", "this", "->", "timeStart", "=", "0", ";", "$", "this", "->", "timeHeaders", "=", "0", ";", "$", "this", "->", "timeResponse", "=", "0", ";", "try", "{", "# Make sure we have a GuzzleHttp\\Client", "$", "this", "->", "createClient", "(", "$", "this", "->", "opts", ")", ";", "$", "this", "->", "timeStart", "=", "microtime", "(", "true", ")", ";", "# Request Options", "$", "opts", "=", "array_merge", "(", "[", "'http_errors'", "=>", "true", ",", "// Exceptions on 4xx response codes", "'connect_timeout'", "=>", "$", "this", "->", "getTimeoutConnect", "(", ")", ",", "// Connect Timeout (seconds)", "'timeout'", "=>", "$", "this", "->", "getTimeoutReceive", "(", ")", ",", "// Receive Timeout (seconds)", "'verify'", "=>", "false", "// Disable SSL verification (handle self generated SSL certs)", "]", ",", "$", "this", "->", "getRequestOptions", "(", ")", ")", ";", "$", "sendOpts", "=", "array_merge", "(", "[", "'on_headers'", "=>", "function", "(", "\\", "GuzzleHttp", "\\", "Psr7", "\\", "Response", "$", "response", ")", "{", "$", "this", "->", "timeHeaders", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "timeStart", ";", "}", ",", "'synchronous'", "=>", "true", ",", "'cookies'", "=>", "$", "this", "->", "cookieJar", ",", "'debug'", "=>", "false", "// 'on_headers' => function ( \\Psr\\Http\\Message\\ResponseInterface $response ) {", "// error_log( print_r($response->getHeaders(), true) );", "// },", "// 'on_stats' => function ( \\GuzzleHttp\\TransferStats $status ) {", "// error_log( $status->getTransferTime().' - '.print_r($status->getHandlerStats(),true) );", "// }", "]", ",", "$", "opts", ")", ";", "# Send the Request", "$", "this", "->", "httpResponse", "=", "$", "this", "->", "guzzleClient", "->", "send", "(", "$", "request", ",", "$", "sendOpts", ")", ";", "# Successful response, break the loop", "$", "retriesLeft", "=", "0", ";", "}", "catch", "(", "\\", "GuzzleHttp", "\\", "Exception", "\\", "ConnectException", "$", "e", ")", "{", "# Network errors", "#", "# Note: For \"Host not found\", \"DNS failure\", \"Network errors\" etc.", "# we might not have a Response Object!", "# Set error String", "$", "this", "->", "lastErrorStr", "=", "$", "e", "->", "getMessage", "(", ")", ";", "# Get the Response Object from the Exception", "if", "(", "$", "e", "->", "hasResponse", "(", ")", ")", "{", "$", "this", "->", "httpResponse", "=", "$", "e", "->", "getResponse", "(", ")", ";", "}", "# No point in retrying", "$", "retriesLeft", "=", "0", ";", "}", "catch", "(", "\\", "GuzzleHttp", "\\", "Exception", "\\", "BadResponseException", "$", "e", ")", "{", "# 4xx (ClientException)", "# 5xx (ServerException)", "#", "# Note: We have a response object available, meaning the target service responded", "# so no retry needed (and it exists so no SDR reporting)", "# Set error String", "$", "this", "->", "lastErrorStr", "=", "$", "e", "->", "getMessage", "(", ")", ";", "# Get the Response Object from the Exception", "if", "(", "$", "e", "->", "hasResponse", "(", ")", ")", "{", "$", "this", "->", "httpResponse", "=", "$", "e", "->", "getResponse", "(", ")", ";", "}", "# Break the while loop (no retries for this error)", "$", "retriesLeft", "=", "0", ";", "}", "catch", "(", "\\", "GuzzleHttp", "\\", "Exception", "\\", "RequestException", "$", "e", ")", "{", "# Also Catches", "# TooManyRedirectsException", "# Set error String", "$", "this", "->", "lastErrorStr", "=", "$", "e", "->", "getMessage", "(", ")", ";", "# Get the Response Object from the Exception", "if", "(", "$", "e", "->", "hasResponse", "(", ")", ")", "{", "$", "this", "->", "httpResponse", "=", "$", "e", "->", "getResponse", "(", ")", ";", "}", "# Should we do a retry?", "if", "(", "$", "retriesLeft", ">", "0", ")", "{", "$", "_sec", "=", "0.1", ";", "// 0.1 seconds = 100 ms", "usleep", "(", "$", "_sec", "*", "1000000", ")", ";", "unset", "(", "$", "_sec", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "# General exception", "#", "# Set error String", "$", "this", "->", "lastErrorStr", "=", "$", "e", "->", "getMessage", "(", ")", ";", "# Break the while loop (no retries for this error)", "$", "retriesLeft", "=", "0", ";", "}", "finally", "{", "$", "this", "->", "timeResponse", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "timeStart", ";", "}", "}", "// while", "return", "$", "this", "->", "httpResponse", ";", "}" ]
Send a GuzzleHttp\Request @param \GuzzleHttp\Psr7\Request $request @param array $opts Guzzle Send Options @return \GuzzleHttp\Response
[ "Send", "a", "GuzzleHttp", "\\", "Request" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Http/Client.php#L100-L226
5,382
Celarius/nofuzz-framework
src/Http/Client.php
Client.custom
public function custom(string $method, string $uri, string $body='', array $headers=[]) { $this->sendRequest($this->createRequest($method,$uri), $headers); return !is_null($this->getResponse()); }
php
public function custom(string $method, string $uri, string $body='', array $headers=[]) { $this->sendRequest($this->createRequest($method,$uri), $headers); return !is_null($this->getResponse()); }
[ "public", "function", "custom", "(", "string", "$", "method", ",", "string", "$", "uri", ",", "string", "$", "body", "=", "''", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "$", "this", "->", "sendRequest", "(", "$", "this", "->", "createRequest", "(", "$", "method", ",", "$", "uri", ")", ",", "$", "headers", ")", ";", "return", "!", "is_null", "(", "$", "this", "->", "getResponse", "(", ")", ")", ";", "}" ]
Send a custom HTTP request @param string $uri The uri to call in the service @param array $headers The http headers @return bool True for success
[ "Send", "a", "custom", "HTTP", "request" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Http/Client.php#L321-L326
5,383
coolms/common
src/Filter/BindableClosure.php
BindableClosure.setCallback
public function setCallback($callback) { if (!$callback instanceof Closure) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid parameter for callback: must be %s', Closure::class )); } return parent::setCallback($callback); }
php
public function setCallback($callback) { if (!$callback instanceof Closure) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid parameter for callback: must be %s', Closure::class )); } return parent::setCallback($callback); }
[ "public", "function", "setCallback", "(", "$", "callback", ")", "{", "if", "(", "!", "$", "callback", "instanceof", "Closure", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid parameter for callback: must be %s'", ",", "Closure", "::", "class", ")", ")", ";", "}", "return", "parent", "::", "setCallback", "(", "$", "callback", ")", ";", "}" ]
Sets a new Closure for this filter @param Closure $callback @throws Exception\InvalidArgumentException @return self
[ "Sets", "a", "new", "Closure", "for", "this", "filter" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Filter/BindableClosure.php#L26-L36
5,384
Flowpack/Flowpack.SingleSignOn.Client
Classes/Flowpack/SingleSignOn/Client/Security/EntryPoint/SingleSignOnRedirect.php
SingleSignOnRedirect.startAuthentication
public function startAuthentication(Request $request, Response $response) { $callbackUri = $request->getUri(); if (!isset($this->options['server'])) { throw new Exception('Missing "server" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.', 1351690358); } $ssoServer = $this->ssoServerFactory->create($this->options['server']); $ssoClient = $this->ssoClientFactory->create(); $redirectUri = $ssoServer->buildAuthenticationEndpointUri($ssoClient, $callbackUri); $response->setStatus(303); $response->setHeader('Location', $redirectUri); }
php
public function startAuthentication(Request $request, Response $response) { $callbackUri = $request->getUri(); if (!isset($this->options['server'])) { throw new Exception('Missing "server" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.', 1351690358); } $ssoServer = $this->ssoServerFactory->create($this->options['server']); $ssoClient = $this->ssoClientFactory->create(); $redirectUri = $ssoServer->buildAuthenticationEndpointUri($ssoClient, $callbackUri); $response->setStatus(303); $response->setHeader('Location', $redirectUri); }
[ "public", "function", "startAuthentication", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "callbackUri", "=", "$", "request", "->", "getUri", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'server'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Missing \"server\" option for SingleSignOnRedirect entry point. Please specifiy one using the entryPointOptions setting.'", ",", "1351690358", ")", ";", "}", "$", "ssoServer", "=", "$", "this", "->", "ssoServerFactory", "->", "create", "(", "$", "this", "->", "options", "[", "'server'", "]", ")", ";", "$", "ssoClient", "=", "$", "this", "->", "ssoClientFactory", "->", "create", "(", ")", ";", "$", "redirectUri", "=", "$", "ssoServer", "->", "buildAuthenticationEndpointUri", "(", "$", "ssoClient", ",", "$", "callbackUri", ")", ";", "$", "response", "->", "setStatus", "(", "303", ")", ";", "$", "response", "->", "setHeader", "(", "'Location'", ",", "$", "redirectUri", ")", ";", "}" ]
Starts the authentication by redirecting to the SSO endpoint The redirect includes the callback URI (the original URI from the given request) the client identifier and a signature of the arguments with the client private key. @param \TYPO3\Flow\Http\Request $request The current request @param \TYPO3\Flow\Http\Response $response The current response @return void
[ "Starts", "the", "authentication", "by", "redirecting", "to", "the", "SSO", "endpoint" ]
0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00
https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Security/EntryPoint/SingleSignOnRedirect.php#L44-L56
5,385
rollun-com/rollun-permission
src/Permission/src/OAuth/CredentialMiddleware.php
CredentialMiddleware.isOAuthAuthenticated
public function isOAuthAuthenticated(ServerRequestInterface $request) { $queryParams = $request->getQueryParams(); $code = $queryParams[GoogleClient::KEY_CODE] ?? null; $state = $queryParams[GoogleClient::KEY_STATE] ?? null; $this->logger->debug( json_encode( [ 'Incoming authorization code: ' . $code, 'Incoming state: ' . $state, 'Redirect uri: ' . $this->getConfig('redirectUri'), ] ) ); if ($this->getSession($request)->get(GoogleClient::KEY_STATE) != $state) { $this->logger->debug("Invalid incoming state"); return false; } if (!$this->googleClient->authenticateWithAuthCode($code)) { $this->logger->debug("Authentication with authorization code failed"); return false; } return true; }
php
public function isOAuthAuthenticated(ServerRequestInterface $request) { $queryParams = $request->getQueryParams(); $code = $queryParams[GoogleClient::KEY_CODE] ?? null; $state = $queryParams[GoogleClient::KEY_STATE] ?? null; $this->logger->debug( json_encode( [ 'Incoming authorization code: ' . $code, 'Incoming state: ' . $state, 'Redirect uri: ' . $this->getConfig('redirectUri'), ] ) ); if ($this->getSession($request)->get(GoogleClient::KEY_STATE) != $state) { $this->logger->debug("Invalid incoming state"); return false; } if (!$this->googleClient->authenticateWithAuthCode($code)) { $this->logger->debug("Authentication with authorization code failed"); return false; } return true; }
[ "public", "function", "isOAuthAuthenticated", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "queryParams", "=", "$", "request", "->", "getQueryParams", "(", ")", ";", "$", "code", "=", "$", "queryParams", "[", "GoogleClient", "::", "KEY_CODE", "]", "??", "null", ";", "$", "state", "=", "$", "queryParams", "[", "GoogleClient", "::", "KEY_STATE", "]", "??", "null", ";", "$", "this", "->", "logger", "->", "debug", "(", "json_encode", "(", "[", "'Incoming authorization code: '", ".", "$", "code", ",", "'Incoming state: '", ".", "$", "state", ",", "'Redirect uri: '", ".", "$", "this", "->", "getConfig", "(", "'redirectUri'", ")", ",", "]", ")", ")", ";", "if", "(", "$", "this", "->", "getSession", "(", "$", "request", ")", "->", "get", "(", "GoogleClient", "::", "KEY_STATE", ")", "!=", "$", "state", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"Invalid incoming state\"", ")", ";", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "googleClient", "->", "authenticateWithAuthCode", "(", "$", "code", ")", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"Authentication with authorization code failed\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if user-agent is authenticated 1. Check state according to OAuth 2.0 2. Try to retrieve access token with authorization code @param ServerRequestInterface $request @return bool|ResponseInterface @throws Exception
[ "Check", "if", "user", "-", "agent", "is", "authenticated" ]
9f58c814337fcfd1e52ecfbf496f95d276d8217e
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/OAuth/CredentialMiddleware.php#L86-L115
5,386
marando/phpSOFA
src/Marando/IAU/iauIr.php
iauIr.Ir
public static function Ir(array &$r) { $r[0][0] = 1.0; $r[0][1] = 0.0; $r[0][2] = 0.0; $r[1][0] = 0.0; $r[1][1] = 1.0; $r[1][2] = 0.0; $r[2][0] = 0.0; $r[2][1] = 0.0; $r[2][2] = 1.0; return; }
php
public static function Ir(array &$r) { $r[0][0] = 1.0; $r[0][1] = 0.0; $r[0][2] = 0.0; $r[1][0] = 0.0; $r[1][1] = 1.0; $r[1][2] = 0.0; $r[2][0] = 0.0; $r[2][1] = 0.0; $r[2][2] = 1.0; return; }
[ "public", "static", "function", "Ir", "(", "array", "&", "$", "r", ")", "{", "$", "r", "[", "0", "]", "[", "0", "]", "=", "1.0", ";", "$", "r", "[", "0", "]", "[", "1", "]", "=", "0.0", ";", "$", "r", "[", "0", "]", "[", "2", "]", "=", "0.0", ";", "$", "r", "[", "1", "]", "[", "0", "]", "=", "0.0", ";", "$", "r", "[", "1", "]", "[", "1", "]", "=", "1.0", ";", "$", "r", "[", "1", "]", "[", "2", "]", "=", "0.0", ";", "$", "r", "[", "2", "]", "[", "0", "]", "=", "0.0", ";", "$", "r", "[", "2", "]", "[", "1", "]", "=", "0.0", ";", "$", "r", "[", "2", "]", "[", "2", "]", "=", "1.0", ";", "return", ";", "}" ]
- - - - - - i a u I r - - - - - - Initialize an r-matrix to the identity matrix. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Returned: r double[3][3] r-matrix This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "i", "a", "u", "I", "r", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauIr.php#L28-L40
5,387
glynnforrest/reform
src/Reform/Form/Row/SelectRow.php
SelectRow.addChoices
public function addChoices(array $choices) { foreach ($choices as $k => $v) { if (is_int($k)) { $k = $this->sensible($v); } $this->choices[$k] = $v; } return $this; }
php
public function addChoices(array $choices) { foreach ($choices as $k => $v) { if (is_int($k)) { $k = $this->sensible($v); } $this->choices[$k] = $v; } return $this; }
[ "public", "function", "addChoices", "(", "array", "$", "choices", ")", "{", "foreach", "(", "$", "choices", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_int", "(", "$", "k", ")", ")", "{", "$", "k", "=", "$", "this", "->", "sensible", "(", "$", "v", ")", ";", "}", "$", "this", "->", "choices", "[", "$", "k", "]", "=", "$", "v", ";", "}", "return", "$", "this", ";", "}" ]
Add to the choices for this row. Keys will be created automatically if no keys are given or, due to PHP's array implementation, keys are strings containing valid integers. @param array $choices An array of keys and values to use for choices
[ "Add", "to", "the", "choices", "for", "this", "row", ".", "Keys", "will", "be", "created", "automatically", "if", "no", "keys", "are", "given", "or", "due", "to", "PHP", "s", "array", "implementation", "keys", "are", "strings", "containing", "valid", "integers", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Row/SelectRow.php#L51-L61
5,388
AthensFramework/Core
src/writer/EmailWriter.php
EmailWriter.visitEmail
public function visitEmail(EmailInterface $email) { $template = "email/{$email->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $email->getId(), "classes" => $email->getClasses(), "data" => $email->getData(), "message" => $email->getMessage(), ] ); }
php
public function visitEmail(EmailInterface $email) { $template = "email/{$email->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $email->getId(), "classes" => $email->getClasses(), "data" => $email->getData(), "message" => $email->getMessage(), ] ); }
[ "public", "function", "visitEmail", "(", "EmailInterface", "$", "email", ")", "{", "$", "template", "=", "\"email/{$email->getType()}.twig\"", ";", "return", "$", "this", "->", "loadTemplate", "(", "$", "template", ")", "->", "render", "(", "[", "\"id\"", "=>", "$", "email", "->", "getId", "(", ")", ",", "\"classes\"", "=>", "$", "email", "->", "getClasses", "(", ")", ",", "\"data\"", "=>", "$", "email", "->", "getData", "(", ")", ",", "\"message\"", "=>", "$", "email", "->", "getMessage", "(", ")", ",", "]", ")", ";", "}" ]
Render an email message into an email body, given its template. @param EmailInterface $email @return string
[ "Render", "an", "email", "message", "into", "an", "email", "body", "given", "its", "template", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/EmailWriter.php#L43-L57
5,389
nattreid/app-manager
src/AppManager.php
AppManager.composerUpdate
public function composerUpdate(bool $force = false): void { $this->maintenance(); if ($force) { $this->composer->update(); } else { $this->composer->authorizedUpdate(); } $this->maintenance(false); }
php
public function composerUpdate(bool $force = false): void { $this->maintenance(); if ($force) { $this->composer->update(); } else { $this->composer->authorizedUpdate(); } $this->maintenance(false); }
[ "public", "function", "composerUpdate", "(", "bool", "$", "force", "=", "false", ")", ":", "void", "{", "$", "this", "->", "maintenance", "(", ")", ";", "if", "(", "$", "force", ")", "{", "$", "this", "->", "composer", "->", "update", "(", ")", ";", "}", "else", "{", "$", "this", "->", "composer", "->", "authorizedUpdate", "(", ")", ";", "}", "$", "this", "->", "maintenance", "(", "false", ")", ";", "}" ]
Aktualizace zdrojovych kodu pomoci composeru @param bool $force @throws InvalidArgumentException
[ "Aktualizace", "zdrojovych", "kodu", "pomoci", "composeru" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/AppManager.php#L147-L156
5,390
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request/curl.php
Request_Curl.http_login
public function http_login($username = '', $password = '', $type = 'any') { $this->set_option(CURLOPT_HTTPAUTH, constant('CURLAUTH_' . strtoupper($type))); $this->set_option(CURLOPT_USERPWD, $username . ':' . $password); return $this; }
php
public function http_login($username = '', $password = '', $type = 'any') { $this->set_option(CURLOPT_HTTPAUTH, constant('CURLAUTH_' . strtoupper($type))); $this->set_option(CURLOPT_USERPWD, $username . ':' . $password); return $this; }
[ "public", "function", "http_login", "(", "$", "username", "=", "''", ",", "$", "password", "=", "''", ",", "$", "type", "=", "'any'", ")", "{", "$", "this", "->", "set_option", "(", "CURLOPT_HTTPAUTH", ",", "constant", "(", "'CURLAUTH_'", ".", "strtoupper", "(", "$", "type", ")", ")", ")", ";", "$", "this", "->", "set_option", "(", "CURLOPT_USERPWD", ",", "$", "username", ".", "':'", ".", "$", "password", ")", ";", "return", "$", "this", ";", "}" ]
Authenticate to an http server @param string $username @param string $password @param string $type @return Request_Curl
[ "Authenticate", "to", "an", "http", "server" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request/curl.php#L71-L77
5,391
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request/curl.php
Request_Curl.set_options
public function set_options(array $options) { foreach ($options as $key => $val) { if (is_string($key) && ! is_numeric($key)) { $key = constant('CURLOPT_' . strtoupper($key)); } $this->options[$key] = $val; } return $this; }
php
public function set_options(array $options) { foreach ($options as $key => $val) { if (is_string($key) && ! is_numeric($key)) { $key = constant('CURLOPT_' . strtoupper($key)); } $this->options[$key] = $val; } return $this; }
[ "public", "function", "set_options", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", "&&", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "key", "=", "constant", "(", "'CURLOPT_'", ".", "strtoupper", "(", "$", "key", ")", ")", ";", "}", "$", "this", "->", "options", "[", "$", "key", "]", "=", "$", "val", ";", "}", "return", "$", "this", ";", "}" ]
Overwrites driver method to set options driver specifically @param int|string $code @param mixed $value @return Request_Curl
[ "Overwrites", "driver", "method", "to", "set", "options", "driver", "specifically" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request/curl.php#L86-L99
5,392
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request/curl.php
Request_Curl.set_defaults
protected function set_defaults() { parent::set_defaults(); $this->headers = array(); if ( ! empty($this->preserve_resource)) { $this->resource = $this->preserve_resource; $this->preserve_resource = null; } return $this; }
php
protected function set_defaults() { parent::set_defaults(); $this->headers = array(); if ( ! empty($this->preserve_resource)) { $this->resource = $this->preserve_resource; $this->preserve_resource = null; } return $this; }
[ "protected", "function", "set_defaults", "(", ")", "{", "parent", "::", "set_defaults", "(", ")", ";", "$", "this", "->", "headers", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "preserve_resource", ")", ")", "{", "$", "this", "->", "resource", "=", "$", "this", "->", "preserve_resource", ";", "$", "this", "->", "preserve_resource", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Extends parent to reset headers as well @return Request_Curl
[ "Extends", "parent", "to", "reset", "headers", "as", "well" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request/curl.php#L205-L217
5,393
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request/curl.php
Request_Curl.encode
protected function encode(array $input) { // Detect the request content type, default to 'text/plain' $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain'); // Get the correct format for the current content type $format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null; switch($format) { // Format as XML case 'xml': /** * If the input array has one item in the top level * then use that item as the root XML element. */ if(count($input) === 1) { $base_node = key($input); return \Format::forge($input[$base_node])->to_xml(null, null, $base_node); } else { return \Format::forge($input)->to_xml(); } break; // Format as JSON case 'json': return \Format::forge($input)->to_json(); break; // Format as PHP Serialized Array case 'serialize': return \Format::forge($input)->to_serialize(); break; // Format as PHP Array case 'php': return \Format::forge($input)->to_php(); break; // Format as CSV case 'csv': return \Format::forge($input)->to_csv(); break; // Format as Query String default: return http_build_query($input, null, '&'); break; } }
php
protected function encode(array $input) { // Detect the request content type, default to 'text/plain' $content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain'); // Get the correct format for the current content type $format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null; switch($format) { // Format as XML case 'xml': /** * If the input array has one item in the top level * then use that item as the root XML element. */ if(count($input) === 1) { $base_node = key($input); return \Format::forge($input[$base_node])->to_xml(null, null, $base_node); } else { return \Format::forge($input)->to_xml(); } break; // Format as JSON case 'json': return \Format::forge($input)->to_json(); break; // Format as PHP Serialized Array case 'serialize': return \Format::forge($input)->to_serialize(); break; // Format as PHP Array case 'php': return \Format::forge($input)->to_php(); break; // Format as CSV case 'csv': return \Format::forge($input)->to_csv(); break; // Format as Query String default: return http_build_query($input, null, '&'); break; } }
[ "protected", "function", "encode", "(", "array", "$", "input", ")", "{", "// Detect the request content type, default to 'text/plain'", "$", "content_type", "=", "isset", "(", "$", "this", "->", "headers", "[", "'Content-Type'", "]", ")", "?", "$", "this", "->", "headers", "[", "'Content-Type'", "]", ":", "$", "this", "->", "response_info", "(", "'content_type'", ",", "'text/plain'", ")", ";", "// Get the correct format for the current content type", "$", "format", "=", "\\", "Arr", "::", "key_exists", "(", "static", "::", "$", "auto_detect_formats", ",", "$", "content_type", ")", "?", "static", "::", "$", "auto_detect_formats", "[", "$", "content_type", "]", ":", "null", ";", "switch", "(", "$", "format", ")", "{", "// Format as XML", "case", "'xml'", ":", "/**\n\t\t\t\t\t * If the input array has one item in the top level\n\t\t\t\t\t * then use that item as the root XML element.\n\t\t\t\t\t */", "if", "(", "count", "(", "$", "input", ")", "===", "1", ")", "{", "$", "base_node", "=", "key", "(", "$", "input", ")", ";", "return", "\\", "Format", "::", "forge", "(", "$", "input", "[", "$", "base_node", "]", ")", "->", "to_xml", "(", "null", ",", "null", ",", "$", "base_node", ")", ";", "}", "else", "{", "return", "\\", "Format", "::", "forge", "(", "$", "input", ")", "->", "to_xml", "(", ")", ";", "}", "break", ";", "// Format as JSON", "case", "'json'", ":", "return", "\\", "Format", "::", "forge", "(", "$", "input", ")", "->", "to_json", "(", ")", ";", "break", ";", "// Format as PHP Serialized Array", "case", "'serialize'", ":", "return", "\\", "Format", "::", "forge", "(", "$", "input", ")", "->", "to_serialize", "(", ")", ";", "break", ";", "// Format as PHP Array", "case", "'php'", ":", "return", "\\", "Format", "::", "forge", "(", "$", "input", ")", "->", "to_php", "(", ")", ";", "break", ";", "// Format as CSV", "case", "'csv'", ":", "return", "\\", "Format", "::", "forge", "(", "$", "input", ")", "->", "to_csv", "(", ")", ";", "break", ";", "// Format as Query String", "default", ":", "return", "http_build_query", "(", "$", "input", ",", "null", ",", "'&'", ")", ";", "break", ";", "}", "}" ]
Function to encode input array depending on the content type @param array $input @return mixed encoded output
[ "Function", "to", "encode", "input", "array", "depending", "on", "the", "content", "type" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request/curl.php#L299-L351
5,394
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Initialize
public function Initialize() { $this->ModuleSortContainer = 'Profile'; $this->Head = new HeadModule($this); $this->AddJsFile('jquery.js'); $this->AddJsFile('jquery.livequery.js'); $this->AddJsFile('jquery.form.js'); $this->AddJsFile('jquery.popup.js'); $this->AddJsFile('jquery.gardenhandleajaxform.js'); $this->AddJsFile('global.js'); $this->AddCssFile('style.css'); $this->AddModule('GuestModule'); parent::Initialize(); Gdn_Theme::Section('Profile'); if ($this->EditMode) $this->CssClass .= 'EditMode'; $this->SetData('Breadcrumbs', array()); $this->CanEditPhotos = C('Garden.Profile.EditPhotos') || Gdn::Session()->CheckPermission('Garden.Users.Edit'); }
php
public function Initialize() { $this->ModuleSortContainer = 'Profile'; $this->Head = new HeadModule($this); $this->AddJsFile('jquery.js'); $this->AddJsFile('jquery.livequery.js'); $this->AddJsFile('jquery.form.js'); $this->AddJsFile('jquery.popup.js'); $this->AddJsFile('jquery.gardenhandleajaxform.js'); $this->AddJsFile('global.js'); $this->AddCssFile('style.css'); $this->AddModule('GuestModule'); parent::Initialize(); Gdn_Theme::Section('Profile'); if ($this->EditMode) $this->CssClass .= 'EditMode'; $this->SetData('Breadcrumbs', array()); $this->CanEditPhotos = C('Garden.Profile.EditPhotos') || Gdn::Session()->CheckPermission('Garden.Users.Edit'); }
[ "public", "function", "Initialize", "(", ")", "{", "$", "this", "->", "ModuleSortContainer", "=", "'Profile'", ";", "$", "this", "->", "Head", "=", "new", "HeadModule", "(", "$", "this", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.livequery.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.form.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.popup.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'jquery.gardenhandleajaxform.js'", ")", ";", "$", "this", "->", "AddJsFile", "(", "'global.js'", ")", ";", "$", "this", "->", "AddCssFile", "(", "'style.css'", ")", ";", "$", "this", "->", "AddModule", "(", "'GuestModule'", ")", ";", "parent", "::", "Initialize", "(", ")", ";", "Gdn_Theme", "::", "Section", "(", "'Profile'", ")", ";", "if", "(", "$", "this", "->", "EditMode", ")", "$", "this", "->", "CssClass", ".=", "'EditMode'", ";", "$", "this", "->", "SetData", "(", "'Breadcrumbs'", ",", "array", "(", ")", ")", ";", "$", "this", "->", "CanEditPhotos", "=", "C", "(", "'Garden.Profile.EditPhotos'", ")", "||", "Gdn", "::", "Session", "(", ")", "->", "CheckPermission", "(", "'Garden.Users.Edit'", ")", ";", "}" ]
Adds JS, CSS, & modules. Automatically run on every use. @since 2.0.0 @access public
[ "Adds", "JS", "CSS", "&", "modules", ".", "Automatically", "run", "on", "every", "use", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L73-L94
5,395
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Activity
public function Activity($UserReference = '', $Username = '', $UserID = '', $Page = '') { $this->Permission('Garden.Profiles.View'); $this->EditMode(FALSE); // Object setup $Session = Gdn::Session(); $this->ActivityModel = new ActivityModel(); // Calculate offset. list($Offset, $Limit) = OffsetLimit($Page, 30); // Get user, tab, and comment $this->GetUserInfo($UserReference, $Username, $UserID); $UserID = $this->User->UserID; $Username = $this->User->Name; $this->_SetBreadcrumbs(T('Activity'), UserUrl($this->User, '', 'activity')); $this->SetTabView('Activity'); $Comment = $this->Form->GetFormValue('Comment'); // Load data to display $this->ProfileUserID = $this->User->UserID; $Limit = 30; $NotifyUserIDs = array(ActivityModel::NOTIFY_PUBLIC); if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) $NotifyUserIDs[] = ActivityModel::NOTIFY_MODS; $Activities = $this->ActivityModel->GetWhere( array('ActivityUserID' => $UserID, 'NotifyUserID' => $NotifyUserIDs), $Offset, $Limit)->ResultArray(); $this->ActivityModel->JoinComments($Activities); $this->SetData('Activities', $Activities); if (count($Activities) > 0) { $LastActivity = $Activities[0]; $LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated); $LastActivityDate = Gdn_Format::ToTimestamp($LastActivity['DateInserted']); if ($LastModifiedDate < $LastActivityDate) $LastModifiedDate = $LastActivityDate; // Make sure to only query this page if the user has no new activity since the requesting browser last saw it. $this->SetLastModified($LastModifiedDate); } // Set the canonical Url. if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) { $this->CanonicalUrl(Url('profile/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), TRUE)); } else { $this->CanonicalUrl(Url('profile/'.strtolower($this->User->Name), TRUE)); } $this->Render(); }
php
public function Activity($UserReference = '', $Username = '', $UserID = '', $Page = '') { $this->Permission('Garden.Profiles.View'); $this->EditMode(FALSE); // Object setup $Session = Gdn::Session(); $this->ActivityModel = new ActivityModel(); // Calculate offset. list($Offset, $Limit) = OffsetLimit($Page, 30); // Get user, tab, and comment $this->GetUserInfo($UserReference, $Username, $UserID); $UserID = $this->User->UserID; $Username = $this->User->Name; $this->_SetBreadcrumbs(T('Activity'), UserUrl($this->User, '', 'activity')); $this->SetTabView('Activity'); $Comment = $this->Form->GetFormValue('Comment'); // Load data to display $this->ProfileUserID = $this->User->UserID; $Limit = 30; $NotifyUserIDs = array(ActivityModel::NOTIFY_PUBLIC); if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) $NotifyUserIDs[] = ActivityModel::NOTIFY_MODS; $Activities = $this->ActivityModel->GetWhere( array('ActivityUserID' => $UserID, 'NotifyUserID' => $NotifyUserIDs), $Offset, $Limit)->ResultArray(); $this->ActivityModel->JoinComments($Activities); $this->SetData('Activities', $Activities); if (count($Activities) > 0) { $LastActivity = $Activities[0]; $LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated); $LastActivityDate = Gdn_Format::ToTimestamp($LastActivity['DateInserted']); if ($LastModifiedDate < $LastActivityDate) $LastModifiedDate = $LastActivityDate; // Make sure to only query this page if the user has no new activity since the requesting browser last saw it. $this->SetLastModified($LastModifiedDate); } // Set the canonical Url. if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) { $this->CanonicalUrl(Url('profile/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), TRUE)); } else { $this->CanonicalUrl(Url('profile/'.strtolower($this->User->Name), TRUE)); } $this->Render(); }
[ "public", "function", "Activity", "(", "$", "UserReference", "=", "''", ",", "$", "Username", "=", "''", ",", "$", "UserID", "=", "''", ",", "$", "Page", "=", "''", ")", "{", "$", "this", "->", "Permission", "(", "'Garden.Profiles.View'", ")", ";", "$", "this", "->", "EditMode", "(", "FALSE", ")", ";", "// Object setup", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "$", "this", "->", "ActivityModel", "=", "new", "ActivityModel", "(", ")", ";", "// Calculate offset.", "list", "(", "$", "Offset", ",", "$", "Limit", ")", "=", "OffsetLimit", "(", "$", "Page", ",", "30", ")", ";", "// Get user, tab, and comment", "$", "this", "->", "GetUserInfo", "(", "$", "UserReference", ",", "$", "Username", ",", "$", "UserID", ")", ";", "$", "UserID", "=", "$", "this", "->", "User", "->", "UserID", ";", "$", "Username", "=", "$", "this", "->", "User", "->", "Name", ";", "$", "this", "->", "_SetBreadcrumbs", "(", "T", "(", "'Activity'", ")", ",", "UserUrl", "(", "$", "this", "->", "User", ",", "''", ",", "'activity'", ")", ")", ";", "$", "this", "->", "SetTabView", "(", "'Activity'", ")", ";", "$", "Comment", "=", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'Comment'", ")", ";", "// Load data to display", "$", "this", "->", "ProfileUserID", "=", "$", "this", "->", "User", "->", "UserID", ";", "$", "Limit", "=", "30", ";", "$", "NotifyUserIDs", "=", "array", "(", "ActivityModel", "::", "NOTIFY_PUBLIC", ")", ";", "if", "(", "Gdn", "::", "Session", "(", ")", "->", "CheckPermission", "(", "'Garden.Moderation.Manage'", ")", ")", "$", "NotifyUserIDs", "[", "]", "=", "ActivityModel", "::", "NOTIFY_MODS", ";", "$", "Activities", "=", "$", "this", "->", "ActivityModel", "->", "GetWhere", "(", "array", "(", "'ActivityUserID'", "=>", "$", "UserID", ",", "'NotifyUserID'", "=>", "$", "NotifyUserIDs", ")", ",", "$", "Offset", ",", "$", "Limit", ")", "->", "ResultArray", "(", ")", ";", "$", "this", "->", "ActivityModel", "->", "JoinComments", "(", "$", "Activities", ")", ";", "$", "this", "->", "SetData", "(", "'Activities'", ",", "$", "Activities", ")", ";", "if", "(", "count", "(", "$", "Activities", ")", ">", "0", ")", "{", "$", "LastActivity", "=", "$", "Activities", "[", "0", "]", ";", "$", "LastModifiedDate", "=", "Gdn_Format", "::", "ToTimestamp", "(", "$", "this", "->", "User", "->", "DateUpdated", ")", ";", "$", "LastActivityDate", "=", "Gdn_Format", "::", "ToTimestamp", "(", "$", "LastActivity", "[", "'DateInserted'", "]", ")", ";", "if", "(", "$", "LastModifiedDate", "<", "$", "LastActivityDate", ")", "$", "LastModifiedDate", "=", "$", "LastActivityDate", ";", "// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.", "$", "this", "->", "SetLastModified", "(", "$", "LastModifiedDate", ")", ";", "}", "// Set the canonical Url.", "if", "(", "is_numeric", "(", "$", "this", "->", "User", "->", "Name", ")", "||", "Gdn_Format", "::", "Url", "(", "$", "this", "->", "User", "->", "Name", ")", "!=", "strtolower", "(", "$", "this", "->", "User", "->", "Name", ")", ")", "{", "$", "this", "->", "CanonicalUrl", "(", "Url", "(", "'profile/'", ".", "$", "this", "->", "User", "->", "UserID", ".", "'/'", ".", "Gdn_Format", "::", "Url", "(", "$", "this", "->", "User", "->", "Name", ")", ",", "TRUE", ")", ")", ";", "}", "else", "{", "$", "this", "->", "CanonicalUrl", "(", "Url", "(", "'profile/'", ".", "strtolower", "(", "$", "this", "->", "User", "->", "Name", ")", ",", "TRUE", ")", ")", ";", "}", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Show activity feed for this user. @since 2.0.0 @access public @param mixed $UserReference Unique identifier, possible ID or username. @param string $Username Username. @param int $UserID Unique ID. @param int $Offset How many to skip (for paging).
[ "Show", "activity", "feed", "for", "this", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L106-L159
5,396
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Clear
public function Clear($UserID = '') { if (empty($_POST)) throw PermissionException('Javascript'); $UserID = is_numeric($UserID) ? $UserID : 0; $Session = Gdn::Session(); if ($UserID != $Session->UserID && !$Session->CheckPermission('Garden.Moderation.Manage')) throw PermissionException('Garden.Moderation.Manage'); if ($UserID > 0) $this->UserModel->SaveAbout($UserID, ''); if ($this->DeliveryType() == DELIVERY_TYPE_ALL) Redirect('/profile'); else { $this->JsonTarget('#Status', '', 'Remove'); $this->Render('Blank', 'Utility'); } }
php
public function Clear($UserID = '') { if (empty($_POST)) throw PermissionException('Javascript'); $UserID = is_numeric($UserID) ? $UserID : 0; $Session = Gdn::Session(); if ($UserID != $Session->UserID && !$Session->CheckPermission('Garden.Moderation.Manage')) throw PermissionException('Garden.Moderation.Manage'); if ($UserID > 0) $this->UserModel->SaveAbout($UserID, ''); if ($this->DeliveryType() == DELIVERY_TYPE_ALL) Redirect('/profile'); else { $this->JsonTarget('#Status', '', 'Remove'); $this->Render('Blank', 'Utility'); } }
[ "public", "function", "Clear", "(", "$", "UserID", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "_POST", ")", ")", "throw", "PermissionException", "(", "'Javascript'", ")", ";", "$", "UserID", "=", "is_numeric", "(", "$", "UserID", ")", "?", "$", "UserID", ":", "0", ";", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "if", "(", "$", "UserID", "!=", "$", "Session", "->", "UserID", "&&", "!", "$", "Session", "->", "CheckPermission", "(", "'Garden.Moderation.Manage'", ")", ")", "throw", "PermissionException", "(", "'Garden.Moderation.Manage'", ")", ";", "if", "(", "$", "UserID", ">", "0", ")", "$", "this", "->", "UserModel", "->", "SaveAbout", "(", "$", "UserID", ",", "''", ")", ";", "if", "(", "$", "this", "->", "DeliveryType", "(", ")", "==", "DELIVERY_TYPE_ALL", ")", "Redirect", "(", "'/profile'", ")", ";", "else", "{", "$", "this", "->", "JsonTarget", "(", "'#Status'", ",", "''", ",", "'Remove'", ")", ";", "$", "this", "->", "Render", "(", "'Blank'", ",", "'Utility'", ")", ";", "}", "}" ]
Clear user's current status message. @since 2.0.0 @access public @param mixed $UserID
[ "Clear", "user", "s", "current", "status", "message", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L168-L186
5,397
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Connections
public function Connections($UserReference = '', $Username = '') { $this->Permission('Garden.SignIn.Allow'); $this->GetUserInfo($UserReference, $Username, '', TRUE); $UserID = GetValueR('User.UserID', $this); $this->_SetBreadcrumbs(T('Social'), UserUrl($this->User, '', 'connections')); $PModel = new Gdn_AuthenticationProviderModel(); $Providers = $PModel->GetProviders(); $this->SetData('_Providers', $Providers); $this->SetData('Connections', array()); $this->EventArguments['User'] = $this->User; $this->FireEvent('GetConnections'); // Add some connection information. foreach ($this->Data['Connections'] as &$Row) { $Provider = GetValue($Row['ProviderKey'], $Providers, array()); TouchValue('Connected', $Row, !is_null(GetValue('UniqueID', $Provider, NULL))); } $this->CanonicalUrl(UserUrl($this->User, '', 'connections')); $this->Title(T('Social')); require_once $this->FetchViewLocation('connection_functions'); $this->Render(); }
php
public function Connections($UserReference = '', $Username = '') { $this->Permission('Garden.SignIn.Allow'); $this->GetUserInfo($UserReference, $Username, '', TRUE); $UserID = GetValueR('User.UserID', $this); $this->_SetBreadcrumbs(T('Social'), UserUrl($this->User, '', 'connections')); $PModel = new Gdn_AuthenticationProviderModel(); $Providers = $PModel->GetProviders(); $this->SetData('_Providers', $Providers); $this->SetData('Connections', array()); $this->EventArguments['User'] = $this->User; $this->FireEvent('GetConnections'); // Add some connection information. foreach ($this->Data['Connections'] as &$Row) { $Provider = GetValue($Row['ProviderKey'], $Providers, array()); TouchValue('Connected', $Row, !is_null(GetValue('UniqueID', $Provider, NULL))); } $this->CanonicalUrl(UserUrl($this->User, '', 'connections')); $this->Title(T('Social')); require_once $this->FetchViewLocation('connection_functions'); $this->Render(); }
[ "public", "function", "Connections", "(", "$", "UserReference", "=", "''", ",", "$", "Username", "=", "''", ")", "{", "$", "this", "->", "Permission", "(", "'Garden.SignIn.Allow'", ")", ";", "$", "this", "->", "GetUserInfo", "(", "$", "UserReference", ",", "$", "Username", ",", "''", ",", "TRUE", ")", ";", "$", "UserID", "=", "GetValueR", "(", "'User.UserID'", ",", "$", "this", ")", ";", "$", "this", "->", "_SetBreadcrumbs", "(", "T", "(", "'Social'", ")", ",", "UserUrl", "(", "$", "this", "->", "User", ",", "''", ",", "'connections'", ")", ")", ";", "$", "PModel", "=", "new", "Gdn_AuthenticationProviderModel", "(", ")", ";", "$", "Providers", "=", "$", "PModel", "->", "GetProviders", "(", ")", ";", "$", "this", "->", "SetData", "(", "'_Providers'", ",", "$", "Providers", ")", ";", "$", "this", "->", "SetData", "(", "'Connections'", ",", "array", "(", ")", ")", ";", "$", "this", "->", "EventArguments", "[", "'User'", "]", "=", "$", "this", "->", "User", ";", "$", "this", "->", "FireEvent", "(", "'GetConnections'", ")", ";", "// Add some connection information.", "foreach", "(", "$", "this", "->", "Data", "[", "'Connections'", "]", "as", "&", "$", "Row", ")", "{", "$", "Provider", "=", "GetValue", "(", "$", "Row", "[", "'ProviderKey'", "]", ",", "$", "Providers", ",", "array", "(", ")", ")", ";", "TouchValue", "(", "'Connected'", ",", "$", "Row", ",", "!", "is_null", "(", "GetValue", "(", "'UniqueID'", ",", "$", "Provider", ",", "NULL", ")", ")", ")", ";", "}", "$", "this", "->", "CanonicalUrl", "(", "UserUrl", "(", "$", "this", "->", "User", ",", "''", ",", "'connections'", ")", ")", ";", "$", "this", "->", "Title", "(", "T", "(", "'Social'", ")", ")", ";", "require_once", "$", "this", "->", "FetchViewLocation", "(", "'connection_functions'", ")", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Lists the connections to other sites. @param int|string $UserReference @param string $Username @since 2.1
[ "Lists", "the", "connections", "to", "other", "sites", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L210-L235
5,398
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Index
public function Index($User = '', $Username = '', $UserID = '', $Page = FALSE) { $this->EditMode(FALSE); $this->GetUserInfo($User, $Username, $UserID); if ($this->User->Admin == 2 && $this->Head) { // Don't index internal accounts. This is in part to prevent vendors from getting endless Google alerts. $this->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex')); $this->Head->AddTag('meta', array('name' => 'googlebot', 'content' => 'noindex')); } // if ($this->User->UserID == Gdn::Session()->UserID) // return $this->Notifications($Page); // elseif (C('Garden.Profile.ShowActivities', TRUE)) if (C('Garden.Profile.ShowActivities', TRUE)) return $this->Activity($User, $Username, $UserID, $Page); else return Gdn::Dispatcher()->Dispatch(UserUrl($this->User, '', 'discussions')); }
php
public function Index($User = '', $Username = '', $UserID = '', $Page = FALSE) { $this->EditMode(FALSE); $this->GetUserInfo($User, $Username, $UserID); if ($this->User->Admin == 2 && $this->Head) { // Don't index internal accounts. This is in part to prevent vendors from getting endless Google alerts. $this->Head->AddTag('meta', array('name' => 'robots', 'content' => 'noindex')); $this->Head->AddTag('meta', array('name' => 'googlebot', 'content' => 'noindex')); } // if ($this->User->UserID == Gdn::Session()->UserID) // return $this->Notifications($Page); // elseif (C('Garden.Profile.ShowActivities', TRUE)) if (C('Garden.Profile.ShowActivities', TRUE)) return $this->Activity($User, $Username, $UserID, $Page); else return Gdn::Dispatcher()->Dispatch(UserUrl($this->User, '', 'discussions')); }
[ "public", "function", "Index", "(", "$", "User", "=", "''", ",", "$", "Username", "=", "''", ",", "$", "UserID", "=", "''", ",", "$", "Page", "=", "FALSE", ")", "{", "$", "this", "->", "EditMode", "(", "FALSE", ")", ";", "$", "this", "->", "GetUserInfo", "(", "$", "User", ",", "$", "Username", ",", "$", "UserID", ")", ";", "if", "(", "$", "this", "->", "User", "->", "Admin", "==", "2", "&&", "$", "this", "->", "Head", ")", "{", "// Don't index internal accounts. This is in part to prevent vendors from getting endless Google alerts.", "$", "this", "->", "Head", "->", "AddTag", "(", "'meta'", ",", "array", "(", "'name'", "=>", "'robots'", ",", "'content'", "=>", "'noindex'", ")", ")", ";", "$", "this", "->", "Head", "->", "AddTag", "(", "'meta'", ",", "array", "(", "'name'", "=>", "'googlebot'", ",", "'content'", "=>", "'noindex'", ")", ")", ";", "}", "// if ($this->User->UserID == Gdn::Session()->UserID)", "// return $this->Notifications($Page);", "// elseif (C('Garden.Profile.ShowActivities', TRUE))", "if", "(", "C", "(", "'Garden.Profile.ShowActivities'", ",", "TRUE", ")", ")", "return", "$", "this", "->", "Activity", "(", "$", "User", ",", "$", "Username", ",", "$", "UserID", ",", "$", "Page", ")", ";", "else", "return", "Gdn", "::", "Dispatcher", "(", ")", "->", "Dispatch", "(", "UserUrl", "(", "$", "this", "->", "User", ",", "''", ",", "'discussions'", ")", ")", ";", "}" ]
Default profile page. If current user's profile, get notifications. Otherwise show their activity (if available) or discussions. @since 2.0.0 @access public @param mixed $User Unique identifier, possible ID or username. @param string $Username. @param int $UserID Unique ID.
[ "Default", "profile", "page", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L429-L446
5,399
bishopb/vanilla
applications/dashboard/controllers/class.profilecontroller.php
ProfileController.Invitations
public function Invitations($UserReference = '', $Username = '', $UserID = '') { $this->Permission('Garden.SignIn.Allow'); $this->EditMode(FALSE); $this->GetUserInfo($UserReference, $Username, $UserID, $this->Form->AuthenticatedPostBack()); $this->SetTabView('Invitations'); $InvitationModel = new InvitationModel(); $this->Form->SetModel($InvitationModel); if ($this->Form->AuthenticatedPostBack()) { // Send the invitation if ($this->Form->Save($this->UserModel)) { $this->InformMessage(T('Your invitation has been sent.')); $this->Form->ClearInputs(); } } $Session = Gdn::Session(); $this->InvitationCount = $this->UserModel->GetInvitationCount($Session->UserID); $this->InvitationData = $InvitationModel->GetByUserID($Session->UserID); $this->Render(); }
php
public function Invitations($UserReference = '', $Username = '', $UserID = '') { $this->Permission('Garden.SignIn.Allow'); $this->EditMode(FALSE); $this->GetUserInfo($UserReference, $Username, $UserID, $this->Form->AuthenticatedPostBack()); $this->SetTabView('Invitations'); $InvitationModel = new InvitationModel(); $this->Form->SetModel($InvitationModel); if ($this->Form->AuthenticatedPostBack()) { // Send the invitation if ($this->Form->Save($this->UserModel)) { $this->InformMessage(T('Your invitation has been sent.')); $this->Form->ClearInputs(); } } $Session = Gdn::Session(); $this->InvitationCount = $this->UserModel->GetInvitationCount($Session->UserID); $this->InvitationData = $InvitationModel->GetByUserID($Session->UserID); $this->Render(); }
[ "public", "function", "Invitations", "(", "$", "UserReference", "=", "''", ",", "$", "Username", "=", "''", ",", "$", "UserID", "=", "''", ")", "{", "$", "this", "->", "Permission", "(", "'Garden.SignIn.Allow'", ")", ";", "$", "this", "->", "EditMode", "(", "FALSE", ")", ";", "$", "this", "->", "GetUserInfo", "(", "$", "UserReference", ",", "$", "Username", ",", "$", "UserID", ",", "$", "this", "->", "Form", "->", "AuthenticatedPostBack", "(", ")", ")", ";", "$", "this", "->", "SetTabView", "(", "'Invitations'", ")", ";", "$", "InvitationModel", "=", "new", "InvitationModel", "(", ")", ";", "$", "this", "->", "Form", "->", "SetModel", "(", "$", "InvitationModel", ")", ";", "if", "(", "$", "this", "->", "Form", "->", "AuthenticatedPostBack", "(", ")", ")", "{", "// Send the invitation", "if", "(", "$", "this", "->", "Form", "->", "Save", "(", "$", "this", "->", "UserModel", ")", ")", "{", "$", "this", "->", "InformMessage", "(", "T", "(", "'Your invitation has been sent.'", ")", ")", ";", "$", "this", "->", "Form", "->", "ClearInputs", "(", ")", ";", "}", "}", "$", "Session", "=", "Gdn", "::", "Session", "(", ")", ";", "$", "this", "->", "InvitationCount", "=", "$", "this", "->", "UserModel", "->", "GetInvitationCount", "(", "$", "Session", "->", "UserID", ")", ";", "$", "this", "->", "InvitationData", "=", "$", "InvitationModel", "->", "GetByUserID", "(", "$", "Session", "->", "UserID", ")", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Manage current user's invitations. @since 2.0.0 @access public
[ "Manage", "current", "user", "s", "invitations", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.profilecontroller.php#L454-L474