id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
224,400
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Search/SqLiteQueryBuilder.php
|
SqLiteQueryBuilder.like
|
public function like($propertyName, $propertyValue) {
$parameterName = ':' . md5($propertyName . '#' . count($this->where));
$this->where[] = '(`' . $propertyName . '` LIKE ' . $parameterName . ')';
$this->parameterMap[$parameterName] = '%' . $propertyValue . '%';
return $this;
}
|
php
|
public function like($propertyName, $propertyValue) {
$parameterName = ':' . md5($propertyName . '#' . count($this->where));
$this->where[] = '(`' . $propertyName . '` LIKE ' . $parameterName . ')';
$this->parameterMap[$parameterName] = '%' . $propertyValue . '%';
return $this;
}
|
[
"public",
"function",
"like",
"(",
"$",
"propertyName",
",",
"$",
"propertyValue",
")",
"{",
"$",
"parameterName",
"=",
"':'",
".",
"md5",
"(",
"$",
"propertyName",
".",
"'#'",
".",
"count",
"(",
"$",
"this",
"->",
"where",
")",
")",
";",
"$",
"this",
"->",
"where",
"[",
"]",
"=",
"'(`'",
".",
"$",
"propertyName",
".",
"'` LIKE '",
".",
"$",
"parameterName",
".",
"')'",
";",
"$",
"this",
"->",
"parameterMap",
"[",
"$",
"parameterName",
"]",
"=",
"'%'",
".",
"$",
"propertyValue",
".",
"'%'",
";",
"return",
"$",
"this",
";",
"}"
] |
add an like query for a given property
@param $propertyName
@param $propertyValue
@return QueryBuilderInterface
|
[
"add",
"an",
"like",
"query",
"for",
"a",
"given",
"property"
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Search/SqLiteQueryBuilder.php#L128-L134
|
224,401
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Search/SqLiteQueryBuilder.php
|
SqLiteQueryBuilder.execute
|
public function execute() {
$query = $this->buildQueryString();
$result = $this->indexClient->executeStatement($query, $this->parameterMap);
if (empty($result)) {
return array();
}
return array_values($result);
}
|
php
|
public function execute() {
$query = $this->buildQueryString();
$result = $this->indexClient->executeStatement($query, $this->parameterMap);
if (empty($result)) {
return array();
}
return array_values($result);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"buildQueryString",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"indexClient",
"->",
"executeStatement",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"parameterMap",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"array_values",
"(",
"$",
"result",
")",
";",
"}"
] |
Execute the query and return the list of results
@return array
|
[
"Execute",
"the",
"query",
"and",
"return",
"the",
"list",
"of",
"results"
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Search/SqLiteQueryBuilder.php#L198-L207
|
224,402
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Search/SqLiteQueryBuilder.php
|
SqLiteQueryBuilder.fulltextMatchResult
|
public function fulltextMatchResult($searchword, $resultTokens = 60, $ellipsis = '...', $beginModifier = '<b>', $endModifier = '</b>') {
$query = $this->buildQueryString();
$results = $this->indexClient->query($query);
// SQLite3 has a hard-coded limit of 999 query variables, so we split the $result in chunks
// of 990 elements (we need some space for our own varialbles), query these, and return the first result.
// @see https://sqlite.org/limits.html -> "Maximum Number Of Host Parameters In A Single SQL Statement"
$chunks = array_chunk($results, 990);
foreach ($chunks as $chunk){
$queryParameters = array();
$identifierParameters = array();
foreach ($chunk as $key => $result) {
$parameterName = ':possibleIdentifier' . $key;
$identifierParameters[] = $parameterName;
$queryParameters[$parameterName] = $result['__identifier__'];
}
$queryParameters[':beginModifier'] = $beginModifier;
$queryParameters[':endModifier'] = $endModifier;
$queryParameters[':ellipsis'] = $ellipsis;
$queryParameters[':resultTokens'] = ($resultTokens * -1);
$matchQuery = 'SELECT snippet(fulltext, :beginModifier, :endModifier, :ellipsis, -1, :resultTokens) as snippet FROM fulltext WHERE fulltext MATCH :searchword AND __identifier__ IN (' . implode(',', $identifierParameters) . ') LIMIT 1;';
$queryParameters[':searchword'] = $searchword;
$matchSnippet = $this->indexClient->executeStatement($matchQuery, $queryParameters);
// If we have a hit here, we stop searching and return it.
if (isset($matchSnippet[0]['snippet']) && $matchSnippet[0]['snippet'] !== '') {
return $matchSnippet[0]['snippet'];
}
}
return '';
}
|
php
|
public function fulltextMatchResult($searchword, $resultTokens = 60, $ellipsis = '...', $beginModifier = '<b>', $endModifier = '</b>') {
$query = $this->buildQueryString();
$results = $this->indexClient->query($query);
// SQLite3 has a hard-coded limit of 999 query variables, so we split the $result in chunks
// of 990 elements (we need some space for our own varialbles), query these, and return the first result.
// @see https://sqlite.org/limits.html -> "Maximum Number Of Host Parameters In A Single SQL Statement"
$chunks = array_chunk($results, 990);
foreach ($chunks as $chunk){
$queryParameters = array();
$identifierParameters = array();
foreach ($chunk as $key => $result) {
$parameterName = ':possibleIdentifier' . $key;
$identifierParameters[] = $parameterName;
$queryParameters[$parameterName] = $result['__identifier__'];
}
$queryParameters[':beginModifier'] = $beginModifier;
$queryParameters[':endModifier'] = $endModifier;
$queryParameters[':ellipsis'] = $ellipsis;
$queryParameters[':resultTokens'] = ($resultTokens * -1);
$matchQuery = 'SELECT snippet(fulltext, :beginModifier, :endModifier, :ellipsis, -1, :resultTokens) as snippet FROM fulltext WHERE fulltext MATCH :searchword AND __identifier__ IN (' . implode(',', $identifierParameters) . ') LIMIT 1;';
$queryParameters[':searchword'] = $searchword;
$matchSnippet = $this->indexClient->executeStatement($matchQuery, $queryParameters);
// If we have a hit here, we stop searching and return it.
if (isset($matchSnippet[0]['snippet']) && $matchSnippet[0]['snippet'] !== '') {
return $matchSnippet[0]['snippet'];
}
}
return '';
}
|
[
"public",
"function",
"fulltextMatchResult",
"(",
"$",
"searchword",
",",
"$",
"resultTokens",
"=",
"60",
",",
"$",
"ellipsis",
"=",
"'...'",
",",
"$",
"beginModifier",
"=",
"'<b>'",
",",
"$",
"endModifier",
"=",
"'</b>'",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"buildQueryString",
"(",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"indexClient",
"->",
"query",
"(",
"$",
"query",
")",
";",
"// SQLite3 has a hard-coded limit of 999 query variables, so we split the $result in chunks",
"// of 990 elements (we need some space for our own varialbles), query these, and return the first result.",
"// @see https://sqlite.org/limits.html -> \"Maximum Number Of Host Parameters In A Single SQL Statement\"",
"$",
"chunks",
"=",
"array_chunk",
"(",
"$",
"results",
",",
"990",
")",
";",
"foreach",
"(",
"$",
"chunks",
"as",
"$",
"chunk",
")",
"{",
"$",
"queryParameters",
"=",
"array",
"(",
")",
";",
"$",
"identifierParameters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"chunk",
"as",
"$",
"key",
"=>",
"$",
"result",
")",
"{",
"$",
"parameterName",
"=",
"':possibleIdentifier'",
".",
"$",
"key",
";",
"$",
"identifierParameters",
"[",
"]",
"=",
"$",
"parameterName",
";",
"$",
"queryParameters",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"result",
"[",
"'__identifier__'",
"]",
";",
"}",
"$",
"queryParameters",
"[",
"':beginModifier'",
"]",
"=",
"$",
"beginModifier",
";",
"$",
"queryParameters",
"[",
"':endModifier'",
"]",
"=",
"$",
"endModifier",
";",
"$",
"queryParameters",
"[",
"':ellipsis'",
"]",
"=",
"$",
"ellipsis",
";",
"$",
"queryParameters",
"[",
"':resultTokens'",
"]",
"=",
"(",
"$",
"resultTokens",
"*",
"-",
"1",
")",
";",
"$",
"matchQuery",
"=",
"'SELECT snippet(fulltext, :beginModifier, :endModifier, :ellipsis, -1, :resultTokens) as snippet FROM fulltext WHERE fulltext MATCH :searchword AND __identifier__ IN ('",
".",
"implode",
"(",
"','",
",",
"$",
"identifierParameters",
")",
".",
"') LIMIT 1;'",
";",
"$",
"queryParameters",
"[",
"':searchword'",
"]",
"=",
"$",
"searchword",
";",
"$",
"matchSnippet",
"=",
"$",
"this",
"->",
"indexClient",
"->",
"executeStatement",
"(",
"$",
"matchQuery",
",",
"$",
"queryParameters",
")",
";",
"// If we have a hit here, we stop searching and return it.",
"if",
"(",
"isset",
"(",
"$",
"matchSnippet",
"[",
"0",
"]",
"[",
"'snippet'",
"]",
")",
"&&",
"$",
"matchSnippet",
"[",
"0",
"]",
"[",
"'snippet'",
"]",
"!==",
"''",
")",
"{",
"return",
"$",
"matchSnippet",
"[",
"0",
"]",
"[",
"'snippet'",
"]",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
Produces a snippet with the first match result for the search term.
@param string $searchword The search word
@param integer $resultTokens The amount of tokens (words) to get surrounding the match hit. (defaults to 60)
@param string $ellipsis added to the end of the string if the text was longer than the snippet produced. (defaults to "...")
@param string $beginModifier added immediately before the searchword in the snippet (defaults to <b>)
@param string $endModifier added immediately after the searchword in the snippet (defaults to </b>)
@return string
|
[
"Produces",
"a",
"snippet",
"with",
"the",
"first",
"match",
"result",
"for",
"the",
"search",
"term",
"."
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Search/SqLiteQueryBuilder.php#L229-L262
|
224,403
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Search/SqLiteQueryBuilder.php
|
SqLiteQueryBuilder.anyMatch
|
public function anyMatch($propertyName, $propertyValues) {
if ($propertyValues === null || empty($propertyValues) || $propertyValues[0] === null) {
return $this;
}
$queryString = null;
$lastElemtentKey = count($propertyValues) - 1;
foreach($propertyValues as $key => $propertyValue) {
$parameterName = ':' . md5($propertyName . '#' . count($this->where) . $key);
$this->parameterMap[$parameterName] = $propertyValue;
if ($key === 0) {
$queryString .= '(';
}
if ($key !== $lastElemtentKey) {
$queryString .= sprintf("(`%s`) = %s OR ", $propertyName, $parameterName);
} else {
$queryString .= sprintf("(`%s`) = %s )", $propertyName, $parameterName);
}
}
$this->where[] = $queryString;
return $this;
}
|
php
|
public function anyMatch($propertyName, $propertyValues) {
if ($propertyValues === null || empty($propertyValues) || $propertyValues[0] === null) {
return $this;
}
$queryString = null;
$lastElemtentKey = count($propertyValues) - 1;
foreach($propertyValues as $key => $propertyValue) {
$parameterName = ':' . md5($propertyName . '#' . count($this->where) . $key);
$this->parameterMap[$parameterName] = $propertyValue;
if ($key === 0) {
$queryString .= '(';
}
if ($key !== $lastElemtentKey) {
$queryString .= sprintf("(`%s`) = %s OR ", $propertyName, $parameterName);
} else {
$queryString .= sprintf("(`%s`) = %s )", $propertyName, $parameterName);
}
}
$this->where[] = $queryString;
return $this;
}
|
[
"public",
"function",
"anyMatch",
"(",
"$",
"propertyName",
",",
"$",
"propertyValues",
")",
"{",
"if",
"(",
"$",
"propertyValues",
"===",
"null",
"||",
"empty",
"(",
"$",
"propertyValues",
")",
"||",
"$",
"propertyValues",
"[",
"0",
"]",
"===",
"null",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"queryString",
"=",
"null",
";",
"$",
"lastElemtentKey",
"=",
"count",
"(",
"$",
"propertyValues",
")",
"-",
"1",
";",
"foreach",
"(",
"$",
"propertyValues",
"as",
"$",
"key",
"=>",
"$",
"propertyValue",
")",
"{",
"$",
"parameterName",
"=",
"':'",
".",
"md5",
"(",
"$",
"propertyName",
".",
"'#'",
".",
"count",
"(",
"$",
"this",
"->",
"where",
")",
".",
"$",
"key",
")",
";",
"$",
"this",
"->",
"parameterMap",
"[",
"$",
"parameterName",
"]",
"=",
"$",
"propertyValue",
";",
"if",
"(",
"$",
"key",
"===",
"0",
")",
"{",
"$",
"queryString",
".=",
"'('",
";",
"}",
"if",
"(",
"$",
"key",
"!==",
"$",
"lastElemtentKey",
")",
"{",
"$",
"queryString",
".=",
"sprintf",
"(",
"\"(`%s`) = %s OR \"",
",",
"$",
"propertyName",
",",
"$",
"parameterName",
")",
";",
"}",
"else",
"{",
"$",
"queryString",
".=",
"sprintf",
"(",
"\"(`%s`) = %s )\"",
",",
"$",
"propertyName",
",",
"$",
"parameterName",
")",
";",
"}",
"}",
"$",
"this",
"->",
"where",
"[",
"]",
"=",
"$",
"queryString",
";",
"return",
"$",
"this",
";",
"}"
] |
Match any value in the given array for the property
@param string $propertyName
@param array $propertyValues
@return QueryBuilder
|
[
"Match",
"any",
"value",
"in",
"the",
"given",
"array",
"for",
"the",
"property"
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Search/SqLiteQueryBuilder.php#L271-L295
|
224,404
|
joomla-framework/language
|
src/Language.php
|
Language.getPaths
|
public function getPaths($extension = null)
{
if (isset($extension))
{
if (isset($this->paths[$extension]))
{
return $this->paths[$extension];
}
return;
}
return $this->paths;
}
|
php
|
public function getPaths($extension = null)
{
if (isset($extension))
{
if (isset($this->paths[$extension]))
{
return $this->paths[$extension];
}
return;
}
return $this->paths;
}
|
[
"public",
"function",
"getPaths",
"(",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"extension",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"paths",
"[",
"$",
"extension",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"paths",
"[",
"$",
"extension",
"]",
";",
"}",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"paths",
";",
"}"
] |
Get a list of language files that have been loaded.
@param string $extension An optional extension name.
@return array
@since 1.0
|
[
"Get",
"a",
"list",
"of",
"language",
"files",
"that",
"have",
"been",
"loaded",
"."
] |
94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf
|
https://github.com/joomla-framework/language/blob/94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf/src/Language.php#L1032-L1045
|
224,405
|
tomloprod/ionic-push-php
|
src/Api/DeviceTokens.php
|
DeviceTokens.paginatedList
|
public function paginatedList($parameters = [])
{
return $this->sendRequest(
self::METHOD_GET,
self::$endPoints['list'] . '?' . http_build_query($parameters)
);
}
|
php
|
public function paginatedList($parameters = [])
{
return $this->sendRequest(
self::METHOD_GET,
self::$endPoints['list'] . '?' . http_build_query($parameters)
);
}
|
[
"public",
"function",
"paginatedList",
"(",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'list'",
"]",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
")",
";",
"}"
] |
Paginated listing of tokens.
@link https://docs.ionic.io/api/endpoints/push.html#get-tokens Ionic documentation
@param array $parameters
@return object $response
|
[
"Paginated",
"listing",
"of",
"tokens",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/DeviceTokens.php#L35-L41
|
224,406
|
tomloprod/ionic-push-php
|
src/Api/DeviceTokens.php
|
DeviceTokens.listAssociatedUsers
|
public function listAssociatedUsers($deviceToken, $parameters = [])
{
return $this->prepareRequest(
self::METHOD_GET,
$deviceToken,
self::$endPoints['listAssociatedUsers'] . '?' . http_build_query($parameters)
);
}
|
php
|
public function listAssociatedUsers($deviceToken, $parameters = [])
{
return $this->prepareRequest(
self::METHOD_GET,
$deviceToken,
self::$endPoints['listAssociatedUsers'] . '?' . http_build_query($parameters)
);
}
|
[
"public",
"function",
"listAssociatedUsers",
"(",
"$",
"deviceToken",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"prepareRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"$",
"deviceToken",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'listAssociatedUsers'",
"]",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
")",
";",
"}"
] |
List users associated with the indicated token
@link https://docs.ionic.io/api/endpoints/push.html#get-tokens-token_id-users Ionic documentation
@param string $deviceToken - Device token
@param array $parameters - Query parameters (pagination).
@return object $response
|
[
"List",
"users",
"associated",
"with",
"the",
"indicated",
"token"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/DeviceTokens.php#L116-L123
|
224,407
|
tomloprod/ionic-push-php
|
src/Api/DeviceTokens.php
|
DeviceTokens.associateUser
|
public function associateUser($deviceToken, $userId)
{
// Replace :user_id by $userId
$endPoint = str_replace(':user_id', $userId, self::$endPoints['associateUser']);
return $this->prepareRequest(
self::METHOD_POST,
$deviceToken,
$endPoint
);
}
|
php
|
public function associateUser($deviceToken, $userId)
{
// Replace :user_id by $userId
$endPoint = str_replace(':user_id', $userId, self::$endPoints['associateUser']);
return $this->prepareRequest(
self::METHOD_POST,
$deviceToken,
$endPoint
);
}
|
[
"public",
"function",
"associateUser",
"(",
"$",
"deviceToken",
",",
"$",
"userId",
")",
"{",
"// Replace :user_id by $userId",
"$",
"endPoint",
"=",
"str_replace",
"(",
"':user_id'",
",",
"$",
"userId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'associateUser'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"prepareRequest",
"(",
"self",
"::",
"METHOD_POST",
",",
"$",
"deviceToken",
",",
"$",
"endPoint",
")",
";",
"}"
] |
Associate the indicated user with the indicated device token
@link https://docs.ionic.io/api/endpoints/push.html#post-tokens-token_id-users-user_id Ionic documentation
@param string $deviceToken - Device token
@param string $userId - User id
@return object $response
|
[
"Associate",
"the",
"indicated",
"user",
"with",
"the",
"indicated",
"device",
"token"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/DeviceTokens.php#L133-L142
|
224,408
|
tomloprod/ionic-push-php
|
src/Api/DeviceTokens.php
|
DeviceTokens.dissociateUser
|
public function dissociateUser($deviceToken, $userId)
{
// Replace :user_id by $userId
$endPoint = str_replace(':user_id', $userId, self::$endPoints['dissociateUser']);
return $this->prepareRequest(
self::METHOD_DELETE,
$deviceToken,
$endPoint
);
}
|
php
|
public function dissociateUser($deviceToken, $userId)
{
// Replace :user_id by $userId
$endPoint = str_replace(':user_id', $userId, self::$endPoints['dissociateUser']);
return $this->prepareRequest(
self::METHOD_DELETE,
$deviceToken,
$endPoint
);
}
|
[
"public",
"function",
"dissociateUser",
"(",
"$",
"deviceToken",
",",
"$",
"userId",
")",
"{",
"// Replace :user_id by $userId",
"$",
"endPoint",
"=",
"str_replace",
"(",
"':user_id'",
",",
"$",
"userId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'dissociateUser'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"prepareRequest",
"(",
"self",
"::",
"METHOD_DELETE",
",",
"$",
"deviceToken",
",",
"$",
"endPoint",
")",
";",
"}"
] |
Dissociate the indicated user with the indicated device token
@link https://docs.ionic.io/api/endpoints/push.html#delete-tokens-token_id-users-user_id Ionic documentation
@param string $deviceToken - Device token
@param string $userId - User id
@return object $response
|
[
"Dissociate",
"the",
"indicated",
"user",
"with",
"the",
"indicated",
"device",
"token"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/DeviceTokens.php#L152-L161
|
224,409
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.show
|
public static function show($terms = null, array $columns = [])
{
$self = self::newSelf();
if (!$self->table()) {
return false;
}
$query = $self->select($columns);
$self->normalizeTerms($query, $terms);
$model = $self->attributes? static::class : $self;
return new Results($query, $model);
}
|
php
|
public static function show($terms = null, array $columns = [])
{
$self = self::newSelf();
if (!$self->table()) {
return false;
}
$query = $self->select($columns);
$self->normalizeTerms($query, $terms);
$model = $self->attributes? static::class : $self;
return new Results($query, $model);
}
|
[
"public",
"static",
"function",
"show",
"(",
"$",
"terms",
"=",
"null",
",",
"array",
"$",
"columns",
"=",
"[",
"]",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"newSelf",
"(",
")",
";",
"if",
"(",
"!",
"$",
"self",
"->",
"table",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"query",
"=",
"$",
"self",
"->",
"select",
"(",
"$",
"columns",
")",
";",
"$",
"self",
"->",
"normalizeTerms",
"(",
"$",
"query",
",",
"$",
"terms",
")",
";",
"$",
"model",
"=",
"$",
"self",
"->",
"attributes",
"?",
"static",
"::",
"class",
":",
"$",
"self",
";",
"return",
"new",
"Results",
"(",
"$",
"query",
",",
"$",
"model",
")",
";",
"}"
] |
Show specific or all data
@param mixed $terms
@param array $columns
@return Results|false
|
[
"Show",
"specific",
"or",
"all",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L69-L84
|
224,410
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.create
|
public static function create(array $pairs = null)
{
$self = self::newSelf($pairs);
if (!empty($self->attributes) && null === $pairs) {
$pairs = $self->attributes;
}
if (!$self->table()) {
return false;
}
if (empty($pairs)) {
throw new \LogicException('Could not create empty data');
}
if ($self->timestamps) {
$pairs[self::CREATED] = $pairs[self::UPDATED] = $self->freshDate();
}
$query = $self->insert(array_keys($pairs))->values(array_values($pairs));
if ($result = $query->execute()) {
$self->attributes[$self->primary()] = $result;
return $result;
}
return false;
}
|
php
|
public static function create(array $pairs = null)
{
$self = self::newSelf($pairs);
if (!empty($self->attributes) && null === $pairs) {
$pairs = $self->attributes;
}
if (!$self->table()) {
return false;
}
if (empty($pairs)) {
throw new \LogicException('Could not create empty data');
}
if ($self->timestamps) {
$pairs[self::CREATED] = $pairs[self::UPDATED] = $self->freshDate();
}
$query = $self->insert(array_keys($pairs))->values(array_values($pairs));
if ($result = $query->execute()) {
$self->attributes[$self->primary()] = $result;
return $result;
}
return false;
}
|
[
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"pairs",
"=",
"null",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"newSelf",
"(",
"$",
"pairs",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"attributes",
")",
"&&",
"null",
"===",
"$",
"pairs",
")",
"{",
"$",
"pairs",
"=",
"$",
"self",
"->",
"attributes",
";",
"}",
"if",
"(",
"!",
"$",
"self",
"->",
"table",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"pairs",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Could not create empty data'",
")",
";",
"}",
"if",
"(",
"$",
"self",
"->",
"timestamps",
")",
"{",
"$",
"pairs",
"[",
"self",
"::",
"CREATED",
"]",
"=",
"$",
"pairs",
"[",
"self",
"::",
"UPDATED",
"]",
"=",
"$",
"self",
"->",
"freshDate",
"(",
")",
";",
"}",
"$",
"query",
"=",
"$",
"self",
"->",
"insert",
"(",
"array_keys",
"(",
"$",
"pairs",
")",
")",
"->",
"values",
"(",
"array_values",
"(",
"$",
"pairs",
")",
")",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"self",
"->",
"attributes",
"[",
"$",
"self",
"->",
"primary",
"(",
")",
"]",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}",
"return",
"false",
";",
"}"
] |
Create new data
@param array $pairs
@return int|false
|
[
"Create",
"new",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L93-L122
|
224,411
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.patch
|
public static function patch($pairs = null, $terms = null)
{
$self = self::newSelf();
if (!$self->table()) {
return false;
}
if (!empty($self->attributes) && null === $terms) {
$terms = $self->attributes;
}
if (empty($pairs)) {
throw new \LogicException('Could not update empty data');
}
if ($self->timestamps) {
$pairs[self::UPDATED] = $self->freshDate();
}
$query = $self->update($pairs);
$self->normalizeTerms($query, $terms);
if ($result = $query->execute()) {
$self->attributes = array_merge($self->attributes, $pairs);
return $result;
}
return 0;
}
|
php
|
public static function patch($pairs = null, $terms = null)
{
$self = self::newSelf();
if (!$self->table()) {
return false;
}
if (!empty($self->attributes) && null === $terms) {
$terms = $self->attributes;
}
if (empty($pairs)) {
throw new \LogicException('Could not update empty data');
}
if ($self->timestamps) {
$pairs[self::UPDATED] = $self->freshDate();
}
$query = $self->update($pairs);
$self->normalizeTerms($query, $terms);
if ($result = $query->execute()) {
$self->attributes = array_merge($self->attributes, $pairs);
return $result;
}
return 0;
}
|
[
"public",
"static",
"function",
"patch",
"(",
"$",
"pairs",
"=",
"null",
",",
"$",
"terms",
"=",
"null",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"newSelf",
"(",
")",
";",
"if",
"(",
"!",
"$",
"self",
"->",
"table",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"attributes",
")",
"&&",
"null",
"===",
"$",
"terms",
")",
"{",
"$",
"terms",
"=",
"$",
"self",
"->",
"attributes",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"pairs",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Could not update empty data'",
")",
";",
"}",
"if",
"(",
"$",
"self",
"->",
"timestamps",
")",
"{",
"$",
"pairs",
"[",
"self",
"::",
"UPDATED",
"]",
"=",
"$",
"self",
"->",
"freshDate",
"(",
")",
";",
"}",
"$",
"query",
"=",
"$",
"self",
"->",
"update",
"(",
"$",
"pairs",
")",
";",
"$",
"self",
"->",
"normalizeTerms",
"(",
"$",
"query",
",",
"$",
"terms",
")",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"self",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"self",
"->",
"attributes",
",",
"$",
"pairs",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"0",
";",
"}"
] |
Update spesific data
@param array $pairs
@param mixed $terms
@return int|false
|
[
"Update",
"spesific",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L132-L163
|
224,412
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.delete
|
public static function delete($terms = null)
{
$self = static::newSelf($terms);
if (!empty($self->attributes) && null === $terms) {
$terms = $self->attributes[$self->primary()];
}
if (empty($terms)) {
throw new \LogicException('Could not delete empty data');
}
if ($self->softDeletes) {
return $self->patch([self::DELETED => $self->freshDate()], $terms);
}
if (!$self->table()) {
return false;
}
$query = $self->remove();
$self->normalizeTerms($query, $terms);
return $query->execute();
}
|
php
|
public static function delete($terms = null)
{
$self = static::newSelf($terms);
if (!empty($self->attributes) && null === $terms) {
$terms = $self->attributes[$self->primary()];
}
if (empty($terms)) {
throw new \LogicException('Could not delete empty data');
}
if ($self->softDeletes) {
return $self->patch([self::DELETED => $self->freshDate()], $terms);
}
if (!$self->table()) {
return false;
}
$query = $self->remove();
$self->normalizeTerms($query, $terms);
return $query->execute();
}
|
[
"public",
"static",
"function",
"delete",
"(",
"$",
"terms",
"=",
"null",
")",
"{",
"$",
"self",
"=",
"static",
"::",
"newSelf",
"(",
"$",
"terms",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"attributes",
")",
"&&",
"null",
"===",
"$",
"terms",
")",
"{",
"$",
"terms",
"=",
"$",
"self",
"->",
"attributes",
"[",
"$",
"self",
"->",
"primary",
"(",
")",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"terms",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Could not delete empty data'",
")",
";",
"}",
"if",
"(",
"$",
"self",
"->",
"softDeletes",
")",
"{",
"return",
"$",
"self",
"->",
"patch",
"(",
"[",
"self",
"::",
"DELETED",
"=>",
"$",
"self",
"->",
"freshDate",
"(",
")",
"]",
",",
"$",
"terms",
")",
";",
"}",
"if",
"(",
"!",
"$",
"self",
"->",
"table",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"query",
"=",
"$",
"self",
"->",
"remove",
"(",
")",
";",
"$",
"self",
"->",
"normalizeTerms",
"(",
"$",
"query",
",",
"$",
"terms",
")",
";",
"return",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}"
] |
Delete specific data
@param mixed $terms
@return int|false
|
[
"Delete",
"specific",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L172-L197
|
224,413
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.restore
|
public static function restore($terms = null)
{
$self = self::newSelf();
if ($self->softDeletes) {
return $self->patch([self::DELETED => '0000-00-00 00:00:00'], $terms);
}
return false;
}
|
php
|
public static function restore($terms = null)
{
$self = self::newSelf();
if ($self->softDeletes) {
return $self->patch([self::DELETED => '0000-00-00 00:00:00'], $terms);
}
return false;
}
|
[
"public",
"static",
"function",
"restore",
"(",
"$",
"terms",
"=",
"null",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"newSelf",
"(",
")",
";",
"if",
"(",
"$",
"self",
"->",
"softDeletes",
")",
"{",
"return",
"$",
"self",
"->",
"patch",
"(",
"[",
"self",
"::",
"DELETED",
"=>",
"'0000-00-00 00:00:00'",
"]",
",",
"$",
"terms",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Restore soft-deleted data
@param mixed $terms
@return int|false
|
[
"Restore",
"soft",
"-",
"deleted",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L206-L215
|
224,414
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.count
|
public function count($terms = null)
{
if (!$this->table()) {
return 0;
}
$query = $this->select(['count(*) count']);
$this->normalizeTerms($query, $terms);
return (int) $query->execute()->fetch()['count'];
}
|
php
|
public function count($terms = null)
{
if (!$this->table()) {
return 0;
}
$query = $this->select(['count(*) count']);
$this->normalizeTerms($query, $terms);
return (int) $query->execute()->fetch()['count'];
}
|
[
"public",
"function",
"count",
"(",
"$",
"terms",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"table",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"select",
"(",
"[",
"'count(*) count'",
"]",
")",
";",
"$",
"this",
"->",
"normalizeTerms",
"(",
"$",
"query",
",",
"$",
"terms",
")",
";",
"return",
"(",
"int",
")",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetch",
"(",
")",
"[",
"'count'",
"]",
";",
"}"
] |
Count all data
@param callable|array|int $terms
@return int
|
[
"Count",
"all",
"data"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L224-L235
|
224,415
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.select
|
protected function select(array $columns = [])
{
$columns = !is_array($columns) ? func_get_args() : $columns;
if (empty($columns)) {
$columns = ['*'];
}
return static::db()->select($columns)->from($this->table());
}
|
php
|
protected function select(array $columns = [])
{
$columns = !is_array($columns) ? func_get_args() : $columns;
if (empty($columns)) {
$columns = ['*'];
}
return static::db()->select($columns)->from($this->table());
}
|
[
"protected",
"function",
"select",
"(",
"array",
"$",
"columns",
"=",
"[",
"]",
")",
"{",
"$",
"columns",
"=",
"!",
"is_array",
"(",
"$",
"columns",
")",
"?",
"func_get_args",
"(",
")",
":",
"$",
"columns",
";",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"columns",
"=",
"[",
"'*'",
"]",
";",
"}",
"return",
"static",
"::",
"db",
"(",
")",
"->",
"select",
"(",
"$",
"columns",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"table",
"(",
")",
")",
";",
"}"
] |
Select data from table
@param array $columns
@return \Slim\PDO\Statement\SelectStatement
|
[
"Select",
"data",
"from",
"table"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L284-L293
|
224,416
|
projek-xyz/slim-framework
|
src/Database/Models.php
|
Models.normalizeTerms
|
protected function normalizeTerms(StatementContainer $stmt, $terms)
{
if ($terms instanceof Models) {
$terms = $terms->key();
}
if (is_callable($terms)) {
$terms($stmt);
} elseif (is_numeric($terms) && !is_float($terms)) {
$stmt->where($this->primary, '=', (int) $terms);
} elseif (is_array($terms)) {
foreach ($terms as $key => $value) {
$sign = '=';
if (strpos($key, ' ') !== false) {
list($key, $sign) = explode(' ', $key);
}
if (is_array($value)) {
$stmt->whereIn($key, $value);
} elseif (null === $value) {
$stmt->whereNull($key);
} else {
$stmt->where($key, $sign, $value);
}
}
}
}
|
php
|
protected function normalizeTerms(StatementContainer $stmt, $terms)
{
if ($terms instanceof Models) {
$terms = $terms->key();
}
if (is_callable($terms)) {
$terms($stmt);
} elseif (is_numeric($terms) && !is_float($terms)) {
$stmt->where($this->primary, '=', (int) $terms);
} elseif (is_array($terms)) {
foreach ($terms as $key => $value) {
$sign = '=';
if (strpos($key, ' ') !== false) {
list($key, $sign) = explode(' ', $key);
}
if (is_array($value)) {
$stmt->whereIn($key, $value);
} elseif (null === $value) {
$stmt->whereNull($key);
} else {
$stmt->where($key, $sign, $value);
}
}
}
}
|
[
"protected",
"function",
"normalizeTerms",
"(",
"StatementContainer",
"$",
"stmt",
",",
"$",
"terms",
")",
"{",
"if",
"(",
"$",
"terms",
"instanceof",
"Models",
")",
"{",
"$",
"terms",
"=",
"$",
"terms",
"->",
"key",
"(",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"terms",
")",
")",
"{",
"$",
"terms",
"(",
"$",
"stmt",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"terms",
")",
"&&",
"!",
"is_float",
"(",
"$",
"terms",
")",
")",
"{",
"$",
"stmt",
"->",
"where",
"(",
"$",
"this",
"->",
"primary",
",",
"'='",
",",
"(",
"int",
")",
"$",
"terms",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"terms",
")",
")",
"{",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"sign",
"=",
"'='",
";",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"sign",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"stmt",
"->",
"whereIn",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"stmt",
"->",
"whereNull",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"stmt",
"->",
"where",
"(",
"$",
"key",
",",
"$",
"sign",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}"
] |
Normalize query terms
@param \Slim\PDO\Statement\StatementContainer $stmt
@param Models|array|int|callable $terms
@return void
|
[
"Normalize",
"query",
"terms"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Database/Models.php#L387-L413
|
224,417
|
coderatio/phpfirebase
|
src/PhpFirebase.php
|
PhpFirebase.getRecord
|
public function getRecord(int $recordID)
{
foreach ($this->getRecords() as $key => $record) {
if ($record[$this->primaryKey] == $recordID) {
return $record;
}
}
return null;
}
|
php
|
public function getRecord(int $recordID)
{
foreach ($this->getRecords() as $key => $record) {
if ($record[$this->primaryKey] == $recordID) {
return $record;
}
}
return null;
}
|
[
"public",
"function",
"getRecord",
"(",
"int",
"$",
"recordID",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRecords",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"record",
"[",
"$",
"this",
"->",
"primaryKey",
"]",
"==",
"$",
"recordID",
")",
"{",
"return",
"$",
"record",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
This function returns a specific record by id
@param int $recordID
@return null|array
|
[
"This",
"function",
"returns",
"a",
"specific",
"record",
"by",
"id"
] |
f9342ef6bf755abc7610c853c958659f5671cd8f
|
https://github.com/coderatio/phpfirebase/blob/f9342ef6bf755abc7610c853c958659f5671cd8f/src/PhpFirebase.php#L98-L107
|
224,418
|
coderatio/phpfirebase
|
src/PhpFirebase.php
|
PhpFirebase.updateRecord
|
public function updateRecord(int $recordID, array $data)
{
foreach ($this->getRecords() as $key => $record) {
if ($recordID == $record[$this->primaryKey]) {
foreach ($data as $dataKey => $dataValue) {
if (isset($record[$dataKey])) {
$record[$dataKey] = $dataValue;
}
}
$this->database->getReference()
->getChild($this->table)
->getChild($key)
->set($record);
}
}
return $this->getRecord($recordID);
}
|
php
|
public function updateRecord(int $recordID, array $data)
{
foreach ($this->getRecords() as $key => $record) {
if ($recordID == $record[$this->primaryKey]) {
foreach ($data as $dataKey => $dataValue) {
if (isset($record[$dataKey])) {
$record[$dataKey] = $dataValue;
}
}
$this->database->getReference()
->getChild($this->table)
->getChild($key)
->set($record);
}
}
return $this->getRecord($recordID);
}
|
[
"public",
"function",
"updateRecord",
"(",
"int",
"$",
"recordID",
",",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRecords",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"recordID",
"==",
"$",
"record",
"[",
"$",
"this",
"->",
"primaryKey",
"]",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataKey",
"=>",
"$",
"dataValue",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"record",
"[",
"$",
"dataKey",
"]",
")",
")",
"{",
"$",
"record",
"[",
"$",
"dataKey",
"]",
"=",
"$",
"dataValue",
";",
"}",
"}",
"$",
"this",
"->",
"database",
"->",
"getReference",
"(",
")",
"->",
"getChild",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"getChild",
"(",
"$",
"key",
")",
"->",
"set",
"(",
"$",
"record",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"getRecord",
"(",
"$",
"recordID",
")",
";",
"}"
] |
This function updates a record
It will return updated records
@param int $recordID
@param array $data
@return array
|
[
"This",
"function",
"updates",
"a",
"record",
"It",
"will",
"return",
"updated",
"records"
] |
f9342ef6bf755abc7610c853c958659f5671cd8f
|
https://github.com/coderatio/phpfirebase/blob/f9342ef6bf755abc7610c853c958659f5671cd8f/src/PhpFirebase.php#L142-L160
|
224,419
|
coderatio/phpfirebase
|
src/PhpFirebase.php
|
PhpFirebase.deleteRecord
|
public function deleteRecord(int $recordID) {
foreach ($this->getRecords() as $key => $record) {
if ($record['id'] == $recordID) {
$this->database->getReference()
->getChild($this->table)
->getChild($key)
->set(null);
return true;
}
}
return false;
}
|
php
|
public function deleteRecord(int $recordID) {
foreach ($this->getRecords() as $key => $record) {
if ($record['id'] == $recordID) {
$this->database->getReference()
->getChild($this->table)
->getChild($key)
->set(null);
return true;
}
}
return false;
}
|
[
"public",
"function",
"deleteRecord",
"(",
"int",
"$",
"recordID",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRecords",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"record",
"[",
"'id'",
"]",
"==",
"$",
"recordID",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"getReference",
"(",
")",
"->",
"getChild",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"getChild",
"(",
"$",
"key",
")",
"->",
"set",
"(",
"null",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
This function deletes a record from your database.
It will return boolean after action was commited
@param int $recordID
@return bool
|
[
"This",
"function",
"deletes",
"a",
"record",
"from",
"your",
"database",
".",
"It",
"will",
"return",
"boolean",
"after",
"action",
"was",
"commited"
] |
f9342ef6bf755abc7610c853c958659f5671cd8f
|
https://github.com/coderatio/phpfirebase/blob/f9342ef6bf755abc7610c853c958659f5671cd8f/src/PhpFirebase.php#L169-L182
|
224,420
|
projek-xyz/slim-framework
|
src/Console/Input.php
|
Input.input
|
public function input($prompt, $default = '', $acceptable = null, $strict = false)
{
if ($this->hasSttyAvailable()) {
$input = $this->climate->input($prompt);
if (! empty($default)) {
$input->defaultTo($default);
}
if (null !== $acceptable) {
$input->accept($acceptable, true);
}
if (true === $strict) {
$input->strict();
}
return $input->prompt();
}
return $default;
}
|
php
|
public function input($prompt, $default = '', $acceptable = null, $strict = false)
{
if ($this->hasSttyAvailable()) {
$input = $this->climate->input($prompt);
if (! empty($default)) {
$input->defaultTo($default);
}
if (null !== $acceptable) {
$input->accept($acceptable, true);
}
if (true === $strict) {
$input->strict();
}
return $input->prompt();
}
return $default;
}
|
[
"public",
"function",
"input",
"(",
"$",
"prompt",
",",
"$",
"default",
"=",
"''",
",",
"$",
"acceptable",
"=",
"null",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSttyAvailable",
"(",
")",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"climate",
"->",
"input",
"(",
"$",
"prompt",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"$",
"input",
"->",
"defaultTo",
"(",
"$",
"default",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"acceptable",
")",
"{",
"$",
"input",
"->",
"accept",
"(",
"$",
"acceptable",
",",
"true",
")",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"strict",
")",
"{",
"$",
"input",
"->",
"strict",
"(",
")",
";",
"}",
"return",
"$",
"input",
"->",
"prompt",
"(",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Wanna ask something
@param string $prompt The question you want to ask for
@param string $default Default answer
@param array|callable $acceptable Acceptable answer
@param bool $strict Case-sensitife?
@return string
|
[
"Wanna",
"ask",
"something"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Console/Input.php#L20-L40
|
224,421
|
projek-xyz/slim-framework
|
src/Console/Input.php
|
Input.password
|
public function password($prompt)
{
if ($this->hasSttyAvailable()) {
$password = $this->climate->password($prompt);
return $password->prompt();
}
return '';
}
|
php
|
public function password($prompt)
{
if ($this->hasSttyAvailable()) {
$password = $this->climate->password($prompt);
return $password->prompt();
}
return '';
}
|
[
"public",
"function",
"password",
"(",
"$",
"prompt",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSttyAvailable",
"(",
")",
")",
"{",
"$",
"password",
"=",
"$",
"this",
"->",
"climate",
"->",
"password",
"(",
"$",
"prompt",
")",
";",
"return",
"$",
"password",
"->",
"prompt",
"(",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Ask something secretly?
@param string $prompt The question you want to ask for
@return string
|
[
"Ask",
"something",
"secretly?"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Console/Input.php#L48-L56
|
224,422
|
projek-xyz/slim-framework
|
src/Console/Input.php
|
Input.confirm
|
public function confirm($prompt)
{
if ($this->hasSttyAvailable()) {
$confirm = $this->climate->confirm($prompt);
return $confirm->confirmed();
}
return '';
}
|
php
|
public function confirm($prompt)
{
if ($this->hasSttyAvailable()) {
$confirm = $this->climate->confirm($prompt);
return $confirm->confirmed();
}
return '';
}
|
[
"public",
"function",
"confirm",
"(",
"$",
"prompt",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSttyAvailable",
"(",
")",
")",
"{",
"$",
"confirm",
"=",
"$",
"this",
"->",
"climate",
"->",
"confirm",
"(",
"$",
"prompt",
")",
";",
"return",
"$",
"confirm",
"->",
"confirmed",
"(",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Choise between yes or no?
@param string $prompt The question you want to ask for
@return bool
|
[
"Choise",
"between",
"yes",
"or",
"no?"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Console/Input.php#L64-L72
|
224,423
|
projek-xyz/slim-framework
|
src/Console/Input.php
|
Input.checkboxes
|
public function checkboxes($prompt, array $options)
{
if ($this->hasSttyAvailable()) {
$checkboxes = $this->climate->checkboxes($prompt, $options);
return $checkboxes->prompt();
}
return '';
}
|
php
|
public function checkboxes($prompt, array $options)
{
if ($this->hasSttyAvailable()) {
$checkboxes = $this->climate->checkboxes($prompt, $options);
return $checkboxes->prompt();
}
return '';
}
|
[
"public",
"function",
"checkboxes",
"(",
"$",
"prompt",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSttyAvailable",
"(",
")",
")",
"{",
"$",
"checkboxes",
"=",
"$",
"this",
"->",
"climate",
"->",
"checkboxes",
"(",
"$",
"prompt",
",",
"$",
"options",
")",
";",
"return",
"$",
"checkboxes",
"->",
"prompt",
"(",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Choise multiple answer from given options?
@param string $prompt The question you want to ask for
@param array $options Available options
@return string
|
[
"Choise",
"multiple",
"answer",
"from",
"given",
"options?"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Console/Input.php#L81-L89
|
224,424
|
projek-xyz/slim-framework
|
src/Console/Input.php
|
Input.radio
|
public function radio($prompt, array $options)
{
if ($this->hasSttyAvailable()) {
$radio = $this->climate->radio($prompt, $options);
return $radio->prompt();
}
return '';
}
|
php
|
public function radio($prompt, array $options)
{
if ($this->hasSttyAvailable()) {
$radio = $this->climate->radio($prompt, $options);
return $radio->prompt();
}
return '';
}
|
[
"public",
"function",
"radio",
"(",
"$",
"prompt",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSttyAvailable",
"(",
")",
")",
"{",
"$",
"radio",
"=",
"$",
"this",
"->",
"climate",
"->",
"radio",
"(",
"$",
"prompt",
",",
"$",
"options",
")",
";",
"return",
"$",
"radio",
"->",
"prompt",
"(",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Choise an answer from given options?
@param string $prompt The question you want to ask for
@param array $options Available options
@return string
|
[
"Choise",
"an",
"answer",
"from",
"given",
"options?"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Console/Input.php#L98-L106
|
224,425
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.setConfig
|
public function setConfig($notificationData, $payloadData = [], $silentNotification = false, $scheduledDateTime = '', $sound = 'default')
{
if (!is_array($notificationData)) {
$notificationData = [$notificationData];
}
if (count($notificationData) > 0) {
$this->requestData = array_merge($this->requestData, ['notification' => $notificationData]);
}
// payload
if (!is_array($payloadData)) {
$payloadData = [$payloadData];
}
if (count($payloadData) > 0) {
$this->requestData['notification']['payload'] = $payloadData;
}
// silent
if ($silentNotification) {
$this->requestData['notification']['android']['content_available'] = 1;
$this->requestData['notification']['ios']['content_available'] = 1;
} else {
unset($this->requestData['notification']['android']['content_available']);
unset($this->requestData['notification']['ios']['content_available']);
}
// scheduled
if ($this->isDatetime($scheduledDateTime)) {
// Convert dateTime to RFC3339
$this->requestData['scheduled'] = date("c", strtotime($scheduledDateTime));
}
// sound
$this->requestData['notification']['android']['sound'] = $sound;
$this->requestData['notification']['ios']['sound'] = $sound;
}
|
php
|
public function setConfig($notificationData, $payloadData = [], $silentNotification = false, $scheduledDateTime = '', $sound = 'default')
{
if (!is_array($notificationData)) {
$notificationData = [$notificationData];
}
if (count($notificationData) > 0) {
$this->requestData = array_merge($this->requestData, ['notification' => $notificationData]);
}
// payload
if (!is_array($payloadData)) {
$payloadData = [$payloadData];
}
if (count($payloadData) > 0) {
$this->requestData['notification']['payload'] = $payloadData;
}
// silent
if ($silentNotification) {
$this->requestData['notification']['android']['content_available'] = 1;
$this->requestData['notification']['ios']['content_available'] = 1;
} else {
unset($this->requestData['notification']['android']['content_available']);
unset($this->requestData['notification']['ios']['content_available']);
}
// scheduled
if ($this->isDatetime($scheduledDateTime)) {
// Convert dateTime to RFC3339
$this->requestData['scheduled'] = date("c", strtotime($scheduledDateTime));
}
// sound
$this->requestData['notification']['android']['sound'] = $sound;
$this->requestData['notification']['ios']['sound'] = $sound;
}
|
[
"public",
"function",
"setConfig",
"(",
"$",
"notificationData",
",",
"$",
"payloadData",
"=",
"[",
"]",
",",
"$",
"silentNotification",
"=",
"false",
",",
"$",
"scheduledDateTime",
"=",
"''",
",",
"$",
"sound",
"=",
"'default'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"notificationData",
")",
")",
"{",
"$",
"notificationData",
"=",
"[",
"$",
"notificationData",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"notificationData",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"requestData",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"requestData",
",",
"[",
"'notification'",
"=>",
"$",
"notificationData",
"]",
")",
";",
"}",
"// payload",
"if",
"(",
"!",
"is_array",
"(",
"$",
"payloadData",
")",
")",
"{",
"$",
"payloadData",
"=",
"[",
"$",
"payloadData",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"payloadData",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'payload'",
"]",
"=",
"$",
"payloadData",
";",
"}",
"// silent",
"if",
"(",
"$",
"silentNotification",
")",
"{",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'android'",
"]",
"[",
"'content_available'",
"]",
"=",
"1",
";",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'ios'",
"]",
"[",
"'content_available'",
"]",
"=",
"1",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'android'",
"]",
"[",
"'content_available'",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'ios'",
"]",
"[",
"'content_available'",
"]",
")",
";",
"}",
"// scheduled",
"if",
"(",
"$",
"this",
"->",
"isDatetime",
"(",
"$",
"scheduledDateTime",
")",
")",
"{",
"// Convert dateTime to RFC3339",
"$",
"this",
"->",
"requestData",
"[",
"'scheduled'",
"]",
"=",
"date",
"(",
"\"c\"",
",",
"strtotime",
"(",
"$",
"scheduledDateTime",
")",
")",
";",
"}",
"// sound",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'android'",
"]",
"[",
"'sound'",
"]",
"=",
"$",
"sound",
";",
"$",
"this",
"->",
"requestData",
"[",
"'notification'",
"]",
"[",
"'ios'",
"]",
"[",
"'sound'",
"]",
"=",
"$",
"sound",
";",
"}"
] |
Set notification config.
@link https://docs.ionic.io/api/endpoints/push.html#post-notifications Ionic documentation
@param array $notificationData
@param array $payloadData - Custom extra data
@param boolean $silentNotification - Determines if the message should be delivered as a silent notification.
@param string $scheduledDateTime - Time to start delivery of the notification Y-m-d H:i:s format
@param string $sound - Filename of audio file to play when a notification is received.
|
[
"Set",
"notification",
"config",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L51-L86
|
224,426
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.paginatedList
|
public function paginatedList($parameters = [])
{
$response = $this->sendRequest(
self::METHOD_GET,
self::$endPoints['list'] . '?' . http_build_query($parameters),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
php
|
public function paginatedList($parameters = [])
{
$response = $this->sendRequest(
self::METHOD_GET,
self::$endPoints['list'] . '?' . http_build_query($parameters),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
[
"public",
"function",
"paginatedList",
"(",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'list'",
"]",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
",",
"$",
"this",
"->",
"requestData",
")",
";",
"$",
"this",
"->",
"resetRequestData",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Paginated listing of Push Notifications.
@link https://docs.ionic.io/api/endpoints/push.html#get-notifications Ionic documentation
@param array $parameters
@return object $response
|
[
"Paginated",
"listing",
"of",
"Push",
"Notifications",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L95-L104
|
224,427
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.retrieve
|
public function retrieve($notificationId)
{
$response = $this->sendRequest(
self::METHOD_GET,
str_replace(':notification_id', $notificationId, self::$endPoints['retrieve']),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
php
|
public function retrieve($notificationId)
{
$response = $this->sendRequest(
self::METHOD_GET,
str_replace(':notification_id', $notificationId, self::$endPoints['retrieve']),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
[
"public",
"function",
"retrieve",
"(",
"$",
"notificationId",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"str_replace",
"(",
"':notification_id'",
",",
"$",
"notificationId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'retrieve'",
"]",
")",
",",
"$",
"this",
"->",
"requestData",
")",
";",
"$",
"this",
"->",
"resetRequestData",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Get a Notification.
@link https://docs.ionic.io/api/endpoints/push.html#get-notifications-notification_id Ionic documentation
@param string $notificationId - Notification id
@return object $response
|
[
"Get",
"a",
"Notification",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L113-L122
|
224,428
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.delete
|
public function delete($notificationId)
{
return $this->sendRequest(
self::METHOD_DELETE,
str_replace(':notification_id', $notificationId, self::$endPoints['delete'])
);
}
|
php
|
public function delete($notificationId)
{
return $this->sendRequest(
self::METHOD_DELETE,
str_replace(':notification_id', $notificationId, self::$endPoints['delete'])
);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"notificationId",
")",
"{",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_DELETE",
",",
"str_replace",
"(",
"':notification_id'",
",",
"$",
"notificationId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'delete'",
"]",
")",
")",
";",
"}"
] |
Deletes a notification.
@link https://docs.ionic.io/api/endpoints/push.html#delete-notifications-notification_id Ionic documentation
@param $notificationId
@return object $response
|
[
"Deletes",
"a",
"notification",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L149-L155
|
224,429
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.deleteAll
|
public function deleteAll()
{
$responses = array();
$notifications = self::paginatedList();
if ($notifications['success']) {
foreach ($notifications['response']['data'] as $notification) {
$responses[] = self::delete($notification->uuid);
}
} else {
return array($notifications);
}
return $responses;
}
|
php
|
public function deleteAll()
{
$responses = array();
$notifications = self::paginatedList();
if ($notifications['success']) {
foreach ($notifications['response']['data'] as $notification) {
$responses[] = self::delete($notification->uuid);
}
} else {
return array($notifications);
}
return $responses;
}
|
[
"public",
"function",
"deleteAll",
"(",
")",
"{",
"$",
"responses",
"=",
"array",
"(",
")",
";",
"$",
"notifications",
"=",
"self",
"::",
"paginatedList",
"(",
")",
";",
"if",
"(",
"$",
"notifications",
"[",
"'success'",
"]",
")",
"{",
"foreach",
"(",
"$",
"notifications",
"[",
"'response'",
"]",
"[",
"'data'",
"]",
"as",
"$",
"notification",
")",
"{",
"$",
"responses",
"[",
"]",
"=",
"self",
"::",
"delete",
"(",
"$",
"notification",
"->",
"uuid",
")",
";",
"}",
"}",
"else",
"{",
"return",
"array",
"(",
"$",
"notifications",
")",
";",
"}",
"return",
"$",
"responses",
";",
"}"
] |
Deletes all notifications
@return array - array of responses
|
[
"Deletes",
"all",
"notifications"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L162-L174
|
224,430
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.listMessages
|
public function listMessages($notificationId, $parameters = [])
{
$endPoint = str_replace(':notification_id', $notificationId, self::$endPoints['listMessages']);
$response = $this->sendRequest(
self::METHOD_GET,
$endPoint . '?' . http_build_query($parameters),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
php
|
public function listMessages($notificationId, $parameters = [])
{
$endPoint = str_replace(':notification_id', $notificationId, self::$endPoints['listMessages']);
$response = $this->sendRequest(
self::METHOD_GET,
$endPoint . '?' . http_build_query($parameters),
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
[
"public",
"function",
"listMessages",
"(",
"$",
"notificationId",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"endPoint",
"=",
"str_replace",
"(",
"':notification_id'",
",",
"$",
"notificationId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'listMessages'",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"$",
"endPoint",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
",",
"$",
"this",
"->",
"requestData",
")",
";",
"$",
"this",
"->",
"resetRequestData",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
List messages of the indicated notification.
@link https://docs.ionic.io/api/endpoints/push.html#get-notifications-notification_id-messages Ionic documentation
@param string $notificationId - Notification id
@param array $parameters
@return object $response
|
[
"List",
"messages",
"of",
"the",
"indicated",
"notification",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L184-L194
|
224,431
|
tomloprod/ionic-push-php
|
src/Api/Notifications.php
|
Notifications.create
|
private function create()
{
$response = $this->sendRequest(
self::METHOD_POST,
self::$endPoints['create'],
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
php
|
private function create()
{
$response = $this->sendRequest(
self::METHOD_POST,
self::$endPoints['create'],
$this->requestData
);
$this->resetRequestData();
return $response;
}
|
[
"private",
"function",
"create",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_POST",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'create'",
"]",
",",
"$",
"this",
"->",
"requestData",
")",
";",
"$",
"this",
"->",
"resetRequestData",
"(",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Create a Push Notification.
Used by "sendNotification" and "sendNotificationToAll".
@private
@return object $response
|
[
"Create",
"a",
"Push",
"Notification",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Notifications.php#L232-L241
|
224,432
|
joomla-framework/language
|
src/Transliterate.php
|
Transliterate.utf8_latin_to_ascii
|
public static function utf8_latin_to_ascii($string, $case = 0)
{
if ($case <= 0)
{
$string = str_replace(array_keys(self::$utf8LowerAccents), array_values(self::$utf8LowerAccents), $string);
}
if ($case >= 0)
{
$string = str_replace(array_keys(self::$utf8UpperAccents), array_values(self::$utf8UpperAccents), $string);
}
return $string;
}
|
php
|
public static function utf8_latin_to_ascii($string, $case = 0)
{
if ($case <= 0)
{
$string = str_replace(array_keys(self::$utf8LowerAccents), array_values(self::$utf8LowerAccents), $string);
}
if ($case >= 0)
{
$string = str_replace(array_keys(self::$utf8UpperAccents), array_values(self::$utf8UpperAccents), $string);
}
return $string;
}
|
[
"public",
"static",
"function",
"utf8_latin_to_ascii",
"(",
"$",
"string",
",",
"$",
"case",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"case",
"<=",
"0",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"utf8LowerAccents",
")",
",",
"array_values",
"(",
"self",
"::",
"$",
"utf8LowerAccents",
")",
",",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"case",
">=",
"0",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"utf8UpperAccents",
")",
",",
"array_values",
"(",
"self",
"::",
"$",
"utf8UpperAccents",
")",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Returns strings transliterated from UTF-8 to Latin
@param string $string String to transliterate
@param int $case Optionally specify upper or lower case. Default to 0 (both).
@return string Transliterated string
@since 1.0
|
[
"Returns",
"strings",
"transliterated",
"from",
"UTF",
"-",
"8",
"to",
"Latin"
] |
94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf
|
https://github.com/joomla-framework/language/blob/94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf/src/Transliterate.php#L255-L268
|
224,433
|
tomloprod/ionic-push-php
|
src/Api/Messages.php
|
Messages.retrieve
|
public function retrieve($messageId)
{
return $this->sendRequest(
self::METHOD_GET,
str_replace(':message_id', $messageId, self::$endPoints['retrieve'])
);
}
|
php
|
public function retrieve($messageId)
{
return $this->sendRequest(
self::METHOD_GET,
str_replace(':message_id', $messageId, self::$endPoints['retrieve'])
);
}
|
[
"public",
"function",
"retrieve",
"(",
"$",
"messageId",
")",
"{",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"self",
"::",
"METHOD_GET",
",",
"str_replace",
"(",
"':message_id'",
",",
"$",
"messageId",
",",
"self",
"::",
"$",
"endPoints",
"[",
"'retrieve'",
"]",
")",
")",
";",
"}"
] |
Get Message details. Use this method to check the current status of a message or to lookup the error code for failures.
@link https://docs.ionic.io/api/endpoints/push.html#get-messages-message_id Ionic documentation
@param string $messageId - Message ID
@return object $response
|
[
"Get",
"Message",
"details",
".",
"Use",
"this",
"method",
"to",
"check",
"the",
"current",
"status",
"of",
"a",
"message",
"or",
"to",
"lookup",
"the",
"error",
"code",
"for",
"failures",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Messages.php#L29-L35
|
224,434
|
projek-xyz/slim-framework
|
src/DefaultServicesProvider.php
|
DefaultServicesProvider.initializeDatabase
|
private function initializeDatabase(array $settings)
{
if (!isset($settings['dsn']) || !$settings['dsn']) {
$settings['charset'] = isset($settings['charset']) ? $settings['charset'] : 'utf8';
$settings['dsn'] = sprintf(
'%s:host=%s;dbname=%s;charset=%s',
$settings['driver'],
$settings['host'],
$settings['name'],
$settings['charset']
);
}
return $settings;
}
|
php
|
private function initializeDatabase(array $settings)
{
if (!isset($settings['dsn']) || !$settings['dsn']) {
$settings['charset'] = isset($settings['charset']) ? $settings['charset'] : 'utf8';
$settings['dsn'] = sprintf(
'%s:host=%s;dbname=%s;charset=%s',
$settings['driver'],
$settings['host'],
$settings['name'],
$settings['charset']
);
}
return $settings;
}
|
[
"private",
"function",
"initializeDatabase",
"(",
"array",
"$",
"settings",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"settings",
"[",
"'dsn'",
"]",
")",
"||",
"!",
"$",
"settings",
"[",
"'dsn'",
"]",
")",
"{",
"$",
"settings",
"[",
"'charset'",
"]",
"=",
"isset",
"(",
"$",
"settings",
"[",
"'charset'",
"]",
")",
"?",
"$",
"settings",
"[",
"'charset'",
"]",
":",
"'utf8'",
";",
"$",
"settings",
"[",
"'dsn'",
"]",
"=",
"sprintf",
"(",
"'%s:host=%s;dbname=%s;charset=%s'",
",",
"$",
"settings",
"[",
"'driver'",
"]",
",",
"$",
"settings",
"[",
"'host'",
"]",
",",
"$",
"settings",
"[",
"'name'",
"]",
",",
"$",
"settings",
"[",
"'charset'",
"]",
")",
";",
"}",
"return",
"$",
"settings",
";",
"}"
] |
Initialize database settings
@param array $settings
@return array
|
[
"Initialize",
"database",
"settings"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/DefaultServicesProvider.php#L263-L277
|
224,435
|
petebrowne/slim-layout-view
|
Slim/LayoutView.php
|
LayoutView.fetch
|
public function fetch($template, $data = null) {
$layout = $this->getLayout($data);
$result = $this->render($template, $data);
if (is_string($layout)) {
$result = $this->renderLayout($layout, $result, $data);
}
return $result;
}
|
php
|
public function fetch($template, $data = null) {
$layout = $this->getLayout($data);
$result = $this->render($template, $data);
if (is_string($layout)) {
$result = $this->renderLayout($layout, $result, $data);
}
return $result;
}
|
[
"public",
"function",
"fetch",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"getLayout",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"renderLayout",
"(",
"$",
"layout",
",",
"$",
"result",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Override the default fetch mechanism to render a layout if set.
@param string $template Path to template file relative to templates directory
@param array $data Any additonal data to be passed to the template.
@return string The fully rendered view as a string.
|
[
"Override",
"the",
"default",
"fetch",
"mechanism",
"to",
"render",
"a",
"layout",
"if",
"set",
"."
] |
5690a052221f3f7d20c5e93e82608fbf2b0ff330
|
https://github.com/petebrowne/slim-layout-view/blob/5690a052221f3f7d20c5e93e82608fbf2b0ff330/Slim/LayoutView.php#L42-L50
|
224,436
|
petebrowne/slim-layout-view
|
Slim/LayoutView.php
|
LayoutView.getLayout
|
public function getLayout($data = null) {
$layout = null;
// 1) Check the passed in data
if (is_array($data) && array_key_exists(self::LAYOUT_KEY, $data)) {
$layout = $data[self::LAYOUT_KEY];
unset($data[self::LAYOUT_KEY]);
}
// 2) Check the data on the View
if ($this->has(self::LAYOUT_KEY)) {
$layout = $this->get(self::LAYOUT_KEY);
$this->remove(self::LAYOUT_KEY);
}
// 3) Check the Slim configuration
if (is_null($layout)) {
$app = Slim::getInstance();
if (isset($app)) {
$layout = $app->config(self::LAYOUT_KEY);
}
}
// 4) Use the default layout
if (is_null($layout)) {
$layout = self::DEFAULT_LAYOUT;
}
return $layout;
}
|
php
|
public function getLayout($data = null) {
$layout = null;
// 1) Check the passed in data
if (is_array($data) && array_key_exists(self::LAYOUT_KEY, $data)) {
$layout = $data[self::LAYOUT_KEY];
unset($data[self::LAYOUT_KEY]);
}
// 2) Check the data on the View
if ($this->has(self::LAYOUT_KEY)) {
$layout = $this->get(self::LAYOUT_KEY);
$this->remove(self::LAYOUT_KEY);
}
// 3) Check the Slim configuration
if (is_null($layout)) {
$app = Slim::getInstance();
if (isset($app)) {
$layout = $app->config(self::LAYOUT_KEY);
}
}
// 4) Use the default layout
if (is_null($layout)) {
$layout = self::DEFAULT_LAYOUT;
}
return $layout;
}
|
[
"public",
"function",
"getLayout",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"layout",
"=",
"null",
";",
"// 1) Check the passed in data",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"array_key_exists",
"(",
"self",
"::",
"LAYOUT_KEY",
",",
"$",
"data",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"data",
"[",
"self",
"::",
"LAYOUT_KEY",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"self",
"::",
"LAYOUT_KEY",
"]",
")",
";",
"}",
"// 2) Check the data on the View",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"self",
"::",
"LAYOUT_KEY",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"get",
"(",
"self",
"::",
"LAYOUT_KEY",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"self",
"::",
"LAYOUT_KEY",
")",
";",
"}",
"// 3) Check the Slim configuration",
"if",
"(",
"is_null",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"app",
"=",
"Slim",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"app",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"app",
"->",
"config",
"(",
"self",
"::",
"LAYOUT_KEY",
")",
";",
"}",
"}",
"// 4) Use the default layout",
"if",
"(",
"is_null",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"layout",
"=",
"self",
"::",
"DEFAULT_LAYOUT",
";",
"}",
"return",
"$",
"layout",
";",
"}"
] |
Returns the layout for this view. This will be either
the 'layout' data value, the applications 'layout' configuration
value, or 'layout.php'.
@param array $data Any additonal data to be passed to the template.
@return string|null
|
[
"Returns",
"the",
"layout",
"for",
"this",
"view",
".",
"This",
"will",
"be",
"either",
"the",
"layout",
"data",
"value",
"the",
"applications",
"layout",
"configuration",
"value",
"or",
"layout",
".",
"php",
"."
] |
5690a052221f3f7d20c5e93e82608fbf2b0ff330
|
https://github.com/petebrowne/slim-layout-view/blob/5690a052221f3f7d20c5e93e82608fbf2b0ff330/Slim/LayoutView.php#L61-L90
|
224,437
|
maxmind/ccfd-api-php
|
src/HTTPBase.php
|
HTTPBase.query
|
public function query()
{
// Query every server using it's domain name.
for ($i = 0; $i < $this->numservers; $i++) {
$result = $this->querySingleServer($this->server[$i]);
if ($this->debug) {
echo "server: {$this->server[$i]}\n";
echo "result: $result\n";
}
if ($result) {
return $result;
}
}
return false;
}
|
php
|
public function query()
{
// Query every server using it's domain name.
for ($i = 0; $i < $this->numservers; $i++) {
$result = $this->querySingleServer($this->server[$i]);
if ($this->debug) {
echo "server: {$this->server[$i]}\n";
echo "result: $result\n";
}
if ($result) {
return $result;
}
}
return false;
}
|
[
"public",
"function",
"query",
"(",
")",
"{",
"// Query every server using it's domain name.",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"numservers",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"querySingleServer",
"(",
"$",
"this",
"->",
"server",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"echo",
"\"server: {$this->server[$i]}\\n\"",
";",
"echo",
"\"result: $result\\n\"",
";",
"}",
"if",
"(",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Query each server.
@return false|string
|
[
"Query",
"each",
"server",
"."
] |
5f6c2a5454e755f1c56be17a1fc0c97576ff010e
|
https://github.com/maxmind/ccfd-api-php/blob/5f6c2a5454e755f1c56be17a1fc0c97576ff010e/src/HTTPBase.php#L187-L202
|
224,438
|
maxmind/ccfd-api-php
|
src/HTTPBase.php
|
HTTPBase.input
|
public function input($inputVars)
{
foreach ($inputVars as $key => $val) {
if (empty($this->allowed_fields[$key])) {
echo "Invalid input $key - perhaps misspelled field?\n";
return false;
}
$this->queries[$key] = urlencode($this->filter_field($key, $val));
}
$this->queries['clientAPI'] = self::API_VERSION;
}
|
php
|
public function input($inputVars)
{
foreach ($inputVars as $key => $val) {
if (empty($this->allowed_fields[$key])) {
echo "Invalid input $key - perhaps misspelled field?\n";
return false;
}
$this->queries[$key] = urlencode($this->filter_field($key, $val));
}
$this->queries['clientAPI'] = self::API_VERSION;
}
|
[
"public",
"function",
"input",
"(",
"$",
"inputVars",
")",
"{",
"foreach",
"(",
"$",
"inputVars",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"allowed_fields",
"[",
"$",
"key",
"]",
")",
")",
"{",
"echo",
"\"Invalid input $key - perhaps misspelled field?\\n\"",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"queries",
"[",
"$",
"key",
"]",
"=",
"urlencode",
"(",
"$",
"this",
"->",
"filter_field",
"(",
"$",
"key",
",",
"$",
"val",
")",
")",
";",
"}",
"$",
"this",
"->",
"queries",
"[",
"'clientAPI'",
"]",
"=",
"self",
"::",
"API_VERSION",
";",
"}"
] |
Validates and stores the inputVars in the queries array.
@param $inputVars
|
[
"Validates",
"and",
"stores",
"the",
"inputVars",
"in",
"the",
"queries",
"array",
"."
] |
5f6c2a5454e755f1c56be17a1fc0c97576ff010e
|
https://github.com/maxmind/ccfd-api-php/blob/5f6c2a5454e755f1c56be17a1fc0c97576ff010e/src/HTTPBase.php#L209-L219
|
224,439
|
mocdk/MOC.ImageOptimizer
|
Classes/Aspects/ThumbnailAspect.php
|
ThumbnailAspect.optimizeThumbnail
|
public function optimizeThumbnail(JoinPointInterface $joinPoint)
{
/** @var \Neos\Media\Domain\Model\Thumbnail $thumbnail */
$thumbnail = $joinPoint->getProxy();
$thumbnailResource = $thumbnail->getResource();
if (!$thumbnailResource) {
return;
}
$streamMetaData = stream_get_meta_data($thumbnailResource->getStream());
$pathAndFilename = $streamMetaData['uri'];
$useGlobalBinary = $this->settings['useGlobalBinary'];
$binaryRootPath = 'Private/Library/node_modules/';
$file = escapeshellarg($pathAndFilename);
$imageType = $thumbnailResource->getMediaType();
if (!array_key_exists($imageType, $this->settings['formats'])) {
$this->systemLogger->log(sprintf('Unsupported type "%s" skipped in optimizeThumbnail', $imageType), LOG_INFO);
return;
}
$librarySettings = $this->settings['formats'][$imageType];
if ($librarySettings['enabled'] === false) {
return;
}
if ($librarySettings['useGlobalBinary'] === true) {
$useGlobalBinary = true;
}
$library = $librarySettings['library'];
$binaryPath = $librarySettings['binaryPath'];
$eelExpression = $librarySettings['arguments'];
$parameters = array_merge($librarySettings['parameters'], ['file' => $file]);
$arguments = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, $parameters);
$binaryPath = $useGlobalBinary === true ? $this->settings['globalBinaryPath'] . $library : $this->packageManager->getPackage('MOC.ImageOptimizer')->getResourcesPath() . $binaryRootPath . $binaryPath;
$cmd = escapeshellcmd($binaryPath) . ' ' . $arguments;
$output = [];
exec($cmd, $output, $result);
$failed = (int)$result !== 0;
$this->systemLogger->log($cmd . ' (' . ($failed ? 'Error: ' . $result : 'OK') . ')', $failed ? LOG_ERR : LOG_INFO, $output);
}
|
php
|
public function optimizeThumbnail(JoinPointInterface $joinPoint)
{
/** @var \Neos\Media\Domain\Model\Thumbnail $thumbnail */
$thumbnail = $joinPoint->getProxy();
$thumbnailResource = $thumbnail->getResource();
if (!$thumbnailResource) {
return;
}
$streamMetaData = stream_get_meta_data($thumbnailResource->getStream());
$pathAndFilename = $streamMetaData['uri'];
$useGlobalBinary = $this->settings['useGlobalBinary'];
$binaryRootPath = 'Private/Library/node_modules/';
$file = escapeshellarg($pathAndFilename);
$imageType = $thumbnailResource->getMediaType();
if (!array_key_exists($imageType, $this->settings['formats'])) {
$this->systemLogger->log(sprintf('Unsupported type "%s" skipped in optimizeThumbnail', $imageType), LOG_INFO);
return;
}
$librarySettings = $this->settings['formats'][$imageType];
if ($librarySettings['enabled'] === false) {
return;
}
if ($librarySettings['useGlobalBinary'] === true) {
$useGlobalBinary = true;
}
$library = $librarySettings['library'];
$binaryPath = $librarySettings['binaryPath'];
$eelExpression = $librarySettings['arguments'];
$parameters = array_merge($librarySettings['parameters'], ['file' => $file]);
$arguments = Utility::evaluateEelExpression($eelExpression, $this->eelEvaluator, $parameters);
$binaryPath = $useGlobalBinary === true ? $this->settings['globalBinaryPath'] . $library : $this->packageManager->getPackage('MOC.ImageOptimizer')->getResourcesPath() . $binaryRootPath . $binaryPath;
$cmd = escapeshellcmd($binaryPath) . ' ' . $arguments;
$output = [];
exec($cmd, $output, $result);
$failed = (int)$result !== 0;
$this->systemLogger->log($cmd . ' (' . ($failed ? 'Error: ' . $result : 'OK') . ')', $failed ? LOG_ERR : LOG_INFO, $output);
}
|
[
"public",
"function",
"optimizeThumbnail",
"(",
"JoinPointInterface",
"$",
"joinPoint",
")",
"{",
"/** @var \\Neos\\Media\\Domain\\Model\\Thumbnail $thumbnail */",
"$",
"thumbnail",
"=",
"$",
"joinPoint",
"->",
"getProxy",
"(",
")",
";",
"$",
"thumbnailResource",
"=",
"$",
"thumbnail",
"->",
"getResource",
"(",
")",
";",
"if",
"(",
"!",
"$",
"thumbnailResource",
")",
"{",
"return",
";",
"}",
"$",
"streamMetaData",
"=",
"stream_get_meta_data",
"(",
"$",
"thumbnailResource",
"->",
"getStream",
"(",
")",
")",
";",
"$",
"pathAndFilename",
"=",
"$",
"streamMetaData",
"[",
"'uri'",
"]",
";",
"$",
"useGlobalBinary",
"=",
"$",
"this",
"->",
"settings",
"[",
"'useGlobalBinary'",
"]",
";",
"$",
"binaryRootPath",
"=",
"'Private/Library/node_modules/'",
";",
"$",
"file",
"=",
"escapeshellarg",
"(",
"$",
"pathAndFilename",
")",
";",
"$",
"imageType",
"=",
"$",
"thumbnailResource",
"->",
"getMediaType",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"imageType",
",",
"$",
"this",
"->",
"settings",
"[",
"'formats'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"systemLogger",
"->",
"log",
"(",
"sprintf",
"(",
"'Unsupported type \"%s\" skipped in optimizeThumbnail'",
",",
"$",
"imageType",
")",
",",
"LOG_INFO",
")",
";",
"return",
";",
"}",
"$",
"librarySettings",
"=",
"$",
"this",
"->",
"settings",
"[",
"'formats'",
"]",
"[",
"$",
"imageType",
"]",
";",
"if",
"(",
"$",
"librarySettings",
"[",
"'enabled'",
"]",
"===",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"librarySettings",
"[",
"'useGlobalBinary'",
"]",
"===",
"true",
")",
"{",
"$",
"useGlobalBinary",
"=",
"true",
";",
"}",
"$",
"library",
"=",
"$",
"librarySettings",
"[",
"'library'",
"]",
";",
"$",
"binaryPath",
"=",
"$",
"librarySettings",
"[",
"'binaryPath'",
"]",
";",
"$",
"eelExpression",
"=",
"$",
"librarySettings",
"[",
"'arguments'",
"]",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"librarySettings",
"[",
"'parameters'",
"]",
",",
"[",
"'file'",
"=>",
"$",
"file",
"]",
")",
";",
"$",
"arguments",
"=",
"Utility",
"::",
"evaluateEelExpression",
"(",
"$",
"eelExpression",
",",
"$",
"this",
"->",
"eelEvaluator",
",",
"$",
"parameters",
")",
";",
"$",
"binaryPath",
"=",
"$",
"useGlobalBinary",
"===",
"true",
"?",
"$",
"this",
"->",
"settings",
"[",
"'globalBinaryPath'",
"]",
".",
"$",
"library",
":",
"$",
"this",
"->",
"packageManager",
"->",
"getPackage",
"(",
"'MOC.ImageOptimizer'",
")",
"->",
"getResourcesPath",
"(",
")",
".",
"$",
"binaryRootPath",
".",
"$",
"binaryPath",
";",
"$",
"cmd",
"=",
"escapeshellcmd",
"(",
"$",
"binaryPath",
")",
".",
"' '",
".",
"$",
"arguments",
";",
"$",
"output",
"=",
"[",
"]",
";",
"exec",
"(",
"$",
"cmd",
",",
"$",
"output",
",",
"$",
"result",
")",
";",
"$",
"failed",
"=",
"(",
"int",
")",
"$",
"result",
"!==",
"0",
";",
"$",
"this",
"->",
"systemLogger",
"->",
"log",
"(",
"$",
"cmd",
".",
"' ('",
".",
"(",
"$",
"failed",
"?",
"'Error: '",
".",
"$",
"result",
":",
"'OK'",
")",
".",
"')'",
",",
"$",
"failed",
"?",
"LOG_ERR",
":",
"LOG_INFO",
",",
"$",
"output",
")",
";",
"}"
] |
After a thumbnail has been refreshed the resource is optimized, meaning the
image is only optimized once when created.
A new resource is generated for every thumbnail, meaning the original is
never touched.
Only local file system target is supported to keep it from being blocking.
It would however be possible to create a local copy of the resource,
process it, import it and set that as the thumbnail resource.
@Flow\AfterReturning("method(Neos\Media\Domain\Model\Thumbnail->refresh())")
@param \Neos\Flow\Aop\JoinPointInterface $joinPoint The current join point
@return void
|
[
"After",
"a",
"thumbnail",
"has",
"been",
"refreshed",
"the",
"resource",
"is",
"optimized",
"meaning",
"the",
"image",
"is",
"only",
"optimized",
"once",
"when",
"created",
"."
] |
c1eb87061fa2c8ffd9f7651229a7719263c0721a
|
https://github.com/mocdk/MOC.ImageOptimizer/blob/c1eb87061fa2c8ffd9f7651229a7719263c0721a/Classes/Aspects/ThumbnailAspect.php#L71-L115
|
224,440
|
php-http/laravel-httplug
|
src/HttplugServiceProvider.php
|
HttplugServiceProvider.registerHttplugFactories
|
protected function registerHttplugFactories()
{
$this->app->bind('httplug.message_factory.default', function ($app) {
return MessageFactoryDiscovery::find();
});
$this->app->alias('httplug.message_factory.default', MessageFactory::class);
$this->app->alias('httplug.message_factory.default', ResponseFactory::class);
$this->app->bind('httplug.uri_factory.default', function ($app) {
return UriFactoryDiscovery::find();
});
$this->app->alias('httplug.uri_factory.default', UriFactory::class);
$this->app->bind('httplug.stream_factory.default', function ($app) {
return StreamFactoryDiscovery::find();
});
$this->app->alias('httplug.stream_factory.default', StreamFactory::class);
}
|
php
|
protected function registerHttplugFactories()
{
$this->app->bind('httplug.message_factory.default', function ($app) {
return MessageFactoryDiscovery::find();
});
$this->app->alias('httplug.message_factory.default', MessageFactory::class);
$this->app->alias('httplug.message_factory.default', ResponseFactory::class);
$this->app->bind('httplug.uri_factory.default', function ($app) {
return UriFactoryDiscovery::find();
});
$this->app->alias('httplug.uri_factory.default', UriFactory::class);
$this->app->bind('httplug.stream_factory.default', function ($app) {
return StreamFactoryDiscovery::find();
});
$this->app->alias('httplug.stream_factory.default', StreamFactory::class);
}
|
[
"protected",
"function",
"registerHttplugFactories",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'httplug.message_factory.default'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"MessageFactoryDiscovery",
"::",
"find",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'httplug.message_factory.default'",
",",
"MessageFactory",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'httplug.message_factory.default'",
",",
"ResponseFactory",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'httplug.uri_factory.default'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"UriFactoryDiscovery",
"::",
"find",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'httplug.uri_factory.default'",
",",
"UriFactory",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'httplug.stream_factory.default'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"StreamFactoryDiscovery",
"::",
"find",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'httplug.stream_factory.default'",
",",
"StreamFactory",
"::",
"class",
")",
";",
"}"
] |
Register php-http interfaces to container.
|
[
"Register",
"php",
"-",
"http",
"interfaces",
"to",
"container",
"."
] |
fae3d1b2a653f645cbe09f32aaff4bab34de14fc
|
https://github.com/php-http/laravel-httplug/blob/fae3d1b2a653f645cbe09f32aaff4bab34de14fc/src/HttplugServiceProvider.php#L45-L62
|
224,441
|
php-http/laravel-httplug
|
src/HttplugServiceProvider.php
|
HttplugServiceProvider.registerHttplug
|
protected function registerHttplug()
{
$this->app->singleton('httplug', function ($app) {
return new HttplugManager($app);
});
$this->app->alias('httplug', HttplugManager::class);
$this->app->singleton('httplug.default', function ($app) {
return $app['httplug']->driver();
});
}
|
php
|
protected function registerHttplug()
{
$this->app->singleton('httplug', function ($app) {
return new HttplugManager($app);
});
$this->app->alias('httplug', HttplugManager::class);
$this->app->singleton('httplug.default', function ($app) {
return $app['httplug']->driver();
});
}
|
[
"protected",
"function",
"registerHttplug",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'httplug'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"HttplugManager",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'httplug'",
",",
"HttplugManager",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'httplug.default'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"[",
"'httplug'",
"]",
"->",
"driver",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Register httplug to container.
|
[
"Register",
"httplug",
"to",
"container",
"."
] |
fae3d1b2a653f645cbe09f32aaff4bab34de14fc
|
https://github.com/php-http/laravel-httplug/blob/fae3d1b2a653f645cbe09f32aaff4bab34de14fc/src/HttplugServiceProvider.php#L67-L77
|
224,442
|
projek-xyz/slim-framework
|
src/Mailer/SmtpDriver.php
|
SmtpDriver.debugMode
|
public function debugMode($mode)
{
if (!isset($this->debugMode[$mode])) {
$mode = 'production';
}
$this->mail->SMTPDebug = $this->debugMode[$mode];
$this->mail->Debugoutput = function ($str, $mode) {
logger(LogLevel::DEBUG, $str, ['debugMode' => $mode]);
};
return $this;
}
|
php
|
public function debugMode($mode)
{
if (!isset($this->debugMode[$mode])) {
$mode = 'production';
}
$this->mail->SMTPDebug = $this->debugMode[$mode];
$this->mail->Debugoutput = function ($str, $mode) {
logger(LogLevel::DEBUG, $str, ['debugMode' => $mode]);
};
return $this;
}
|
[
"public",
"function",
"debugMode",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"debugMode",
"[",
"$",
"mode",
"]",
")",
")",
"{",
"$",
"mode",
"=",
"'production'",
";",
"}",
"$",
"this",
"->",
"mail",
"->",
"SMTPDebug",
"=",
"$",
"this",
"->",
"debugMode",
"[",
"$",
"mode",
"]",
";",
"$",
"this",
"->",
"mail",
"->",
"Debugoutput",
"=",
"function",
"(",
"$",
"str",
",",
"$",
"mode",
")",
"{",
"logger",
"(",
"LogLevel",
"::",
"DEBUG",
",",
"$",
"str",
",",
"[",
"'debugMode'",
"=>",
"$",
"mode",
"]",
")",
";",
"}",
";",
"return",
"$",
"this",
";",
"}"
] |
Set mailer debug mode
@param string $mode
@return $this
|
[
"Set",
"mailer",
"debug",
"mode"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/Mailer/SmtpDriver.php#L65-L77
|
224,443
|
robrogers3/laravel-jsonaware-exception-handler
|
src/ServiceProvider.php
|
ServiceProvider.boot
|
public function boot()
{
$path = __DIR__ . '/../resources/lang/en/exceptionmessages.php';
$this->publishes([
$path => resource_path("lang/vendor/{$this->namespace}/en/exceptionmessages.php"),
]);
$this->loadTranslationsFrom($path, $this->namespace);
}
|
php
|
public function boot()
{
$path = __DIR__ . '/../resources/lang/en/exceptionmessages.php';
$this->publishes([
$path => resource_path("lang/vendor/{$this->namespace}/en/exceptionmessages.php"),
]);
$this->loadTranslationsFrom($path, $this->namespace);
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"path",
"=",
"__DIR__",
".",
"'/../resources/lang/en/exceptionmessages.php'",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"$",
"path",
"=>",
"resource_path",
"(",
"\"lang/vendor/{$this->namespace}/en/exceptionmessages.php\"",
")",
",",
"]",
")",
";",
"$",
"this",
"->",
"loadTranslationsFrom",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"namespace",
")",
";",
"}"
] |
Registers resources for the package.
|
[
"Registers",
"resources",
"for",
"the",
"package",
"."
] |
6821b2f25762e0a7df9d0ecff49448361aea449c
|
https://github.com/robrogers3/laravel-jsonaware-exception-handler/blob/6821b2f25762e0a7df9d0ecff49448361aea449c/src/ServiceProvider.php#L26-L35
|
224,444
|
minimalcode-org/search
|
src/Internal/Node.php
|
Node.append
|
public function append($operator, Criteria $criteria)
{
$this->children[] = new Node(self::TYPE_LEAF, $operator, $criteria);
$this->mostRecentCriteria = $criteria;
return $this;
}
|
php
|
public function append($operator, Criteria $criteria)
{
$this->children[] = new Node(self::TYPE_LEAF, $operator, $criteria);
$this->mostRecentCriteria = $criteria;
return $this;
}
|
[
"public",
"function",
"append",
"(",
"$",
"operator",
",",
"Criteria",
"$",
"criteria",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"]",
"=",
"new",
"Node",
"(",
"self",
"::",
"TYPE_LEAF",
",",
"$",
"operator",
",",
"$",
"criteria",
")",
";",
"$",
"this",
"->",
"mostRecentCriteria",
"=",
"$",
"criteria",
";",
"return",
"$",
"this",
";",
"}"
] |
Appends a leaf node to the children of this node.
@param string $operator ("AND"|"OR"|"")
@param Criteria $criteria
@return $this
|
[
"Appends",
"a",
"leaf",
"node",
"to",
"the",
"children",
"of",
"this",
"node",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Internal/Node.php#L106-L112
|
224,445
|
minimalcode-org/search
|
src/Internal/Node.php
|
Node.connect
|
public function connect()
{
$crotch = new Node(self::TYPE_CROTCH, self::OPERATOR_BLANK, null);
$crotch->children = \array_merge($crotch->children, $this->children);
$crotch->isNegatingWholeChildren = $this->isNegatingWholeChildren;
$this->isNegatingWholeChildren = false;
$this->children = [$crotch];
return $this;
}
|
php
|
public function connect()
{
$crotch = new Node(self::TYPE_CROTCH, self::OPERATOR_BLANK, null);
$crotch->children = \array_merge($crotch->children, $this->children);
$crotch->isNegatingWholeChildren = $this->isNegatingWholeChildren;
$this->isNegatingWholeChildren = false;
$this->children = [$crotch];
return $this;
}
|
[
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"crotch",
"=",
"new",
"Node",
"(",
"self",
"::",
"TYPE_CROTCH",
",",
"self",
"::",
"OPERATOR_BLANK",
",",
"null",
")",
";",
"$",
"crotch",
"->",
"children",
"=",
"\\",
"array_merge",
"(",
"$",
"crotch",
"->",
"children",
",",
"$",
"this",
"->",
"children",
")",
";",
"$",
"crotch",
"->",
"isNegatingWholeChildren",
"=",
"$",
"this",
"->",
"isNegatingWholeChildren",
";",
"$",
"this",
"->",
"isNegatingWholeChildren",
"=",
"false",
";",
"$",
"this",
"->",
"children",
"=",
"[",
"$",
"crotch",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Connects the children to a new parent tree.
@return $this
|
[
"Connects",
"the",
"children",
"to",
"a",
"new",
"parent",
"tree",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Internal/Node.php#L119-L128
|
224,446
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Domain/Service/SqLiteIndex.php
|
SqLiteIndex.bindFulltextParametersToStatement
|
protected function bindFulltextParametersToStatement(\SQLite3Stmt $preparedStatement, $fulltext) {
$preparedStatement->bindValue(':h1', isset($fulltext['h1']) ? $fulltext['h1'] : '');
$preparedStatement->bindValue(':h2', isset($fulltext['h2']) ? $fulltext['h2'] : '');
$preparedStatement->bindValue(':h3', isset($fulltext['h3']) ? $fulltext['h3'] : '');
$preparedStatement->bindValue(':h4', isset($fulltext['h4']) ? $fulltext['h4'] : '');
$preparedStatement->bindValue(':h5', isset($fulltext['h5']) ? $fulltext['h5'] : '');
$preparedStatement->bindValue(':h6', isset($fulltext['h6']) ? $fulltext['h6'] : '');
$preparedStatement->bindValue(':text', isset($fulltext['text']) ? $fulltext['text'] : '');
}
|
php
|
protected function bindFulltextParametersToStatement(\SQLite3Stmt $preparedStatement, $fulltext) {
$preparedStatement->bindValue(':h1', isset($fulltext['h1']) ? $fulltext['h1'] : '');
$preparedStatement->bindValue(':h2', isset($fulltext['h2']) ? $fulltext['h2'] : '');
$preparedStatement->bindValue(':h3', isset($fulltext['h3']) ? $fulltext['h3'] : '');
$preparedStatement->bindValue(':h4', isset($fulltext['h4']) ? $fulltext['h4'] : '');
$preparedStatement->bindValue(':h5', isset($fulltext['h5']) ? $fulltext['h5'] : '');
$preparedStatement->bindValue(':h6', isset($fulltext['h6']) ? $fulltext['h6'] : '');
$preparedStatement->bindValue(':text', isset($fulltext['text']) ? $fulltext['text'] : '');
}
|
[
"protected",
"function",
"bindFulltextParametersToStatement",
"(",
"\\",
"SQLite3Stmt",
"$",
"preparedStatement",
",",
"$",
"fulltext",
")",
"{",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h1'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h1'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h1'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h2'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h2'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h2'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h3'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h3'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h3'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h4'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h4'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h4'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h5'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h5'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h5'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':h6'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'h6'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'h6'",
"]",
":",
"''",
")",
";",
"$",
"preparedStatement",
"->",
"bindValue",
"(",
"':text'",
",",
"isset",
"(",
"$",
"fulltext",
"[",
"'text'",
"]",
")",
"?",
"$",
"fulltext",
"[",
"'text'",
"]",
":",
"''",
")",
";",
"}"
] |
Binds fulltext parameters to a prepared statement as this happens in multiple places.
@param \SQLite3Stmt $preparedStatement
@param $fulltext
|
[
"Binds",
"fulltext",
"parameters",
"to",
"a",
"prepared",
"statement",
"as",
"this",
"happens",
"in",
"multiple",
"places",
"."
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Domain/Service/SqLiteIndex.php#L164-L172
|
224,447
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Domain/Service/SqLiteIndex.php
|
SqLiteIndex.findOneByIdentifier
|
public function findOneByIdentifier($identifier) {
$statement = $this->connection->prepare('SELECT * FROM objects WHERE __identifier__ = :identifier LIMIT 1');
$statement->bindValue(':identifier', $identifier);
return $statement->execute()->fetchArray(SQLITE3_ASSOC);
}
|
php
|
public function findOneByIdentifier($identifier) {
$statement = $this->connection->prepare('SELECT * FROM objects WHERE __identifier__ = :identifier LIMIT 1');
$statement->bindValue(':identifier', $identifier);
return $statement->execute()->fetchArray(SQLITE3_ASSOC);
}
|
[
"public",
"function",
"findOneByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"'SELECT * FROM objects WHERE __identifier__ = :identifier LIMIT 1'",
")",
";",
"$",
"statement",
"->",
"bindValue",
"(",
"':identifier'",
",",
"$",
"identifier",
")",
";",
"return",
"$",
"statement",
"->",
"execute",
"(",
")",
"->",
"fetchArray",
"(",
"SQLITE3_ASSOC",
")",
";",
"}"
] |
Returns an index entry by identifier or NULL if it doesn't exist.
@param string $identifier
@return array|FALSE
|
[
"Returns",
"an",
"index",
"entry",
"by",
"identifier",
"or",
"NULL",
"if",
"it",
"doesn",
"t",
"exist",
"."
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Domain/Service/SqLiteIndex.php#L180-L185
|
224,448
|
Flowpack/Flowpack.SimpleSearch
|
Classes/Domain/Service/SqLiteIndex.php
|
SqLiteIndex.executeStatement
|
public function executeStatement($statementQuery, array $parameters) {
$statement = $this->connection->prepare($statementQuery);
foreach ($parameters as $parameterName => $parameterValue) {
$statement->bindValue($parameterName, $parameterValue);
}
$result = $statement->execute();
$resultArray = array();
while ($resultRow = $result->fetchArray(SQLITE3_ASSOC)) {
$resultArray[] = $resultRow;
}
return $resultArray;
}
|
php
|
public function executeStatement($statementQuery, array $parameters) {
$statement = $this->connection->prepare($statementQuery);
foreach ($parameters as $parameterName => $parameterValue) {
$statement->bindValue($parameterName, $parameterValue);
}
$result = $statement->execute();
$resultArray = array();
while ($resultRow = $result->fetchArray(SQLITE3_ASSOC)) {
$resultArray[] = $resultRow;
}
return $resultArray;
}
|
[
"public",
"function",
"executeStatement",
"(",
"$",
"statementQuery",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"$",
"statementQuery",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameterName",
"=>",
"$",
"parameterValue",
")",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"$",
"parameterName",
",",
"$",
"parameterValue",
")",
";",
"}",
"$",
"result",
"=",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"$",
"resultArray",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"resultRow",
"=",
"$",
"result",
"->",
"fetchArray",
"(",
"SQLITE3_ASSOC",
")",
")",
"{",
"$",
"resultArray",
"[",
"]",
"=",
"$",
"resultRow",
";",
"}",
"return",
"$",
"resultArray",
";",
"}"
] |
Execute a prepared statement.
@param string $statementQuery The statement query
@param array $parameters The statement parameters as map
@return \SQLite3Stmt
|
[
"Execute",
"a",
"prepared",
"statement",
"."
] |
f231fa434a873e6bb60c95e63cf92dc536a0ccb6
|
https://github.com/Flowpack/Flowpack.SimpleSearch/blob/f231fa434a873e6bb60c95e63cf92dc536a0ccb6/Classes/Domain/Service/SqLiteIndex.php#L213-L226
|
224,449
|
joomla-framework/language
|
src/Stemmer/Porteren.php
|
Porteren.stem
|
public function stem($token, $lang)
{
// Check if the token is long enough to merit stemming.
if (\strlen($token) <= 2)
{
return $token;
}
// Check if the language is English or All.
if ($lang !== 'en')
{
return $token;
}
// Stem the token if it is not in the cache.
if (!isset($this->cache[$lang][$token]))
{
// Stem the token.
$result = $token;
$result = self::step1ab($result);
$result = self::step1c($result);
$result = self::step2($result);
$result = self::step3($result);
$result = self::step4($result);
$result = self::step5($result);
// Add the token to the cache.
$this->cache[$lang][$token] = $result;
}
return $this->cache[$lang][$token];
}
|
php
|
public function stem($token, $lang)
{
// Check if the token is long enough to merit stemming.
if (\strlen($token) <= 2)
{
return $token;
}
// Check if the language is English or All.
if ($lang !== 'en')
{
return $token;
}
// Stem the token if it is not in the cache.
if (!isset($this->cache[$lang][$token]))
{
// Stem the token.
$result = $token;
$result = self::step1ab($result);
$result = self::step1c($result);
$result = self::step2($result);
$result = self::step3($result);
$result = self::step4($result);
$result = self::step5($result);
// Add the token to the cache.
$this->cache[$lang][$token] = $result;
}
return $this->cache[$lang][$token];
}
|
[
"public",
"function",
"stem",
"(",
"$",
"token",
",",
"$",
"lang",
")",
"{",
"// Check if the token is long enough to merit stemming.",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"token",
")",
"<=",
"2",
")",
"{",
"return",
"$",
"token",
";",
"}",
"// Check if the language is English or All.",
"if",
"(",
"$",
"lang",
"!==",
"'en'",
")",
"{",
"return",
"$",
"token",
";",
"}",
"// Stem the token if it is not in the cache.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"lang",
"]",
"[",
"$",
"token",
"]",
")",
")",
"{",
"// Stem the token.",
"$",
"result",
"=",
"$",
"token",
";",
"$",
"result",
"=",
"self",
"::",
"step1ab",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"self",
"::",
"step1c",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"self",
"::",
"step2",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"self",
"::",
"step3",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"self",
"::",
"step4",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"self",
"::",
"step5",
"(",
"$",
"result",
")",
";",
"// Add the token to the cache.",
"$",
"this",
"->",
"cache",
"[",
"$",
"lang",
"]",
"[",
"$",
"token",
"]",
"=",
"$",
"result",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"lang",
"]",
"[",
"$",
"token",
"]",
";",
"}"
] |
Method to stem a token and return the root.
@param string $token The token to stem.
@param string $lang The language of the token.
@return string The root token.
@since 1.0
|
[
"Method",
"to",
"stem",
"a",
"token",
"and",
"return",
"the",
"root",
"."
] |
94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf
|
https://github.com/joomla-framework/language/blob/94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf/src/Stemmer/Porteren.php#L50-L81
|
224,450
|
joomla-framework/language
|
src/Stemmer/Porteren.php
|
Porteren.replace
|
private static function replace(&$str, $check, $repl, $m = null)
{
$len = 0 - \strlen($check);
if (substr($str, $len) == $check)
{
$substr = substr($str, 0, $len);
if ($m === null || self::m($substr) > $m)
{
$str = $substr . $repl;
}
return true;
}
return false;
}
|
php
|
private static function replace(&$str, $check, $repl, $m = null)
{
$len = 0 - \strlen($check);
if (substr($str, $len) == $check)
{
$substr = substr($str, 0, $len);
if ($m === null || self::m($substr) > $m)
{
$str = $substr . $repl;
}
return true;
}
return false;
}
|
[
"private",
"static",
"function",
"replace",
"(",
"&",
"$",
"str",
",",
"$",
"check",
",",
"$",
"repl",
",",
"$",
"m",
"=",
"null",
")",
"{",
"$",
"len",
"=",
"0",
"-",
"\\",
"strlen",
"(",
"$",
"check",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"str",
",",
"$",
"len",
")",
"==",
"$",
"check",
")",
"{",
"$",
"substr",
"=",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"$",
"len",
")",
";",
"if",
"(",
"$",
"m",
"===",
"null",
"||",
"self",
"::",
"m",
"(",
"$",
"substr",
")",
">",
"$",
"m",
")",
"{",
"$",
"str",
"=",
"$",
"substr",
".",
"$",
"repl",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Replaces the first string with the second, at the end of the string. If third
arg is given, then the preceding string must match that m count at least.
@param string $str String to check
@param string $check Ending to check for
@param string $repl Replacement string
@param integer $m Optional minimum number of m() to meet
@return boolean Whether the $check string was at the end
of the $str string. True does not necessarily mean
that it was replaced.
@since 1.0
|
[
"Replaces",
"the",
"first",
"string",
"with",
"the",
"second",
"at",
"the",
"end",
"of",
"the",
"string",
".",
"If",
"third",
"arg",
"is",
"given",
"then",
"the",
"preceding",
"string",
"must",
"match",
"that",
"m",
"count",
"at",
"least",
"."
] |
94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf
|
https://github.com/joomla-framework/language/blob/94c81b65b73b69a72214fbc5b2f1d9d4fc4429cf/src/Stemmer/Porteren.php#L413-L430
|
224,451
|
projek-xyz/slim-framework
|
src/View.php
|
View.directory
|
public function directory($path = null)
{
if (null === $path) {
return $this->plates->getDirectory();
}
return $this->plates->getDirectory().'/'.$path;
}
|
php
|
public function directory($path = null)
{
if (null === $path) {
return $this->plates->getDirectory();
}
return $this->plates->getDirectory().'/'.$path;
}
|
[
"public",
"function",
"directory",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"plates",
"->",
"getDirectory",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"plates",
"->",
"getDirectory",
"(",
")",
".",
"'/'",
".",
"$",
"path",
";",
"}"
] |
Get view directory
@param string|null $path
@return string
|
[
"Get",
"view",
"directory"
] |
733337b7be3db6629a151e2e2cd0068cdb2c1daf
|
https://github.com/projek-xyz/slim-framework/blob/733337b7be3db6629a151e2e2cd0068cdb2c1daf/src/View.php#L49-L56
|
224,452
|
adman9000/laravel-binance
|
src/BinanceAPI.php
|
BinanceAPI.getRecentTrades
|
public function getRecentTrades($symbol = 'BNBBTC', $limit = 500)
{
$data = [
'symbol' => $symbol,
'limit' => $limit,
];
$b = $this->privateRequest('v3/myTrades', $data);
return $b;
}
|
php
|
public function getRecentTrades($symbol = 'BNBBTC', $limit = 500)
{
$data = [
'symbol' => $symbol,
'limit' => $limit,
];
$b = $this->privateRequest('v3/myTrades', $data);
return $b;
}
|
[
"public",
"function",
"getRecentTrades",
"(",
"$",
"symbol",
"=",
"'BNBBTC'",
",",
"$",
"limit",
"=",
"500",
")",
"{",
"$",
"data",
"=",
"[",
"'symbol'",
"=>",
"$",
"symbol",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"privateRequest",
"(",
"'v3/myTrades'",
",",
"$",
"data",
")",
";",
"return",
"$",
"b",
";",
"}"
] |
Get trades for a specific account and symbol
@param string $symbol Currency pair
@param int $limit Limit of trades. Max. 500
@return mixed
@throws \Exception
|
[
"Get",
"trades",
"for",
"a",
"specific",
"account",
"and",
"symbol"
] |
d0e1acf8fb2af42597156e0baaeeac0f029bf912
|
https://github.com/adman9000/laravel-binance/blob/d0e1acf8fb2af42597156e0baaeeac0f029bf912/src/BinanceAPI.php#L153-L163
|
224,453
|
adman9000/laravel-binance
|
src/BinanceAPI.php
|
BinanceAPI.trade
|
public function trade($symbol, $quantity, $side, $type = 'MARKET', $price = false)
{
$data = [
'symbol' => $symbol,
'side' => $side,
'type' => $type,
'quantity' => $quantity
];
if($price !== false)
{
$data['price'] = $price;
}
$b = $this->privateRequest('v3/order', $data, 'POST');
return $b;
}
|
php
|
public function trade($symbol, $quantity, $side, $type = 'MARKET', $price = false)
{
$data = [
'symbol' => $symbol,
'side' => $side,
'type' => $type,
'quantity' => $quantity
];
if($price !== false)
{
$data['price'] = $price;
}
$b = $this->privateRequest('v3/order', $data, 'POST');
return $b;
}
|
[
"public",
"function",
"trade",
"(",
"$",
"symbol",
",",
"$",
"quantity",
",",
"$",
"side",
",",
"$",
"type",
"=",
"'MARKET'",
",",
"$",
"price",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"[",
"'symbol'",
"=>",
"$",
"symbol",
",",
"'side'",
"=>",
"$",
"side",
",",
"'type'",
"=>",
"$",
"type",
",",
"'quantity'",
"=>",
"$",
"quantity",
"]",
";",
"if",
"(",
"$",
"price",
"!==",
"false",
")",
"{",
"$",
"data",
"[",
"'price'",
"]",
"=",
"$",
"price",
";",
"}",
"$",
"b",
"=",
"$",
"this",
"->",
"privateRequest",
"(",
"'v3/order'",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"return",
"$",
"b",
";",
"}"
] |
Base trade function
@param string $symbol Asset pair to trade
@param string $quantity Amount of trade asset
@param string $side BUY, SELL
@param string $type MARKET, LIMIT, STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, TAKE_PROFIT_LIMIT, LIMIT_MAKER
@param bool $price Limit price
@return mixed
@throws \Exception
|
[
"Base",
"trade",
"function"
] |
d0e1acf8fb2af42597156e0baaeeac0f029bf912
|
https://github.com/adman9000/laravel-binance/blob/d0e1acf8fb2af42597156e0baaeeac0f029bf912/src/BinanceAPI.php#L196-L212
|
224,454
|
JDGrimes/wpppb
|
src/WPPPB/Loader.php
|
WPPPB_Loader.install_plugins
|
public function install_plugins() {
$result = system(
WP_PHP_BINARY
. ' ' . escapeshellarg( dirname( dirname( __FILE__ ) ) . '/bin/install-plugins.php' )
. ' ' . escapeshellarg( json_encode( $this->plugins ) )
. ' ' . escapeshellarg( $this->locate_wp_tests_config() )
. ' ' . (int) is_multisite()
. ' ' . escapeshellarg( json_encode( $this->files ) )
, $exit_code
);
if ( 0 !== $exit_code ) {
echo( 'Remote plugin installation failed with exit code ' . $exit_code . PHP_EOL );
exit( 1 );
} elseif ( ! empty( $result ) ) {
echo( PHP_EOL . 'Remote plugin installation produced unexpected output.' . PHP_EOL );
exit( 1 );
}
// The caching functions may not be loaded yet.
if ( function_exists( 'wp_cache_flush' ) ) {
wp_cache_flush();
}
remove_action( 'all', array( $this, 'install_plugins' ) );
}
|
php
|
public function install_plugins() {
$result = system(
WP_PHP_BINARY
. ' ' . escapeshellarg( dirname( dirname( __FILE__ ) ) . '/bin/install-plugins.php' )
. ' ' . escapeshellarg( json_encode( $this->plugins ) )
. ' ' . escapeshellarg( $this->locate_wp_tests_config() )
. ' ' . (int) is_multisite()
. ' ' . escapeshellarg( json_encode( $this->files ) )
, $exit_code
);
if ( 0 !== $exit_code ) {
echo( 'Remote plugin installation failed with exit code ' . $exit_code . PHP_EOL );
exit( 1 );
} elseif ( ! empty( $result ) ) {
echo( PHP_EOL . 'Remote plugin installation produced unexpected output.' . PHP_EOL );
exit( 1 );
}
// The caching functions may not be loaded yet.
if ( function_exists( 'wp_cache_flush' ) ) {
wp_cache_flush();
}
remove_action( 'all', array( $this, 'install_plugins' ) );
}
|
[
"public",
"function",
"install_plugins",
"(",
")",
"{",
"$",
"result",
"=",
"system",
"(",
"WP_PHP_BINARY",
".",
"' '",
".",
"escapeshellarg",
"(",
"dirname",
"(",
"dirname",
"(",
"__FILE__",
")",
")",
".",
"'/bin/install-plugins.php'",
")",
".",
"' '",
".",
"escapeshellarg",
"(",
"json_encode",
"(",
"$",
"this",
"->",
"plugins",
")",
")",
".",
"' '",
".",
"escapeshellarg",
"(",
"$",
"this",
"->",
"locate_wp_tests_config",
"(",
")",
")",
".",
"' '",
".",
"(",
"int",
")",
"is_multisite",
"(",
")",
".",
"' '",
".",
"escapeshellarg",
"(",
"json_encode",
"(",
"$",
"this",
"->",
"files",
")",
")",
",",
"$",
"exit_code",
")",
";",
"if",
"(",
"0",
"!==",
"$",
"exit_code",
")",
"{",
"echo",
"(",
"'Remote plugin installation failed with exit code '",
".",
"$",
"exit_code",
".",
"PHP_EOL",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"echo",
"(",
"PHP_EOL",
".",
"'Remote plugin installation produced unexpected output.'",
".",
"PHP_EOL",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"// The caching functions may not be loaded yet.",
"if",
"(",
"function_exists",
"(",
"'wp_cache_flush'",
")",
")",
"{",
"wp_cache_flush",
"(",
")",
";",
"}",
"remove_action",
"(",
"'all'",
",",
"array",
"(",
"$",
"this",
",",
"'install_plugins'",
")",
")",
";",
"}"
] |
Installs the plugins via a separate PHP process.
You do not need to call this directly, it is only public because it is hooked
to an action by self::hook_up_installer().
@since 0.1.0
|
[
"Installs",
"the",
"plugins",
"via",
"a",
"separate",
"PHP",
"process",
"."
] |
cc117cfe2e28c8e7d49fa4e02313ce00490d07ec
|
https://github.com/JDGrimes/wpppb/blob/cc117cfe2e28c8e7d49fa4e02313ce00490d07ec/src/WPPPB/Loader.php#L141-L167
|
224,455
|
JDGrimes/wpppb
|
src/WPPPB/Loader.php
|
WPPPB_Loader.phpunit_compat
|
public function phpunit_compat() {
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
$tests_dir = $this->get_wp_tests_dir();
// Back-compat for older WP versions.
if ( file_exists( $tests_dir . '/includes/phpunit6-compat.php' ) ) {
/**
* Compatibility with PHPUnit 6+.
*
* @since 0.3.2
*/
require_once $tests_dir . '/includes/phpunit6-compat.php';
} else {
/**
* Compatibility with PHPUnit 6+.
*
* @since 0.3.6
*/
require_once $tests_dir . '/includes/phpunit6/compat.php';
}
class_alias(
'PHPUnit\Framework\Constraint\Constraint'
, 'PHPUnit_Framework_Constraint'
);
}
}
|
php
|
public function phpunit_compat() {
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
$tests_dir = $this->get_wp_tests_dir();
// Back-compat for older WP versions.
if ( file_exists( $tests_dir . '/includes/phpunit6-compat.php' ) ) {
/**
* Compatibility with PHPUnit 6+.
*
* @since 0.3.2
*/
require_once $tests_dir . '/includes/phpunit6-compat.php';
} else {
/**
* Compatibility with PHPUnit 6+.
*
* @since 0.3.6
*/
require_once $tests_dir . '/includes/phpunit6/compat.php';
}
class_alias(
'PHPUnit\Framework\Constraint\Constraint'
, 'PHPUnit_Framework_Constraint'
);
}
}
|
[
"public",
"function",
"phpunit_compat",
"(",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'PHPUnit\\Runner\\Version'",
")",
")",
"{",
"$",
"tests_dir",
"=",
"$",
"this",
"->",
"get_wp_tests_dir",
"(",
")",
";",
"// Back-compat for older WP versions.",
"if",
"(",
"file_exists",
"(",
"$",
"tests_dir",
".",
"'/includes/phpunit6-compat.php'",
")",
")",
"{",
"/**\n\t\t\t\t * Compatibility with PHPUnit 6+.\n\t\t\t\t *\n\t\t\t\t * @since 0.3.2\n\t\t\t\t */",
"require_once",
"$",
"tests_dir",
".",
"'/includes/phpunit6-compat.php'",
";",
"}",
"else",
"{",
"/**\n\t\t\t\t * Compatibility with PHPUnit 6+.\n\t\t\t\t *\n\t\t\t\t * @since 0.3.6\n\t\t\t\t */",
"require_once",
"$",
"tests_dir",
".",
"'/includes/phpunit6/compat.php'",
";",
"}",
"class_alias",
"(",
"'PHPUnit\\Framework\\Constraint\\Constraint'",
",",
"'PHPUnit_Framework_Constraint'",
")",
";",
"}",
"}"
] |
Ensures compatibility with the current PHPUnit version.
@since 0.3.2
|
[
"Ensures",
"compatibility",
"with",
"the",
"current",
"PHPUnit",
"version",
"."
] |
cc117cfe2e28c8e7d49fa4e02313ce00490d07ec
|
https://github.com/JDGrimes/wpppb/blob/cc117cfe2e28c8e7d49fa4e02313ce00490d07ec/src/WPPPB/Loader.php#L227-L258
|
224,456
|
nWidart/forecast-php
|
src/Forecast.php
|
Forecast.get
|
public function get($latitude = null, $longitude = null, $time = null)
{
$this->guardAgainstEmptyArgument($latitude, 'latitude');
$this->guardAgainstEmptyArgument($longitude, 'longitude');
$url = $this->getUrl($latitude, $longitude, $time);
$forecast = $this->getClient()->get($url);
return $forecast->json();
}
|
php
|
public function get($latitude = null, $longitude = null, $time = null)
{
$this->guardAgainstEmptyArgument($latitude, 'latitude');
$this->guardAgainstEmptyArgument($longitude, 'longitude');
$url = $this->getUrl($latitude, $longitude, $time);
$forecast = $this->getClient()->get($url);
return $forecast->json();
}
|
[
"public",
"function",
"get",
"(",
"$",
"latitude",
"=",
"null",
",",
"$",
"longitude",
"=",
"null",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"guardAgainstEmptyArgument",
"(",
"$",
"latitude",
",",
"'latitude'",
")",
";",
"$",
"this",
"->",
"guardAgainstEmptyArgument",
"(",
"$",
"longitude",
",",
"'longitude'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"time",
")",
";",
"$",
"forecast",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"get",
"(",
"$",
"url",
")",
";",
"return",
"$",
"forecast",
"->",
"json",
"(",
")",
";",
"}"
] |
Get the weather for the given latitude and longitude
Optionally pass in a time for the query
@param null|string $latitude
@param null|string $longitude
@param null|string $time
@return array
|
[
"Get",
"the",
"weather",
"for",
"the",
"given",
"latitude",
"and",
"longitude",
"Optionally",
"pass",
"in",
"a",
"time",
"for",
"the",
"query"
] |
70203d9f01996e404916ee9a6b257ab640ddfaaa
|
https://github.com/nWidart/forecast-php/blob/70203d9f01996e404916ee9a6b257ab640ddfaaa/src/Forecast.php#L39-L49
|
224,457
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.where
|
public static function where($field)
{
$root = new Node(Node::TYPE_CROTCH, Node::OPERATOR_BLANK);
$criteria = new Criteria($field, $root);
$root->append(Node::OPERATOR_BLANK, $criteria);
return $criteria;
}
|
php
|
public static function where($field)
{
$root = new Node(Node::TYPE_CROTCH, Node::OPERATOR_BLANK);
$criteria = new Criteria($field, $root);
$root->append(Node::OPERATOR_BLANK, $criteria);
return $criteria;
}
|
[
"public",
"static",
"function",
"where",
"(",
"$",
"field",
")",
"{",
"$",
"root",
"=",
"new",
"Node",
"(",
"Node",
"::",
"TYPE_CROTCH",
",",
"Node",
"::",
"OPERATOR_BLANK",
")",
";",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"$",
"field",
",",
"$",
"root",
")",
";",
"$",
"root",
"->",
"append",
"(",
"Node",
"::",
"OPERATOR_BLANK",
",",
"$",
"criteria",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] |
Static factory method to create a new Criteria for the provided field.
@param string $field
@return $this
@throws \InvalidArgumentException if the field param is not a string
|
[
"Static",
"factory",
"method",
"to",
"create",
"a",
"new",
"Criteria",
"for",
"the",
"provided",
"field",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L83-L90
|
224,458
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.is
|
public function is($value)
{
if ($value === null) {
return $this->isNull();
}
if (\is_array($value)) {
return $this->in($value);
}
$this->predicates[] = $this->processValue($value);
return $this;
}
|
php
|
public function is($value)
{
if ($value === null) {
return $this->isNull();
}
if (\is_array($value)) {
return $this->in($value);
}
$this->predicates[] = $this->processValue($value);
return $this;
}
|
[
"public",
"function",
"is",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"isNull",
"(",
")",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"in",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Creates new predicate without any wildcards for each entry.
For arrays the Criteria::in() method is equivalent but more performant.
@param mixed|array $value
@return $this
|
[
"Creates",
"new",
"predicate",
"without",
"any",
"wildcards",
"for",
"each",
"entry",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L195-L208
|
224,459
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.withinBox
|
public function withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude)
{
$this->predicates[] = '[' . $this->processFloat($startLatitude) . ',' . $this->processFloat($startLongitude) .
' TO ' . $this->processFloat($endLatitude) . ',' . $this->processFloat($endLongitude) . ']';
return $this;
}
|
php
|
public function withinBox($startLatitude, $startLongitude, $endLatitude, $endLongitude)
{
$this->predicates[] = '[' . $this->processFloat($startLatitude) . ',' . $this->processFloat($startLongitude) .
' TO ' . $this->processFloat($endLatitude) . ',' . $this->processFloat($endLongitude) . ']';
return $this;
}
|
[
"public",
"function",
"withinBox",
"(",
"$",
"startLatitude",
",",
"$",
"startLongitude",
",",
"$",
"endLatitude",
",",
"$",
"endLongitude",
")",
"{",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"'['",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"startLatitude",
")",
".",
"','",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"startLongitude",
")",
".",
"' TO '",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"endLatitude",
")",
".",
"','",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"endLongitude",
")",
".",
"']'",
";",
"return",
"$",
"this",
";",
"}"
] |
Creates new predicate for a RANGE spatial search.
Finds exactly everything in a rectangular area, such as the area covered by a map the user is looking at.
@param float $startLatitude
@param float $startLongitude
@param float $endLatitude
@param float $endLongitude
@return $this
|
[
"Creates",
"new",
"predicate",
"for",
"a",
"RANGE",
"spatial",
"search",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L263-L269
|
224,460
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.nearCircle
|
public function nearCircle($latitude, $longitude, $distance)
{
$this->assertPositiveFloat($distance);
$this->predicates[] = '{!bbox pt=' . $this->processFloat($latitude) . ',' . $this->processFloat($longitude) .
' sfield=' . $this->field . ' d=' . $this->processFloat($distance) . '}';
$this->isHideFieldName = true;
return $this;
}
|
php
|
public function nearCircle($latitude, $longitude, $distance)
{
$this->assertPositiveFloat($distance);
$this->predicates[] = '{!bbox pt=' . $this->processFloat($latitude) . ',' . $this->processFloat($longitude) .
' sfield=' . $this->field . ' d=' . $this->processFloat($distance) . '}';
$this->isHideFieldName = true;
return $this;
}
|
[
"public",
"function",
"nearCircle",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"distance",
")",
"{",
"$",
"this",
"->",
"assertPositiveFloat",
"(",
"$",
"distance",
")",
";",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"'{!bbox pt='",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"latitude",
")",
".",
"','",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"longitude",
")",
".",
"' sfield='",
".",
"$",
"this",
"->",
"field",
".",
"' d='",
".",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"distance",
")",
".",
"'}'",
";",
"$",
"this",
"->",
"isHideFieldName",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Creates new predicate for !bbox filter.
The !bbox filter is very similar to !geofilt except it uses the bounding box of the calculated circle.
The rectangular shape is faster to compute and so it's sometimes used as an alternative to !geofilt
when it's acceptable to return points outside of the radius.
@param float $latitude
@param float $longitude
@param float $distance
@return $this
@throws \InvalidArgumentException if radius is negative
|
[
"Creates",
"new",
"predicate",
"for",
"!bbox",
"filter",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L284-L293
|
224,461
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.contains
|
public function contains($value)
{
if (\is_array($value)) {
/** @noinspection ForeachSourceInspection */
foreach ($value as $item) {
$this->contains($item);
}
} else {
$this->predicates[] = '*' . $this->processValue($value) . '*';
}
return $this;
}
|
php
|
public function contains($value)
{
if (\is_array($value)) {
/** @noinspection ForeachSourceInspection */
foreach ($value as $item) {
$this->contains($item);
}
} else {
$this->predicates[] = '*' . $this->processValue($value) . '*';
}
return $this;
}
|
[
"public",
"function",
"contains",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"/** @noinspection ForeachSourceInspection */",
"foreach",
"(",
"$",
"value",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"contains",
"(",
"$",
"item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"'*'",
".",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
")",
".",
"'*'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Crates new predicate with leading and trailing wildcards for each entry.
@param string|string[] $value
@return $this
|
[
"Crates",
"new",
"predicate",
"with",
"leading",
"and",
"trailing",
"wildcards",
"for",
"each",
"entry",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L321-L333
|
224,462
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.startsWith
|
public function startsWith($prefix)
{
if (\is_array($prefix)) {
/** @noinspection ForeachSourceInspection */
foreach ($prefix as $item) {
$this->startsWith($item);
}
} else {
$this->assertNotBlanks($prefix);
$this->predicates[] = $this->processValue($prefix) . '*';
}
return $this;
}
|
php
|
public function startsWith($prefix)
{
if (\is_array($prefix)) {
/** @noinspection ForeachSourceInspection */
foreach ($prefix as $item) {
$this->startsWith($item);
}
} else {
$this->assertNotBlanks($prefix);
$this->predicates[] = $this->processValue($prefix) . '*';
}
return $this;
}
|
[
"public",
"function",
"startsWith",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"prefix",
")",
")",
"{",
"/** @noinspection ForeachSourceInspection */",
"foreach",
"(",
"$",
"prefix",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"startsWith",
"(",
"$",
"item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"assertNotBlanks",
"(",
"$",
"prefix",
")",
";",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"prefix",
")",
".",
"'*'",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Crates new predicate with trailing wildcard for each entry.
@param string|string[] $prefix
@return $this
@throws \InvalidArgumentException if prefix contains blank char
|
[
"Crates",
"new",
"predicate",
"with",
"trailing",
"wildcard",
"for",
"each",
"entry",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L342-L355
|
224,463
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.endsWith
|
public function endsWith($postfix)
{
if (\is_array($postfix)) {
/** @noinspection ForeachSourceInspection */
foreach ($postfix as $item) {
$this->endsWith($item);
}
} else {
$this->assertNotBlanks($postfix);
$this->predicates[] = '*' . $this->processValue($postfix);
}
return $this;
}
|
php
|
public function endsWith($postfix)
{
if (\is_array($postfix)) {
/** @noinspection ForeachSourceInspection */
foreach ($postfix as $item) {
$this->endsWith($item);
}
} else {
$this->assertNotBlanks($postfix);
$this->predicates[] = '*' . $this->processValue($postfix);
}
return $this;
}
|
[
"public",
"function",
"endsWith",
"(",
"$",
"postfix",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"postfix",
")",
")",
"{",
"/** @noinspection ForeachSourceInspection */",
"foreach",
"(",
"$",
"postfix",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"endsWith",
"(",
"$",
"item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"assertNotBlanks",
"(",
"$",
"postfix",
")",
";",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"'*'",
".",
"$",
"this",
"->",
"processValue",
"(",
"$",
"postfix",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Crates new predicate with leading wildcard for each entry.
@param string|string[] $postfix
@return $this
@throws \InvalidArgumentException if postfix contains blank char
|
[
"Crates",
"new",
"predicate",
"with",
"leading",
"wildcard",
"for",
"each",
"entry",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L364-L377
|
224,464
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.fuzzy
|
public function fuzzy($value, $levenshteinDistance = null)
{
if ($levenshteinDistance !== null && ($levenshteinDistance < 0)) {
throw new InvalidArgumentException('Levenshtein Distance has to be 0 or above');
}
/** Float deprecated in Solr */
$this->predicates[] = $this->processValue($value) . '~' .
($levenshteinDistance === null ? '' :
(is_float($levenshteinDistance) ? $this->processFloat($levenshteinDistance) : (int) $levenshteinDistance));
return $this;
}
|
php
|
public function fuzzy($value, $levenshteinDistance = null)
{
if ($levenshteinDistance !== null && ($levenshteinDistance < 0)) {
throw new InvalidArgumentException('Levenshtein Distance has to be 0 or above');
}
/** Float deprecated in Solr */
$this->predicates[] = $this->processValue($value) . '~' .
($levenshteinDistance === null ? '' :
(is_float($levenshteinDistance) ? $this->processFloat($levenshteinDistance) : (int) $levenshteinDistance));
return $this;
}
|
[
"public",
"function",
"fuzzy",
"(",
"$",
"value",
",",
"$",
"levenshteinDistance",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"levenshteinDistance",
"!==",
"null",
"&&",
"(",
"$",
"levenshteinDistance",
"<",
"0",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Levenshtein Distance has to be 0 or above'",
")",
";",
"}",
"/** Float deprecated in Solr */",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
")",
".",
"'~'",
".",
"(",
"$",
"levenshteinDistance",
"===",
"null",
"?",
"''",
":",
"(",
"is_float",
"(",
"$",
"levenshteinDistance",
")",
"?",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"levenshteinDistance",
")",
":",
"(",
"int",
")",
"$",
"levenshteinDistance",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Crates new predicate with trailing ~ optionally followed by levensteinDistance.
@param string $value
@param int|float $levenshteinDistance optional
@return $this
@throws \InvalidArgumentException if levensteinDistance with wrong bounds
|
[
"Crates",
"new",
"predicate",
"with",
"trailing",
"~",
"optionally",
"followed",
"by",
"levensteinDistance",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L411-L423
|
224,465
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.sloppy
|
public function sloppy($phrase, $distance)
{
if ($distance <= 0) {
throw new InvalidArgumentException('Slop distance has to be greater than 0.');
}
if (\strpos($phrase, ' ') === false) {
throw new InvalidArgumentException('Sloppy phrase must consist of multiple terms, separated with spaces.');
}
$this->predicates[] = $this->processValue($phrase) . '~' . $distance;
return $this;
}
|
php
|
public function sloppy($phrase, $distance)
{
if ($distance <= 0) {
throw new InvalidArgumentException('Slop distance has to be greater than 0.');
}
if (\strpos($phrase, ' ') === false) {
throw new InvalidArgumentException('Sloppy phrase must consist of multiple terms, separated with spaces.');
}
$this->predicates[] = $this->processValue($phrase) . '~' . $distance;
return $this;
}
|
[
"public",
"function",
"sloppy",
"(",
"$",
"phrase",
",",
"$",
"distance",
")",
"{",
"if",
"(",
"$",
"distance",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Slop distance has to be greater than 0.'",
")",
";",
"}",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"phrase",
",",
"' '",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Sloppy phrase must consist of multiple terms, separated with spaces.'",
")",
";",
"}",
"$",
"this",
"->",
"predicates",
"[",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"phrase",
")",
".",
"'~'",
".",
"$",
"distance",
";",
"return",
"$",
"this",
";",
"}"
] |
Crates new precidate with trailing ~ followed by distance.
@param string $phrase
@param int $distance
@return $this
@throws \InvalidArgumentException if sloppy distance < 0
@throws \InvalidArgumentException if sloppy phrase without multiple terms
|
[
"Crates",
"new",
"precidate",
"with",
"trailing",
"~",
"followed",
"by",
"distance",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L434-L447
|
224,466
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.boost
|
public function boost($value)
{
if ($value < 0) {
throw new InvalidArgumentException('Boost must not be negative.');
}
$this->boost = $this->processFloat($value);
return $this;
}
|
php
|
public function boost($value)
{
if ($value < 0) {
throw new InvalidArgumentException('Boost must not be negative.');
}
$this->boost = $this->processFloat($value);
return $this;
}
|
[
"public",
"function",
"boost",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"<",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Boost must not be negative.'",
")",
";",
"}",
"$",
"this",
"->",
"boost",
"=",
"$",
"this",
"->",
"processFloat",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Boost positive hit with given factor. eg. ^2.3 value.
@param float $value
@return $this
@throws \InvalidArgumentException if provided boost is negative
|
[
"Boost",
"positive",
"hit",
"with",
"given",
"factor",
".",
"eg",
".",
"^2",
".",
"3",
"value",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L481-L490
|
224,467
|
minimalcode-org/search
|
src/Criteria.php
|
Criteria.traverse
|
private function traverse(Node $node)
{
$query = '';
if ($node->getOperator() !== Node::OPERATOR_BLANK) {
$query .= ' ' . $node->getOperator() . ' ';
}
if ($node->getType() === Node::TYPE_CROTCH) {
$addsParentheses = $node->isNegatingWholeChildren()
|| ($node !== $this->root && \count($node->getChildren()) > 1);
if ($node->isNegatingWholeChildren()) {
$query .= '-';
}
if ($addsParentheses) {
$query .= '(';
}
foreach ($node->getChildren() as $child) {
$query .= $this->traverse($child);
}
if ($addsParentheses) {
$query .= ')';
}
} else {// if ($node->getType() === Node::TYPE_LEAF) { is always true
$criteria = $node->getCriteria();
$countPredicates = \count($criteria->predicates);
$addsParentheses = $countPredicates > 1;
if ($countPredicates === 0) {
$criteria->isNotNull();// where("field"); => field:[* TO *]
$countPredicates = 1;
}
if ($criteria->isNegating) {
$query .= '-';
}
if (! $criteria->isHideFieldName) {
$query .= $criteria->field . ':';// "field:" prefix
}
if ($addsParentheses) {
$query .= '(';
}
$i = 0;
while ($i < $countPredicates) {
$query .= $criteria->predicates[$i];
if (($i + 1) !== $countPredicates) {
$query .= ' ';// field:(a b c d...) This falls upon the solr q.op param (default OR)
}
$i++;
}
if ($addsParentheses) {
$query .= ')';
}
if ($criteria->boost) {
$query .= '^' . $criteria->boost;// field:foo^5.0
}
}
return $query;
}
|
php
|
private function traverse(Node $node)
{
$query = '';
if ($node->getOperator() !== Node::OPERATOR_BLANK) {
$query .= ' ' . $node->getOperator() . ' ';
}
if ($node->getType() === Node::TYPE_CROTCH) {
$addsParentheses = $node->isNegatingWholeChildren()
|| ($node !== $this->root && \count($node->getChildren()) > 1);
if ($node->isNegatingWholeChildren()) {
$query .= '-';
}
if ($addsParentheses) {
$query .= '(';
}
foreach ($node->getChildren() as $child) {
$query .= $this->traverse($child);
}
if ($addsParentheses) {
$query .= ')';
}
} else {// if ($node->getType() === Node::TYPE_LEAF) { is always true
$criteria = $node->getCriteria();
$countPredicates = \count($criteria->predicates);
$addsParentheses = $countPredicates > 1;
if ($countPredicates === 0) {
$criteria->isNotNull();// where("field"); => field:[* TO *]
$countPredicates = 1;
}
if ($criteria->isNegating) {
$query .= '-';
}
if (! $criteria->isHideFieldName) {
$query .= $criteria->field . ':';// "field:" prefix
}
if ($addsParentheses) {
$query .= '(';
}
$i = 0;
while ($i < $countPredicates) {
$query .= $criteria->predicates[$i];
if (($i + 1) !== $countPredicates) {
$query .= ' ';// field:(a b c d...) This falls upon the solr q.op param (default OR)
}
$i++;
}
if ($addsParentheses) {
$query .= ')';
}
if ($criteria->boost) {
$query .= '^' . $criteria->boost;// field:foo^5.0
}
}
return $query;
}
|
[
"private",
"function",
"traverse",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"query",
"=",
"''",
";",
"if",
"(",
"$",
"node",
"->",
"getOperator",
"(",
")",
"!==",
"Node",
"::",
"OPERATOR_BLANK",
")",
"{",
"$",
"query",
".=",
"' '",
".",
"$",
"node",
"->",
"getOperator",
"(",
")",
".",
"' '",
";",
"}",
"if",
"(",
"$",
"node",
"->",
"getType",
"(",
")",
"===",
"Node",
"::",
"TYPE_CROTCH",
")",
"{",
"$",
"addsParentheses",
"=",
"$",
"node",
"->",
"isNegatingWholeChildren",
"(",
")",
"||",
"(",
"$",
"node",
"!==",
"$",
"this",
"->",
"root",
"&&",
"\\",
"count",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
")",
">",
"1",
")",
";",
"if",
"(",
"$",
"node",
"->",
"isNegatingWholeChildren",
"(",
")",
")",
"{",
"$",
"query",
".=",
"'-'",
";",
"}",
"if",
"(",
"$",
"addsParentheses",
")",
"{",
"$",
"query",
".=",
"'('",
";",
"}",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"query",
".=",
"$",
"this",
"->",
"traverse",
"(",
"$",
"child",
")",
";",
"}",
"if",
"(",
"$",
"addsParentheses",
")",
"{",
"$",
"query",
".=",
"')'",
";",
"}",
"}",
"else",
"{",
"// if ($node->getType() === Node::TYPE_LEAF) { is always true",
"$",
"criteria",
"=",
"$",
"node",
"->",
"getCriteria",
"(",
")",
";",
"$",
"countPredicates",
"=",
"\\",
"count",
"(",
"$",
"criteria",
"->",
"predicates",
")",
";",
"$",
"addsParentheses",
"=",
"$",
"countPredicates",
">",
"1",
";",
"if",
"(",
"$",
"countPredicates",
"===",
"0",
")",
"{",
"$",
"criteria",
"->",
"isNotNull",
"(",
")",
";",
"// where(\"field\"); => field:[* TO *]",
"$",
"countPredicates",
"=",
"1",
";",
"}",
"if",
"(",
"$",
"criteria",
"->",
"isNegating",
")",
"{",
"$",
"query",
".=",
"'-'",
";",
"}",
"if",
"(",
"!",
"$",
"criteria",
"->",
"isHideFieldName",
")",
"{",
"$",
"query",
".=",
"$",
"criteria",
"->",
"field",
".",
"':'",
";",
"// \"field:\" prefix",
"}",
"if",
"(",
"$",
"addsParentheses",
")",
"{",
"$",
"query",
".=",
"'('",
";",
"}",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"i",
"<",
"$",
"countPredicates",
")",
"{",
"$",
"query",
".=",
"$",
"criteria",
"->",
"predicates",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"(",
"$",
"i",
"+",
"1",
")",
"!==",
"$",
"countPredicates",
")",
"{",
"$",
"query",
".=",
"' '",
";",
"// field:(a b c d...) This falls upon the solr q.op param (default OR)",
"}",
"$",
"i",
"++",
";",
"}",
"if",
"(",
"$",
"addsParentheses",
")",
"{",
"$",
"query",
".=",
"')'",
";",
"}",
"if",
"(",
"$",
"criteria",
"->",
"boost",
")",
"{",
"$",
"query",
".=",
"'^'",
".",
"$",
"criteria",
"->",
"boost",
";",
"// field:foo^5.0",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] |
Parses and manages the current node tree of predicates.
@param Node $node
@return string
|
[
"Parses",
"and",
"manages",
"the",
"current",
"node",
"tree",
"of",
"predicates",
"."
] |
f225300618b6567056196508298a9e7e6b5b484f
|
https://github.com/minimalcode-org/search/blob/f225300618b6567056196508298a9e7e6b5b484f/src/Criteria.php#L518-L588
|
224,468
|
tomloprod/ionic-push-php
|
src/Api/Request.php
|
Request.sendRequest
|
public function sendRequest($method, $endPoint, $data = '')
{
$data = json_encode($data);
$headers = [
'Authorization: Bearer ' . $this->ionicAPIToken,
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
];
$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
curl_setopt($curlHandler, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlHandler, CURLOPT_HEADER, false);
switch ($method) {
case self::METHOD_POST:
curl_setopt($curlHandler, CURLOPT_POST, true);
break;
case self::METHOD_GET:
case self::METHOD_DELETE:
case self::METHOD_PATCH:
curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
break;
}
if (!empty($data)) {
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curlHandler, CURLINFO_HEADER_OUT, true);
curl_setopt($curlHandler, CURLOPT_URL, self::$ionicBaseURL . $endPoint);
$response = curl_exec($curlHandler);
$statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
curl_close($curlHandler);
$response = json_decode($response);
if (!$this->isSuccessResponse($statusCode)) {
$this->throwRequestException($statusCode, $response);
}
// Return response.
return $response;
}
|
php
|
public function sendRequest($method, $endPoint, $data = '')
{
$data = json_encode($data);
$headers = [
'Authorization: Bearer ' . $this->ionicAPIToken,
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
];
$curlHandler = curl_init();
curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
curl_setopt($curlHandler, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlHandler, CURLOPT_HEADER, false);
switch ($method) {
case self::METHOD_POST:
curl_setopt($curlHandler, CURLOPT_POST, true);
break;
case self::METHOD_GET:
case self::METHOD_DELETE:
case self::METHOD_PATCH:
curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
break;
}
if (!empty($data)) {
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curlHandler, CURLINFO_HEADER_OUT, true);
curl_setopt($curlHandler, CURLOPT_URL, self::$ionicBaseURL . $endPoint);
$response = curl_exec($curlHandler);
$statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
curl_close($curlHandler);
$response = json_decode($response);
if (!$this->isSuccessResponse($statusCode)) {
$this->throwRequestException($statusCode, $response);
}
// Return response.
return $response;
}
|
[
"public",
"function",
"sendRequest",
"(",
"$",
"method",
",",
"$",
"endPoint",
",",
"$",
"data",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"headers",
"=",
"[",
"'Authorization: Bearer '",
".",
"$",
"this",
"->",
"ionicAPIToken",
",",
"'Content-Type: application/json'",
",",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"data",
")",
",",
"]",
";",
"$",
"curlHandler",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"$",
"this",
"->",
"connectTimeout",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_TIMEOUT",
",",
"$",
"this",
"->",
"timeout",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"$",
"this",
"->",
"sslVerifyPeer",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"self",
"::",
"METHOD_POST",
":",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"break",
";",
"case",
"self",
"::",
"METHOD_GET",
":",
"case",
"self",
"::",
"METHOD_DELETE",
":",
"case",
"self",
"::",
"METHOD_PATCH",
":",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"method",
")",
";",
"break",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLINFO_HEADER_OUT",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curlHandler",
",",
"CURLOPT_URL",
",",
"self",
"::",
"$",
"ionicBaseURL",
".",
"$",
"endPoint",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"curlHandler",
")",
";",
"$",
"statusCode",
"=",
"curl_getinfo",
"(",
"$",
"curlHandler",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"curlHandler",
")",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"response",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isSuccessResponse",
"(",
"$",
"statusCode",
")",
")",
"{",
"$",
"this",
"->",
"throwRequestException",
"(",
"$",
"statusCode",
",",
"$",
"response",
")",
";",
"}",
"// Return response.",
"return",
"$",
"response",
";",
"}"
] |
Send requests to the Ionic Push API.
INFO: https://docs.ionic.io/api/http.html#response-structure
@param string $method
@param string $endPoint
@param string $data
@throws RequestException
@return object
|
[
"Send",
"requests",
"to",
"the",
"Ionic",
"Push",
"API",
"."
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Request.php#L58-L110
|
224,469
|
tomloprod/ionic-push-php
|
src/Api/Request.php
|
Request.throwRequestException
|
private function throwRequestException($statusCode, $response)
{
if ($response && isset($response->error)) {
$type = $response->error->type;
$message = $this->getResponseErrorMessage($response->error);
$link = $response->error->link;
} elseif ($this->isServerErrorResponse($statusCode)) {
$type = 'Server Error';
$message = RequestException::$statusTexts[$statusCode];
$link = '';
} else {
$type = 'Client Error';
$message = RequestException::$statusTexts[$statusCode];
$link = '';
}
throw new RequestException($type, $message, $link, $statusCode);
}
|
php
|
private function throwRequestException($statusCode, $response)
{
if ($response && isset($response->error)) {
$type = $response->error->type;
$message = $this->getResponseErrorMessage($response->error);
$link = $response->error->link;
} elseif ($this->isServerErrorResponse($statusCode)) {
$type = 'Server Error';
$message = RequestException::$statusTexts[$statusCode];
$link = '';
} else {
$type = 'Client Error';
$message = RequestException::$statusTexts[$statusCode];
$link = '';
}
throw new RequestException($type, $message, $link, $statusCode);
}
|
[
"private",
"function",
"throwRequestException",
"(",
"$",
"statusCode",
",",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"&&",
"isset",
"(",
"$",
"response",
"->",
"error",
")",
")",
"{",
"$",
"type",
"=",
"$",
"response",
"->",
"error",
"->",
"type",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"getResponseErrorMessage",
"(",
"$",
"response",
"->",
"error",
")",
";",
"$",
"link",
"=",
"$",
"response",
"->",
"error",
"->",
"link",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isServerErrorResponse",
"(",
"$",
"statusCode",
")",
")",
"{",
"$",
"type",
"=",
"'Server Error'",
";",
"$",
"message",
"=",
"RequestException",
"::",
"$",
"statusTexts",
"[",
"$",
"statusCode",
"]",
";",
"$",
"link",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"'Client Error'",
";",
"$",
"message",
"=",
"RequestException",
"::",
"$",
"statusTexts",
"[",
"$",
"statusCode",
"]",
";",
"$",
"link",
"=",
"''",
";",
"}",
"throw",
"new",
"RequestException",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"link",
",",
"$",
"statusCode",
")",
";",
"}"
] |
Throw the RequestException error with error detail
@private
@param number $statusCode
@param mixed $response
@throws RequestException
@return void
|
[
"Throw",
"the",
"RequestException",
"error",
"with",
"error",
"detail"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Request.php#L182-L199
|
224,470
|
tomloprod/ionic-push-php
|
src/Api/Request.php
|
Request.getResponseErrorMessage
|
private function getResponseErrorMessage($error)
{
$message = $error->message;
if (isset($error->details) && is_array($error->details)) {
foreach ($error->details as $detail) {
$message .= implode(' - ', $detail->errors).' ['.$detail->error_type.' in '.$detail->parameter.'] ';
}
}
return $message;
}
|
php
|
private function getResponseErrorMessage($error)
{
$message = $error->message;
if (isset($error->details) && is_array($error->details)) {
foreach ($error->details as $detail) {
$message .= implode(' - ', $detail->errors).' ['.$detail->error_type.' in '.$detail->parameter.'] ';
}
}
return $message;
}
|
[
"private",
"function",
"getResponseErrorMessage",
"(",
"$",
"error",
")",
"{",
"$",
"message",
"=",
"$",
"error",
"->",
"message",
";",
"if",
"(",
"isset",
"(",
"$",
"error",
"->",
"details",
")",
"&&",
"is_array",
"(",
"$",
"error",
"->",
"details",
")",
")",
"{",
"foreach",
"(",
"$",
"error",
"->",
"details",
"as",
"$",
"detail",
")",
"{",
"$",
"message",
".=",
"implode",
"(",
"' - '",
",",
"$",
"detail",
"->",
"errors",
")",
".",
"' ['",
".",
"$",
"detail",
"->",
"error_type",
".",
"' in '",
".",
"$",
"detail",
"->",
"parameter",
".",
"'] '",
";",
"}",
"}",
"return",
"$",
"message",
";",
"}"
] |
Generate a full message from response error request
@private
@param object $error
@return string
|
[
"Generate",
"a",
"full",
"message",
"from",
"response",
"error",
"request"
] |
ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa
|
https://github.com/tomloprod/ionic-push-php/blob/ad4f545b58d1c839960c3c1e7c16e8e04fe9e4aa/src/Api/Request.php#L209-L220
|
224,471
|
webfactory/doctrine-orm-test-infrastructure
|
src/Webfactory/Doctrine/Config/FileDatabaseConnectionConfiguration.php
|
FileDatabaseConnectionConfiguration.toDatabaseFilePath
|
private function toDatabaseFilePath($filePath)
{
if ($filePath === null) {
$temporaryFile = sys_get_temp_dir() . '/' . uniqid('db-', true) . '.sqlite';
// Ensure that the temporary file is removed on shutdown, otherwise the filesystem
// might be cluttered with database files.
register_shutdown_function(array($this, 'cleanUp'));
return $temporaryFile;
}
return $filePath;
}
|
php
|
private function toDatabaseFilePath($filePath)
{
if ($filePath === null) {
$temporaryFile = sys_get_temp_dir() . '/' . uniqid('db-', true) . '.sqlite';
// Ensure that the temporary file is removed on shutdown, otherwise the filesystem
// might be cluttered with database files.
register_shutdown_function(array($this, 'cleanUp'));
return $temporaryFile;
}
return $filePath;
}
|
[
"private",
"function",
"toDatabaseFilePath",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"$",
"filePath",
"===",
"null",
")",
"{",
"$",
"temporaryFile",
"=",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"uniqid",
"(",
"'db-'",
",",
"true",
")",
".",
"'.sqlite'",
";",
"// Ensure that the temporary file is removed on shutdown, otherwise the filesystem",
"// might be cluttered with database files.",
"register_shutdown_function",
"(",
"array",
"(",
"$",
"this",
",",
"'cleanUp'",
")",
")",
";",
"return",
"$",
"temporaryFile",
";",
"}",
"return",
"$",
"filePath",
";",
"}"
] |
Returns a file path for the database file.
Generates a unique file name if the given $filePath is null.
@param string|null $filePath
@return string
|
[
"Returns",
"a",
"file",
"path",
"for",
"the",
"database",
"file",
"."
] |
7385fd39d8d2a609cc1edebe9375c2c9bb6da84a
|
https://github.com/webfactory/doctrine-orm-test-infrastructure/blob/7385fd39d8d2a609cc1edebe9375c2c9bb6da84a/src/Webfactory/Doctrine/Config/FileDatabaseConnectionConfiguration.php#L68-L78
|
224,472
|
artkonekt/address
|
src/Models/Province.php
|
Province.findByCountryAndCode
|
public static function findByCountryAndCode($country, $code)
{
$country = is_object($country) ? $country->id : $country;
return ProvinceProxy::byCountry($country)
->where('code', $code)
->take(1)
->get()
->first();
}
|
php
|
public static function findByCountryAndCode($country, $code)
{
$country = is_object($country) ? $country->id : $country;
return ProvinceProxy::byCountry($country)
->where('code', $code)
->take(1)
->get()
->first();
}
|
[
"public",
"static",
"function",
"findByCountryAndCode",
"(",
"$",
"country",
",",
"$",
"code",
")",
"{",
"$",
"country",
"=",
"is_object",
"(",
"$",
"country",
")",
"?",
"$",
"country",
"->",
"id",
":",
"$",
"country",
";",
"return",
"ProvinceProxy",
"::",
"byCountry",
"(",
"$",
"country",
")",
"->",
"where",
"(",
"'code'",
",",
"$",
"code",
")",
"->",
"take",
"(",
"1",
")",
"->",
"get",
"(",
")",
"->",
"first",
"(",
")",
";",
"}"
] |
Returns a single province object by country and code
@param \Konekt\Address\Contracts\Country|string $country
@param string $code
@return \Konekt\Address\Contracts\Province
|
[
"Returns",
"a",
"single",
"province",
"object",
"by",
"country",
"and",
"code"
] |
1804292674b02dbb02a7f76bffdfd260b6a5d841
|
https://github.com/artkonekt/address/blob/1804292674b02dbb02a7f76bffdfd260b6a5d841/src/Models/Province.php#L60-L69
|
224,473
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.executeUpdates
|
private function executeUpdates(ClassMetadata $class, array $options = array())
{
$className = $class->name;
$persister = $this->getXmlEntityPersister($className);
$hasPreUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::preUpdate]);
$hasPreUpdateListeners = $this->evm->hasListeners(Events::preUpdate);
$hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]);
$hasPostUpdateListeners = $this->evm->hasListeners(Events::postUpdate);
foreach ($this->entityUpdates as $oid => $xmlEntity) {
if (get_class($xmlEntity) == $className || $xmlEntity instanceof Proxy && $xmlEntity instanceof $className) {
// if ( ! $class->isEmbeddedDocument) {
if ($hasPreUpdateLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::preUpdate, $xmlEntity);
// $this->recomputeSingleDocumentChangeSet($class, $xmlEntity);
}
if ($hasPreUpdateListeners) {
$this->evm->dispatchEvent(Events::preUpdate, new Event\PreUpdateEventArgs(
$xmlEntity, $this->xem, $this->entityChangeSets[$oid])
);
}
$persister->update($xmlEntity);
unset($this->entityUpdates[$oid]);
if ($hasPostUpdateLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::postUpdate, $xmlEntity);
}
if ($hasPostUpdateListeners) {
$this->evm->dispatchEvent(Events::postUpdate, new Event\LifecycleEventArgs($xmlEntity, $this->xem));
}
// $this->cascadePostUpdateAndPostPersist($class, $xmlEntity);
}
}
}
|
php
|
private function executeUpdates(ClassMetadata $class, array $options = array())
{
$className = $class->name;
$persister = $this->getXmlEntityPersister($className);
$hasPreUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::preUpdate]);
$hasPreUpdateListeners = $this->evm->hasListeners(Events::preUpdate);
$hasPostUpdateLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postUpdate]);
$hasPostUpdateListeners = $this->evm->hasListeners(Events::postUpdate);
foreach ($this->entityUpdates as $oid => $xmlEntity) {
if (get_class($xmlEntity) == $className || $xmlEntity instanceof Proxy && $xmlEntity instanceof $className) {
// if ( ! $class->isEmbeddedDocument) {
if ($hasPreUpdateLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::preUpdate, $xmlEntity);
// $this->recomputeSingleDocumentChangeSet($class, $xmlEntity);
}
if ($hasPreUpdateListeners) {
$this->evm->dispatchEvent(Events::preUpdate, new Event\PreUpdateEventArgs(
$xmlEntity, $this->xem, $this->entityChangeSets[$oid])
);
}
$persister->update($xmlEntity);
unset($this->entityUpdates[$oid]);
if ($hasPostUpdateLifecycleCallbacks) {
$class->invokeLifecycleCallbacks(Events::postUpdate, $xmlEntity);
}
if ($hasPostUpdateListeners) {
$this->evm->dispatchEvent(Events::postUpdate, new Event\LifecycleEventArgs($xmlEntity, $this->xem));
}
// $this->cascadePostUpdateAndPostPersist($class, $xmlEntity);
}
}
}
|
[
"private",
"function",
"executeUpdates",
"(",
"ClassMetadata",
"$",
"class",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"className",
"=",
"$",
"class",
"->",
"name",
";",
"$",
"persister",
"=",
"$",
"this",
"->",
"getXmlEntityPersister",
"(",
"$",
"className",
")",
";",
"$",
"hasPreUpdateLifecycleCallbacks",
"=",
"isset",
"(",
"$",
"class",
"->",
"lifecycleCallbacks",
"[",
"Events",
"::",
"preUpdate",
"]",
")",
";",
"$",
"hasPreUpdateListeners",
"=",
"$",
"this",
"->",
"evm",
"->",
"hasListeners",
"(",
"Events",
"::",
"preUpdate",
")",
";",
"$",
"hasPostUpdateLifecycleCallbacks",
"=",
"isset",
"(",
"$",
"class",
"->",
"lifecycleCallbacks",
"[",
"Events",
"::",
"postUpdate",
"]",
")",
";",
"$",
"hasPostUpdateListeners",
"=",
"$",
"this",
"->",
"evm",
"->",
"hasListeners",
"(",
"Events",
"::",
"postUpdate",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entityUpdates",
"as",
"$",
"oid",
"=>",
"$",
"xmlEntity",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
"==",
"$",
"className",
"||",
"$",
"xmlEntity",
"instanceof",
"Proxy",
"&&",
"$",
"xmlEntity",
"instanceof",
"$",
"className",
")",
"{",
"// if ( ! $class->isEmbeddedDocument) {",
"if",
"(",
"$",
"hasPreUpdateLifecycleCallbacks",
")",
"{",
"$",
"class",
"->",
"invokeLifecycleCallbacks",
"(",
"Events",
"::",
"preUpdate",
",",
"$",
"xmlEntity",
")",
";",
"// $this->recomputeSingleDocumentChangeSet($class, $xmlEntity);",
"}",
"if",
"(",
"$",
"hasPreUpdateListeners",
")",
"{",
"$",
"this",
"->",
"evm",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"preUpdate",
",",
"new",
"Event",
"\\",
"PreUpdateEventArgs",
"(",
"$",
"xmlEntity",
",",
"$",
"this",
"->",
"xem",
",",
"$",
"this",
"->",
"entityChangeSets",
"[",
"$",
"oid",
"]",
")",
")",
";",
"}",
"$",
"persister",
"->",
"update",
"(",
"$",
"xmlEntity",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"entityUpdates",
"[",
"$",
"oid",
"]",
")",
";",
"if",
"(",
"$",
"hasPostUpdateLifecycleCallbacks",
")",
"{",
"$",
"class",
"->",
"invokeLifecycleCallbacks",
"(",
"Events",
"::",
"postUpdate",
",",
"$",
"xmlEntity",
")",
";",
"}",
"if",
"(",
"$",
"hasPostUpdateListeners",
")",
"{",
"$",
"this",
"->",
"evm",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postUpdate",
",",
"new",
"Event",
"\\",
"LifecycleEventArgs",
"(",
"$",
"xmlEntity",
",",
"$",
"this",
"->",
"xem",
")",
")",
";",
"}",
"// $this->cascadePostUpdateAndPostPersist($class, $xmlEntity);",
"}",
"}",
"}"
] |
Executes all xml entity updates for documents of the specified type.
@param Doctrine\OXM\Mapping\ClassMetadata $class
@param array $options Array of options to be used with update()
|
[
"Executes",
"all",
"xml",
"entity",
"updates",
"for",
"documents",
"of",
"the",
"specified",
"type",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L342-L378
|
224,474
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.doRefresh
|
private function doRefresh($xmlEntity, array &$visited)
{
$oid = spl_object_hash($xmlEntity);
if (isset($visited[$oid])) {
return; // Prevent infinite recursion
}
$visited[$oid] = $xmlEntity; // mark visited
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
if ($this->getXmlEntityState($xmlEntity) == self::STATE_MANAGED) {
// @todo refresh xml-entity
} else {
throw new \InvalidArgumentException("XmlEntity is not MANAGED.");
}
}
|
php
|
private function doRefresh($xmlEntity, array &$visited)
{
$oid = spl_object_hash($xmlEntity);
if (isset($visited[$oid])) {
return; // Prevent infinite recursion
}
$visited[$oid] = $xmlEntity; // mark visited
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
if ($this->getXmlEntityState($xmlEntity) == self::STATE_MANAGED) {
// @todo refresh xml-entity
} else {
throw new \InvalidArgumentException("XmlEntity is not MANAGED.");
}
}
|
[
"private",
"function",
"doRefresh",
"(",
"$",
"xmlEntity",
",",
"array",
"&",
"$",
"visited",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"xmlEntity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"visited",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"return",
";",
"// Prevent infinite recursion",
"}",
"$",
"visited",
"[",
"$",
"oid",
"]",
"=",
"$",
"xmlEntity",
";",
"// mark visited",
"$",
"class",
"=",
"$",
"this",
"->",
"xem",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getXmlEntityState",
"(",
"$",
"xmlEntity",
")",
"==",
"self",
"::",
"STATE_MANAGED",
")",
"{",
"// @todo refresh xml-entity",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"XmlEntity is not MANAGED.\"",
")",
";",
"}",
"}"
] |
Executes a refresh operation on an xml-entity.
@param object $xmlEntity The xml-entity to refresh.
@param array $visited The already visited xml-entities during cascades.
@throws InvalidArgumentException If the xml-entity is not MANAGED.
|
[
"Executes",
"a",
"refresh",
"operation",
"on",
"an",
"xml",
"-",
"entity",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L393-L408
|
224,475
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.doDetach
|
private function doDetach($xmlEntity, array &$visited)
{
$oid = spl_object_hash($xmlEntity);
if (isset($visited[$oid])) {
return; // Prevent infinite recursion
}
$visited[$oid] = $xmlEntity; // mark visited
switch ($this->getXmlEntityState($xmlEntity, self::STATE_DETACHED)) {
case self::STATE_MANAGED:
$this->removeFromIdentityMap($xmlEntity);
unset($this->entityIdentifiers[$oid], $this->entityUpdates[$oid],
$this->entityDeletions[$oid], $this->entityIdentifiers[$oid],
$this->entityStates[$oid], $this->originalEntityData[$oid]);
break;
case self::STATE_NEW:
case self::STATE_DETACHED:
return;
}
//$this->cascadeDetach($document, $visited);
}
|
php
|
private function doDetach($xmlEntity, array &$visited)
{
$oid = spl_object_hash($xmlEntity);
if (isset($visited[$oid])) {
return; // Prevent infinite recursion
}
$visited[$oid] = $xmlEntity; // mark visited
switch ($this->getXmlEntityState($xmlEntity, self::STATE_DETACHED)) {
case self::STATE_MANAGED:
$this->removeFromIdentityMap($xmlEntity);
unset($this->entityIdentifiers[$oid], $this->entityUpdates[$oid],
$this->entityDeletions[$oid], $this->entityIdentifiers[$oid],
$this->entityStates[$oid], $this->originalEntityData[$oid]);
break;
case self::STATE_NEW:
case self::STATE_DETACHED:
return;
}
//$this->cascadeDetach($document, $visited);
}
|
[
"private",
"function",
"doDetach",
"(",
"$",
"xmlEntity",
",",
"array",
"&",
"$",
"visited",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"xmlEntity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"visited",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"return",
";",
"// Prevent infinite recursion",
"}",
"$",
"visited",
"[",
"$",
"oid",
"]",
"=",
"$",
"xmlEntity",
";",
"// mark visited",
"switch",
"(",
"$",
"this",
"->",
"getXmlEntityState",
"(",
"$",
"xmlEntity",
",",
"self",
"::",
"STATE_DETACHED",
")",
")",
"{",
"case",
"self",
"::",
"STATE_MANAGED",
":",
"$",
"this",
"->",
"removeFromIdentityMap",
"(",
"$",
"xmlEntity",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"entityIdentifiers",
"[",
"$",
"oid",
"]",
",",
"$",
"this",
"->",
"entityUpdates",
"[",
"$",
"oid",
"]",
",",
"$",
"this",
"->",
"entityDeletions",
"[",
"$",
"oid",
"]",
",",
"$",
"this",
"->",
"entityIdentifiers",
"[",
"$",
"oid",
"]",
",",
"$",
"this",
"->",
"entityStates",
"[",
"$",
"oid",
"]",
",",
"$",
"this",
"->",
"originalEntityData",
"[",
"$",
"oid",
"]",
")",
";",
"break",
";",
"case",
"self",
"::",
"STATE_NEW",
":",
"case",
"self",
"::",
"STATE_DETACHED",
":",
"return",
";",
"}",
"//$this->cascadeDetach($document, $visited);",
"}"
] |
Executes a detach operation on the given xml-entity.
@param object $xmlEntity
@param array $visited
@internal This method always considers xml-entities with an assigned identifier as DETACHED.
|
[
"Executes",
"a",
"detach",
"operation",
"on",
"the",
"given",
"xml",
"-",
"entity",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L429-L451
|
224,476
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.persist
|
public function persist($xmlEntity)
{
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
if ($class->isMappedSuperclass) {
throw OXMException::cannotPersistMappedSuperclass($class->name);
}
if (!$class->isRoot) {
throw OXMException::canOnlyPersistRootClasses($class->name);
}
$visited = array();
$this->doPersist($xmlEntity, $visited);
}
|
php
|
public function persist($xmlEntity)
{
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
if ($class->isMappedSuperclass) {
throw OXMException::cannotPersistMappedSuperclass($class->name);
}
if (!$class->isRoot) {
throw OXMException::canOnlyPersistRootClasses($class->name);
}
$visited = array();
$this->doPersist($xmlEntity, $visited);
}
|
[
"public",
"function",
"persist",
"(",
"$",
"xmlEntity",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"xem",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isMappedSuperclass",
")",
"{",
"throw",
"OXMException",
"::",
"cannotPersistMappedSuperclass",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"if",
"(",
"!",
"$",
"class",
"->",
"isRoot",
")",
"{",
"throw",
"OXMException",
"::",
"canOnlyPersistRootClasses",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"$",
"visited",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"doPersist",
"(",
"$",
"xmlEntity",
",",
"$",
"visited",
")",
";",
"}"
] |
Persists an xml entity as part of the current unit of work.
@param object $xmlEntity The xml entity to persist.
|
[
"Persists",
"an",
"xml",
"entity",
"as",
"part",
"of",
"the",
"current",
"unit",
"of",
"work",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L589-L601
|
224,477
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.scheduleForDirtyCheck
|
public function scheduleForDirtyCheck($xmlEntity)
{
$rootClassName = $this->xem->getClassMetadata(get_class($xmlEntity))->rootXmlEntityName;
$this->scheduledForDirtyCheck[$rootClassName][spl_object_hash($xmlEntity)] = $xmlEntity;
}
|
php
|
public function scheduleForDirtyCheck($xmlEntity)
{
$rootClassName = $this->xem->getClassMetadata(get_class($xmlEntity))->rootXmlEntityName;
$this->scheduledForDirtyCheck[$rootClassName][spl_object_hash($xmlEntity)] = $xmlEntity;
}
|
[
"public",
"function",
"scheduleForDirtyCheck",
"(",
"$",
"xmlEntity",
")",
"{",
"$",
"rootClassName",
"=",
"$",
"this",
"->",
"xem",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
")",
"->",
"rootXmlEntityName",
";",
"$",
"this",
"->",
"scheduledForDirtyCheck",
"[",
"$",
"rootClassName",
"]",
"[",
"spl_object_hash",
"(",
"$",
"xmlEntity",
")",
"]",
"=",
"$",
"xmlEntity",
";",
"}"
] |
Schedules a xml entity for dirty-checking at commit-time.
@param object $xmlEntity The xml entity to schedule for dirty-checking.
@todo Rename: scheduleForSynchronization
|
[
"Schedules",
"a",
"xml",
"entity",
"for",
"dirty",
"-",
"checking",
"at",
"commit",
"-",
"time",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L663-L667
|
224,478
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.scheduleForInsert
|
public function scheduleForInsert($xmlEntity)
{
$oid = spl_object_hash($xmlEntity);
if (isset($this->entityUpdates[$oid])) {
throw new \InvalidArgumentException("Dirty xml entity can not be scheduled for insertion.");
}
if (isset($this->entityDeletions[$oid])) {
throw new \InvalidArgumentException("Removed xml entity can not be scheduled for insertion.");
}
if (isset($this->entityInsertions[$oid])) {
throw new \InvalidArgumentException("Xml entity can not be scheduled for insertion twice.");
}
$this->entityInsertions[$oid] = $xmlEntity;
if (isset($this->entityIdentifiers[$oid])) {
$this->addToIdentityMap($xmlEntity);
}
}
|
php
|
public function scheduleForInsert($xmlEntity)
{
$oid = spl_object_hash($xmlEntity);
if (isset($this->entityUpdates[$oid])) {
throw new \InvalidArgumentException("Dirty xml entity can not be scheduled for insertion.");
}
if (isset($this->entityDeletions[$oid])) {
throw new \InvalidArgumentException("Removed xml entity can not be scheduled for insertion.");
}
if (isset($this->entityInsertions[$oid])) {
throw new \InvalidArgumentException("Xml entity can not be scheduled for insertion twice.");
}
$this->entityInsertions[$oid] = $xmlEntity;
if (isset($this->entityIdentifiers[$oid])) {
$this->addToIdentityMap($xmlEntity);
}
}
|
[
"public",
"function",
"scheduleForInsert",
"(",
"$",
"xmlEntity",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"xmlEntity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityUpdates",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Dirty xml entity can not be scheduled for insertion.\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityDeletions",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Removed xml entity can not be scheduled for insertion.\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityInsertions",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Xml entity can not be scheduled for insertion twice.\"",
")",
";",
"}",
"$",
"this",
"->",
"entityInsertions",
"[",
"$",
"oid",
"]",
"=",
"$",
"xmlEntity",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityIdentifiers",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addToIdentityMap",
"(",
"$",
"xmlEntity",
")",
";",
"}",
"}"
] |
Schedules an document for insertion into the database.
If the document already has an identifier, it will be added to the identity map.
@param object $xmlEntity The document to schedule for insertion.
|
[
"Schedules",
"an",
"document",
"for",
"insertion",
"into",
"the",
"database",
".",
"If",
"the",
"document",
"already",
"has",
"an",
"identifier",
"it",
"will",
"be",
"added",
"to",
"the",
"identity",
"map",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L706-L725
|
224,479
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.getXmlEntityState
|
public function getXmlEntityState($xmlEntity, $assume = null)
{
$oid = spl_object_hash($xmlEntity);
if ( ! isset($this->entityStates[$oid])) {
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
// State can only be NEW or DETACHED, because MANAGED/REMOVED states are known.
// Note that you can not remember the NEW or DETACHED state in _documentStates since
// the UoW does not hold references to such objects and the object hash can be reused.
// More generally because the state may "change" between NEW/DETACHED without the UoW being aware of it.
if ($assume === null) {
$id = $class->getIdentifierValue($xmlEntity);
if ( ! $id) {
return self::STATE_NEW;
} else {
// Last try before db lookup: check the identity map.
if ($this->tryGetById($id, $class->rootXmlEntityName)) {
return self::STATE_DETACHED;
} else {
// db lookup
if ($this->getXmlEntityPersister(get_class($xmlEntity))->exists($xmlEntity)) {
return self::STATE_DETACHED;
} else {
return self::STATE_NEW;
}
}
}
} else {
return $assume;
}
}
return $this->entityStates[$oid];
}
|
php
|
public function getXmlEntityState($xmlEntity, $assume = null)
{
$oid = spl_object_hash($xmlEntity);
if ( ! isset($this->entityStates[$oid])) {
$class = $this->xem->getClassMetadata(get_class($xmlEntity));
// State can only be NEW or DETACHED, because MANAGED/REMOVED states are known.
// Note that you can not remember the NEW or DETACHED state in _documentStates since
// the UoW does not hold references to such objects and the object hash can be reused.
// More generally because the state may "change" between NEW/DETACHED without the UoW being aware of it.
if ($assume === null) {
$id = $class->getIdentifierValue($xmlEntity);
if ( ! $id) {
return self::STATE_NEW;
} else {
// Last try before db lookup: check the identity map.
if ($this->tryGetById($id, $class->rootXmlEntityName)) {
return self::STATE_DETACHED;
} else {
// db lookup
if ($this->getXmlEntityPersister(get_class($xmlEntity))->exists($xmlEntity)) {
return self::STATE_DETACHED;
} else {
return self::STATE_NEW;
}
}
}
} else {
return $assume;
}
}
return $this->entityStates[$oid];
}
|
[
"public",
"function",
"getXmlEntityState",
"(",
"$",
"xmlEntity",
",",
"$",
"assume",
"=",
"null",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"xmlEntity",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityStates",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"xem",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
")",
";",
"// State can only be NEW or DETACHED, because MANAGED/REMOVED states are known.",
"// Note that you can not remember the NEW or DETACHED state in _documentStates since",
"// the UoW does not hold references to such objects and the object hash can be reused.",
"// More generally because the state may \"change\" between NEW/DETACHED without the UoW being aware of it.",
"if",
"(",
"$",
"assume",
"===",
"null",
")",
"{",
"$",
"id",
"=",
"$",
"class",
"->",
"getIdentifierValue",
"(",
"$",
"xmlEntity",
")",
";",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"return",
"self",
"::",
"STATE_NEW",
";",
"}",
"else",
"{",
"// Last try before db lookup: check the identity map.",
"if",
"(",
"$",
"this",
"->",
"tryGetById",
"(",
"$",
"id",
",",
"$",
"class",
"->",
"rootXmlEntityName",
")",
")",
"{",
"return",
"self",
"::",
"STATE_DETACHED",
";",
"}",
"else",
"{",
"// db lookup",
"if",
"(",
"$",
"this",
"->",
"getXmlEntityPersister",
"(",
"get_class",
"(",
"$",
"xmlEntity",
")",
")",
"->",
"exists",
"(",
"$",
"xmlEntity",
")",
")",
"{",
"return",
"self",
"::",
"STATE_DETACHED",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"STATE_NEW",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"return",
"$",
"assume",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"entityStates",
"[",
"$",
"oid",
"]",
";",
"}"
] |
Gets the state of an xml entity within the current unit of work.
NOTE: This method sees xml entities that are not MANAGED or REMOVED and have a
populated identifier, whether it is generated or manually assigned, as
DETACHED. This can be incorrect for manually assigned identifiers.
@param object $xmlEntity
@param integer $assume The state to assume if the state is not yet known. This is usually
used to avoid costly state lookups, in the worst case with a filesystem
lookup.
@return int The document state.
|
[
"Gets",
"the",
"state",
"of",
"an",
"xml",
"entity",
"within",
"the",
"current",
"unit",
"of",
"work",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L782-L815
|
224,480
|
doctrine/oxm
|
lib/Doctrine/OXM/UnitOfWork.php
|
UnitOfWork.propertyChanged
|
function propertyChanged($entity, $propertyName, $oldValue, $newValue)
{
$oid = spl_object_hash($entity);
$class = $this->xem->getClassMetadata(get_class($entity));
if ( ! isset($class->fieldMappings[$propertyName])) {
return; // ignore non-persistent fields
}
// Update changeset and mark entity for synchronization
$this->entityChangeSets[$oid][$propertyName] = array($oldValue, $newValue);
if ( ! isset($this->scheduledForDirtyCheck[$class->rootXmlEntityName][$oid])) {
$this->scheduleForDirtyCheck($entity);
}
}
|
php
|
function propertyChanged($entity, $propertyName, $oldValue, $newValue)
{
$oid = spl_object_hash($entity);
$class = $this->xem->getClassMetadata(get_class($entity));
if ( ! isset($class->fieldMappings[$propertyName])) {
return; // ignore non-persistent fields
}
// Update changeset and mark entity for synchronization
$this->entityChangeSets[$oid][$propertyName] = array($oldValue, $newValue);
if ( ! isset($this->scheduledForDirtyCheck[$class->rootXmlEntityName][$oid])) {
$this->scheduleForDirtyCheck($entity);
}
}
|
[
"function",
"propertyChanged",
"(",
"$",
"entity",
",",
"$",
"propertyName",
",",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"$",
"oid",
"=",
"spl_object_hash",
"(",
"$",
"entity",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"xem",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"class",
"->",
"fieldMappings",
"[",
"$",
"propertyName",
"]",
")",
")",
"{",
"return",
";",
"// ignore non-persistent fields",
"}",
"// Update changeset and mark entity for synchronization",
"$",
"this",
"->",
"entityChangeSets",
"[",
"$",
"oid",
"]",
"[",
"$",
"propertyName",
"]",
"=",
"array",
"(",
"$",
"oldValue",
",",
"$",
"newValue",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"scheduledForDirtyCheck",
"[",
"$",
"class",
"->",
"rootXmlEntityName",
"]",
"[",
"$",
"oid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"scheduleForDirtyCheck",
"(",
"$",
"entity",
")",
";",
"}",
"}"
] |
Notifies the listener of a property change.
@param object $sender The object on which the property changed.
@param string $propertyName The name of the property that changed.
@param mixed $oldValue The old value of the property that changed.
@param mixed $newValue The new value of the property that changed.
|
[
"Notifies",
"the",
"listener",
"of",
"a",
"property",
"change",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/UnitOfWork.php#L841-L855
|
224,481
|
bramstroker/zf2-fullpage-cache
|
src/Strategy/Route.php
|
Route.checkParams
|
protected function checkParams(RouteMatch $match, $routeConfig)
{
if (!isset($routeConfig['params'])) {
return true;
}
$params = (array) $routeConfig['params'];
foreach ($params as $name => $value) {
$param = $match->getParam($name, null);
if (null === $param) {
continue;
}
if (!$this->checkParam($param, $value)) {
return false;
}
}
return true;
}
|
php
|
protected function checkParams(RouteMatch $match, $routeConfig)
{
if (!isset($routeConfig['params'])) {
return true;
}
$params = (array) $routeConfig['params'];
foreach ($params as $name => $value) {
$param = $match->getParam($name, null);
if (null === $param) {
continue;
}
if (!$this->checkParam($param, $value)) {
return false;
}
}
return true;
}
|
[
"protected",
"function",
"checkParams",
"(",
"RouteMatch",
"$",
"match",
",",
"$",
"routeConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"routeConfig",
"[",
"'params'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"params",
"=",
"(",
"array",
")",
"$",
"routeConfig",
"[",
"'params'",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"param",
"=",
"$",
"match",
"->",
"getParam",
"(",
"$",
"name",
",",
"null",
")",
";",
"if",
"(",
"null",
"===",
"$",
"param",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"param",
",",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if we should cache the request based on the params in the routematch
@param RouteMatch $match
@param array $routeConfig
@return bool
|
[
"Check",
"if",
"we",
"should",
"cache",
"the",
"request",
"based",
"on",
"the",
"params",
"in",
"the",
"routematch"
] |
ae2cf413e445163a6725afbca597d6fb98c38f0d
|
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Strategy/Route.php#L55-L75
|
224,482
|
bramstroker/zf2-fullpage-cache
|
src/Strategy/Route.php
|
Route.checkHttpMethod
|
protected function checkHttpMethod(MvcEvent $event, $routeConfig)
{
$request = $event->getRequest();
if (!$request instanceof HttpRequest) {
return false;
}
if (isset($routeConfig['http_methods'])) {
$methods = (array) $routeConfig['http_methods'];
if (!in_array($request->getMethod(), $methods)) {
return false;
}
}
return true;
}
|
php
|
protected function checkHttpMethod(MvcEvent $event, $routeConfig)
{
$request = $event->getRequest();
if (!$request instanceof HttpRequest) {
return false;
}
if (isset($routeConfig['http_methods'])) {
$methods = (array) $routeConfig['http_methods'];
if (!in_array($request->getMethod(), $methods)) {
return false;
}
}
return true;
}
|
[
"protected",
"function",
"checkHttpMethod",
"(",
"MvcEvent",
"$",
"event",
",",
"$",
"routeConfig",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"$",
"request",
"instanceof",
"HttpRequest",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"routeConfig",
"[",
"'http_methods'",
"]",
")",
")",
"{",
"$",
"methods",
"=",
"(",
"array",
")",
"$",
"routeConfig",
"[",
"'http_methods'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
",",
"$",
"methods",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if we should cache the request based on http method requested
@param MvcEvent $event
@param $routeConfig
@return bool
|
[
"Check",
"if",
"we",
"should",
"cache",
"the",
"request",
"based",
"on",
"http",
"method",
"requested"
] |
ae2cf413e445163a6725afbca597d6fb98c38f0d
|
https://github.com/bramstroker/zf2-fullpage-cache/blob/ae2cf413e445163a6725afbca597d6fb98c38f0d/src/Strategy/Route.php#L105-L120
|
224,483
|
doctrine/oxm
|
lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getReflectionClass
|
public function getReflectionClass()
{
if ( ! $this->reflClass) {
$this->reflClass = new \ReflectionClass($this->name);
}
return $this->reflClass;
}
|
php
|
public function getReflectionClass()
{
if ( ! $this->reflClass) {
$this->reflClass = new \ReflectionClass($this->name);
}
return $this->reflClass;
}
|
[
"public",
"function",
"getReflectionClass",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"reflClass",
")",
"{",
"$",
"this",
"->",
"reflClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reflClass",
";",
"}"
] |
Gets the ReflectionClass instance of the mapped class.
@return \ReflectionClass
|
[
"Gets",
"the",
"ReflectionClass",
"instance",
"of",
"the",
"mapped",
"class",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php#L342-L348
|
224,484
|
doctrine/oxm
|
lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getFieldXmlNode
|
public function getFieldXmlNode($fieldName)
{
return isset($this->fieldMappings[$fieldName]) ?
$this->fieldMappings[$fieldName]['node'] : null;
}
|
php
|
public function getFieldXmlNode($fieldName)
{
return isset($this->fieldMappings[$fieldName]) ?
$this->fieldMappings[$fieldName]['node'] : null;
}
|
[
"public",
"function",
"getFieldXmlNode",
"(",
"$",
"fieldName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
")",
"?",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'node'",
"]",
":",
"null",
";",
"}"
] |
Gets the type of an xml name.
@return string one of ("node", "attribute", "text")
|
[
"Gets",
"the",
"type",
"of",
"an",
"xml",
"name",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php#L775-L779
|
224,485
|
doctrine/oxm
|
lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getFieldName
|
public function getFieldName($xmlName)
{
return isset($this->xmlFieldMap[$xmlName]) ?
$this->xmlFieldMap[$xmlName] : null;
}
|
php
|
public function getFieldName($xmlName)
{
return isset($this->xmlFieldMap[$xmlName]) ?
$this->xmlFieldMap[$xmlName] : null;
}
|
[
"public",
"function",
"getFieldName",
"(",
"$",
"xmlName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"xmlFieldMap",
"[",
"$",
"xmlName",
"]",
")",
"?",
"$",
"this",
"->",
"xmlFieldMap",
"[",
"$",
"xmlName",
"]",
":",
"null",
";",
"}"
] |
Gets the field name for a xml name.
If no field name can be found the xml name is returned.
@param string $xmlName xml name
@return string field name
|
[
"Gets",
"the",
"field",
"name",
"for",
"a",
"xml",
"name",
".",
"If",
"no",
"field",
"name",
"can",
"be",
"found",
"the",
"xml",
"name",
"is",
"returned",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Mapping/ClassMetadataInfo.php#L801-L805
|
224,486
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.avatar
|
public function avatar($email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$baseUrl = $this->useHttps ? $this->https($this->baseUrl) : $this->baseUrl;
$url = $baseUrl . "avatar/" . $this->generateHash($email);
} else {
throw new InvalidArgumentException("The avatar filter must be passed a valid Email address");
}
if ($this->rating) {
$url = $this->rating($url, $this->rating);
}
if ($this->size) {
$url = $this->size($url, $this->size);
}
if ($this->default) {
$url = $this->def($url, $this->default);
}
return $url;
}
|
php
|
public function avatar($email) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$baseUrl = $this->useHttps ? $this->https($this->baseUrl) : $this->baseUrl;
$url = $baseUrl . "avatar/" . $this->generateHash($email);
} else {
throw new InvalidArgumentException("The avatar filter must be passed a valid Email address");
}
if ($this->rating) {
$url = $this->rating($url, $this->rating);
}
if ($this->size) {
$url = $this->size($url, $this->size);
}
if ($this->default) {
$url = $this->def($url, $this->default);
}
return $url;
}
|
[
"public",
"function",
"avatar",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_VALIDATE_EMAIL",
")",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"useHttps",
"?",
"$",
"this",
"->",
"https",
"(",
"$",
"this",
"->",
"baseUrl",
")",
":",
"$",
"this",
"->",
"baseUrl",
";",
"$",
"url",
"=",
"$",
"baseUrl",
".",
"\"avatar/\"",
".",
"$",
"this",
"->",
"generateHash",
"(",
"$",
"email",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The avatar filter must be passed a valid Email address\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"rating",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"rating",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"rating",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"size",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"size",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"size",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"default",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"def",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"default",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Get a Gravatar Avatar URL
@param string $email Gravatar Email address
@return string Gravatar Avatar URL
@throws \InvalidArgumentException If $email is invalid
|
[
"Get",
"a",
"Gravatar",
"Avatar",
"URL"
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L60-L81
|
224,487
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.https
|
public function https($value) {
if (strpos($value, $this->baseUrl) === false) {
throw new InvalidArgumentException("You can only convert existing Gravatar URLs to HTTPS");
}
else {
return str_replace($this->baseUrl, $this->httpsUrl, $value);
}
}
|
php
|
public function https($value) {
if (strpos($value, $this->baseUrl) === false) {
throw new InvalidArgumentException("You can only convert existing Gravatar URLs to HTTPS");
}
else {
return str_replace($this->baseUrl, $this->httpsUrl, $value);
}
}
|
[
"public",
"function",
"https",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"baseUrl",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You can only convert existing Gravatar URLs to HTTPS\"",
")",
";",
"}",
"else",
"{",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"baseUrl",
",",
"$",
"this",
"->",
"httpsUrl",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Change a Gravatar URL to its Secure version
@param string $value URL to convert
@return string Converted URL
@throws \InvalidArgumentException If $value isn't an existing Gravatar URL
|
[
"Change",
"a",
"Gravatar",
"URL",
"to",
"its",
"Secure",
"version"
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L89-L96
|
224,488
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.size
|
public function size($value, $px) {
if (!is_numeric($px) || $px < 0 || $px > 2048) {
throw new InvalidArgumentException("You must pass the size filter a valid number between 0 and 2048");
}
else if (strpos($value, $this->baseUrl) === false
&& strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You must pass the size filter an existing Gravatar URL");
}
else {
return $this->query($value, array("size" => $px));
}
}
|
php
|
public function size($value, $px) {
if (!is_numeric($px) || $px < 0 || $px > 2048) {
throw new InvalidArgumentException("You must pass the size filter a valid number between 0 and 2048");
}
else if (strpos($value, $this->baseUrl) === false
&& strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You must pass the size filter an existing Gravatar URL");
}
else {
return $this->query($value, array("size" => $px));
}
}
|
[
"public",
"function",
"size",
"(",
"$",
"value",
",",
"$",
"px",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"px",
")",
"||",
"$",
"px",
"<",
"0",
"||",
"$",
"px",
">",
"2048",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You must pass the size filter a valid number between 0 and 2048\"",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"baseUrl",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"httpsUrl",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You must pass the size filter an existing Gravatar URL\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"value",
",",
"array",
"(",
"\"size\"",
"=>",
"$",
"px",
")",
")",
";",
"}",
"}"
] |
Change the Size of a Gravatar URL
@param string $value
@param integer $px
@return string Sized Gravatar URL
|
[
"Change",
"the",
"Size",
"of",
"a",
"Gravatar",
"URL"
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L104-L115
|
224,489
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.def
|
public function def($value, $default, $force = false) {
if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You can only a default to existing Gravatar URLs");
}
else if (!filter_var($default, FILTER_VALIDATE_URL) && !in_array($default, $this->defaults)) {
throw new InvalidArgumentException("Default must be a URL or valid default");
}
else if (!is_bool($force)) {
throw new InvalidArgumentException("The force option for a default must be boolean");
}
else {
if (filter_var($default, FILTER_VALIDATE_URL)) $default = urlencode($default);
$addition = array("default" => $default);
if ($force) {
$addition["forcedefault"] = 'y';
}
return $this->query($value, $addition);
}
}
|
php
|
public function def($value, $default, $force = false) {
if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You can only a default to existing Gravatar URLs");
}
else if (!filter_var($default, FILTER_VALIDATE_URL) && !in_array($default, $this->defaults)) {
throw new InvalidArgumentException("Default must be a URL or valid default");
}
else if (!is_bool($force)) {
throw new InvalidArgumentException("The force option for a default must be boolean");
}
else {
if (filter_var($default, FILTER_VALIDATE_URL)) $default = urlencode($default);
$addition = array("default" => $default);
if ($force) {
$addition["forcedefault"] = 'y';
}
return $this->query($value, $addition);
}
}
|
[
"public",
"function",
"def",
"(",
"$",
"value",
",",
"$",
"default",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"baseUrl",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"httpsUrl",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You can only a default to existing Gravatar URLs\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"default",
",",
"FILTER_VALIDATE_URL",
")",
"&&",
"!",
"in_array",
"(",
"$",
"default",
",",
"$",
"this",
"->",
"defaults",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Default must be a URL or valid default\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"force",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The force option for a default must be boolean\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"default",
",",
"FILTER_VALIDATE_URL",
")",
")",
"$",
"default",
"=",
"urlencode",
"(",
"$",
"default",
")",
";",
"$",
"addition",
"=",
"array",
"(",
"\"default\"",
"=>",
"$",
"default",
")",
";",
"if",
"(",
"$",
"force",
")",
"{",
"$",
"addition",
"[",
"\"forcedefault\"",
"]",
"=",
"'y'",
";",
"}",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"value",
",",
"$",
"addition",
")",
";",
"}",
"}"
] |
Specify a default Image for when there is no matching Gravatar image.
@param string $value
@param string $default
@param boolean $force Always load the default image
@return string Gravatar URL with a default image.
|
[
"Specify",
"a",
"default",
"Image",
"for",
"when",
"there",
"is",
"no",
"matching",
"Gravatar",
"image",
"."
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L124-L142
|
224,490
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.rating
|
public function rating($value, $rating) {
if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You can only add a rating to an existing Gravatar URL");
}
else if (!in_array(strtolower($rating), $this->ratings)) {
throw new InvalidArgumentException("Rating must be g,pg,r or x");
}
else {
return $this->query($value, array("rating" => $rating));
}
}
|
php
|
public function rating($value, $rating) {
if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) {
throw new InvalidArgumentException("You can only add a rating to an existing Gravatar URL");
}
else if (!in_array(strtolower($rating), $this->ratings)) {
throw new InvalidArgumentException("Rating must be g,pg,r or x");
}
else {
return $this->query($value, array("rating" => $rating));
}
}
|
[
"public",
"function",
"rating",
"(",
"$",
"value",
",",
"$",
"rating",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"baseUrl",
")",
"===",
"false",
"&&",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"httpsUrl",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"You can only add a rating to an existing Gravatar URL\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"rating",
")",
",",
"$",
"this",
"->",
"ratings",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Rating must be g,pg,r or x\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"value",
",",
"array",
"(",
"\"rating\"",
"=>",
"$",
"rating",
")",
")",
";",
"}",
"}"
] |
Specify the maximum rating for an avatar
@param string $value
@param string $rating Expects g,pg,r or x
@return string Gravatar URL with a rating specified
|
[
"Specify",
"the",
"maximum",
"rating",
"for",
"an",
"avatar"
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L150-L160
|
224,491
|
ry167/twig-gravatar
|
src/TwigGravatar.php
|
TwigGravatar.query
|
private function query($string, array $addition) {
parse_str(parse_url( $string, PHP_URL_QUERY), $queryList);
foreach ($addition as $key => $value) {
$queryList[$key] = $value;
}
$url = sprintf(
'%s://%s%s%s',
parse_url($string, PHP_URL_SCHEME),
parse_url($string, PHP_URL_HOST),
parse_url($string, PHP_URL_PATH),
!empty($queryList) ? '?'.http_build_query($queryList) : ''
);
return $url;
}
|
php
|
private function query($string, array $addition) {
parse_str(parse_url( $string, PHP_URL_QUERY), $queryList);
foreach ($addition as $key => $value) {
$queryList[$key] = $value;
}
$url = sprintf(
'%s://%s%s%s',
parse_url($string, PHP_URL_SCHEME),
parse_url($string, PHP_URL_HOST),
parse_url($string, PHP_URL_PATH),
!empty($queryList) ? '?'.http_build_query($queryList) : ''
);
return $url;
}
|
[
"private",
"function",
"query",
"(",
"$",
"string",
",",
"array",
"$",
"addition",
")",
"{",
"parse_str",
"(",
"parse_url",
"(",
"$",
"string",
",",
"PHP_URL_QUERY",
")",
",",
"$",
"queryList",
")",
";",
"foreach",
"(",
"$",
"addition",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"queryList",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"url",
"=",
"sprintf",
"(",
"'%s://%s%s%s'",
",",
"parse_url",
"(",
"$",
"string",
",",
"PHP_URL_SCHEME",
")",
",",
"parse_url",
"(",
"$",
"string",
",",
"PHP_URL_HOST",
")",
",",
"parse_url",
"(",
"$",
"string",
",",
"PHP_URL_PATH",
")",
",",
"!",
"empty",
"(",
"$",
"queryList",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"queryList",
")",
":",
"''",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
Generate the query string
@param string $string
@param array $addition Array of what parameters to add
@return string
|
[
"Generate",
"the",
"query",
"string"
] |
baea4afdd3024bddc3b5682446c9951e0256c3b0
|
https://github.com/ry167/twig-gravatar/blob/baea4afdd3024bddc3b5682446c9951e0256c3b0/src/TwigGravatar.php#L178-L194
|
224,492
|
doctrine/oxm
|
lib/Doctrine/OXM/XmlEntityManager.php
|
XmlEntityManager.getRepository
|
public function getRepository($entityName)
{
$entityName = ltrim($entityName, '\\');
if (isset($this->repositories[$entityName])) {
return $this->repositories[$entityName];
}
$metadata = $this->getClassMetadata($entityName);
$customRepositoryClassName = $metadata->customRepositoryClassName;
if ($customRepositoryClassName !== null) {
$repository = new $customRepositoryClassName($this, $metadata);
} else {
$repository = new XmlEntityRepository($this, $metadata);
}
$this->repositories[$entityName] = $repository;
return $repository;
}
|
php
|
public function getRepository($entityName)
{
$entityName = ltrim($entityName, '\\');
if (isset($this->repositories[$entityName])) {
return $this->repositories[$entityName];
}
$metadata = $this->getClassMetadata($entityName);
$customRepositoryClassName = $metadata->customRepositoryClassName;
if ($customRepositoryClassName !== null) {
$repository = new $customRepositoryClassName($this, $metadata);
} else {
$repository = new XmlEntityRepository($this, $metadata);
}
$this->repositories[$entityName] = $repository;
return $repository;
}
|
[
"public",
"function",
"getRepository",
"(",
"$",
"entityName",
")",
"{",
"$",
"entityName",
"=",
"ltrim",
"(",
"$",
"entityName",
",",
"'\\\\'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"entityName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"repositories",
"[",
"$",
"entityName",
"]",
";",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getClassMetadata",
"(",
"$",
"entityName",
")",
";",
"$",
"customRepositoryClassName",
"=",
"$",
"metadata",
"->",
"customRepositoryClassName",
";",
"if",
"(",
"$",
"customRepositoryClassName",
"!==",
"null",
")",
"{",
"$",
"repository",
"=",
"new",
"$",
"customRepositoryClassName",
"(",
"$",
"this",
",",
"$",
"metadata",
")",
";",
"}",
"else",
"{",
"$",
"repository",
"=",
"new",
"XmlEntityRepository",
"(",
"$",
"this",
",",
"$",
"metadata",
")",
";",
"}",
"$",
"this",
"->",
"repositories",
"[",
"$",
"entityName",
"]",
"=",
"$",
"repository",
";",
"return",
"$",
"repository",
";",
"}"
] |
Gets the repository for a class.
@param string $entityName
@return \Doctrine\Common\Persistence\ObjectRepository
|
[
"Gets",
"the",
"repository",
"for",
"a",
"class",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/XmlEntityManager.php#L241-L260
|
224,493
|
doctrine/oxm
|
lib/Doctrine/OXM/XmlEntityManager.php
|
XmlEntityManager.refresh
|
public function refresh($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->errorIfClosed();
$this->unitOfWork->refresh($entity);
}
|
php
|
public function refresh($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->errorIfClosed();
$this->unitOfWork->refresh($entity);
}
|
[
"public",
"function",
"refresh",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"entity",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"entity",
")",
")",
";",
"}",
"$",
"this",
"->",
"errorIfClosed",
"(",
")",
";",
"$",
"this",
"->",
"unitOfWork",
"->",
"refresh",
"(",
"$",
"entity",
")",
";",
"}"
] |
Refreshes the persistent state of an entity from the filesystem,
overriding any local changes that have not yet been persisted.
@param object $entity The entity to refresh.
|
[
"Refreshes",
"the",
"persistent",
"state",
"of",
"an",
"entity",
"from",
"the",
"filesystem",
"overriding",
"any",
"local",
"changes",
"that",
"have",
"not",
"yet",
"been",
"persisted",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/XmlEntityManager.php#L310-L317
|
224,494
|
doctrine/oxm
|
lib/Doctrine/OXM/XmlEntityManager.php
|
XmlEntityManager.persist
|
public function persist($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->errorIfClosed();
$this->unitOfWork->persist($entity);
}
|
php
|
public function persist($entity)
{
if ( ! is_object($entity)) {
throw new \InvalidArgumentException(gettype($entity));
}
$this->errorIfClosed();
$this->unitOfWork->persist($entity);
}
|
[
"public",
"function",
"persist",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"entity",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"entity",
")",
")",
";",
"}",
"$",
"this",
"->",
"errorIfClosed",
"(",
")",
";",
"$",
"this",
"->",
"unitOfWork",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"}"
] |
Tells the XmlEntityManager to make an instance managed and persistent.
The entity will be entered into the filesystem at or before transaction
commit or as a result of the flush operation.
NOTE: The persist operation always considers entities that are not yet known to
this XmlEntityManager as NEW. Do not pass detached entities to the persist operation.
@param object $object The instance to make managed and persistent.
|
[
"Tells",
"the",
"XmlEntityManager",
"to",
"make",
"an",
"instance",
"managed",
"and",
"persistent",
"."
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/XmlEntityManager.php#L381-L388
|
224,495
|
artkonekt/address
|
src/Utils/PersonNameSplitter.php
|
PersonNameSplitter.split
|
public static function split($name, NameOrder $nameOrder = null)
{
$name = trim($name);
$parts = explode(' ', $name);
$nameOrder = $nameOrder ?: NameOrderProxy::create(); // create default if none was given
switch (count($parts)) {
case 1:
return ['firstname' => $name];
break;
case 2:
if ($nameOrder->isEastern()) {
return [
'firstname' => $parts[1],
'lastname' => $parts[0]
];
}
return [
'firstname' => $parts[0],
'lastname' => $parts[1]
];
break;
case 3:
if ($nameOrder->isEastern()) {
return [
'firstname' => $parts[1] . ' ' . $parts[2] ,
'lastname' => $parts[0]
];
}
return [
'firstname' => $parts[0] . ' ' . $parts[1],
'lastname' => $parts[2]
];
break;
}
if ($nameOrder->isEastern()) {
return [
'firstname' => array_last($parts),
'lastname' => implode(' ', array_except($parts, count($parts) - 1))
];
}
return [
'firstname' => array_first($parts),
'lastname' => implode(' ', array_except($parts, 0))
];
}
|
php
|
public static function split($name, NameOrder $nameOrder = null)
{
$name = trim($name);
$parts = explode(' ', $name);
$nameOrder = $nameOrder ?: NameOrderProxy::create(); // create default if none was given
switch (count($parts)) {
case 1:
return ['firstname' => $name];
break;
case 2:
if ($nameOrder->isEastern()) {
return [
'firstname' => $parts[1],
'lastname' => $parts[0]
];
}
return [
'firstname' => $parts[0],
'lastname' => $parts[1]
];
break;
case 3:
if ($nameOrder->isEastern()) {
return [
'firstname' => $parts[1] . ' ' . $parts[2] ,
'lastname' => $parts[0]
];
}
return [
'firstname' => $parts[0] . ' ' . $parts[1],
'lastname' => $parts[2]
];
break;
}
if ($nameOrder->isEastern()) {
return [
'firstname' => array_last($parts),
'lastname' => implode(' ', array_except($parts, count($parts) - 1))
];
}
return [
'firstname' => array_first($parts),
'lastname' => implode(' ', array_except($parts, 0))
];
}
|
[
"public",
"static",
"function",
"split",
"(",
"$",
"name",
",",
"NameOrder",
"$",
"nameOrder",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"$",
"name",
")",
";",
"$",
"nameOrder",
"=",
"$",
"nameOrder",
"?",
":",
"NameOrderProxy",
"::",
"create",
"(",
")",
";",
"// create default if none was given",
"switch",
"(",
"count",
"(",
"$",
"parts",
")",
")",
"{",
"case",
"1",
":",
"return",
"[",
"'firstname'",
"=>",
"$",
"name",
"]",
";",
"break",
";",
"case",
"2",
":",
"if",
"(",
"$",
"nameOrder",
"->",
"isEastern",
"(",
")",
")",
"{",
"return",
"[",
"'firstname'",
"=>",
"$",
"parts",
"[",
"1",
"]",
",",
"'lastname'",
"=>",
"$",
"parts",
"[",
"0",
"]",
"]",
";",
"}",
"return",
"[",
"'firstname'",
"=>",
"$",
"parts",
"[",
"0",
"]",
",",
"'lastname'",
"=>",
"$",
"parts",
"[",
"1",
"]",
"]",
";",
"break",
";",
"case",
"3",
":",
"if",
"(",
"$",
"nameOrder",
"->",
"isEastern",
"(",
")",
")",
"{",
"return",
"[",
"'firstname'",
"=>",
"$",
"parts",
"[",
"1",
"]",
".",
"' '",
".",
"$",
"parts",
"[",
"2",
"]",
",",
"'lastname'",
"=>",
"$",
"parts",
"[",
"0",
"]",
"]",
";",
"}",
"return",
"[",
"'firstname'",
"=>",
"$",
"parts",
"[",
"0",
"]",
".",
"' '",
".",
"$",
"parts",
"[",
"1",
"]",
",",
"'lastname'",
"=>",
"$",
"parts",
"[",
"2",
"]",
"]",
";",
"break",
";",
"}",
"if",
"(",
"$",
"nameOrder",
"->",
"isEastern",
"(",
")",
")",
"{",
"return",
"[",
"'firstname'",
"=>",
"array_last",
"(",
"$",
"parts",
")",
",",
"'lastname'",
"=>",
"implode",
"(",
"' '",
",",
"array_except",
"(",
"$",
"parts",
",",
"count",
"(",
"$",
"parts",
")",
"-",
"1",
")",
")",
"]",
";",
"}",
"return",
"[",
"'firstname'",
"=>",
"array_first",
"(",
"$",
"parts",
")",
",",
"'lastname'",
"=>",
"implode",
"(",
"' '",
",",
"array_except",
"(",
"$",
"parts",
",",
"0",
")",
")",
"]",
";",
"}"
] |
Parse and split a fullname into firstname & lastname.
Returns an array with attributes as keys eg.:
$name = 'Charlie Firpo' -> [ 'firstname' => 'Charlie', 'lastname' => 'Firpo']
Note that these are just rough guesses
@param string $name
@param NameOrder $nameOrder
@return array
|
[
"Parse",
"and",
"split",
"a",
"fullname",
"into",
"firstname",
"&",
"lastname",
"."
] |
1804292674b02dbb02a7f76bffdfd260b6a5d841
|
https://github.com/artkonekt/address/blob/1804292674b02dbb02a7f76bffdfd260b6a5d841/src/Utils/PersonNameSplitter.php#L32-L81
|
224,496
|
doctrine/oxm
|
lib/Doctrine/OXM/Id/UuidGenerator.php
|
UuidGenerator.generate
|
public function generate(XmlEntityManager $xem, $xmlEntity)
{
if (!$this->salt) {
throw new \Exception('Guid Generator requires a salt to be provided.');
}
$guid = $this->generateV4();
return $this->generateV5($guid, $this->salt);
}
|
php
|
public function generate(XmlEntityManager $xem, $xmlEntity)
{
if (!$this->salt) {
throw new \Exception('Guid Generator requires a salt to be provided.');
}
$guid = $this->generateV4();
return $this->generateV5($guid, $this->salt);
}
|
[
"public",
"function",
"generate",
"(",
"XmlEntityManager",
"$",
"xem",
",",
"$",
"xmlEntity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"salt",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Guid Generator requires a salt to be provided.'",
")",
";",
"}",
"$",
"guid",
"=",
"$",
"this",
"->",
"generateV4",
"(",
")",
";",
"return",
"$",
"this",
"->",
"generateV5",
"(",
"$",
"guid",
",",
"$",
"this",
"->",
"salt",
")",
";",
"}"
] |
Generates a new GUID
@return string
|
[
"Generates",
"a",
"new",
"GUID"
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Id/UuidGenerator.php#L78-L86
|
224,497
|
doctrine/oxm
|
lib/Doctrine/OXM/Id/UuidGenerator.php
|
UuidGenerator.generateV4
|
public function generateV4()
{
return sprintf('%04x%04x%04x%04x%04x%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
|
php
|
public function generateV4()
{
return sprintf('%04x%04x%04x%04x%04x%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
}
|
[
"public",
"function",
"generateV4",
"(",
")",
"{",
"return",
"sprintf",
"(",
"'%04x%04x%04x%04x%04x%04x%04x%04x'",
",",
"// 32 bits for \"time_low\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_mid\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"// 16 bits for \"time_hi_and_version\",",
"// four most significant bits holds version number 4",
"mt_rand",
"(",
"0",
",",
"0x0fff",
")",
"|",
"0x4000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\",",
"// 8 bits for \"clk_seq_low\",",
"// two most significant bits holds zero and one for variant DCE1.1",
"mt_rand",
"(",
"0",
",",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
")",
";",
"}"
] |
Generates a v4 GUID
@return string
|
[
"Generates",
"a",
"v4",
"GUID"
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Id/UuidGenerator.php#L93-L113
|
224,498
|
doctrine/oxm
|
lib/Doctrine/OXM/Id/UuidGenerator.php
|
UuidGenerator.generateV5
|
public function generateV5($namespace, $salt)
{
if (!$this->isValid($namespace)) {
throw new \Exception('Provided $namespace is invalid: ' . $namespace);
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-','{','}'), '', $namespace);
// Binary Value
$nstr = '';
// Convert Namespace UUID to bits
for ($i = 0; $i < strlen($nhex); $i += 2) {
$nstr .= chr(hexdec($nhex[$i] . $nhex[$i+1]));
}
// Calculate hash value
$hash = sha1($nstr . $salt);
$guid = sprintf('%08s%04s%04x%04x%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 3
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12)
);
return $guid;
}
|
php
|
public function generateV5($namespace, $salt)
{
if (!$this->isValid($namespace)) {
throw new \Exception('Provided $namespace is invalid: ' . $namespace);
}
// Get hexadecimal components of namespace
$nhex = str_replace(array('-','{','}'), '', $namespace);
// Binary Value
$nstr = '';
// Convert Namespace UUID to bits
for ($i = 0; $i < strlen($nhex); $i += 2) {
$nstr .= chr(hexdec($nhex[$i] . $nhex[$i+1]));
}
// Calculate hash value
$hash = sha1($nstr . $salt);
$guid = sprintf('%08s%04s%04x%04x%12s',
// 32 bits for "time_low"
substr($hash, 0, 8),
// 16 bits for "time_mid"
substr($hash, 8, 4),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 3
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
// 48 bits for "node"
substr($hash, 20, 12)
);
return $guid;
}
|
[
"public",
"function",
"generateV5",
"(",
"$",
"namespace",
",",
"$",
"salt",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValid",
"(",
"$",
"namespace",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Provided $namespace is invalid: '",
".",
"$",
"namespace",
")",
";",
"}",
"// Get hexadecimal components of namespace",
"$",
"nhex",
"=",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"'{'",
",",
"'}'",
")",
",",
"''",
",",
"$",
"namespace",
")",
";",
"// Binary Value",
"$",
"nstr",
"=",
"''",
";",
"// Convert Namespace UUID to bits",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"nhex",
")",
";",
"$",
"i",
"+=",
"2",
")",
"{",
"$",
"nstr",
".=",
"chr",
"(",
"hexdec",
"(",
"$",
"nhex",
"[",
"$",
"i",
"]",
".",
"$",
"nhex",
"[",
"$",
"i",
"+",
"1",
"]",
")",
")",
";",
"}",
"// Calculate hash value",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"nstr",
".",
"$",
"salt",
")",
";",
"$",
"guid",
"=",
"sprintf",
"(",
"'%08s%04s%04x%04x%12s'",
",",
"// 32 bits for \"time_low\"",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"8",
")",
",",
"// 16 bits for \"time_mid\"",
"substr",
"(",
"$",
"hash",
",",
"8",
",",
"4",
")",
",",
"// 16 bits for \"time_hi_and_version\",",
"// four most significant bits holds version number 3",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hash",
",",
"12",
",",
"4",
")",
")",
"&",
"0x0fff",
")",
"|",
"0x3000",
",",
"// 16 bits, 8 bits for \"clk_seq_hi_res\",",
"// 8 bits for \"clk_seq_low\",",
"// two most significant bits holds zero and one for variant DCE1.1",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"hash",
",",
"16",
",",
"4",
")",
")",
"&",
"0x3fff",
")",
"|",
"0x8000",
",",
"// 48 bits for \"node\"",
"substr",
"(",
"$",
"hash",
",",
"20",
",",
"12",
")",
")",
";",
"return",
"$",
"guid",
";",
"}"
] |
Generates a v5 GUID
@param string $namespace The GUID to seed with
@param string $salt The string to salt this new UUID with
@return string
|
[
"Generates",
"a",
"v5",
"GUID"
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Id/UuidGenerator.php#L122-L163
|
224,499
|
doctrine/oxm
|
lib/Doctrine/OXM/Tools/XmlEntityGenerator.php
|
XmlEntityGenerator.generate
|
public function generate(array $metadatas, $outputDirectory)
{
foreach ($metadatas as $metadata) {
$this->writeXmlEntityClass($metadata, $outputDirectory);
}
}
|
php
|
public function generate(array $metadatas, $outputDirectory)
{
foreach ($metadatas as $metadata) {
$this->writeXmlEntityClass($metadata, $outputDirectory);
}
}
|
[
"public",
"function",
"generate",
"(",
"array",
"$",
"metadatas",
",",
"$",
"outputDirectory",
")",
"{",
"foreach",
"(",
"$",
"metadatas",
"as",
"$",
"metadata",
")",
"{",
"$",
"this",
"->",
"writeXmlEntityClass",
"(",
"$",
"metadata",
",",
"$",
"outputDirectory",
")",
";",
"}",
"}"
] |
Generate and write xml-entity classes for the given array of ClassMetadataInfo instances
@param array $metadatas
@param string $outputDirectory
@return void
|
[
"Generate",
"and",
"write",
"xml",
"-",
"entity",
"classes",
"for",
"the",
"given",
"array",
"of",
"ClassMetadataInfo",
"instances"
] |
dec0f71d8219975165ba52cad6f0d538d8d2ffee
|
https://github.com/doctrine/oxm/blob/dec0f71d8219975165ba52cad6f0d538d8d2ffee/lib/Doctrine/OXM/Tools/XmlEntityGenerator.php#L147-L152
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.