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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
35,000 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTaxonomy | function getTaxonomy($taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy);
return $this->sendRequest('wp.getTaxonomy', $params);
} | php | function getTaxonomy($taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy);
return $this->sendRequest('wp.getTaxonomy', $params);
} | [
"function",
"getTaxonomy",
"(",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getTaxonomy'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve information about a taxonomy.
@param string $taxonomy the name of the selected taxonomy
@return array taxonomy information
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTaxonomy | [
"Retrieve",
"information",
"about",
"a",
"taxonomy",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L413-L418 |
35,001 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTerm | function getTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.getTerm', $params);
} | php | function getTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.getTerm', $params);
} | [
"function",
"getTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
"$",
"termId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getTerm'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve a taxonomy term.
@param integer $termId
@param string $taxonomy
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerm | [
"Retrieve",
"a",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L444-L449 |
35,002 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getTerms | function getTerms($taxonomy, array $filter = array())
{
$params = array(1, $this->username, $this->password, $taxonomy, $filter);
return $this->sendRequest('wp.getTerms', $params);
} | php | function getTerms($taxonomy, array $filter = array())
{
$params = array(1, $this->username, $this->password, $taxonomy, $filter);
return $this->sendRequest('wp.getTerms', $params);
} | [
"function",
"getTerms",
"(",
"$",
"taxonomy",
",",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
"$",
"filter",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getTerms'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve list of terms in a taxonomy.
@param string $taxonomy
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.getTerms | [
"Retrieve",
"list",
"of",
"terms",
"in",
"a",
"taxonomy",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L461-L466 |
35,003 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.newTerm | function newTerm($name, $taxomony, $slug = null, $description = null, $parentId = null)
{
$content = array(
'name' => $name,
'taxonomy' => $taxomony,
);
if ($slug) {
$content['slug'] = $slug;
}
if ($description) {
$content['description'] = $description;
}
if ($parentId) {
$content['parent'] = $parentId;
}
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newTerm', $params);
} | php | function newTerm($name, $taxomony, $slug = null, $description = null, $parentId = null)
{
$content = array(
'name' => $name,
'taxonomy' => $taxomony,
);
if ($slug) {
$content['slug'] = $slug;
}
if ($description) {
$content['description'] = $description;
}
if ($parentId) {
$content['parent'] = $parentId;
}
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.newTerm', $params);
} | [
"function",
"newTerm",
"(",
"$",
"name",
",",
"$",
"taxomony",
",",
"$",
"slug",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"parentId",
"=",
"null",
")",
"{",
"$",
"content",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'taxonomy'",
"=>",
"$",
"taxomony",
",",
")",
";",
"if",
"(",
"$",
"slug",
")",
"{",
"$",
"content",
"[",
"'slug'",
"]",
"=",
"$",
"slug",
";",
"}",
"if",
"(",
"$",
"description",
")",
"{",
"$",
"content",
"[",
"'description'",
"]",
"=",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"parentId",
")",
"{",
"$",
"content",
"[",
"'parent'",
"]",
"=",
"$",
"parentId",
";",
"}",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.newTerm'",
",",
"$",
"params",
")",
";",
"}"
] | Create a new taxonomy term.
@param string $name
@param string $taxomony
@param string $slug
@param string $description
@param integer $parentId
@return integer new term id
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.newTerm | [
"Create",
"a",
"new",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L481-L499 |
35,004 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editTerm | function editTerm($termId, $taxonomy, array $content = array())
{
$content['taxonomy'] = $taxonomy;
$params = array(1, $this->username, $this->password, $termId, $content);
return $this->sendRequest('wp.editTerm', $params);
} | php | function editTerm($termId, $taxonomy, array $content = array())
{
$content['taxonomy'] = $taxonomy;
$params = array(1, $this->username, $this->password, $termId, $content);
return $this->sendRequest('wp.editTerm', $params);
} | [
"function",
"editTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
",",
"array",
"$",
"content",
"=",
"array",
"(",
")",
")",
"{",
"$",
"content",
"[",
"'taxonomy'",
"]",
"=",
"$",
"taxonomy",
";",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"termId",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.editTerm'",
",",
"$",
"params",
")",
";",
"}"
] | Edit an existing taxonomy term.
@param integer $termId
@param string $taxonomy
@param array $content
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.editTerm | [
"Edit",
"an",
"existing",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L512-L518 |
35,005 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deleteTerm | function deleteTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.deleteTerm', $params);
} | php | function deleteTerm($termId, $taxonomy)
{
$params = array(1, $this->username, $this->password, $taxonomy, $termId);
return $this->sendRequest('wp.deleteTerm', $params);
} | [
"function",
"deleteTerm",
"(",
"$",
"termId",
",",
"$",
"taxonomy",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"taxonomy",
",",
"$",
"termId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.deleteTerm'",
",",
"$",
"params",
")",
";",
"}"
] | Delete an existing taxonomy term.
@param integer $termId
@param string $taxonomy
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Taxonomies#wp.deleteTerm | [
"Delete",
"an",
"existing",
"taxonomy",
"term",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L530-L535 |
35,006 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getMediaLibrary | function getMediaLibrary(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getMediaLibrary', $params);
} | php | function getMediaLibrary(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getMediaLibrary', $params);
} | [
"function",
"getMediaLibrary",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"filter",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getMediaLibrary'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve list of media items.
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Media#wp.getMediaLibrary | [
"Retrieve",
"list",
"of",
"media",
"items",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L562-L567 |
35,007 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getCommentCount | function getCommentCount($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.getCommentCount', $params);
} | php | function getCommentCount($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.getCommentCount', $params);
} | [
"function",
"getCommentCount",
"(",
"$",
"postId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getCommentCount'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve comment count for a specific post.
@param integer $postId
@return integer
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getCommentCount | [
"Retrieve",
"comment",
"count",
"for",
"a",
"specific",
"post",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L610-L615 |
35,008 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getComment | function getComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.getComment', $params);
} | php | function getComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.getComment', $params);
} | [
"function",
"getComment",
"(",
"$",
"commentId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getComment'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve a comment.
@param integer $commentId
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComment | [
"Retrieve",
"a",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L626-L631 |
35,009 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getComments | function getComments(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getComments', $params);
} | php | function getComments(array $filter = array())
{
$params = array(1, $this->username, $this->password, $filter);
return $this->sendRequest('wp.getComments', $params);
} | [
"function",
"getComments",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"filter",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getComments'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve list of comments.
@param array $filter
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.getComments | [
"Retrieve",
"list",
"of",
"comments",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L642-L647 |
35,010 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editComment | function editComment($commentId, array $comment)
{
$params = array(1, $this->username, $this->password, $commentId, $comment);
return $this->sendRequest('wp.editComment', $params);
} | php | function editComment($commentId, array $comment)
{
$params = array(1, $this->username, $this->password, $commentId, $comment);
return $this->sendRequest('wp.editComment', $params);
} | [
"function",
"editComment",
"(",
"$",
"commentId",
",",
"array",
"$",
"comment",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
",",
"$",
"comment",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.editComment'",
",",
"$",
"params",
")",
";",
"}"
] | Edit an existing comment.
@param integer $commentId
@param array $comment
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.editComment | [
"Edit",
"an",
"existing",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L676-L681 |
35,011 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deleteComment | function deleteComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.deleteComment', $params);
} | php | function deleteComment($commentId)
{
$params = array(1, $this->username, $this->password, $commentId);
return $this->sendRequest('wp.deleteComment', $params);
} | [
"function",
"deleteComment",
"(",
"$",
"commentId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"commentId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.deleteComment'",
",",
"$",
"params",
")",
";",
"}"
] | Remove an existing comment.
@param integer $commentId
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Comments#wp.deleteComment | [
"Remove",
"an",
"existing",
"comment",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L692-L697 |
35,012 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getOptions | function getOptions(array $options = array())
{
if (empty($options)) {
$params = array(1, $this->username, $this->password);
} else {
$params = array(1, $this->username, $this->password, $options);
}
return $this->sendRequest('wp.getOptions', $params);
} | php | function getOptions(array $options = array())
{
if (empty($options)) {
$params = array(1, $this->username, $this->password);
} else {
$params = array(1, $this->username, $this->password, $options);
}
return $this->sendRequest('wp.getOptions', $params);
} | [
"function",
"getOptions",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
")",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getOptions'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve blog options.
@param array $options
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.getOptions | [
"Retrieve",
"blog",
"options",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L722-L731 |
35,013 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setOptions | function setOptions(array $options)
{
$params = array(1, $this->username, $this->password, $options);
return $this->sendRequest('wp.setOptions', $params);
} | php | function setOptions(array $options)
{
$params = array(1, $this->username, $this->password, $options);
return $this->sendRequest('wp.setOptions', $params);
} | [
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.setOptions'",
",",
"$",
"params",
")",
";",
"}"
] | Edit blog options.
@param array $options
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Options#wp.setOptions | [
"Edit",
"blog",
"options",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L742-L747 |
35,014 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getUser | function getUser($userId, array $fields = array())
{
$params = array(1, $this->username, $this->password, $userId);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUser', $params);
} | php | function getUser($userId, array $fields = array())
{
$params = array(1, $this->username, $this->password, $userId);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUser', $params);
} | [
"function",
"getUser",
"(",
"$",
"userId",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"fields",
";",
"}",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getUser'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve a user.
@param integer $userId
@param array $fields Optional. List of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUser | [
"Retrieve",
"a",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L773-L781 |
35,015 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getUsers | function getUsers(array $filters = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filters);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUsers', $params);
} | php | function getUsers(array $filters = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filters);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getUsers', $params);
} | [
"function",
"getUsers",
"(",
"array",
"$",
"filters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"filters",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"fields",
";",
"}",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getUsers'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve list of users.
@param array $filters
@param array $fields
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getUsers | [
"Retrieve",
"list",
"of",
"users",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L793-L801 |
35,016 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getProfile | function getProfile(array $fields = array())
{
$params = array(1, $this->username, $this->password);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getProfile', $params);
} | php | function getProfile(array $fields = array())
{
$params = array(1, $this->username, $this->password);
if (!empty($fields)) {
$params[] = $fields;
}
return $this->sendRequest('wp.getProfile', $params);
} | [
"function",
"getProfile",
"(",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"fields",
";",
"}",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.getProfile'",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve profile of the requesting user.
@param array $fields
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.getProfile | [
"Retrieve",
"profile",
"of",
"the",
"requesting",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L812-L820 |
35,017 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editProfile | function editProfile(array $content)
{
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.editProfile', $params);
} | php | function editProfile(array $content)
{
$params = array(1, $this->username, $this->password, $content);
return $this->sendRequest('wp.editProfile', $params);
} | [
"function",
"editProfile",
"(",
"array",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'wp.editProfile'",
",",
"$",
"params",
")",
";",
"}"
] | Edit profile of the requesting user.
@param array $content
@return boolean
http://codex.wordpress.org/XML-RPC_WordPress_API/Users#wp.editProfile | [
"Edit",
"profile",
"of",
"the",
"requesting",
"user",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L831-L836 |
35,018 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setXmlrpcType | private function setXmlrpcType(&$array)
{
foreach ($array as $key => $element) {
if (is_a($element, '\DateTime')) {
$array[$key] = $element->format("Ymd\TH:i:sO");
xmlrpc_set_type($array[$key], 'datetime');
} elseif (is_array($element)) {
$this->setXmlrpcType($array[$key]);
}
}
} | php | private function setXmlrpcType(&$array)
{
foreach ($array as $key => $element) {
if (is_a($element, '\DateTime')) {
$array[$key] = $element->format("Ymd\TH:i:sO");
xmlrpc_set_type($array[$key], 'datetime');
} elseif (is_array($element)) {
$this->setXmlrpcType($array[$key]);
}
}
} | [
"private",
"function",
"setXmlrpcType",
"(",
"&",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"element",
",",
"'\\DateTime'",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"element",
"->",
"format",
"(",
"\"Ymd\\TH:i:sO\"",
")",
";",
"xmlrpc_set_type",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
",",
"'datetime'",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"element",
")",
")",
"{",
"$",
"this",
"->",
"setXmlrpcType",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] | Set the correct type for each element in an array
@param array $array
@since 2.2 | [
"Set",
"the",
"correct",
"type",
"for",
"each",
"element",
"in",
"an",
"array"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L938-L948 |
35,019 | TopShelfCraft/SuperSort | src/SuperSort.php | SuperSort.init | public function init()
{
parent::init();
self::$plugin = $this;
Craft::$app->getView()->registerTwigExtension(new SuperSortTwigExtension());
} | php | public function init()
{
parent::init();
self::$plugin = $this;
Craft::$app->getView()->registerTwigExtension(new SuperSortTwigExtension());
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"self",
"::",
"$",
"plugin",
"=",
"$",
"this",
";",
"Craft",
"::",
"$",
"app",
"->",
"getView",
"(",
")",
"->",
"registerTwigExtension",
"(",
"new",
"SuperSortTwigExtension",
"(",
")",
")",
";",
"}"
] | Initializes the plugin, sets its static self-reference, and registers the Twig extension. | [
"Initializes",
"the",
"plugin",
"sets",
"its",
"static",
"self",
"-",
"reference",
"and",
"registers",
"the",
"Twig",
"extension",
"."
] | 8e3e23e30b49a9fbb285e6b2dd0b458de74e340d | https://github.com/TopShelfCraft/SuperSort/blob/8e3e23e30b49a9fbb285e6b2dd0b458de74e340d/src/SuperSort.php#L46-L54 |
35,020 | hail-framework/framework | src/Util/Utf8String.php | Utf8String.pad | public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
{
if ($side === STR_PAD_BOTH) {
$length -= $this->count();
if ($length <= 0) {
return $this;
}
$left = (int) ($length / 2);
$right = $length - $left;
$this->_string = Strings::padRight(
Strings::padLeft($this->_string, $left, $piece),
$right, $piece
);
} elseif (STR_PAD_LEFT === $side) {
$this->_string = Strings::padLeft($this->_string, $length, $piece);
} else {
$this->_string = Strings::padRight($this->_string, $length, $piece);
}
return $this;
} | php | public function pad(int $length, string $piece = ' ', int $side = STR_PAD_RIGHT)
{
if ($side === STR_PAD_BOTH) {
$length -= $this->count();
if ($length <= 0) {
return $this;
}
$left = (int) ($length / 2);
$right = $length - $left;
$this->_string = Strings::padRight(
Strings::padLeft($this->_string, $left, $piece),
$right, $piece
);
} elseif (STR_PAD_LEFT === $side) {
$this->_string = Strings::padLeft($this->_string, $length, $piece);
} else {
$this->_string = Strings::padRight($this->_string, $length, $piece);
}
return $this;
} | [
"public",
"function",
"pad",
"(",
"int",
"$",
"length",
",",
"string",
"$",
"piece",
"=",
"' '",
",",
"int",
"$",
"side",
"=",
"STR_PAD_RIGHT",
")",
"{",
"if",
"(",
"$",
"side",
"===",
"STR_PAD_BOTH",
")",
"{",
"$",
"length",
"-=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"length",
"<=",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"left",
"=",
"(",
"int",
")",
"(",
"$",
"length",
"/",
"2",
")",
";",
"$",
"right",
"=",
"$",
"length",
"-",
"$",
"left",
";",
"$",
"this",
"->",
"_string",
"=",
"Strings",
"::",
"padRight",
"(",
"Strings",
"::",
"padLeft",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"left",
",",
"$",
"piece",
")",
",",
"$",
"right",
",",
"$",
"piece",
")",
";",
"}",
"elseif",
"(",
"STR_PAD_LEFT",
"===",
"$",
"side",
")",
"{",
"$",
"this",
"->",
"_string",
"=",
"Strings",
"::",
"padLeft",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"length",
",",
"$",
"piece",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_string",
"=",
"Strings",
"::",
"padRight",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"length",
",",
"$",
"piece",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Pad the current string to a certain length with another piece, aka piece.
@param int $length Length.
@param string $piece Piece.
@param int $side Whether we append at the end or the beginning
of the current string.
@return self | [
"Pad",
"the",
"current",
"string",
"to",
"a",
"certain",
"length",
"with",
"another",
"piece",
"aka",
"piece",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L223-L246 |
35,021 | hail-framework/framework | src/Util/Utf8String.php | Utf8String.toAscii | public function toAscii()
{
if (0 === \preg_match('#[\x80-\xff]#', $this->_string)) {
return $this;
}
$this->_string = Strings::toAscii($this->_string);
return $this;
} | php | public function toAscii()
{
if (0 === \preg_match('#[\x80-\xff]#', $this->_string)) {
return $this;
}
$this->_string = Strings::toAscii($this->_string);
return $this;
} | [
"public",
"function",
"toAscii",
"(",
")",
"{",
"if",
"(",
"0",
"===",
"\\",
"preg_match",
"(",
"'#[\\x80-\\xff]#'",
",",
"$",
"this",
"->",
"_string",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_string",
"=",
"Strings",
"::",
"toAscii",
"(",
"$",
"this",
"->",
"_string",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Transform a UTF-8 string into an ASCII one.
@return self
@throws \Exception | [
"Transform",
"a",
"UTF",
"-",
"8",
"string",
"into",
"an",
"ASCII",
"one",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L425-L434 |
35,022 | hail-framework/framework | src/Util/Utf8String.php | Utf8String.offsetSet | public function offsetSet($offset, $value)
{
$head = null;
$offset = $this->computeOffset($offset);
if (0 < $offset) {
$head = \mb_substr($this->_string, 0, $offset);
}
$tail = \mb_substr($this->_string, $offset + 1);
$this->_string = $head . $value . $tail;
$this->_direction = null;
return $this;
} | php | public function offsetSet($offset, $value)
{
$head = null;
$offset = $this->computeOffset($offset);
if (0 < $offset) {
$head = \mb_substr($this->_string, 0, $offset);
}
$tail = \mb_substr($this->_string, $offset + 1);
$this->_string = $head . $value . $tail;
$this->_direction = null;
return $this;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"$",
"head",
"=",
"null",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"computeOffset",
"(",
"$",
"offset",
")",
";",
"if",
"(",
"0",
"<",
"$",
"offset",
")",
"{",
"$",
"head",
"=",
"\\",
"mb_substr",
"(",
"$",
"this",
"->",
"_string",
",",
"0",
",",
"$",
"offset",
")",
";",
"}",
"$",
"tail",
"=",
"\\",
"mb_substr",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"offset",
"+",
"1",
")",
";",
"$",
"this",
"->",
"_string",
"=",
"$",
"head",
".",
"$",
"value",
".",
"$",
"tail",
";",
"$",
"this",
"->",
"_direction",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Set a specific character of the current string.
@param int $offset Offset (can be negative and unbound).
@param string $value Value.
@return self | [
"Set",
"a",
"specific",
"character",
"of",
"the",
"current",
"string",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L534-L548 |
35,023 | hail-framework/framework | src/Util/Utf8String.php | Utf8String.offsetExists | public function offsetExists($offset)
{
if (!\is_int($offset)) {
return false;
}
$len = $this->count();
return $offset >= -$len && $offset < $len;
} | php | public function offsetExists($offset)
{
if (!\is_int($offset)) {
return false;
}
$len = $this->count();
return $offset >= -$len && $offset < $len;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"len",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"return",
"$",
"offset",
">=",
"-",
"$",
"len",
"&&",
"$",
"offset",
"<",
"$",
"len",
";",
"}"
] | Check if a specific offset exists.
@return bool | [
"Check",
"if",
"a",
"specific",
"offset",
"exists",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L567-L576 |
35,024 | hail-framework/framework | src/Util/Utf8String.php | Utf8String.reduce | public function reduce($start, $length = null)
{
$this->_string = \mb_substr($this->_string, $start, $length);
return $this;
} | php | public function reduce($start, $length = null)
{
$this->_string = \mb_substr($this->_string, $start, $length);
return $this;
} | [
"public",
"function",
"reduce",
"(",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_string",
"=",
"\\",
"mb_substr",
"(",
"$",
"this",
"->",
"_string",
",",
"$",
"start",
",",
"$",
"length",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Reduce the strings.
@param int $start Position of first character.
@param int $length Maximum number of characters.
@return self | [
"Reduce",
"the",
"strings",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Utf8String.php#L586-L591 |
35,025 | hail-framework/framework | src/Template/Processor/Processor.php | Processor.before | protected static function before(Element $element, string $phpExpression): void
{
$element->insertBeforeSelf(
static::toPhp($phpExpression)
);
} | php | protected static function before(Element $element, string $phpExpression): void
{
$element->insertBeforeSelf(
static::toPhp($phpExpression)
);
} | [
"protected",
"static",
"function",
"before",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"insertBeforeSelf",
"(",
"static",
"::",
"toPhp",
"(",
"$",
"phpExpression",
")",
")",
";",
"}"
] | insert a php code before an element.
@param Element $element
@param string $phpExpression | [
"insert",
"a",
"php",
"code",
"before",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L30-L35 |
35,026 | hail-framework/framework | src/Template/Processor/Processor.php | Processor.after | protected static function after(Element $element, string $phpExpression): void
{
$element->insertAfterSelf(
static::toPhp($phpExpression)
);
} | php | protected static function after(Element $element, string $phpExpression): void
{
$element->insertAfterSelf(
static::toPhp($phpExpression)
);
} | [
"protected",
"static",
"function",
"after",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"insertAfterSelf",
"(",
"static",
"::",
"toPhp",
"(",
"$",
"phpExpression",
")",
")",
";",
"}"
] | insert a php code after an element.
@param Element $element
@param string $phpExpression | [
"insert",
"a",
"php",
"code",
"after",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L43-L48 |
35,027 | hail-framework/framework | src/Template/Processor/Processor.php | Processor.text | protected static function text(Element $element, string $phpExpression): void
{
$element->removeChildren();
if ($phpExpression) {
$element->appendChild(
static::toPhp($phpExpression)
);
}
} | php | protected static function text(Element $element, string $phpExpression): void
{
$element->removeChildren();
if ($phpExpression) {
$element->appendChild(
static::toPhp($phpExpression)
);
}
} | [
"protected",
"static",
"function",
"text",
"(",
"Element",
"$",
"element",
",",
"string",
"$",
"phpExpression",
")",
":",
"void",
"{",
"$",
"element",
"->",
"removeChildren",
"(",
")",
";",
"if",
"(",
"$",
"phpExpression",
")",
"{",
"$",
"element",
"->",
"appendChild",
"(",
"static",
"::",
"toPhp",
"(",
"$",
"phpExpression",
")",
")",
";",
"}",
"}"
] | set inner text of the an element.
@param Element $element
@param string $phpExpression | [
"set",
"inner",
"text",
"of",
"the",
"an",
"element",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Template/Processor/Processor.php#L56-L65 |
35,028 | htmlburger/wpemerge-cli | src/CarbonFields/Carbon_Rich_Text_Widget.php | Carbon_Rich_Text_Widget.front_end | public function front_end( $args, $instance ) {
if ( $instance['title'] ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
echo $args['before_title'] . $title . $args['after_title'];
}
echo apply_filters( 'the_content', $instance['content'] );
} | php | public function front_end( $args, $instance ) {
if ( $instance['title'] ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
echo $args['before_title'] . $title . $args['after_title'];
}
echo apply_filters( 'the_content', $instance['content'] );
} | [
"public",
"function",
"front_end",
"(",
"$",
"args",
",",
"$",
"instance",
")",
"{",
"if",
"(",
"$",
"instance",
"[",
"'title'",
"]",
")",
"{",
"$",
"title",
"=",
"apply_filters",
"(",
"'widget_title'",
",",
"$",
"instance",
"[",
"'title'",
"]",
",",
"$",
"instance",
",",
"$",
"this",
"->",
"id_base",
")",
";",
"echo",
"$",
"args",
"[",
"'before_title'",
"]",
".",
"$",
"title",
".",
"$",
"args",
"[",
"'after_title'",
"]",
";",
"}",
"echo",
"apply_filters",
"(",
"'the_content'",
",",
"$",
"instance",
"[",
"'content'",
"]",
")",
";",
"}"
] | Renders the widget front-end.
@param array $args Widgets arguments.
@param array $instance Instance values.
@return void | [
"Renders",
"the",
"widget",
"front",
"-",
"end",
"."
] | 075f1982b7dd87039a4e7bbc05caf676a10fe862 | https://github.com/htmlburger/wpemerge-cli/blob/075f1982b7dd87039a4e7bbc05caf676a10fe862/src/CarbonFields/Carbon_Rich_Text_Widget.php#L34-L42 |
35,029 | hail-framework/framework | src/Util/Yaml/Dumper.php | Dumper.requiresSingleQuoting | private static function requiresSingleQuoting(string $value): bool
{
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (\in_array(\strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'], true)) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return \preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
} | php | private static function requiresSingleQuoting(string $value): bool
{
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (\in_array(\strtolower($value), ['null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'], true)) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return \preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
} | [
"private",
"static",
"function",
"requiresSingleQuoting",
"(",
"string",
"$",
"value",
")",
":",
"bool",
"{",
"// Determines if a PHP value is entirely composed of a value that would",
"// require single quoting in YAML.",
"if",
"(",
"\\",
"in_array",
"(",
"\\",
"strtolower",
"(",
"$",
"value",
")",
",",
"[",
"'null'",
",",
"'~'",
",",
"'true'",
",",
"'false'",
",",
"'y'",
",",
"'n'",
",",
"'yes'",
",",
"'no'",
",",
"'on'",
",",
"'off'",
"]",
",",
"true",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Determines if the PHP value contains any single characters that would",
"// cause it to require single quoting in YAML.",
"return",
"\\",
"preg_match",
"(",
"'/[ \\s \\' \" \\: \\{ \\} \\[ \\] , & \\* \\# \\?] | \\A[ \\- ? | < > = ! % @ ` ]/x'",
",",
"$",
"value",
")",
";",
"}"
] | Determines if a PHP value would require single quoting in YAML.
@param string $value A PHP value
@return bool True if the value would require single quotes | [
"Determines",
"if",
"a",
"PHP",
"value",
"would",
"require",
"single",
"quoting",
"in",
"YAML",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Yaml/Dumper.php#L267-L278 |
35,030 | Becklyn/RadBundle | src/Path/PathHelper.php | PathHelper.join | public static function join (...$paths) : string
{
$normalized = [];
foreach ($paths as $index => $path)
{
if (0 !== $index)
{
$path = \ltrim($path, "/");
}
if ($index !== \count($paths) - 1)
{
$path = \rtrim($path, "/");
}
$normalized[] = $path;
}
return \implode("/", $normalized);
} | php | public static function join (...$paths) : string
{
$normalized = [];
foreach ($paths as $index => $path)
{
if (0 !== $index)
{
$path = \ltrim($path, "/");
}
if ($index !== \count($paths) - 1)
{
$path = \rtrim($path, "/");
}
$normalized[] = $path;
}
return \implode("/", $normalized);
} | [
"public",
"static",
"function",
"join",
"(",
"...",
"$",
"paths",
")",
":",
"string",
"{",
"$",
"normalized",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"index",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"0",
"!==",
"$",
"index",
")",
"{",
"$",
"path",
"=",
"\\",
"ltrim",
"(",
"$",
"path",
",",
"\"/\"",
")",
";",
"}",
"if",
"(",
"$",
"index",
"!==",
"\\",
"count",
"(",
"$",
"paths",
")",
"-",
"1",
")",
"{",
"$",
"path",
"=",
"\\",
"rtrim",
"(",
"$",
"path",
",",
"\"/\"",
")",
";",
"}",
"$",
"normalized",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"return",
"\\",
"implode",
"(",
"\"/\"",
",",
"$",
"normalized",
")",
";",
"}"
] | Joins path segments to one full path.
@param string[] ...$paths
@return string | [
"Joins",
"path",
"segments",
"to",
"one",
"full",
"path",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Path/PathHelper.php#L17-L37 |
35,031 | Kuestenschmiede/TrackingBundle | Resources/contao/dca/tl_c4g_tracking_pois.php | tl_c4g_tracking_pois.getTypes | public function getTypes()
{
$groups = array();
foreach ($GLOBALS['FE_MOD'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$groups[$k][] = $kk;
}
}
return $groups;
} | php | public function getTypes()
{
$groups = array();
foreach ($GLOBALS['FE_MOD'] as $k=>$v)
{
foreach (array_keys($v) as $kk)
{
$groups[$k][] = $kk;
}
}
return $groups;
} | [
"public",
"function",
"getTypes",
"(",
")",
"{",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'FE_MOD'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"v",
")",
"as",
"$",
"kk",
")",
"{",
"$",
"groups",
"[",
"$",
"k",
"]",
"[",
"]",
"=",
"$",
"kk",
";",
"}",
"}",
"return",
"$",
"groups",
";",
"}"
] | Return all front end modules as array
@return array | [
"Return",
"all",
"front",
"end",
"modules",
"as",
"array"
] | 7ad1b8ef3103854dfce8309d2eed7060febaa4ee | https://github.com/Kuestenschmiede/TrackingBundle/blob/7ad1b8ef3103854dfce8309d2eed7060febaa4ee/Resources/contao/dca/tl_c4g_tracking_pois.php#L260-L273 |
35,032 | TheBnl/silverstripe-pageslices | src/controller/PageSliceController.php | PageSliceController.getCacheKey | public function getCacheKey()
{
$cacheKey = implode('_', array(
$this->ID,
strtotime($this->LastEdited),
strtotime($this->Parent()->LastEdited),
Versioned::get_reading_mode()
));
$this->extend('updateCacheKey', $cacheKey);
return $cacheKey;
} | php | public function getCacheKey()
{
$cacheKey = implode('_', array(
$this->ID,
strtotime($this->LastEdited),
strtotime($this->Parent()->LastEdited),
Versioned::get_reading_mode()
));
$this->extend('updateCacheKey', $cacheKey);
return $cacheKey;
} | [
"public",
"function",
"getCacheKey",
"(",
")",
"{",
"$",
"cacheKey",
"=",
"implode",
"(",
"'_'",
",",
"array",
"(",
"$",
"this",
"->",
"ID",
",",
"strtotime",
"(",
"$",
"this",
"->",
"LastEdited",
")",
",",
"strtotime",
"(",
"$",
"this",
"->",
"Parent",
"(",
")",
"->",
"LastEdited",
")",
",",
"Versioned",
"::",
"get_reading_mode",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"'updateCacheKey'",
",",
"$",
"cacheKey",
")",
";",
"return",
"$",
"cacheKey",
";",
"}"
] | The Cache key with basis properties
Extend this on your subclass for more specific properties
@return string | [
"The",
"Cache",
"key",
"with",
"basis",
"properties",
"Extend",
"this",
"on",
"your",
"subclass",
"for",
"more",
"specific",
"properties"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/controller/PageSliceController.php#L118-L128 |
35,033 | TheBnl/silverstripe-pageslices | src/controller/PageSliceController.php | PageSliceController.getTemplate | public function getTemplate()
{
if (!$this->useCaching()) {
$result = $this->renderTemplate();
} else {
$cache = Injector::inst()->get(CacheInterface::class . '.PageSlices');
if (!$cache->has($this->getCacheKey())) {
$result = $this->renderTemplate();
$cache->set($this->getCacheKey(), $result);
} else {
$result = $cache->get($this->getCacheKey());
}
}
return $result;
} | php | public function getTemplate()
{
if (!$this->useCaching()) {
$result = $this->renderTemplate();
} else {
$cache = Injector::inst()->get(CacheInterface::class . '.PageSlices');
if (!$cache->has($this->getCacheKey())) {
$result = $this->renderTemplate();
$cache->set($this->getCacheKey(), $result);
} else {
$result = $cache->get($this->getCacheKey());
}
}
return $result;
} | [
"public",
"function",
"getTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"useCaching",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"renderTemplate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"cache",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"CacheInterface",
"::",
"class",
".",
"'.PageSlices'",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"->",
"has",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"renderTemplate",
"(",
")",
";",
"$",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
",",
"$",
"result",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"cache",
"->",
"get",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Return the rendered template
@return \HTMLText | [
"Return",
"the",
"rendered",
"template"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/controller/PageSliceController.php#L135-L150 |
35,034 | hiqdev/hipanel-module-server | src/models/traits/AssignSwitchTrait.php | AssignSwitchTrait.generateUniqueValidators | protected function generateUniqueValidators(): array
{
if (empty($this->switchVariants)) {
throw new InvalidConfigException('Please specify `switchVariants` array to use AssignSwitchTrait::generateUniqueValidators()');
}
$rules = [];
foreach ($this->switchVariants as $variant) {
$rules[] = [
[$variant . '_port'],
function ($attribute, $params, $validator) use ($variant) {
if ($this->{$attribute} && $this->{$variant . '_id'}) {
$query = Binding::find();
$query->andWhere(['port' => $this->{$attribute}]);
$query->andWhere(['switch_id' => $this->{$variant . '_id'}]);
$query->andWhere(['ne', 'base_device_id', $this->id]);
/** @var Binding[] $bindings */
$bindings = $query->all();
if (!empty($bindings)) {
$binding = reset($bindings);
$this->addError($attribute, Yii::t('hipanel:server', '{switch}::{port} already taken by {device}', [
'switch' => $binding->switch_name,
'port' => $binding->port,
'device' => $binding->device_name,
]));
}
}
},
];
}
return $rules;
} | php | protected function generateUniqueValidators(): array
{
if (empty($this->switchVariants)) {
throw new InvalidConfigException('Please specify `switchVariants` array to use AssignSwitchTrait::generateUniqueValidators()');
}
$rules = [];
foreach ($this->switchVariants as $variant) {
$rules[] = [
[$variant . '_port'],
function ($attribute, $params, $validator) use ($variant) {
if ($this->{$attribute} && $this->{$variant . '_id'}) {
$query = Binding::find();
$query->andWhere(['port' => $this->{$attribute}]);
$query->andWhere(['switch_id' => $this->{$variant . '_id'}]);
$query->andWhere(['ne', 'base_device_id', $this->id]);
/** @var Binding[] $bindings */
$bindings = $query->all();
if (!empty($bindings)) {
$binding = reset($bindings);
$this->addError($attribute, Yii::t('hipanel:server', '{switch}::{port} already taken by {device}', [
'switch' => $binding->switch_name,
'port' => $binding->port,
'device' => $binding->device_name,
]));
}
}
},
];
}
return $rules;
} | [
"protected",
"function",
"generateUniqueValidators",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"switchVariants",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Please specify `switchVariants` array to use AssignSwitchTrait::generateUniqueValidators()'",
")",
";",
"}",
"$",
"rules",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"switchVariants",
"as",
"$",
"variant",
")",
"{",
"$",
"rules",
"[",
"]",
"=",
"[",
"[",
"$",
"variant",
".",
"'_port'",
"]",
",",
"function",
"(",
"$",
"attribute",
",",
"$",
"params",
",",
"$",
"validator",
")",
"use",
"(",
"$",
"variant",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"{",
"$",
"attribute",
"}",
"&&",
"$",
"this",
"->",
"{",
"$",
"variant",
".",
"'_id'",
"}",
")",
"{",
"$",
"query",
"=",
"Binding",
"::",
"find",
"(",
")",
";",
"$",
"query",
"->",
"andWhere",
"(",
"[",
"'port'",
"=>",
"$",
"this",
"->",
"{",
"$",
"attribute",
"}",
"]",
")",
";",
"$",
"query",
"->",
"andWhere",
"(",
"[",
"'switch_id'",
"=>",
"$",
"this",
"->",
"{",
"$",
"variant",
".",
"'_id'",
"}",
"]",
")",
";",
"$",
"query",
"->",
"andWhere",
"(",
"[",
"'ne'",
",",
"'base_device_id'",
",",
"$",
"this",
"->",
"id",
"]",
")",
";",
"/** @var Binding[] $bindings */",
"$",
"bindings",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"bindings",
")",
")",
"{",
"$",
"binding",
"=",
"reset",
"(",
"$",
"bindings",
")",
";",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"Yii",
"::",
"t",
"(",
"'hipanel:server'",
",",
"'{switch}::{port} already taken by {device}'",
",",
"[",
"'switch'",
"=>",
"$",
"binding",
"->",
"switch_name",
",",
"'port'",
"=>",
"$",
"binding",
"->",
"port",
",",
"'device'",
"=>",
"$",
"binding",
"->",
"device_name",
",",
"]",
")",
")",
";",
"}",
"}",
"}",
",",
"]",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] | Added to model's rules list of switch pairs.
@throws InvalidConfigException
@return array | [
"Added",
"to",
"model",
"s",
"rules",
"list",
"of",
"switch",
"pairs",
"."
] | e40c3601952cf1fd420ebb97093ee17a33ff3207 | https://github.com/hiqdev/hipanel-module-server/blob/e40c3601952cf1fd420ebb97093ee17a33ff3207/src/models/traits/AssignSwitchTrait.php#L90-L122 |
35,035 | DoSomething/gateway | src/Resources/NorthstarUser.php | NorthstarUser.displayName | public function displayName()
{
if (! empty($this->first_name) && ! empty($this->last_name)) {
return $this->first_name.' '.$this->last_name;
}
if (! empty($this->first_name) && ! empty($this->last_initial)) {
return $this->first_name.' '.$this->last_initial.'.';
}
return $this->id;
} | php | public function displayName()
{
if (! empty($this->first_name) && ! empty($this->last_name)) {
return $this->first_name.' '.$this->last_name;
}
if (! empty($this->first_name) && ! empty($this->last_initial)) {
return $this->first_name.' '.$this->last_initial.'.';
}
return $this->id;
} | [
"public",
"function",
"displayName",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"first_name",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"last_name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"first_name",
".",
"' '",
".",
"$",
"this",
"->",
"last_name",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"first_name",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"last_initial",
")",
")",
"{",
"return",
"$",
"this",
"->",
"first_name",
".",
"' '",
".",
"$",
"this",
"->",
"last_initial",
".",
"'.'",
";",
"}",
"return",
"$",
"this",
"->",
"id",
";",
"}"
] | Get the user's display name.
@return mixed|string | [
"Get",
"the",
"user",
"s",
"display",
"name",
"."
] | 89c1c59c6af038dff790df6d5aaa9fc703246568 | https://github.com/DoSomething/gateway/blob/89c1c59c6af038dff790df6d5aaa9fc703246568/src/Resources/NorthstarUser.php#L25-L36 |
35,036 | DoSomething/gateway | src/Resources/NorthstarUser.php | NorthstarUser.prettyMobile | public function prettyMobile($fallback = '')
{
if (! isset($this->mobile)) {
return $fallback;
}
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$formattedNumber = $phoneUtil->parse($this->mobile, 'US');
return $phoneUtil->format($formattedNumber, PhoneNumberFormat::INTERNATIONAL);
} catch (\libphonenumber\NumberParseException $e) {
return $this->number;
}
} | php | public function prettyMobile($fallback = '')
{
if (! isset($this->mobile)) {
return $fallback;
}
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$formattedNumber = $phoneUtil->parse($this->mobile, 'US');
return $phoneUtil->format($formattedNumber, PhoneNumberFormat::INTERNATIONAL);
} catch (\libphonenumber\NumberParseException $e) {
return $this->number;
}
} | [
"public",
"function",
"prettyMobile",
"(",
"$",
"fallback",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mobile",
")",
")",
"{",
"return",
"$",
"fallback",
";",
"}",
"$",
"phoneUtil",
"=",
"PhoneNumberUtil",
"::",
"getInstance",
"(",
")",
";",
"try",
"{",
"$",
"formattedNumber",
"=",
"$",
"phoneUtil",
"->",
"parse",
"(",
"$",
"this",
"->",
"mobile",
",",
"'US'",
")",
";",
"return",
"$",
"phoneUtil",
"->",
"format",
"(",
"$",
"formattedNumber",
",",
"PhoneNumberFormat",
"::",
"INTERNATIONAL",
")",
";",
"}",
"catch",
"(",
"\\",
"libphonenumber",
"\\",
"NumberParseException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"number",
";",
"}",
"}"
] | Get the user's formatted mobile number.
@param string $fallback - Text to display if no mobile is set
@return mixed|string | [
"Get",
"the",
"user",
"s",
"formatted",
"mobile",
"number",
"."
] | 89c1c59c6af038dff790df6d5aaa9fc703246568 | https://github.com/DoSomething/gateway/blob/89c1c59c6af038dff790df6d5aaa9fc703246568/src/Resources/NorthstarUser.php#L44-L58 |
35,037 | mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getMethodInstance | protected function getMethodInstance(&$object, $methodName)
{
$method = new ReflectionMethod(get_class($object), $methodName);
$method->setAccessible(true);
return $method;
} | php | protected function getMethodInstance(&$object, $methodName)
{
$method = new ReflectionMethod(get_class($object), $methodName);
$method->setAccessible(true);
return $method;
} | [
"protected",
"function",
"getMethodInstance",
"(",
"&",
"$",
"object",
",",
"$",
"methodName",
")",
"{",
"$",
"method",
"=",
"new",
"ReflectionMethod",
"(",
"get_class",
"(",
"$",
"object",
")",
",",
"$",
"methodName",
")",
";",
"$",
"method",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"$",
"method",
";",
"}"
] | Internal method to get the `ReflectionMethod` instance
@param object $object Instantiated object that we will run method on
@param string $methodName Method name
@return ReflectionMethod | [
"Internal",
"method",
"to",
"get",
"the",
"ReflectionMethod",
"instance"
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L31-L37 |
35,038 | mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getProperties | protected function getProperties(&$object, $filter = 256 | 512 | 1024)
{
$properties = (new ReflectionClass($object))->getProperties($filter);
//Removes properties added by PHPUnit, if the object is a mock
$properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
return !string_starts_with($property->getName(), '__phpunit');
}) : $properties;
$values = array_map(function ($property) use ($object) {
$property->setAccessible(true);
return $property->getValue($object);
}, $properties);
return array_combine(objects_map($properties, 'getName'), $values);
} | php | protected function getProperties(&$object, $filter = 256 | 512 | 1024)
{
$properties = (new ReflectionClass($object))->getProperties($filter);
//Removes properties added by PHPUnit, if the object is a mock
$properties = $object instanceof MockObject ? array_filter($properties, function ($property) {
return !string_starts_with($property->getName(), '__phpunit');
}) : $properties;
$values = array_map(function ($property) use ($object) {
$property->setAccessible(true);
return $property->getValue($object);
}, $properties);
return array_combine(objects_map($properties, 'getName'), $values);
} | [
"protected",
"function",
"getProperties",
"(",
"&",
"$",
"object",
",",
"$",
"filter",
"=",
"256",
"|",
"512",
"|",
"1024",
")",
"{",
"$",
"properties",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"object",
")",
")",
"->",
"getProperties",
"(",
"$",
"filter",
")",
";",
"//Removes properties added by PHPUnit, if the object is a mock",
"$",
"properties",
"=",
"$",
"object",
"instanceof",
"MockObject",
"?",
"array_filter",
"(",
"$",
"properties",
",",
"function",
"(",
"$",
"property",
")",
"{",
"return",
"!",
"string_starts_with",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"'__phpunit'",
")",
";",
"}",
")",
":",
"$",
"properties",
";",
"$",
"values",
"=",
"array_map",
"(",
"function",
"(",
"$",
"property",
")",
"use",
"(",
"$",
"object",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"$",
"property",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"}",
",",
"$",
"properties",
")",
";",
"return",
"array_combine",
"(",
"objects_map",
"(",
"$",
"properties",
",",
"'getName'",
")",
",",
"$",
"values",
")",
";",
"}"
] | Gets all properties as array with property names as keys.
If the object is a mock, it removes the properties added by PHPUnit.
@param object $object Object from which to get properties
@param int $filter The optional filter, for filtering desired property
types. It's configured using `ReflectionProperty` constants, and
default is public, protected and private properties
@return array Property names as keys and property values as values
@link http://php.net/manual/en/class.reflectionproperty.php#reflectionproperty.constants.modifiers
@since 1.1.4 | [
"Gets",
"all",
"properties",
"as",
"array",
"with",
"property",
"names",
"as",
"keys",
"."
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L51-L67 |
35,039 | mirko-pagliai/php-tools | src/ReflectionTrait.php | ReflectionTrait.getPropertyInstance | protected function getPropertyInstance(&$object, $name)
{
$property = new ReflectionProperty(get_class($object), $name);
$property->setAccessible(true);
return $property;
} | php | protected function getPropertyInstance(&$object, $name)
{
$property = new ReflectionProperty(get_class($object), $name);
$property->setAccessible(true);
return $property;
} | [
"protected",
"function",
"getPropertyInstance",
"(",
"&",
"$",
"object",
",",
"$",
"name",
")",
"{",
"$",
"property",
"=",
"new",
"ReflectionProperty",
"(",
"get_class",
"(",
"$",
"object",
")",
",",
"$",
"name",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"$",
"property",
";",
"}"
] | Internal method to get the `ReflectionProperty` instance
@param object $object Instantiated object that has the property
@param string $name Property name
@return ReflectionProperty | [
"Internal",
"method",
"to",
"get",
"the",
"ReflectionProperty",
"instance"
] | 46003b05490de4b570b46c6377f1e09139ffe43b | https://github.com/mirko-pagliai/php-tools/blob/46003b05490de4b570b46c6377f1e09139ffe43b/src/ReflectionTrait.php#L75-L81 |
35,040 | hail-framework/framework | src/Image/Imagick/Color.php | Color.getInt | public function getInt()
{
$r = $this->getRedValue();
$g = $this->getGreenValue();
$b = $this->getBlueValue();
$a = (int) round($this->getAlphaValue() * 255);
return (int) (($a << 24) + ($r << 16) + ($g << 8) + $b);
} | php | public function getInt()
{
$r = $this->getRedValue();
$g = $this->getGreenValue();
$b = $this->getBlueValue();
$a = (int) round($this->getAlphaValue() * 255);
return (int) (($a << 24) + ($r << 16) + ($g << 8) + $b);
} | [
"public",
"function",
"getInt",
"(",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"getRedValue",
"(",
")",
";",
"$",
"g",
"=",
"$",
"this",
"->",
"getGreenValue",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getBlueValue",
"(",
")",
";",
"$",
"a",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"this",
"->",
"getAlphaValue",
"(",
")",
"*",
"255",
")",
";",
"return",
"(",
"int",
")",
"(",
"(",
"$",
"a",
"<<",
"24",
")",
"+",
"(",
"$",
"r",
"<<",
"16",
")",
"+",
"(",
"$",
"g",
"<<",
"8",
")",
"+",
"$",
"b",
")",
";",
"}"
] | Calculates integer value of current color instance
@return int | [
"Calculates",
"integer",
"value",
"of",
"current",
"color",
"instance"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/Imagick/Color.php#L128-L136 |
35,041 | hail-framework/framework | src/Image/Imagick/Color.php | Color.setPixel | private function setPixel($r, $g, $b, $a = null)
{
$a = $a ?? 1;
return $this->pixel = new \ImagickPixel(
sprintf('rgba(%d, %d, %d, %.2F)', $r, $g, $b, $a)
);
} | php | private function setPixel($r, $g, $b, $a = null)
{
$a = $a ?? 1;
return $this->pixel = new \ImagickPixel(
sprintf('rgba(%d, %d, %d, %.2F)', $r, $g, $b, $a)
);
} | [
"private",
"function",
"setPixel",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
",",
"$",
"a",
"=",
"null",
")",
"{",
"$",
"a",
"=",
"$",
"a",
"??",
"1",
";",
"return",
"$",
"this",
"->",
"pixel",
"=",
"new",
"\\",
"ImagickPixel",
"(",
"sprintf",
"(",
"'rgba(%d, %d, %d, %.2F)'",
",",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
",",
"$",
"a",
")",
")",
";",
"}"
] | Initiates ImagickPixel from given RGBA values
@param int $r ;
@param int $g
@param int $b
@param int $a
@return \ImagickPixel | [
"Initiates",
"ImagickPixel",
"from",
"given",
"RGBA",
"values"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/Imagick/Color.php#L262-L269 |
35,042 | hail-framework/framework | src/Http/Message/Uri.php | Uri.filterUserInfo | private function filterUserInfo(string $part): string
{
// Note the addition of `%` to initial charset; this allows `|` portion
// to match and thus prevent double-encoding.
return \preg_replace_callback(
'/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/u',
[$this, 'urlEncodeChar'],
$part
);
} | php | private function filterUserInfo(string $part): string
{
// Note the addition of `%` to initial charset; this allows `|` portion
// to match and thus prevent double-encoding.
return \preg_replace_callback(
'/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/u',
[$this, 'urlEncodeChar'],
$part
);
} | [
"private",
"function",
"filterUserInfo",
"(",
"string",
"$",
"part",
")",
":",
"string",
"{",
"// Note the addition of `%` to initial charset; this allows `|` portion",
"// to match and thus prevent double-encoding.",
"return",
"\\",
"preg_replace_callback",
"(",
"'/(?:[^%'",
".",
"self",
"::",
"CHAR_UNRESERVED",
".",
"self",
"::",
"CHAR_SUB_DELIMS",
".",
"']+|%(?![A-Fa-f0-9]{2}))/u'",
",",
"[",
"$",
"this",
",",
"'urlEncodeChar'",
"]",
",",
"$",
"part",
")",
";",
"}"
] | Filters a part of user info in a URI to ensure it is properly encoded.
@param string $part
@return string | [
"Filters",
"a",
"part",
"of",
"user",
"info",
"in",
"a",
"URI",
"to",
"ensure",
"it",
"is",
"properly",
"encoded",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Http/Message/Uri.php#L350-L359 |
35,043 | hail-framework/framework | src/Http/Message/Uri.php | Uri.fromArray | public static function fromArray(array $server)
{
$uri = new self('');
if (isset($server['HTTPS'])) {
$uri->scheme = $server['HTTPS'] === 'on' ? 'https' : 'http';
}
[$host, $port] = Helpers::getHostAndPortFromArray($server);
$uri->host = \strtolower($host);
$uri->port = $uri->filterPort($port);
$path = Helpers::getRequestUri($server);
$fragment = '';
if (\strpos($path, '#') !== false) {
[$path, $fragment] = \explode('#', $path, 2);
}
$uri->path = $uri->filterPath(\explode('?', $path, 2)[0]);
$uri->fragment = $uri->filterFragment($fragment);
if (isset($server['QUERY_STRING'])) {
$uri->query = $uri->filterQuery($server['QUERY_STRING']);
}
return $uri;
} | php | public static function fromArray(array $server)
{
$uri = new self('');
if (isset($server['HTTPS'])) {
$uri->scheme = $server['HTTPS'] === 'on' ? 'https' : 'http';
}
[$host, $port] = Helpers::getHostAndPortFromArray($server);
$uri->host = \strtolower($host);
$uri->port = $uri->filterPort($port);
$path = Helpers::getRequestUri($server);
$fragment = '';
if (\strpos($path, '#') !== false) {
[$path, $fragment] = \explode('#', $path, 2);
}
$uri->path = $uri->filterPath(\explode('?', $path, 2)[0]);
$uri->fragment = $uri->filterFragment($fragment);
if (isset($server['QUERY_STRING'])) {
$uri->query = $uri->filterQuery($server['QUERY_STRING']);
}
return $uri;
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"server",
")",
"{",
"$",
"uri",
"=",
"new",
"self",
"(",
"''",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTPS'",
"]",
")",
")",
"{",
"$",
"uri",
"->",
"scheme",
"=",
"$",
"server",
"[",
"'HTTPS'",
"]",
"===",
"'on'",
"?",
"'https'",
":",
"'http'",
";",
"}",
"[",
"$",
"host",
",",
"$",
"port",
"]",
"=",
"Helpers",
"::",
"getHostAndPortFromArray",
"(",
"$",
"server",
")",
";",
"$",
"uri",
"->",
"host",
"=",
"\\",
"strtolower",
"(",
"$",
"host",
")",
";",
"$",
"uri",
"->",
"port",
"=",
"$",
"uri",
"->",
"filterPort",
"(",
"$",
"port",
")",
";",
"$",
"path",
"=",
"Helpers",
"::",
"getRequestUri",
"(",
"$",
"server",
")",
";",
"$",
"fragment",
"=",
"''",
";",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"path",
",",
"'#'",
")",
"!==",
"false",
")",
"{",
"[",
"$",
"path",
",",
"$",
"fragment",
"]",
"=",
"\\",
"explode",
"(",
"'#'",
",",
"$",
"path",
",",
"2",
")",
";",
"}",
"$",
"uri",
"->",
"path",
"=",
"$",
"uri",
"->",
"filterPath",
"(",
"\\",
"explode",
"(",
"'?'",
",",
"$",
"path",
",",
"2",
")",
"[",
"0",
"]",
")",
";",
"$",
"uri",
"->",
"fragment",
"=",
"$",
"uri",
"->",
"filterFragment",
"(",
"$",
"fragment",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'QUERY_STRING'",
"]",
")",
")",
"{",
"$",
"uri",
"->",
"query",
"=",
"$",
"uri",
"->",
"filterQuery",
"(",
"$",
"server",
"[",
"'QUERY_STRING'",
"]",
")",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] | Get a Uri populated with values from server variables.
@param array $server Typically $_SERVER or similar structure.
@return UriInterface
@throws \InvalidArgumentException | [
"Get",
"a",
"Uri",
"populated",
"with",
"values",
"from",
"server",
"variables",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Http/Message/Uri.php#L481-L509 |
35,044 | hail-framework/framework | src/Filesystem/Adapter/Sftp.php | Sftp.setNetSftpConnection | public function setNetSftpConnection($connection, $sftp)
{
$this->connection = $connection;
$this->sftp = $sftp;
return $this;
} | php | public function setNetSftpConnection($connection, $sftp)
{
$this->connection = $connection;
$this->sftp = $sftp;
return $this;
} | [
"public",
"function",
"setNetSftpConnection",
"(",
"$",
"connection",
",",
"$",
"sftp",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"$",
"connection",
";",
"$",
"this",
"->",
"sftp",
"=",
"$",
"sftp",
";",
"return",
"$",
"this",
";",
"}"
] | Inject the SFTP instance.
@param resource $connection
@param resource $sftp
@return $this | [
"Inject",
"the",
"SFTP",
"instance",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Filesystem/Adapter/Sftp.php#L103-L109 |
35,045 | hail-framework/framework | src/Image/Gd/Commands/BlurCommand.php | BlurCommand.execute | public function execute($image)
{
$amount = (int) $this->argument(0)->between(0, 100)->value(1);
for ($i=0; $i < $amount; ++$i) {
imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR);
}
return true;
} | php | public function execute($image)
{
$amount = (int) $this->argument(0)->between(0, 100)->value(1);
for ($i=0; $i < $amount; ++$i) {
imagefilter($image->getCore(), IMG_FILTER_GAUSSIAN_BLUR);
}
return true;
} | [
"public",
"function",
"execute",
"(",
"$",
"image",
")",
"{",
"$",
"amount",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"argument",
"(",
"0",
")",
"->",
"between",
"(",
"0",
",",
"100",
")",
"->",
"value",
"(",
"1",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"amount",
";",
"++",
"$",
"i",
")",
"{",
"imagefilter",
"(",
"$",
"image",
"->",
"getCore",
"(",
")",
",",
"IMG_FILTER_GAUSSIAN_BLUR",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Applies blur effect on image
@param \Hail\Image\Image $image
@return bool | [
"Applies",
"blur",
"effect",
"on",
"image"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/Gd/Commands/BlurCommand.php#L13-L22 |
35,046 | systemson/collection | src/Set.php | Set.groupBy | public function groupBy(string $column): CollectionInterface
{
$return = [];
foreach ($this->toArray() as $item) {
if (isset($item[$column])) {
$key = $item[$column];
$return[$key] = $item;
}
// Must throw exception if item column does not exists
}
return new Collection($return);
} | php | public function groupBy(string $column): CollectionInterface
{
$return = [];
foreach ($this->toArray() as $item) {
if (isset($item[$column])) {
$key = $item[$column];
$return[$key] = $item;
}
// Must throw exception if item column does not exists
}
return new Collection($return);
} | [
"public",
"function",
"groupBy",
"(",
"string",
"$",
"column",
")",
":",
"CollectionInterface",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"key",
"=",
"$",
"item",
"[",
"$",
"column",
"]",
";",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"// Must throw exception if item column does not exists",
"}",
"return",
"new",
"Collection",
"(",
"$",
"return",
")",
";",
"}"
] | Returns a new Collection grouped by the specified column.
@todo MUST throw exception if the column does not exists
@param string $column The column to group by.
@return Collection A new collection instance. | [
"Returns",
"a",
"new",
"Collection",
"grouped",
"by",
"the",
"specified",
"column",
"."
] | fb3ae1a78806aafabc0562db96822e8b99dc2a64 | https://github.com/systemson/collection/blob/fb3ae1a78806aafabc0562db96822e8b99dc2a64/src/Set.php#L79-L92 |
35,047 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.command_args | public function command_args(CommandInterface $cmd, $cmdSignature)
{
$args = [];
$arguments = $cmd->getArguments();
// for command that does not define an argument, we just complete the argument by file paths.
if ($arguments === []) {
return ['*:default:_files'];
}
$idx = 0;
foreach ($arguments as $a) {
$comp = '';
if ($a->multiple) {
$comp .= '*:' . $a->name;
} else {
$comp .= ':' . $a->name;
}
if ($a->validValues || $a->suggestions) {
if ($a->validValues) {
if (is_callable($a->validValues)) {
$comp .= ':{' . implode(' ', [
$this->meta_command_name(),
Util::qq($a->name),
$cmdSignature,
'arg',
$idx,
'valid-values',
]) . '}';
} elseif ($values = $a->getValidValues()) {
$comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
}
} elseif ($a->suggestions) {
if (is_callable($a->suggestions)) {
$comp .= ':{' . implode(' ', [
$this->meta_command_name(),
Util::qq($a->name),
$cmdSignature,
'arg',
$idx,
'suggestions',
]) . '}';
} elseif ($values = $a->getSuggestions()) {
$comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
}
}
} elseif (in_array($a->isa, ['file', 'path', 'dir'], true)) {
switch ($a->isa) {
case 'file':
$comp .= ':_files';
break;
case 'path':
$comp .= ':_path_files';
break;
case 'dir':
$comp .= ':_directories';
break;
}
if ($a->glob) {
$comp .= " -g \"{$a->glob}\"";
}
}
$args[] = Util::q($comp);
$idx++;
}
return empty($args) ? null : $args;
} | php | public function command_args(CommandInterface $cmd, $cmdSignature)
{
$args = [];
$arguments = $cmd->getArguments();
// for command that does not define an argument, we just complete the argument by file paths.
if ($arguments === []) {
return ['*:default:_files'];
}
$idx = 0;
foreach ($arguments as $a) {
$comp = '';
if ($a->multiple) {
$comp .= '*:' . $a->name;
} else {
$comp .= ':' . $a->name;
}
if ($a->validValues || $a->suggestions) {
if ($a->validValues) {
if (is_callable($a->validValues)) {
$comp .= ':{' . implode(' ', [
$this->meta_command_name(),
Util::qq($a->name),
$cmdSignature,
'arg',
$idx,
'valid-values',
]) . '}';
} elseif ($values = $a->getValidValues()) {
$comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
}
} elseif ($a->suggestions) {
if (is_callable($a->suggestions)) {
$comp .= ':{' . implode(' ', [
$this->meta_command_name(),
Util::qq($a->name),
$cmdSignature,
'arg',
$idx,
'suggestions',
]) . '}';
} elseif ($values = $a->getSuggestions()) {
$comp .= ':(' . implode(' ', Util::array_qq($values)) . ')';
}
}
} elseif (in_array($a->isa, ['file', 'path', 'dir'], true)) {
switch ($a->isa) {
case 'file':
$comp .= ':_files';
break;
case 'path':
$comp .= ':_path_files';
break;
case 'dir':
$comp .= ':_directories';
break;
}
if ($a->glob) {
$comp .= " -g \"{$a->glob}\"";
}
}
$args[] = Util::q($comp);
$idx++;
}
return empty($args) ? null : $args;
} | [
"public",
"function",
"command_args",
"(",
"CommandInterface",
"$",
"cmd",
",",
"$",
"cmdSignature",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"arguments",
"=",
"$",
"cmd",
"->",
"getArguments",
"(",
")",
";",
"// for command that does not define an argument, we just complete the argument by file paths.",
"if",
"(",
"$",
"arguments",
"===",
"[",
"]",
")",
"{",
"return",
"[",
"'*:default:_files'",
"]",
";",
"}",
"$",
"idx",
"=",
"0",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"a",
")",
"{",
"$",
"comp",
"=",
"''",
";",
"if",
"(",
"$",
"a",
"->",
"multiple",
")",
"{",
"$",
"comp",
".=",
"'*:'",
".",
"$",
"a",
"->",
"name",
";",
"}",
"else",
"{",
"$",
"comp",
".=",
"':'",
".",
"$",
"a",
"->",
"name",
";",
"}",
"if",
"(",
"$",
"a",
"->",
"validValues",
"||",
"$",
"a",
"->",
"suggestions",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"validValues",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"a",
"->",
"validValues",
")",
")",
"{",
"$",
"comp",
".=",
"':{'",
".",
"implode",
"(",
"' '",
",",
"[",
"$",
"this",
"->",
"meta_command_name",
"(",
")",
",",
"Util",
"::",
"qq",
"(",
"$",
"a",
"->",
"name",
")",
",",
"$",
"cmdSignature",
",",
"'arg'",
",",
"$",
"idx",
",",
"'valid-values'",
",",
"]",
")",
".",
"'}'",
";",
"}",
"elseif",
"(",
"$",
"values",
"=",
"$",
"a",
"->",
"getValidValues",
"(",
")",
")",
"{",
"$",
"comp",
".=",
"':('",
".",
"implode",
"(",
"' '",
",",
"Util",
"::",
"array_qq",
"(",
"$",
"values",
")",
")",
".",
"')'",
";",
"}",
"}",
"elseif",
"(",
"$",
"a",
"->",
"suggestions",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"a",
"->",
"suggestions",
")",
")",
"{",
"$",
"comp",
".=",
"':{'",
".",
"implode",
"(",
"' '",
",",
"[",
"$",
"this",
"->",
"meta_command_name",
"(",
")",
",",
"Util",
"::",
"qq",
"(",
"$",
"a",
"->",
"name",
")",
",",
"$",
"cmdSignature",
",",
"'arg'",
",",
"$",
"idx",
",",
"'suggestions'",
",",
"]",
")",
".",
"'}'",
";",
"}",
"elseif",
"(",
"$",
"values",
"=",
"$",
"a",
"->",
"getSuggestions",
"(",
")",
")",
"{",
"$",
"comp",
".=",
"':('",
".",
"implode",
"(",
"' '",
",",
"Util",
"::",
"array_qq",
"(",
"$",
"values",
")",
")",
".",
"')'",
";",
"}",
"}",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"a",
"->",
"isa",
",",
"[",
"'file'",
",",
"'path'",
",",
"'dir'",
"]",
",",
"true",
")",
")",
"{",
"switch",
"(",
"$",
"a",
"->",
"isa",
")",
"{",
"case",
"'file'",
":",
"$",
"comp",
".=",
"':_files'",
";",
"break",
";",
"case",
"'path'",
":",
"$",
"comp",
".=",
"':_path_files'",
";",
"break",
";",
"case",
"'dir'",
":",
"$",
"comp",
".=",
"':_directories'",
";",
"break",
";",
"}",
"if",
"(",
"$",
"a",
"->",
"glob",
")",
"{",
"$",
"comp",
".=",
"\" -g \\\"{$a->glob}\\\"\"",
";",
"}",
"}",
"$",
"args",
"[",
"]",
"=",
"Util",
"::",
"q",
"(",
"$",
"comp",
")",
";",
"$",
"idx",
"++",
";",
"}",
"return",
"empty",
"(",
"$",
"args",
")",
"?",
"null",
":",
"$",
"args",
";",
"}"
] | Return args as a alternative
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }" | [
"Return",
"args",
"as",
"a",
"alternative"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L200-L269 |
35,048 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.command_args_case | public function command_args_case(CommandInterface $cmd)
{
$buf = new Buffer;
$buf->appendLine('case $state in');
foreach ($cmd->getArguments() as $a) {
$buf->appendLine("({$a->name})");
if ($a->validValues || $a->suggestions) {
$buf->appendLine('_values ' . $this->render_argument_completion_values($a) . ' && ret=0');
} elseif (in_array($a->isa, ['file', 'path', 'dir'], true)) {
$buf->appendLine($this->render_argument_completion_handler($a) . ' && ret=0');
}
$buf->appendLine(';;');
}
$buf->appendLine('esac');
return $buf->__toString();
} | php | public function command_args_case(CommandInterface $cmd)
{
$buf = new Buffer;
$buf->appendLine('case $state in');
foreach ($cmd->getArguments() as $a) {
$buf->appendLine("({$a->name})");
if ($a->validValues || $a->suggestions) {
$buf->appendLine('_values ' . $this->render_argument_completion_values($a) . ' && ret=0');
} elseif (in_array($a->isa, ['file', 'path', 'dir'], true)) {
$buf->appendLine($this->render_argument_completion_handler($a) . ' && ret=0');
}
$buf->appendLine(';;');
}
$buf->appendLine('esac');
return $buf->__toString();
} | [
"public",
"function",
"command_args_case",
"(",
"CommandInterface",
"$",
"cmd",
")",
"{",
"$",
"buf",
"=",
"new",
"Buffer",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"'case $state in'",
")",
";",
"foreach",
"(",
"$",
"cmd",
"->",
"getArguments",
"(",
")",
"as",
"$",
"a",
")",
"{",
"$",
"buf",
"->",
"appendLine",
"(",
"\"({$a->name})\"",
")",
";",
"if",
"(",
"$",
"a",
"->",
"validValues",
"||",
"$",
"a",
"->",
"suggestions",
")",
"{",
"$",
"buf",
"->",
"appendLine",
"(",
"'_values '",
".",
"$",
"this",
"->",
"render_argument_completion_values",
"(",
"$",
"a",
")",
".",
"' && ret=0'",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"a",
"->",
"isa",
",",
"[",
"'file'",
",",
"'path'",
",",
"'dir'",
"]",
",",
"true",
")",
")",
"{",
"$",
"buf",
"->",
"appendLine",
"(",
"$",
"this",
"->",
"render_argument_completion_handler",
"(",
"$",
"a",
")",
".",
"' && ret=0'",
")",
";",
"}",
"$",
"buf",
"->",
"appendLine",
"(",
"';;'",
")",
";",
"}",
"$",
"buf",
"->",
"appendLine",
"(",
"'esac'",
")",
";",
"return",
"$",
"buf",
"->",
"__toString",
"(",
")",
";",
"}"
] | complete argument cases | [
"complete",
"argument",
"cases"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L349-L367 |
35,049 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.commandFlags | public function commandFlags(CommandInterface $cmd, $cmdSignature)
{
$args = [];
$specs = $cmd->getOptionCollection();
/*
'(- 1 *)--version[display version and copyright information]' \
'(- 1 *)--help[print a short help statement]' \
*/
foreach ($specs->options as $opt) {
$args[] = $this->optionFlagItem($opt, $cmdSignature);
}
return empty($args) ? null : $args;
} | php | public function commandFlags(CommandInterface $cmd, $cmdSignature)
{
$args = [];
$specs = $cmd->getOptionCollection();
/*
'(- 1 *)--version[display version and copyright information]' \
'(- 1 *)--help[print a short help statement]' \
*/
foreach ($specs->options as $opt) {
$args[] = $this->optionFlagItem($opt, $cmdSignature);
}
return empty($args) ? null : $args;
} | [
"public",
"function",
"commandFlags",
"(",
"CommandInterface",
"$",
"cmd",
",",
"$",
"cmdSignature",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"specs",
"=",
"$",
"cmd",
"->",
"getOptionCollection",
"(",
")",
";",
"/*\n '(- 1 *)--version[display version and copyright information]' \\\n '(- 1 *)--help[print a short help statement]' \\\n */",
"foreach",
"(",
"$",
"specs",
"->",
"options",
"as",
"$",
"opt",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"this",
"->",
"optionFlagItem",
"(",
"$",
"opt",
",",
"$",
"cmdSignature",
")",
";",
"}",
"return",
"empty",
"(",
"$",
"args",
")",
"?",
"null",
":",
"$",
"args",
";",
"}"
] | Return the zsh array code of the flags of a command.
@return string[] | [
"Return",
"the",
"zsh",
"array",
"code",
"of",
"the",
"flags",
"of",
"a",
"command",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L374-L387 |
35,050 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.commandSubcommandStates | public function commandSubcommandStates(CommandInterface $cmd)
{
$args = [];
$cmds = $this->visibleCommands($cmd->getCommands());
foreach ($cmds as $c) {
$args[] = sprintf("'%s:->%s'", $c->name(), $c->name()); // generate argument states
}
return $args;
} | php | public function commandSubcommandStates(CommandInterface $cmd)
{
$args = [];
$cmds = $this->visibleCommands($cmd->getCommands());
foreach ($cmds as $c) {
$args[] = sprintf("'%s:->%s'", $c->name(), $c->name()); // generate argument states
}
return $args;
} | [
"public",
"function",
"commandSubcommandStates",
"(",
"CommandInterface",
"$",
"cmd",
")",
"{",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"cmds",
"=",
"$",
"this",
"->",
"visibleCommands",
"(",
"$",
"cmd",
"->",
"getCommands",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"cmds",
"as",
"$",
"c",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"sprintf",
"(",
"\"'%s:->%s'\"",
",",
"$",
"c",
"->",
"name",
"(",
")",
",",
"$",
"c",
"->",
"name",
"(",
")",
")",
";",
"// generate argument states",
"}",
"return",
"$",
"args",
";",
"}"
] | Return subcommand completion status as an array of string
@param Command $cmd The command object
@return string[] | [
"Return",
"subcommand",
"completion",
"status",
"as",
"an",
"array",
"of",
"string"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L397-L406 |
35,051 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.commandmetaCallbackFunction | public function commandmetaCallbackFunction(CommandInterface $cmd)
{
$cmdSignature = $cmd->getSignature();
$buf = new Buffer;
$buf->indent();
$buf->appendLine("local curcontext=\$curcontext state line ret=1");
$buf->appendLine("declare -A opt_args");
$buf->appendLine("declare -A values");
$buf->appendLine("local ret=1");
/*
values=$(example/demo meta commit arg 1 valid-values)
_values "description" ${=values} && ret=0
return ret
*/
$buf->appendLine("local desc=\$1");
$buf->appendLine("local valtype=\$3");
$buf->appendLine("local pos=\$4");
$buf->appendLine("local completion=\$5");
$metaCommand = [$this->programName, 'meta', $cmdSignature, '$valtype', '$pos', '$completion'];
$buf->appendLine('$(' . implode(" ", $metaCommand) . ')');
$buf->appendLine('_values $desc ${=values} && ret=0'); // expand value array as arguments
$buf->appendLine('return ret');
$funcName = $this->commandFunctionName($cmdSignature);
return $this->compFunction($funcName, $buf);
} | php | public function commandmetaCallbackFunction(CommandInterface $cmd)
{
$cmdSignature = $cmd->getSignature();
$buf = new Buffer;
$buf->indent();
$buf->appendLine("local curcontext=\$curcontext state line ret=1");
$buf->appendLine("declare -A opt_args");
$buf->appendLine("declare -A values");
$buf->appendLine("local ret=1");
/*
values=$(example/demo meta commit arg 1 valid-values)
_values "description" ${=values} && ret=0
return ret
*/
$buf->appendLine("local desc=\$1");
$buf->appendLine("local valtype=\$3");
$buf->appendLine("local pos=\$4");
$buf->appendLine("local completion=\$5");
$metaCommand = [$this->programName, 'meta', $cmdSignature, '$valtype', '$pos', '$completion'];
$buf->appendLine('$(' . implode(" ", $metaCommand) . ')');
$buf->appendLine('_values $desc ${=values} && ret=0'); // expand value array as arguments
$buf->appendLine('return ret');
$funcName = $this->commandFunctionName($cmdSignature);
return $this->compFunction($funcName, $buf);
} | [
"public",
"function",
"commandmetaCallbackFunction",
"(",
"CommandInterface",
"$",
"cmd",
")",
"{",
"$",
"cmdSignature",
"=",
"$",
"cmd",
"->",
"getSignature",
"(",
")",
";",
"$",
"buf",
"=",
"new",
"Buffer",
";",
"$",
"buf",
"->",
"indent",
"(",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local curcontext=\\$curcontext state line ret=1\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"declare -A opt_args\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"declare -A values\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local ret=1\"",
")",
";",
"/*\n values=$(example/demo meta commit arg 1 valid-values)\n _values \"description\" ${=values} && ret=0\n return ret\n */",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local desc=\\$1\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local valtype=\\$3\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local pos=\\$4\"",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"local completion=\\$5\"",
")",
";",
"$",
"metaCommand",
"=",
"[",
"$",
"this",
"->",
"programName",
",",
"'meta'",
",",
"$",
"cmdSignature",
",",
"'$valtype'",
",",
"'$pos'",
",",
"'$completion'",
"]",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"'$('",
".",
"implode",
"(",
"\" \"",
",",
"$",
"metaCommand",
")",
".",
"')'",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"'_values $desc ${=values} && ret=0'",
")",
";",
"// expand value array as arguments",
"$",
"buf",
"->",
"appendLine",
"(",
"'return ret'",
")",
";",
"$",
"funcName",
"=",
"$",
"this",
"->",
"commandFunctionName",
"(",
"$",
"cmdSignature",
")",
";",
"return",
"$",
"this",
"->",
"compFunction",
"(",
"$",
"funcName",
",",
"$",
"buf",
")",
";",
"}"
] | Zsh function usage
example/demo meta commit arg 1 valid-values
appName meta sub1.sub2.sub3 opt email valid-values | [
"Zsh",
"function",
"usage"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L476-L507 |
35,052 | hail-framework/framework | src/Console/Completion/ZshGenerator.php | ZshGenerator.compFunction | protected function compFunction($name, $code)
{
$buf = new Buffer;
$buf->appendLine("$name () {");
$buf->indent();
$buf->appendBuffer($code);
$buf->unindent();
$buf->appendLine("}");
return $buf;
} | php | protected function compFunction($name, $code)
{
$buf = new Buffer;
$buf->appendLine("$name () {");
$buf->indent();
$buf->appendBuffer($code);
$buf->unindent();
$buf->appendLine("}");
return $buf;
} | [
"protected",
"function",
"compFunction",
"(",
"$",
"name",
",",
"$",
"code",
")",
"{",
"$",
"buf",
"=",
"new",
"Buffer",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"$name () {\"",
")",
";",
"$",
"buf",
"->",
"indent",
"(",
")",
";",
"$",
"buf",
"->",
"appendBuffer",
"(",
"$",
"code",
")",
";",
"$",
"buf",
"->",
"unindent",
"(",
")",
";",
"$",
"buf",
"->",
"appendLine",
"(",
"\"}\"",
")",
";",
"return",
"$",
"buf",
";",
"}"
] | wrap zsh code with function | [
"wrap",
"zsh",
"code",
"with",
"function"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Completion/ZshGenerator.php#L629-L639 |
35,053 | TheBnl/silverstripe-pageslices | src/model/PageSlice.php | PageSlice.onAfterDuplicate | public function onAfterDuplicate(PageSlice $slice)
{
// Check if there are relations set
// Loop over each set relation
// Copy all items in the relation over to the new object
if ($hasManyRelations = $slice->data()->hasMany()) {
foreach ($hasManyRelations as $relation => $class) {
foreach ($slice->$relation() as $object) {
/** @var DataObject $object */
$copy = $object->duplicate(true);
$this->$relation()->add($copy);
}
}
}
} | php | public function onAfterDuplicate(PageSlice $slice)
{
// Check if there are relations set
// Loop over each set relation
// Copy all items in the relation over to the new object
if ($hasManyRelations = $slice->data()->hasMany()) {
foreach ($hasManyRelations as $relation => $class) {
foreach ($slice->$relation() as $object) {
/** @var DataObject $object */
$copy = $object->duplicate(true);
$this->$relation()->add($copy);
}
}
}
} | [
"public",
"function",
"onAfterDuplicate",
"(",
"PageSlice",
"$",
"slice",
")",
"{",
"// Check if there are relations set",
"// Loop over each set relation",
"// Copy all items in the relation over to the new object",
"if",
"(",
"$",
"hasManyRelations",
"=",
"$",
"slice",
"->",
"data",
"(",
")",
"->",
"hasMany",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"hasManyRelations",
"as",
"$",
"relation",
"=>",
"$",
"class",
")",
"{",
"foreach",
"(",
"$",
"slice",
"->",
"$",
"relation",
"(",
")",
"as",
"$",
"object",
")",
"{",
"/** @var DataObject $object */",
"$",
"copy",
"=",
"$",
"object",
"->",
"duplicate",
"(",
"true",
")",
";",
"$",
"this",
"->",
"$",
"relation",
"(",
")",
"->",
"add",
"(",
"$",
"copy",
")",
";",
"}",
"}",
"}",
"}"
] | If this slice holds has_many content
on duplicate copy the content over
@param PageSlice $slice | [
"If",
"this",
"slice",
"holds",
"has_many",
"content",
"on",
"duplicate",
"copy",
"the",
"content",
"over"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/model/PageSlice.php#L88-L102 |
35,054 | TheBnl/silverstripe-pageslices | src/model/PageSlice.php | PageSlice.createSliceID | private function createSliceID()
{
$urlFilter = URLSegmentFilter::create();
if ($sliceID = $urlFilter->filter($this->getField('Title'))) {
if (!$this->Parent()->PageSlices()->filter(array('ID:not' => $this->ID, 'SliceID' => $sliceID))->exists()) {
$this->setField('SliceID', $sliceID);
} else {
$this->setField('SliceID', "$sliceID-{$this->ID}");
}
}
} | php | private function createSliceID()
{
$urlFilter = URLSegmentFilter::create();
if ($sliceID = $urlFilter->filter($this->getField('Title'))) {
if (!$this->Parent()->PageSlices()->filter(array('ID:not' => $this->ID, 'SliceID' => $sliceID))->exists()) {
$this->setField('SliceID', $sliceID);
} else {
$this->setField('SliceID', "$sliceID-{$this->ID}");
}
}
} | [
"private",
"function",
"createSliceID",
"(",
")",
"{",
"$",
"urlFilter",
"=",
"URLSegmentFilter",
"::",
"create",
"(",
")",
";",
"if",
"(",
"$",
"sliceID",
"=",
"$",
"urlFilter",
"->",
"filter",
"(",
"$",
"this",
"->",
"getField",
"(",
"'Title'",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Parent",
"(",
")",
"->",
"PageSlices",
"(",
")",
"->",
"filter",
"(",
"array",
"(",
"'ID:not'",
"=>",
"$",
"this",
"->",
"ID",
",",
"'SliceID'",
"=>",
"$",
"sliceID",
")",
")",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setField",
"(",
"'SliceID'",
",",
"$",
"sliceID",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setField",
"(",
"'SliceID'",
",",
"\"$sliceID-{$this->ID}\"",
")",
";",
"}",
"}",
"}"
] | Create a readable ID based on the slice title | [
"Create",
"a",
"readable",
"ID",
"based",
"on",
"the",
"slice",
"title"
] | 5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b | https://github.com/TheBnl/silverstripe-pageslices/blob/5ac2f2a7b6d43e9e5b1852bbe47b0aaf98de168b/src/model/PageSlice.php#L128-L138 |
35,055 | hail-framework/framework | src/Image/AbstractEncoder.php | AbstractEncoder.process | public function process(Image $image, $format = null, $quality = null)
{
$this->setImage($image);
$this->setFormat($format);
$this->setQuality($quality);
switch (strtolower($this->format)) {
case 'data-url':
$this->result = $this->processDataUrl();
break;
case 'gif':
case 'image/gif':
$this->result = $this->processGif();
break;
case 'png':
case 'image/png':
case 'image/x-png':
$this->result = $this->processPng();
break;
case 'jpg':
case 'jpeg':
case 'image/jpg':
case 'image/jpeg':
case 'image/pjpeg':
$this->result = $this->processJpeg();
break;
case 'tif':
case 'tiff':
case 'image/tiff':
case 'image/tif':
case 'image/x-tif':
case 'image/x-tiff':
$this->result = $this->processTiff();
break;
case 'bmp':
case 'ms-bmp':
case 'x-bitmap':
case 'x-bmp':
case 'x-ms-bmp':
case 'x-win-bitmap':
case 'x-windows-bmp':
case 'x-xbitmap':
case 'image/bmp':
case 'image/ms-bmp':
case 'image/x-bitmap':
case 'image/x-bmp':
case 'image/x-ms-bmp':
case 'image/x-win-bitmap':
case 'image/x-windows-bmp':
case 'image/x-xbitmap':
$this->result = $this->processBmp();
break;
case 'ico':
case 'image/x-ico':
case 'image/x-icon':
case 'image/vnd.microsoft.icon':
$this->result = $this->processIco();
break;
case 'psd':
case 'image/vnd.adobe.photoshop':
$this->result = $this->processPsd();
break;
case 'webp':
case 'image/webp':
case 'image/x-webp':
$this->result = $this->processWebp();
break;
default:
throw new \Hail\Image\Exception\NotSupportedException(
"Encoding format ({$format}) is not supported."
);
}
$this->setImage(null);
return $image->setEncoded($this->result);
} | php | public function process(Image $image, $format = null, $quality = null)
{
$this->setImage($image);
$this->setFormat($format);
$this->setQuality($quality);
switch (strtolower($this->format)) {
case 'data-url':
$this->result = $this->processDataUrl();
break;
case 'gif':
case 'image/gif':
$this->result = $this->processGif();
break;
case 'png':
case 'image/png':
case 'image/x-png':
$this->result = $this->processPng();
break;
case 'jpg':
case 'jpeg':
case 'image/jpg':
case 'image/jpeg':
case 'image/pjpeg':
$this->result = $this->processJpeg();
break;
case 'tif':
case 'tiff':
case 'image/tiff':
case 'image/tif':
case 'image/x-tif':
case 'image/x-tiff':
$this->result = $this->processTiff();
break;
case 'bmp':
case 'ms-bmp':
case 'x-bitmap':
case 'x-bmp':
case 'x-ms-bmp':
case 'x-win-bitmap':
case 'x-windows-bmp':
case 'x-xbitmap':
case 'image/bmp':
case 'image/ms-bmp':
case 'image/x-bitmap':
case 'image/x-bmp':
case 'image/x-ms-bmp':
case 'image/x-win-bitmap':
case 'image/x-windows-bmp':
case 'image/x-xbitmap':
$this->result = $this->processBmp();
break;
case 'ico':
case 'image/x-ico':
case 'image/x-icon':
case 'image/vnd.microsoft.icon':
$this->result = $this->processIco();
break;
case 'psd':
case 'image/vnd.adobe.photoshop':
$this->result = $this->processPsd();
break;
case 'webp':
case 'image/webp':
case 'image/x-webp':
$this->result = $this->processWebp();
break;
default:
throw new \Hail\Image\Exception\NotSupportedException(
"Encoding format ({$format}) is not supported."
);
}
$this->setImage(null);
return $image->setEncoded($this->result);
} | [
"public",
"function",
"process",
"(",
"Image",
"$",
"image",
",",
"$",
"format",
"=",
"null",
",",
"$",
"quality",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setImage",
"(",
"$",
"image",
")",
";",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"format",
")",
";",
"$",
"this",
"->",
"setQuality",
"(",
"$",
"quality",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"format",
")",
")",
"{",
"case",
"'data-url'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processDataUrl",
"(",
")",
";",
"break",
";",
"case",
"'gif'",
":",
"case",
"'image/gif'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processGif",
"(",
")",
";",
"break",
";",
"case",
"'png'",
":",
"case",
"'image/png'",
":",
"case",
"'image/x-png'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processPng",
"(",
")",
";",
"break",
";",
"case",
"'jpg'",
":",
"case",
"'jpeg'",
":",
"case",
"'image/jpg'",
":",
"case",
"'image/jpeg'",
":",
"case",
"'image/pjpeg'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processJpeg",
"(",
")",
";",
"break",
";",
"case",
"'tif'",
":",
"case",
"'tiff'",
":",
"case",
"'image/tiff'",
":",
"case",
"'image/tif'",
":",
"case",
"'image/x-tif'",
":",
"case",
"'image/x-tiff'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processTiff",
"(",
")",
";",
"break",
";",
"case",
"'bmp'",
":",
"case",
"'ms-bmp'",
":",
"case",
"'x-bitmap'",
":",
"case",
"'x-bmp'",
":",
"case",
"'x-ms-bmp'",
":",
"case",
"'x-win-bitmap'",
":",
"case",
"'x-windows-bmp'",
":",
"case",
"'x-xbitmap'",
":",
"case",
"'image/bmp'",
":",
"case",
"'image/ms-bmp'",
":",
"case",
"'image/x-bitmap'",
":",
"case",
"'image/x-bmp'",
":",
"case",
"'image/x-ms-bmp'",
":",
"case",
"'image/x-win-bitmap'",
":",
"case",
"'image/x-windows-bmp'",
":",
"case",
"'image/x-xbitmap'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processBmp",
"(",
")",
";",
"break",
";",
"case",
"'ico'",
":",
"case",
"'image/x-ico'",
":",
"case",
"'image/x-icon'",
":",
"case",
"'image/vnd.microsoft.icon'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processIco",
"(",
")",
";",
"break",
";",
"case",
"'psd'",
":",
"case",
"'image/vnd.adobe.photoshop'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processPsd",
"(",
")",
";",
"break",
";",
"case",
"'webp'",
":",
"case",
"'image/webp'",
":",
"case",
"'image/x-webp'",
":",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"processWebp",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Hail",
"\\",
"Image",
"\\",
"Exception",
"\\",
"NotSupportedException",
"(",
"\"Encoding format ({$format}) is not supported.\"",
")",
";",
"}",
"$",
"this",
"->",
"setImage",
"(",
"null",
")",
";",
"return",
"$",
"image",
"->",
"setEncoded",
"(",
"$",
"this",
"->",
"result",
")",
";",
"}"
] | Process a given image
@param Image $image
@param string $format
@param int $quality
@return Image | [
"Process",
"a",
"given",
"image"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/AbstractEncoder.php#L92-L178 |
35,056 | hail-framework/framework | src/Database/Migration/Manager.php | Manager.getMigrationFiles | protected function getMigrationFiles()
{
$config = $this->getConfig();
$paths = $config->getMigrationPaths();
$files = [];
foreach ($paths as $path) {
$files[] = Util::glob($path . DIRECTORY_SEPARATOR . '*.php');
}
$files = array_merge(...$files);
// glob() can return the same file multiple times
// This will cause the migration to fail with a
// false assumption of duplicate migrations
// http://php.net/manual/en/function.glob.php#110340
return array_unique($files);
} | php | protected function getMigrationFiles()
{
$config = $this->getConfig();
$paths = $config->getMigrationPaths();
$files = [];
foreach ($paths as $path) {
$files[] = Util::glob($path . DIRECTORY_SEPARATOR . '*.php');
}
$files = array_merge(...$files);
// glob() can return the same file multiple times
// This will cause the migration to fail with a
// false assumption of duplicate migrations
// http://php.net/manual/en/function.glob.php#110340
return array_unique($files);
} | [
"protected",
"function",
"getMigrationFiles",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"paths",
"=",
"$",
"config",
"->",
"getMigrationPaths",
"(",
")",
";",
"$",
"files",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"Util",
"::",
"glob",
"(",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"'*.php'",
")",
";",
"}",
"$",
"files",
"=",
"array_merge",
"(",
"...",
"$",
"files",
")",
";",
"// glob() can return the same file multiple times",
"// This will cause the migration to fail with a",
"// false assumption of duplicate migrations",
"// http://php.net/manual/en/function.glob.php#110340",
"return",
"array_unique",
"(",
"$",
"files",
")",
";",
"}"
] | Returns a list of migration files found in the provided migration paths.
@return string[] | [
"Returns",
"a",
"list",
"of",
"migration",
"files",
"found",
"in",
"the",
"provided",
"migration",
"paths",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Manager.php#L682-L699 |
35,057 | hail-framework/framework | src/Database/Migration/Manager.php | Manager.getSeedDependenciesInstances | private function getSeedDependenciesInstances(AbstractSeed $seed)
{
$dependenciesInstances = [];
$dependencies = $seed->getDependencies();
if (!empty($dependencies)) {
foreach ($dependencies as $dependency) {
foreach ($this->seeds as $seed) {
if (\get_class($seed) === $dependency) {
$dependenciesInstances[$dependency] = $seed;
}
}
}
}
return $dependenciesInstances;
} | php | private function getSeedDependenciesInstances(AbstractSeed $seed)
{
$dependenciesInstances = [];
$dependencies = $seed->getDependencies();
if (!empty($dependencies)) {
foreach ($dependencies as $dependency) {
foreach ($this->seeds as $seed) {
if (\get_class($seed) === $dependency) {
$dependenciesInstances[$dependency] = $seed;
}
}
}
}
return $dependenciesInstances;
} | [
"private",
"function",
"getSeedDependenciesInstances",
"(",
"AbstractSeed",
"$",
"seed",
")",
"{",
"$",
"dependenciesInstances",
"=",
"[",
"]",
";",
"$",
"dependencies",
"=",
"$",
"seed",
"->",
"getDependencies",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dependencies",
")",
")",
"{",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"seeds",
"as",
"$",
"seed",
")",
"{",
"if",
"(",
"\\",
"get_class",
"(",
"$",
"seed",
")",
"===",
"$",
"dependency",
")",
"{",
"$",
"dependenciesInstances",
"[",
"$",
"dependency",
"]",
"=",
"$",
"seed",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"dependenciesInstances",
";",
"}"
] | Get seed dependencies instances from seed dependency array
@param AbstractSeed $seed Seed
@return AbstractSeed[] | [
"Get",
"seed",
"dependencies",
"instances",
"from",
"seed",
"dependency",
"array"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Manager.php#L722-L737 |
35,058 | hail-framework/framework | src/Database/Migration/Manager.php | Manager.orderSeedsByDependencies | private function orderSeedsByDependencies(array $seeds)
{
$orderedSeeds = [];
foreach ($seeds as $seed) {
$key = \get_class($seed);
$dependencies = $this->getSeedDependenciesInstances($seed);
if (!empty($dependencies)) {
$orderedSeeds[$key] = $seed;
$orderedSeeds = \array_merge($this->orderSeedsByDependencies($dependencies), $orderedSeeds);
} else {
$orderedSeeds[$key] = $seed;
}
}
return $orderedSeeds;
} | php | private function orderSeedsByDependencies(array $seeds)
{
$orderedSeeds = [];
foreach ($seeds as $seed) {
$key = \get_class($seed);
$dependencies = $this->getSeedDependenciesInstances($seed);
if (!empty($dependencies)) {
$orderedSeeds[$key] = $seed;
$orderedSeeds = \array_merge($this->orderSeedsByDependencies($dependencies), $orderedSeeds);
} else {
$orderedSeeds[$key] = $seed;
}
}
return $orderedSeeds;
} | [
"private",
"function",
"orderSeedsByDependencies",
"(",
"array",
"$",
"seeds",
")",
"{",
"$",
"orderedSeeds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"seeds",
"as",
"$",
"seed",
")",
"{",
"$",
"key",
"=",
"\\",
"get_class",
"(",
"$",
"seed",
")",
";",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"getSeedDependenciesInstances",
"(",
"$",
"seed",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dependencies",
")",
")",
"{",
"$",
"orderedSeeds",
"[",
"$",
"key",
"]",
"=",
"$",
"seed",
";",
"$",
"orderedSeeds",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"orderSeedsByDependencies",
"(",
"$",
"dependencies",
")",
",",
"$",
"orderedSeeds",
")",
";",
"}",
"else",
"{",
"$",
"orderedSeeds",
"[",
"$",
"key",
"]",
"=",
"$",
"seed",
";",
"}",
"}",
"return",
"$",
"orderedSeeds",
";",
"}"
] | Order seeds by dependencies
@param AbstractSeed[] $seeds Seeds
@return AbstractSeed[] | [
"Order",
"seeds",
"by",
"dependencies"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Manager.php#L746-L761 |
35,059 | hail-framework/framework | src/Database/Migration/Manager.php | Manager.getSeeds | public function getSeeds()
{
if (null === $this->seeds) {
$phpFiles = $this->getSeedFiles();
// filter the files to only get the ones that match our naming scheme
$fileNames = [];
/** @var AbstractSeed[] $seeds */
$seeds = [];
foreach ($phpFiles as $filePath) {
if (Util::isValidSeedFileName(basename($filePath))) {
$config = $this->getConfig();
$namespace = $config->getSeedNamespaceByPath(dirname($filePath));
// convert the filename to a class name
$class = (null === $namespace ? '' : $namespace . '\\') . pathinfo($filePath, PATHINFO_FILENAME);
$fileNames[$class] = basename($filePath);
// load the seed file
/** @noinspection PhpIncludeInspection */
require_once $filePath;
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf(
'Could not find class "%s" in file "%s"',
$class,
$filePath
));
}
// instantiate it
$seed = new $class($this->getCommand());
if (!($seed instanceof AbstractSeed)) {
throw new \InvalidArgumentException(sprintf(
'The class "%s" in file "%s" must extend \Hail\Database\Migration\Seed\AbstractSeed',
$class,
$filePath
));
}
$seeds[$class] = $seed;
}
}
ksort($seeds);
$this->setSeeds($seeds);
}
$this->seeds = $this->orderSeedsByDependencies($this->seeds);
return $this->seeds;
} | php | public function getSeeds()
{
if (null === $this->seeds) {
$phpFiles = $this->getSeedFiles();
// filter the files to only get the ones that match our naming scheme
$fileNames = [];
/** @var AbstractSeed[] $seeds */
$seeds = [];
foreach ($phpFiles as $filePath) {
if (Util::isValidSeedFileName(basename($filePath))) {
$config = $this->getConfig();
$namespace = $config->getSeedNamespaceByPath(dirname($filePath));
// convert the filename to a class name
$class = (null === $namespace ? '' : $namespace . '\\') . pathinfo($filePath, PATHINFO_FILENAME);
$fileNames[$class] = basename($filePath);
// load the seed file
/** @noinspection PhpIncludeInspection */
require_once $filePath;
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf(
'Could not find class "%s" in file "%s"',
$class,
$filePath
));
}
// instantiate it
$seed = new $class($this->getCommand());
if (!($seed instanceof AbstractSeed)) {
throw new \InvalidArgumentException(sprintf(
'The class "%s" in file "%s" must extend \Hail\Database\Migration\Seed\AbstractSeed',
$class,
$filePath
));
}
$seeds[$class] = $seed;
}
}
ksort($seeds);
$this->setSeeds($seeds);
}
$this->seeds = $this->orderSeedsByDependencies($this->seeds);
return $this->seeds;
} | [
"public",
"function",
"getSeeds",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"seeds",
")",
"{",
"$",
"phpFiles",
"=",
"$",
"this",
"->",
"getSeedFiles",
"(",
")",
";",
"// filter the files to only get the ones that match our naming scheme",
"$",
"fileNames",
"=",
"[",
"]",
";",
"/** @var AbstractSeed[] $seeds */",
"$",
"seeds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"phpFiles",
"as",
"$",
"filePath",
")",
"{",
"if",
"(",
"Util",
"::",
"isValidSeedFileName",
"(",
"basename",
"(",
"$",
"filePath",
")",
")",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"namespace",
"=",
"$",
"config",
"->",
"getSeedNamespaceByPath",
"(",
"dirname",
"(",
"$",
"filePath",
")",
")",
";",
"// convert the filename to a class name",
"$",
"class",
"=",
"(",
"null",
"===",
"$",
"namespace",
"?",
"''",
":",
"$",
"namespace",
".",
"'\\\\'",
")",
".",
"pathinfo",
"(",
"$",
"filePath",
",",
"PATHINFO_FILENAME",
")",
";",
"$",
"fileNames",
"[",
"$",
"class",
"]",
"=",
"basename",
"(",
"$",
"filePath",
")",
";",
"// load the seed file",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"filePath",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Could not find class \"%s\" in file \"%s\"'",
",",
"$",
"class",
",",
"$",
"filePath",
")",
")",
";",
"}",
"// instantiate it",
"$",
"seed",
"=",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"getCommand",
"(",
")",
")",
";",
"if",
"(",
"!",
"(",
"$",
"seed",
"instanceof",
"AbstractSeed",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The class \"%s\" in file \"%s\" must extend \\Hail\\Database\\Migration\\Seed\\AbstractSeed'",
",",
"$",
"class",
",",
"$",
"filePath",
")",
")",
";",
"}",
"$",
"seeds",
"[",
"$",
"class",
"]",
"=",
"$",
"seed",
";",
"}",
"}",
"ksort",
"(",
"$",
"seeds",
")",
";",
"$",
"this",
"->",
"setSeeds",
"(",
"$",
"seeds",
")",
";",
"}",
"$",
"this",
"->",
"seeds",
"=",
"$",
"this",
"->",
"orderSeedsByDependencies",
"(",
"$",
"this",
"->",
"seeds",
")",
";",
"return",
"$",
"this",
"->",
"seeds",
";",
"}"
] | Gets an array of database seeders.
@throws \InvalidArgumentException
@return AbstractSeed[] | [
"Gets",
"an",
"array",
"of",
"database",
"seeders",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Manager.php#L769-L821 |
35,060 | systemson/collection | src/Bag.php | Bag.pushTo | public function pushTo($key, $value): bool
{
if (is_array($value)) {
foreach ($value as $subKeykey => $value) {
$this[$key][$subKeykey] = $value;
}
} else {
$this[$key][] = $value;
}
return true;
} | php | public function pushTo($key, $value): bool
{
if (is_array($value)) {
foreach ($value as $subKeykey => $value) {
$this[$key][$subKeykey] = $value;
}
} else {
$this[$key][] = $value;
}
return true;
} | [
"public",
"function",
"pushTo",
"(",
"$",
"key",
",",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"subKeykey",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"[",
"$",
"key",
"]",
"[",
"$",
"subKeykey",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"true",
";",
"}"
] | Push a new item at the end of a item in the collection.
@todo MUST accept multilevel keys.
@param string $key The item's key
@param mixed $value The item's value
@return bool | [
"Push",
"a",
"new",
"item",
"at",
"the",
"end",
"of",
"a",
"item",
"in",
"the",
"collection",
"."
] | fb3ae1a78806aafabc0562db96822e8b99dc2a64 | https://github.com/systemson/collection/blob/fb3ae1a78806aafabc0562db96822e8b99dc2a64/src/Bag.php#L37-L48 |
35,061 | hiqdev/hipanel-module-dns | src/validators/MxValueValidator.php | MxValueValidator.extractPriority | public function extractPriority($model, $attribute)
{
$priorityAttribute = $this->priorityAttribute;
preg_match($this->priorityExtractPattern, $model->$attribute, $matches);
if ($matches[2] !== '') {
$model->$priorityAttribute = $matches[2];
$model->$attribute = $matches[3];
}
} | php | public function extractPriority($model, $attribute)
{
$priorityAttribute = $this->priorityAttribute;
preg_match($this->priorityExtractPattern, $model->$attribute, $matches);
if ($matches[2] !== '') {
$model->$priorityAttribute = $matches[2];
$model->$attribute = $matches[3];
}
} | [
"public",
"function",
"extractPriority",
"(",
"$",
"model",
",",
"$",
"attribute",
")",
"{",
"$",
"priorityAttribute",
"=",
"$",
"this",
"->",
"priorityAttribute",
";",
"preg_match",
"(",
"$",
"this",
"->",
"priorityExtractPattern",
",",
"$",
"model",
"->",
"$",
"attribute",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"matches",
"[",
"2",
"]",
"!==",
"''",
")",
"{",
"$",
"model",
"->",
"$",
"priorityAttribute",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"model",
"->",
"$",
"attribute",
"=",
"$",
"matches",
"[",
"3",
"]",
";",
"}",
"}"
] | Extracts priority to separated model attribute.
@param $model Model
@param $attribute | [
"Extracts",
"priority",
"to",
"separated",
"model",
"attribute",
"."
] | 7e9199c95d91a979b7bd4fd07fe801dbe9e69183 | https://github.com/hiqdev/hipanel-module-dns/blob/7e9199c95d91a979b7bd4fd07fe801dbe9e69183/src/validators/MxValueValidator.php#L57-L65 |
35,062 | Wikifab/mediawiki-extensions-MsUpload | SetFileDescription.php | SetFileDescription.APIFauxRequest | private function APIFauxRequest($data = [],
$wasPosted = false,
$session = null,
$protocol = 'http' ){
$res = array();
$apiParams = new \FauxRequest($data, $wasPosted, $session, $protocol);
try {
$api = new \ApiMain( $apiParams );
$api->execute();
$res = $api->getResult()->getResultData();
} catch (\Exception $e) {
trigger_error("API exception : " . $e->getMessage(), E_USER_WARNING);
}
return $res;
} | php | private function APIFauxRequest($data = [],
$wasPosted = false,
$session = null,
$protocol = 'http' ){
$res = array();
$apiParams = new \FauxRequest($data, $wasPosted, $session, $protocol);
try {
$api = new \ApiMain( $apiParams );
$api->execute();
$res = $api->getResult()->getResultData();
} catch (\Exception $e) {
trigger_error("API exception : " . $e->getMessage(), E_USER_WARNING);
}
return $res;
} | [
"private",
"function",
"APIFauxRequest",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"wasPosted",
"=",
"false",
",",
"$",
"session",
"=",
"null",
",",
"$",
"protocol",
"=",
"'http'",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"$",
"apiParams",
"=",
"new",
"\\",
"FauxRequest",
"(",
"$",
"data",
",",
"$",
"wasPosted",
",",
"$",
"session",
",",
"$",
"protocol",
")",
";",
"try",
"{",
"$",
"api",
"=",
"new",
"\\",
"ApiMain",
"(",
"$",
"apiParams",
")",
";",
"$",
"api",
"->",
"execute",
"(",
")",
";",
"$",
"res",
"=",
"$",
"api",
"->",
"getResult",
"(",
")",
"->",
"getResultData",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"\"API exception : \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"E_USER_WARNING",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Execute a request to the API within mediawiki using FauxRequest
@param $data array Array of non-urlencoded key => value pairs, the fake GET/POST values
@param $wasPosted bool Whether to treat the data as POST
@param $session MediaWiki\\Session\\Session | array | null Session, session data array, or null
@param $protocol string 'http' or 'https'
@return array the result data array
@see https://doc.wikimedia.org/mediawiki-core/master/php/classFauxRequest.html | [
"Execute",
"a",
"request",
"to",
"the",
"API",
"within",
"mediawiki",
"using",
"FauxRequest"
] | 77bdf0b66dcfc7b12a710fc6cb2b17a0baf7b5ac | https://github.com/Wikifab/mediawiki-extensions-MsUpload/blob/77bdf0b66dcfc7b12a710fc6cb2b17a0baf7b5ac/SetFileDescription.php#L186-L204 |
35,063 | hail-framework/framework | src/Util/MimeType.php | MimeType.getMimeTypeByFile | public static function getMimeTypeByFile(string $file)
{
if (!\is_file($file) || !\class_exists('\finfo', false)) {
return null;
}
try {
$finfo = new \finfo(FILEINFO_MIME_TYPE);
return $finfo->file($file) ?: null;
// @codeCoverageIgnoreStart
} catch (\ErrorException $e) {
// This is caused by an array to string conversion error.
return null;
}
} | php | public static function getMimeTypeByFile(string $file)
{
if (!\is_file($file) || !\class_exists('\finfo', false)) {
return null;
}
try {
$finfo = new \finfo(FILEINFO_MIME_TYPE);
return $finfo->file($file) ?: null;
// @codeCoverageIgnoreStart
} catch (\ErrorException $e) {
// This is caused by an array to string conversion error.
return null;
}
} | [
"public",
"static",
"function",
"getMimeTypeByFile",
"(",
"string",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"\\",
"is_file",
"(",
"$",
"file",
")",
"||",
"!",
"\\",
"class_exists",
"(",
"'\\finfo'",
",",
"false",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"$",
"finfo",
"=",
"new",
"\\",
"finfo",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"return",
"$",
"finfo",
"->",
"file",
"(",
"$",
"file",
")",
"?",
":",
"null",
";",
"// @codeCoverageIgnoreStart",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
"// This is caused by an array to string conversion error.",
"return",
"null",
";",
"}",
"}"
] | Detects MIME Type based on file.
@param string $file
@return string|null MIME Type or NULL if no mime type detected | [
"Detects",
"MIME",
"Type",
"based",
"on",
"file",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/MimeType.php#L111-L126 |
35,064 | hail-framework/framework | src/Session/Segment.php | Segment.get | public function get($key, $alt = null)
{
$this->resumeSession();
return $_SESSION[$this->name][$key] ?? $alt;
} | php | public function get($key, $alt = null)
{
$this->resumeSession();
return $_SESSION[$this->name][$key] ?? $alt;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"alt",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"resumeSession",
"(",
")",
";",
"return",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"name",
"]",
"[",
"$",
"key",
"]",
"??",
"$",
"alt",
";",
"}"
] | Returns the value of a key in the segment.
@param string $key The key in the segment.
@param mixed $alt An alternative value to return if the key is not set.
@return mixed | [
"Returns",
"the",
"value",
"of",
"a",
"key",
"in",
"the",
"segment",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Session/Segment.php#L60-L65 |
35,065 | hail-framework/framework | src/Util/StreamFilter.php | StreamFilter.append | public static function append($stream, $callback, $read_write = STREAM_FILTER_ALL)
{
$ret = @\stream_filter_append($stream, self::register(), $read_write, $callback);
if ($ret === false) {
$error = \error_get_last() + ['message' => ''];
throw new \RuntimeException('Unable to append filter: ' . $error['message']);
}
return $ret;
} | php | public static function append($stream, $callback, $read_write = STREAM_FILTER_ALL)
{
$ret = @\stream_filter_append($stream, self::register(), $read_write, $callback);
if ($ret === false) {
$error = \error_get_last() + ['message' => ''];
throw new \RuntimeException('Unable to append filter: ' . $error['message']);
}
return $ret;
} | [
"public",
"static",
"function",
"append",
"(",
"$",
"stream",
",",
"$",
"callback",
",",
"$",
"read_write",
"=",
"STREAM_FILTER_ALL",
")",
"{",
"$",
"ret",
"=",
"@",
"\\",
"stream_filter_append",
"(",
"$",
"stream",
",",
"self",
"::",
"register",
"(",
")",
",",
"$",
"read_write",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"ret",
"===",
"false",
")",
"{",
"$",
"error",
"=",
"\\",
"error_get_last",
"(",
")",
"+",
"[",
"'message'",
"=>",
"''",
"]",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to append filter: '",
".",
"$",
"error",
"[",
"'message'",
"]",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | append a callback filter to the given stream
@param resource $stream
@param callable $callback
@param int $read_write
@return resource filter resource which can be used for `remove()`
@throws \RuntimeException on error
@uses stream_filter_append() | [
"append",
"a",
"callback",
"filter",
"to",
"the",
"given",
"stream"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/StreamFilter.php#L23-L32 |
35,066 | hail-framework/framework | src/Util/StreamFilter.php | StreamFilter.prepend | public static function prepend($stream, $callback, $read_write = STREAM_FILTER_ALL)
{
$ret = @\stream_filter_prepend($stream, self::register(), $read_write, $callback);
if ($ret === false) {
$error = \error_get_last() + ['message' => ''];
throw new \RuntimeException('Unable to prepend filter: ' . $error['message']);
}
return $ret;
} | php | public static function prepend($stream, $callback, $read_write = STREAM_FILTER_ALL)
{
$ret = @\stream_filter_prepend($stream, self::register(), $read_write, $callback);
if ($ret === false) {
$error = \error_get_last() + ['message' => ''];
throw new \RuntimeException('Unable to prepend filter: ' . $error['message']);
}
return $ret;
} | [
"public",
"static",
"function",
"prepend",
"(",
"$",
"stream",
",",
"$",
"callback",
",",
"$",
"read_write",
"=",
"STREAM_FILTER_ALL",
")",
"{",
"$",
"ret",
"=",
"@",
"\\",
"stream_filter_prepend",
"(",
"$",
"stream",
",",
"self",
"::",
"register",
"(",
")",
",",
"$",
"read_write",
",",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"ret",
"===",
"false",
")",
"{",
"$",
"error",
"=",
"\\",
"error_get_last",
"(",
")",
"+",
"[",
"'message'",
"=>",
"''",
"]",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to prepend filter: '",
".",
"$",
"error",
"[",
"'message'",
"]",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | prepend a callback filter to the given stream
@param resource $stream
@param callable $callback
@param int $read_write
@return resource filter resource which can be used for `remove()`
@throws \RuntimeException on error
@uses stream_filter_prepend() | [
"prepend",
"a",
"callback",
"filter",
"to",
"the",
"given",
"stream"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/StreamFilter.php#L45-L54 |
35,067 | hail-framework/framework | src/Util/StreamFilter.php | StreamFilter.register | public static function register()
{
if (self::$registered === null) {
self::$registered = 'stream-callback';
\stream_filter_register(self::$registered, CallbackFilter::class);
}
return self::$registered;
} | php | public static function register()
{
if (self::$registered === null) {
self::$registered = 'stream-callback';
\stream_filter_register(self::$registered, CallbackFilter::class);
}
return self::$registered;
} | [
"public",
"static",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"registered",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"registered",
"=",
"'stream-callback'",
";",
"\\",
"stream_filter_register",
"(",
"self",
"::",
"$",
"registered",
",",
"CallbackFilter",
"::",
"class",
")",
";",
"}",
"return",
"self",
"::",
"$",
"registered",
";",
"}"
] | registers the callback filter and returns the resulting filter name
There should be little reason to call this function manually.
@return string filter name
@uses CallbackFilter | [
"registers",
"the",
"callback",
"filter",
"and",
"returns",
"the",
"resulting",
"filter",
"name"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/StreamFilter.php#L147-L155 |
35,068 | mcrumm/pecan | src/Readline.php | Readline.setCompleter | public function setCompleter(callable $completer)
{
if (!Readline::isFullySupported()) {
throw new \LogicException(sprintf('%s requires readline support to use the completer.', __CLASS__));
}
$this->completer = $completer;
return $this;
} | php | public function setCompleter(callable $completer)
{
if (!Readline::isFullySupported()) {
throw new \LogicException(sprintf('%s requires readline support to use the completer.', __CLASS__));
}
$this->completer = $completer;
return $this;
} | [
"public",
"function",
"setCompleter",
"(",
"callable",
"$",
"completer",
")",
"{",
"if",
"(",
"!",
"Readline",
"::",
"isFullySupported",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'%s requires readline support to use the completer.'",
",",
"__CLASS__",
")",
")",
";",
"}",
"$",
"this",
"->",
"completer",
"=",
"$",
"completer",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the auto-complete callback
@param callable $completer
@return $this
@throws \LogicException When PHP is not compiled with readline support. | [
"Sets",
"the",
"auto",
"-",
"complete",
"callback"
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L134-L142 |
35,069 | mcrumm/pecan | src/Readline.php | Readline.prompt | public function prompt()
{
if ($this->hasReadline) {
readline_callback_handler_install($this->getPrompt(), [ $this, 'lineHandler' ]);
} else {
if ($this->paused) { $this->resume(); }
$this->console->log($this->getPrompt());
}
return $this;
} | php | public function prompt()
{
if ($this->hasReadline) {
readline_callback_handler_install($this->getPrompt(), [ $this, 'lineHandler' ]);
} else {
if ($this->paused) { $this->resume(); }
$this->console->log($this->getPrompt());
}
return $this;
} | [
"public",
"function",
"prompt",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasReadline",
")",
"{",
"readline_callback_handler_install",
"(",
"$",
"this",
"->",
"getPrompt",
"(",
")",
",",
"[",
"$",
"this",
",",
"'lineHandler'",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"paused",
")",
"{",
"$",
"this",
"->",
"resume",
"(",
")",
";",
"}",
"$",
"this",
"->",
"console",
"->",
"log",
"(",
"$",
"this",
"->",
"getPrompt",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Writes the prompt to the output.
@return $this | [
"Writes",
"the",
"prompt",
"to",
"the",
"output",
"."
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L182-L192 |
35,070 | mcrumm/pecan | src/Readline.php | Readline.question | public function question($query, callable $callback)
{
if (!is_callable($callback)) { return $this; }
if ($this->questionCallback) {
$this->prompt();
} else {
$this->oldPrompt = $this->prompt;
$this->setPrompt($query);
$this->questionCallback = $callback;
$this->prompt();
}
return $this;
} | php | public function question($query, callable $callback)
{
if (!is_callable($callback)) { return $this; }
if ($this->questionCallback) {
$this->prompt();
} else {
$this->oldPrompt = $this->prompt;
$this->setPrompt($query);
$this->questionCallback = $callback;
$this->prompt();
}
return $this;
} | [
"public",
"function",
"question",
"(",
"$",
"query",
",",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"questionCallback",
")",
"{",
"$",
"this",
"->",
"prompt",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"oldPrompt",
"=",
"$",
"this",
"->",
"prompt",
";",
"$",
"this",
"->",
"setPrompt",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"questionCallback",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"prompt",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Prompts for input.
@param string $query
@param callable $callback
@return $this | [
"Prompts",
"for",
"input",
"."
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L201-L215 |
35,071 | mcrumm/pecan | src/Readline.php | Readline.pause | public function pause()
{
if ($this->paused) { return $this; }
$this->input->pause();
$this->paused = true;
$this->emit('pause');
return $this;
} | php | public function pause()
{
if ($this->paused) { return $this; }
$this->input->pause();
$this->paused = true;
$this->emit('pause');
return $this;
} | [
"public",
"function",
"pause",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"paused",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"input",
"->",
"pause",
"(",
")",
";",
"$",
"this",
"->",
"paused",
"=",
"true",
";",
"$",
"this",
"->",
"emit",
"(",
"'pause'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Pauses the input stream.
@return $this | [
"Pauses",
"the",
"input",
"stream",
"."
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L221-L228 |
35,072 | mcrumm/pecan | src/Readline.php | Readline.resume | public function resume()
{
if (!$this->paused) { return $this; }
$this->input->resume();
$this->paused = false;
$this->emit('resume');
return $this;
} | php | public function resume()
{
if (!$this->paused) { return $this; }
$this->input->resume();
$this->paused = false;
$this->emit('resume');
return $this;
} | [
"public",
"function",
"resume",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"paused",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"input",
"->",
"resume",
"(",
")",
";",
"$",
"this",
"->",
"paused",
"=",
"false",
";",
"$",
"this",
"->",
"emit",
"(",
"'resume'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Resumes the input stream.
@return $this | [
"Resumes",
"the",
"input",
"stream",
"."
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L234-L241 |
35,073 | mcrumm/pecan | src/Readline.php | Readline.close | public function close()
{
if ($this->closed) { return; }
$this->pause();
$this->closed = true;
$this->emit('close');
} | php | public function close()
{
if ($this->closed) { return; }
$this->pause();
$this->closed = true;
$this->emit('close');
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closed",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"pause",
"(",
")",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"$",
"this",
"->",
"emit",
"(",
"'close'",
")",
";",
"}"
] | Closes the streams.
@return $this | [
"Closes",
"the",
"streams",
"."
] | f35f01249587a4df45c7d3ab78f3e51919471177 | https://github.com/mcrumm/pecan/blob/f35f01249587a4df45c7d3ab78f3e51919471177/src/Readline.php#L247-L253 |
35,074 | hail-framework/framework | src/Util/Inflector.php | Inflector.camelize | public static function camelize(string $string, string $delimiter = '_'): string
{
$cacheKey = __FUNCTION__ . $delimiter;
$result = static::_cache($cacheKey, $string);
if ($result === false) {
$result = \str_replace(' ', '', static::humanize($string, $delimiter));
static::_cache($cacheKey, $string, $result);
}
return $result;
} | php | public static function camelize(string $string, string $delimiter = '_'): string
{
$cacheKey = __FUNCTION__ . $delimiter;
$result = static::_cache($cacheKey, $string);
if ($result === false) {
$result = \str_replace(' ', '', static::humanize($string, $delimiter));
static::_cache($cacheKey, $string, $result);
}
return $result;
} | [
"public",
"static",
"function",
"camelize",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"delimiter",
"=",
"'_'",
")",
":",
"string",
"{",
"$",
"cacheKey",
"=",
"__FUNCTION__",
".",
"$",
"delimiter",
";",
"$",
"result",
"=",
"static",
"::",
"_cache",
"(",
"$",
"cacheKey",
",",
"$",
"string",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"result",
"=",
"\\",
"str_replace",
"(",
"' '",
",",
"''",
",",
"static",
"::",
"humanize",
"(",
"$",
"string",
",",
"$",
"delimiter",
")",
")",
";",
"static",
"::",
"_cache",
"(",
"$",
"cacheKey",
",",
"$",
"string",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the input lower_case_delimited_string as a CamelCasedString.
@param string $string String to camelize
@param string $delimiter the delimiter in the input string
@return string CamelizedStringLikeThis.
@link http://book.cakephp.org/3.0/en/core-libraries/inflector.html#creating-camelcase-and-under-scored-forms | [
"Returns",
"the",
"input",
"lower_case_delimited_string",
"as",
"a",
"CamelCasedString",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Util/Inflector.php#L586-L598 |
35,075 | Becklyn/RadBundle | src/Model/SortableModelTrait.php | SortableModelTrait.flushSortOrderMapping | protected function flushSortOrderMapping (SortableHelper $sortableHelper, $sortMapping, array $where = []) : bool
{
if ($sortableHelper->applySorting($sortMapping, $where))
{
$this->flush();
return true;
}
return false;
} | php | protected function flushSortOrderMapping (SortableHelper $sortableHelper, $sortMapping, array $where = []) : bool
{
if ($sortableHelper->applySorting($sortMapping, $where))
{
$this->flush();
return true;
}
return false;
} | [
"protected",
"function",
"flushSortOrderMapping",
"(",
"SortableHelper",
"$",
"sortableHelper",
",",
"$",
"sortMapping",
",",
"array",
"$",
"where",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"sortableHelper",
"->",
"applySorting",
"(",
"$",
"sortMapping",
",",
"$",
"where",
")",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Applies the sort order mapping as provided in the parameters.
The model should wrap this method and use type hints on the $where parameter entries.
@param SortableHelper $sortableHelper
@param array|mixed $sortMapping
@param array $where
@return bool | [
"Applies",
"the",
"sort",
"order",
"mapping",
"as",
"provided",
"in",
"the",
"parameters",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Model/SortableModelTrait.php#L21-L30 |
35,076 | bradfeehan/guzzle-modular-service-descriptions | lib/ServiceDescriptionLoader.php | ServiceDescriptionLoader.loadModular | protected function loadModular($path)
{
$config = array();
// Loop over files in $path (recursing into sub-directories)
foreach ($this->filesIn($path) as $file) {
// Determine the relative path of the current file by
// stripping $path from the beginning of the absolute path
$nestPath = $this->getNestPath($file->getPathname(), $path);
$content = $this->configLoader->load($file->getPathname());
$config = $this->merge($config, $this->nest($content, $nestPath));
}
return $config;
} | php | protected function loadModular($path)
{
$config = array();
// Loop over files in $path (recursing into sub-directories)
foreach ($this->filesIn($path) as $file) {
// Determine the relative path of the current file by
// stripping $path from the beginning of the absolute path
$nestPath = $this->getNestPath($file->getPathname(), $path);
$content = $this->configLoader->load($file->getPathname());
$config = $this->merge($config, $this->nest($content, $nestPath));
}
return $config;
} | [
"protected",
"function",
"loadModular",
"(",
"$",
"path",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"// Loop over files in $path (recursing into sub-directories)",
"foreach",
"(",
"$",
"this",
"->",
"filesIn",
"(",
"$",
"path",
")",
"as",
"$",
"file",
")",
"{",
"// Determine the relative path of the current file by",
"// stripping $path from the beginning of the absolute path",
"$",
"nestPath",
"=",
"$",
"this",
"->",
"getNestPath",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"$",
"path",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"configLoader",
"->",
"load",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"merge",
"(",
"$",
"config",
",",
"$",
"this",
"->",
"nest",
"(",
"$",
"content",
",",
"$",
"nestPath",
")",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Loads a modular service description
@param string $path Path to the service description to load
@return array | [
"Loads",
"a",
"modular",
"service",
"description"
] | 81fe516ffcfd2c12b28fe1232b832e633f817e3b | https://github.com/bradfeehan/guzzle-modular-service-descriptions/blob/81fe516ffcfd2c12b28fe1232b832e633f817e3b/lib/ServiceDescriptionLoader.php#L86-L101 |
35,077 | bradfeehan/guzzle-modular-service-descriptions | lib/ServiceDescriptionLoader.php | ServiceDescriptionLoader.getNestPath | protected function getNestPath($path, $base)
{
$ds = preg_quote(DIRECTORY_SEPARATOR, '#');
return preg_replace(
// patterns to remove
array(
// strip the leading path (make it relative to the
// root of the service description)
'#^' . preg_quote($base, '#') . $ds . '#',
// Ignore trailing __index.foo
'#^(.*?)(:?' . $ds . '?__index)?\\.(:?\\w+)$#',
// Remove path components ending with .group
'#\\w+\\.group(' . $ds . '|$)#',
// Remove any trailing slash
'#' . $ds . '+$#',
// Translate any remaining backslash delimiters (Windows)
'#\\\\#'
),
// replacements (corresponding with patterns above)
array(
'',
'\\1',
'',
'',
'/'
),
$path
);
} | php | protected function getNestPath($path, $base)
{
$ds = preg_quote(DIRECTORY_SEPARATOR, '#');
return preg_replace(
// patterns to remove
array(
// strip the leading path (make it relative to the
// root of the service description)
'#^' . preg_quote($base, '#') . $ds . '#',
// Ignore trailing __index.foo
'#^(.*?)(:?' . $ds . '?__index)?\\.(:?\\w+)$#',
// Remove path components ending with .group
'#\\w+\\.group(' . $ds . '|$)#',
// Remove any trailing slash
'#' . $ds . '+$#',
// Translate any remaining backslash delimiters (Windows)
'#\\\\#'
),
// replacements (corresponding with patterns above)
array(
'',
'\\1',
'',
'',
'/'
),
$path
);
} | [
"protected",
"function",
"getNestPath",
"(",
"$",
"path",
",",
"$",
"base",
")",
"{",
"$",
"ds",
"=",
"preg_quote",
"(",
"DIRECTORY_SEPARATOR",
",",
"'#'",
")",
";",
"return",
"preg_replace",
"(",
"// patterns to remove",
"array",
"(",
"// strip the leading path (make it relative to the",
"// root of the service description)",
"'#^'",
".",
"preg_quote",
"(",
"$",
"base",
",",
"'#'",
")",
".",
"$",
"ds",
".",
"'#'",
",",
"// Ignore trailing __index.foo",
"'#^(.*?)(:?'",
".",
"$",
"ds",
".",
"'?__index)?\\\\.(:?\\\\w+)$#'",
",",
"// Remove path components ending with .group",
"'#\\\\w+\\\\.group('",
".",
"$",
"ds",
".",
"'|$)#'",
",",
"// Remove any trailing slash",
"'#'",
".",
"$",
"ds",
".",
"'+$#'",
",",
"// Translate any remaining backslash delimiters (Windows)",
"'#\\\\\\\\#'",
")",
",",
"// replacements (corresponding with patterns above)",
"array",
"(",
"''",
",",
"'\\\\1'",
",",
"''",
",",
"''",
",",
"'/'",
")",
",",
"$",
"path",
")",
";",
"}"
] | Determines the path to nest content for a file's path name
@param string $path The absolute path to the file
@param string $base The absolute path to the base directory of
the service description this file belongs to
@return string | [
"Determines",
"the",
"path",
"to",
"nest",
"content",
"for",
"a",
"file",
"s",
"path",
"name"
] | 81fe516ffcfd2c12b28fe1232b832e633f817e3b | https://github.com/bradfeehan/guzzle-modular-service-descriptions/blob/81fe516ffcfd2c12b28fe1232b832e633f817e3b/lib/ServiceDescriptionLoader.php#L125-L158 |
35,078 | bradfeehan/guzzle-modular-service-descriptions | lib/ServiceDescriptionLoader.php | ServiceDescriptionLoader.nest | private function nest($value, $path)
{
if ($path) {
$elements = explode('/', $path);
foreach (array_reverse($elements) as $element) {
$value = array($element => $value);
}
}
return $value;
} | php | private function nest($value, $path)
{
if ($path) {
$elements = explode('/', $path);
foreach (array_reverse($elements) as $element) {
$value = array($element => $value);
}
}
return $value;
} | [
"private",
"function",
"nest",
"(",
"$",
"value",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"elements",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"elements",
")",
"as",
"$",
"element",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"element",
"=>",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Nests an array under a particular path
As an example:
nest(array('foo' => 'bar'), 'baz/qux')
This will return:
array(
'baz' => array(
'qux' => array(
'foo' => 'bar'
)
)
)
@param mixed $value The value to put at the given path
@param string $path The slash-separated path to put the value
@return array | [
"Nests",
"an",
"array",
"under",
"a",
"particular",
"path"
] | 81fe516ffcfd2c12b28fe1232b832e633f817e3b | https://github.com/bradfeehan/guzzle-modular-service-descriptions/blob/81fe516ffcfd2c12b28fe1232b832e633f817e3b/lib/ServiceDescriptionLoader.php#L203-L214 |
35,079 | bradfeehan/guzzle-modular-service-descriptions | lib/ServiceDescriptionLoader.php | ServiceDescriptionLoader.sortConfig | protected function sortConfig(array $config)
{
// Sort operations
if (isset($config['operations'])) {
$operations = $config['operations'];
$nodes = array();
// Create empty dependencies array
foreach (array_keys($operations) as $key) {
$nodes[$key] = array(
'in' => array(), // inbound dependencies
'out' => array(), // outbound dependencies
);
}
// Populate dependencies
foreach ($operations as $key => $operation) {
if (isset($operation['extends'])) {
// This key depends on the thing being extended
$nodes[$key]['in'][] = $operation['extends'];
// The thing being extended depends on this key
$nodes[$operation['extends']]['out'][] = $key;
}
}
// Build up $independent
$independent = array();
foreach ($nodes as $key => $node) {
if (empty($node['in'])) {
$independent[] = $key;
}
}
// While we have nodes with no inbound edges, remove it
// from the graph and add it to the end of the list
$sorted = array();
while (!empty($independent)) {
$key = array_shift($independent);
$sorted[$key] = $operations[$key];
// Go over this node's dependencies
foreach ($nodes[$key]['out'] as $dependency) {
$nodes[$dependency]['in'] = array_diff(
$nodes[$dependency]['in'],
array($key)
);
// If the dependency has all of its inbound deps...
if (empty($nodes[$dependency]['in'])) {
// ...it's ready to be processed, add it to $independent.
$independent[] = $dependency;
}
}
$nodes[$key]['out'] = array();
}
foreach ($nodes as $node) {
if (!empty($node['in']) or !empty($node['out'])) {
throw new RuntimeException(
"Couldn't sort graph, cycle detected!"
);
}
}
$config['operations'] = $sorted;
}
return $config;
} | php | protected function sortConfig(array $config)
{
// Sort operations
if (isset($config['operations'])) {
$operations = $config['operations'];
$nodes = array();
// Create empty dependencies array
foreach (array_keys($operations) as $key) {
$nodes[$key] = array(
'in' => array(), // inbound dependencies
'out' => array(), // outbound dependencies
);
}
// Populate dependencies
foreach ($operations as $key => $operation) {
if (isset($operation['extends'])) {
// This key depends on the thing being extended
$nodes[$key]['in'][] = $operation['extends'];
// The thing being extended depends on this key
$nodes[$operation['extends']]['out'][] = $key;
}
}
// Build up $independent
$independent = array();
foreach ($nodes as $key => $node) {
if (empty($node['in'])) {
$independent[] = $key;
}
}
// While we have nodes with no inbound edges, remove it
// from the graph and add it to the end of the list
$sorted = array();
while (!empty($independent)) {
$key = array_shift($independent);
$sorted[$key] = $operations[$key];
// Go over this node's dependencies
foreach ($nodes[$key]['out'] as $dependency) {
$nodes[$dependency]['in'] = array_diff(
$nodes[$dependency]['in'],
array($key)
);
// If the dependency has all of its inbound deps...
if (empty($nodes[$dependency]['in'])) {
// ...it's ready to be processed, add it to $independent.
$independent[] = $dependency;
}
}
$nodes[$key]['out'] = array();
}
foreach ($nodes as $node) {
if (!empty($node['in']) or !empty($node['out'])) {
throw new RuntimeException(
"Couldn't sort graph, cycle detected!"
);
}
}
$config['operations'] = $sorted;
}
return $config;
} | [
"protected",
"function",
"sortConfig",
"(",
"array",
"$",
"config",
")",
"{",
"// Sort operations",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'operations'",
"]",
")",
")",
"{",
"$",
"operations",
"=",
"$",
"config",
"[",
"'operations'",
"]",
";",
"$",
"nodes",
"=",
"array",
"(",
")",
";",
"// Create empty dependencies array",
"foreach",
"(",
"array_keys",
"(",
"$",
"operations",
")",
"as",
"$",
"key",
")",
"{",
"$",
"nodes",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
"'in'",
"=>",
"array",
"(",
")",
",",
"// inbound dependencies",
"'out'",
"=>",
"array",
"(",
")",
",",
"// outbound dependencies",
")",
";",
"}",
"// Populate dependencies",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"key",
"=>",
"$",
"operation",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"operation",
"[",
"'extends'",
"]",
")",
")",
"{",
"// This key depends on the thing being extended",
"$",
"nodes",
"[",
"$",
"key",
"]",
"[",
"'in'",
"]",
"[",
"]",
"=",
"$",
"operation",
"[",
"'extends'",
"]",
";",
"// The thing being extended depends on this key",
"$",
"nodes",
"[",
"$",
"operation",
"[",
"'extends'",
"]",
"]",
"[",
"'out'",
"]",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"// Build up $independent",
"$",
"independent",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"key",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"node",
"[",
"'in'",
"]",
")",
")",
"{",
"$",
"independent",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"// While we have nodes with no inbound edges, remove it",
"// from the graph and add it to the end of the list",
"$",
"sorted",
"=",
"array",
"(",
")",
";",
"while",
"(",
"!",
"empty",
"(",
"$",
"independent",
")",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"independent",
")",
";",
"$",
"sorted",
"[",
"$",
"key",
"]",
"=",
"$",
"operations",
"[",
"$",
"key",
"]",
";",
"// Go over this node's dependencies",
"foreach",
"(",
"$",
"nodes",
"[",
"$",
"key",
"]",
"[",
"'out'",
"]",
"as",
"$",
"dependency",
")",
"{",
"$",
"nodes",
"[",
"$",
"dependency",
"]",
"[",
"'in'",
"]",
"=",
"array_diff",
"(",
"$",
"nodes",
"[",
"$",
"dependency",
"]",
"[",
"'in'",
"]",
",",
"array",
"(",
"$",
"key",
")",
")",
";",
"// If the dependency has all of its inbound deps...",
"if",
"(",
"empty",
"(",
"$",
"nodes",
"[",
"$",
"dependency",
"]",
"[",
"'in'",
"]",
")",
")",
"{",
"// ...it's ready to be processed, add it to $independent.",
"$",
"independent",
"[",
"]",
"=",
"$",
"dependency",
";",
"}",
"}",
"$",
"nodes",
"[",
"$",
"key",
"]",
"[",
"'out'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"[",
"'in'",
"]",
")",
"or",
"!",
"empty",
"(",
"$",
"node",
"[",
"'out'",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't sort graph, cycle detected!\"",
")",
";",
"}",
"}",
"$",
"config",
"[",
"'operations'",
"]",
"=",
"$",
"sorted",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Sorts the config so that dependencies are defined before use
Guzzle requires things to be defined before they're used as the
target of an "extends" declaration. This method sorts the config
so that this is the case. This is called a topological sort.
@param array $config The configuration to sort
@return array The sorted configuration | [
"Sorts",
"the",
"config",
"so",
"that",
"dependencies",
"are",
"defined",
"before",
"use"
] | 81fe516ffcfd2c12b28fe1232b832e633f817e3b | https://github.com/bradfeehan/guzzle-modular-service-descriptions/blob/81fe516ffcfd2c12b28fe1232b832e633f817e3b/lib/ServiceDescriptionLoader.php#L247-L317 |
35,080 | hail-framework/framework | src/I18n/Gettext/Extractors/VueJs.php | VueJs.isAttributeMatching | private static function isAttributeMatching($attributeName, $attributePrefixes)
{
foreach ($attributePrefixes as $prefix) {
if (\strpos($attributeName, $prefix) === 0) {
return true;
}
}
return false;
} | php | private static function isAttributeMatching($attributeName, $attributePrefixes)
{
foreach ($attributePrefixes as $prefix) {
if (\strpos($attributeName, $prefix) === 0) {
return true;
}
}
return false;
} | [
"private",
"static",
"function",
"isAttributeMatching",
"(",
"$",
"attributeName",
",",
"$",
"attributePrefixes",
")",
"{",
"foreach",
"(",
"$",
"attributePrefixes",
"as",
"$",
"prefix",
")",
"{",
"if",
"(",
"\\",
"strpos",
"(",
"$",
"attributeName",
",",
"$",
"prefix",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if this attribute name should be parsed for translations
@param string $attributeName
@param string[] $attributePrefixes
@return bool | [
"Check",
"if",
"this",
"attribute",
"name",
"should",
"be",
"parsed",
"for",
"translations"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Extractors/VueJs.php#L240-L249 |
35,081 | cfxmarkets/php-public-models | src/Exchange/Asset.php | Asset.serializeAttribute | public function serializeAttribute($name)
{
if ($name === 'issuanceCloseDate') {
$val = $this->getIssuanceCloseDate();
if ($val instanceof \DateTimeInterface) {
$val = $val->format(\DateTime::RFC3339);
}
return (string)$val;
}
return parent::serializeAttribute($name);
} | php | public function serializeAttribute($name)
{
if ($name === 'issuanceCloseDate') {
$val = $this->getIssuanceCloseDate();
if ($val instanceof \DateTimeInterface) {
$val = $val->format(\DateTime::RFC3339);
}
return (string)$val;
}
return parent::serializeAttribute($name);
} | [
"public",
"function",
"serializeAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'issuanceCloseDate'",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"getIssuanceCloseDate",
"(",
")",
";",
"if",
"(",
"$",
"val",
"instanceof",
"\\",
"DateTimeInterface",
")",
"{",
"$",
"val",
"=",
"$",
"val",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"RFC3339",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"val",
";",
"}",
"return",
"parent",
"::",
"serializeAttribute",
"(",
"$",
"name",
")",
";",
"}"
] | Serialize issuanceCloseDate field to a value that SQL understands
We have to do this here because when order intents are serialized that already have a issuanceCloseDate date
set, they end up sending malformed data to the API. This is because \DateTime actually does implement
jsonSerialize, but in a way that breaks our implementation. | [
"Serialize",
"issuanceCloseDate",
"field",
"to",
"a",
"value",
"that",
"SQL",
"understands"
] | b91a58f7d9519b98b29c58f0911e976e361a5f65 | https://github.com/cfxmarkets/php-public-models/blob/b91a58f7d9519b98b29c58f0911e976e361a5f65/src/Exchange/Asset.php#L217-L227 |
35,082 | hail-framework/framework | src/Debugger/Bar/QueryPanel.php | QueryPanel.getColorInRange | public function getColorInRange($value)
{
$a = [54, 170, 31];
$b = [220, 1, 57];
[$min, $max] = $this->extremes;
$d = $max - $min;
$lin = ($value - $min) / ($d ?: 0.5); // prevent x/0
$color = [];
for ($i = 0; $i < 3; ++$i) {
$color[$i] = (int) ($a[$i] + ($b[$i] - $a[$i]) * $lin);
}
return 'rgb(' . \implode(',', $color) . ')';
} | php | public function getColorInRange($value)
{
$a = [54, 170, 31];
$b = [220, 1, 57];
[$min, $max] = $this->extremes;
$d = $max - $min;
$lin = ($value - $min) / ($d ?: 0.5); // prevent x/0
$color = [];
for ($i = 0; $i < 3; ++$i) {
$color[$i] = (int) ($a[$i] + ($b[$i] - $a[$i]) * $lin);
}
return 'rgb(' . \implode(',', $color) . ')';
} | [
"public",
"function",
"getColorInRange",
"(",
"$",
"value",
")",
"{",
"$",
"a",
"=",
"[",
"54",
",",
"170",
",",
"31",
"]",
";",
"$",
"b",
"=",
"[",
"220",
",",
"1",
",",
"57",
"]",
";",
"[",
"$",
"min",
",",
"$",
"max",
"]",
"=",
"$",
"this",
"->",
"extremes",
";",
"$",
"d",
"=",
"$",
"max",
"-",
"$",
"min",
";",
"$",
"lin",
"=",
"(",
"$",
"value",
"-",
"$",
"min",
")",
"/",
"(",
"$",
"d",
"?",
":",
"0.5",
")",
";",
"// prevent x/0\r",
"$",
"color",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"++",
"$",
"i",
")",
"{",
"$",
"color",
"[",
"$",
"i",
"]",
"=",
"(",
"int",
")",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
"+",
"(",
"$",
"b",
"[",
"$",
"i",
"]",
"-",
"$",
"a",
"[",
"$",
"i",
"]",
")",
"*",
"$",
"lin",
")",
";",
"}",
"return",
"'rgb('",
".",
"\\",
"implode",
"(",
"','",
",",
"$",
"color",
")",
".",
"')'",
";",
"}"
] | Linear color gradient
@param float $value
@return string hex color
@internal | [
"Linear",
"color",
"gradient"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Debugger/Bar/QueryPanel.php#L91-L104 |
35,083 | hail-framework/framework | src/Console/Option/OptionParser.php | OptionParser.preprocessingArguments | protected function preprocessingArguments(array $argv)
{
// preprocessing arguments
$newArgv = [];
$extra = [];
$afterDash = false;
foreach ($argv as $arg) {
if ($arg === '--') {
$afterDash = true;
continue;
}
if ($afterDash) {
$extra[] = $arg;
continue;
}
$a = new Argument($arg);
if ($a->anyOfOptions($this->specs) && $a->containsOptionValue()) {
list($opt, $val) = $a->splitAsOption();
array_push($newArgv, $opt, $val);
} else {
$newArgv[] = $arg;
}
}
return [$newArgv, $extra];
} | php | protected function preprocessingArguments(array $argv)
{
// preprocessing arguments
$newArgv = [];
$extra = [];
$afterDash = false;
foreach ($argv as $arg) {
if ($arg === '--') {
$afterDash = true;
continue;
}
if ($afterDash) {
$extra[] = $arg;
continue;
}
$a = new Argument($arg);
if ($a->anyOfOptions($this->specs) && $a->containsOptionValue()) {
list($opt, $val) = $a->splitAsOption();
array_push($newArgv, $opt, $val);
} else {
$newArgv[] = $arg;
}
}
return [$newArgv, $extra];
} | [
"protected",
"function",
"preprocessingArguments",
"(",
"array",
"$",
"argv",
")",
"{",
"// preprocessing arguments",
"$",
"newArgv",
"=",
"[",
"]",
";",
"$",
"extra",
"=",
"[",
"]",
";",
"$",
"afterDash",
"=",
"false",
";",
"foreach",
"(",
"$",
"argv",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"arg",
"===",
"'--'",
")",
"{",
"$",
"afterDash",
"=",
"true",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"afterDash",
")",
"{",
"$",
"extra",
"[",
"]",
"=",
"$",
"arg",
";",
"continue",
";",
"}",
"$",
"a",
"=",
"new",
"Argument",
"(",
"$",
"arg",
")",
";",
"if",
"(",
"$",
"a",
"->",
"anyOfOptions",
"(",
"$",
"this",
"->",
"specs",
")",
"&&",
"$",
"a",
"->",
"containsOptionValue",
"(",
")",
")",
"{",
"list",
"(",
"$",
"opt",
",",
"$",
"val",
")",
"=",
"$",
"a",
"->",
"splitAsOption",
"(",
")",
";",
"array_push",
"(",
"$",
"newArgv",
",",
"$",
"opt",
",",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"newArgv",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"}",
"return",
"[",
"$",
"newArgv",
",",
"$",
"extra",
"]",
";",
"}"
] | preprocess the argv array
- split option and option value
- separate arguments after "--" | [
"preprocess",
"the",
"argv",
"array"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Option/OptionParser.php#L104-L130 |
35,084 | hail-framework/framework | src/I18n/Gettext/Languages/Language.php | Language.getAll | public static function getAll()
{
$result = [];
foreach (\array_keys(CldrData::getLanguageNames()) as $cldrLanguageId) {
$result[] = new Language(CldrData::getLanguageInfo($cldrLanguageId));
}
return $result;
} | php | public static function getAll()
{
$result = [];
foreach (\array_keys(CldrData::getLanguageNames()) as $cldrLanguageId) {
$result[] = new Language(CldrData::getLanguageInfo($cldrLanguageId));
}
return $result;
} | [
"public",
"static",
"function",
"getAll",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"\\",
"array_keys",
"(",
"CldrData",
"::",
"getLanguageNames",
"(",
")",
")",
"as",
"$",
"cldrLanguageId",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"new",
"Language",
"(",
"CldrData",
"::",
"getLanguageInfo",
"(",
"$",
"cldrLanguageId",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Return a list of all languages available.
@return Language[] | [
"Return",
"a",
"list",
"of",
"all",
"languages",
"available",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Languages/Language.php#L116-L124 |
35,085 | hail-framework/framework | src/I18n/Gettext/Languages/Language.php | Language.getById | public static function getById($id)
{
$result = null;
$info = CldrData::getLanguageInfo($id);
if (isset($info)) {
$result = new Language($info);
}
return $result;
} | php | public static function getById($id)
{
$result = null;
$info = CldrData::getLanguageInfo($id);
if (isset($info)) {
$result = new Language($info);
}
return $result;
} | [
"public",
"static",
"function",
"getById",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"info",
"=",
"CldrData",
"::",
"getLanguageInfo",
"(",
"$",
"id",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"info",
")",
")",
"{",
"$",
"result",
"=",
"new",
"Language",
"(",
"$",
"info",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Return a Language instance given the language id
@param string $id
@return Language|null | [
"Return",
"a",
"Language",
"instance",
"given",
"the",
"language",
"id"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Languages/Language.php#L133-L142 |
35,086 | hail-framework/framework | src/I18n/Gettext/Languages/Language.php | Language.buildFormula | private function buildFormula()
{
$numCategories = \count($this->categories);
switch ($numCategories) {
case 1:
// Just one category
return '0';
case 2:
return self::reduceFormula(self::reverseFormula($this->categories[0]->formula));
default:
$formula = (string) ($numCategories - 1);
for ($i = $numCategories - 2; $i >= 0; $i--) {
$fl = self::reduceFormula($this->categories[$i]->formula);
if (!\preg_match('/^\([^()]+\)$/', $fl)) {
$fl = "($fl)";
}
$formula = "$fl ? $i : $formula";
if ($i > 0) {
$formula = "($formula)";
}
}
return $formula;
}
} | php | private function buildFormula()
{
$numCategories = \count($this->categories);
switch ($numCategories) {
case 1:
// Just one category
return '0';
case 2:
return self::reduceFormula(self::reverseFormula($this->categories[0]->formula));
default:
$formula = (string) ($numCategories - 1);
for ($i = $numCategories - 2; $i >= 0; $i--) {
$fl = self::reduceFormula($this->categories[$i]->formula);
if (!\preg_match('/^\([^()]+\)$/', $fl)) {
$fl = "($fl)";
}
$formula = "$fl ? $i : $formula";
if ($i > 0) {
$formula = "($formula)";
}
}
return $formula;
}
} | [
"private",
"function",
"buildFormula",
"(",
")",
"{",
"$",
"numCategories",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"categories",
")",
";",
"switch",
"(",
"$",
"numCategories",
")",
"{",
"case",
"1",
":",
"// Just one category",
"return",
"'0'",
";",
"case",
"2",
":",
"return",
"self",
"::",
"reduceFormula",
"(",
"self",
"::",
"reverseFormula",
"(",
"$",
"this",
"->",
"categories",
"[",
"0",
"]",
"->",
"formula",
")",
")",
";",
"default",
":",
"$",
"formula",
"=",
"(",
"string",
")",
"(",
"$",
"numCategories",
"-",
"1",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"numCategories",
"-",
"2",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"fl",
"=",
"self",
"::",
"reduceFormula",
"(",
"$",
"this",
"->",
"categories",
"[",
"$",
"i",
"]",
"->",
"formula",
")",
";",
"if",
"(",
"!",
"\\",
"preg_match",
"(",
"'/^\\([^()]+\\)$/'",
",",
"$",
"fl",
")",
")",
"{",
"$",
"fl",
"=",
"\"($fl)\"",
";",
"}",
"$",
"formula",
"=",
"\"$fl ? $i : $formula\"",
";",
"if",
"(",
"$",
"i",
">",
"0",
")",
"{",
"$",
"formula",
"=",
"\"($formula)\"",
";",
"}",
"}",
"return",
"$",
"formula",
";",
"}",
"}"
] | Build the formula starting from the currently defined categories.
@return string | [
"Build",
"the",
"formula",
"starting",
"from",
"the",
"currently",
"defined",
"categories",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Languages/Language.php#L284-L308 |
35,087 | hail-framework/framework | src/I18n/Gettext/Languages/Language.php | Language.reverseFormula | private static function reverseFormula($formula)
{
if (\preg_match('/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula)) {
return \str_replace(' == ', ' != ', $formula);
}
if (\preg_match('/^n( % \d+)? != \d+(\.\.\d+|,\d+)*?$/', $formula)) {
return \str_replace(' != ', ' == ', $formula);
}
if (\preg_match('/^\(?n == \d+ \|\| n == \d+\)?$/', $formula)) {
return \trim(\str_replace([' == ', ' || '], [' != ', ' && '], $formula), '()');
}
$m = null;
if (\preg_match('/^(n(?: % \d+)?) == (\d+) && (n(?: % \d+)?) != (\d+)$/', $formula, $m)) {
return "{$m[1]} != {$m[2]} || {$m[3]} == {$m[4]}";
}
switch ($formula) {
case '(n == 1 || n == 2 || n == 3) || n % 10 != 4 && n % 10 != 6 && n % 10 != 9':
return 'n != 1 && n != 2 && n != 3 && (n % 10 == 4 || n % 10 == 6 || n % 10 == 9)';
case '(n == 0 || n == 1) || n >= 11 && n <= 99':
return 'n >= 2 && (n < 11 || n > 99)';
}
throw new \InvalidArgumentException("Unable to reverse the formula '$formula'");
} | php | private static function reverseFormula($formula)
{
if (\preg_match('/^n( % \d+)? == \d+(\.\.\d+|,\d+)*?$/', $formula)) {
return \str_replace(' == ', ' != ', $formula);
}
if (\preg_match('/^n( % \d+)? != \d+(\.\.\d+|,\d+)*?$/', $formula)) {
return \str_replace(' != ', ' == ', $formula);
}
if (\preg_match('/^\(?n == \d+ \|\| n == \d+\)?$/', $formula)) {
return \trim(\str_replace([' == ', ' || '], [' != ', ' && '], $formula), '()');
}
$m = null;
if (\preg_match('/^(n(?: % \d+)?) == (\d+) && (n(?: % \d+)?) != (\d+)$/', $formula, $m)) {
return "{$m[1]} != {$m[2]} || {$m[3]} == {$m[4]}";
}
switch ($formula) {
case '(n == 1 || n == 2 || n == 3) || n % 10 != 4 && n % 10 != 6 && n % 10 != 9':
return 'n != 1 && n != 2 && n != 3 && (n % 10 == 4 || n % 10 == 6 || n % 10 == 9)';
case '(n == 0 || n == 1) || n >= 11 && n <= 99':
return 'n >= 2 && (n < 11 || n > 99)';
}
throw new \InvalidArgumentException("Unable to reverse the formula '$formula'");
} | [
"private",
"static",
"function",
"reverseFormula",
"(",
"$",
"formula",
")",
"{",
"if",
"(",
"\\",
"preg_match",
"(",
"'/^n( % \\d+)? == \\d+(\\.\\.\\d+|,\\d+)*?$/'",
",",
"$",
"formula",
")",
")",
"{",
"return",
"\\",
"str_replace",
"(",
"' == '",
",",
"' != '",
",",
"$",
"formula",
")",
";",
"}",
"if",
"(",
"\\",
"preg_match",
"(",
"'/^n( % \\d+)? != \\d+(\\.\\.\\d+|,\\d+)*?$/'",
",",
"$",
"formula",
")",
")",
"{",
"return",
"\\",
"str_replace",
"(",
"' != '",
",",
"' == '",
",",
"$",
"formula",
")",
";",
"}",
"if",
"(",
"\\",
"preg_match",
"(",
"'/^\\(?n == \\d+ \\|\\| n == \\d+\\)?$/'",
",",
"$",
"formula",
")",
")",
"{",
"return",
"\\",
"trim",
"(",
"\\",
"str_replace",
"(",
"[",
"' == '",
",",
"' || '",
"]",
",",
"[",
"' != '",
",",
"' && '",
"]",
",",
"$",
"formula",
")",
",",
"'()'",
")",
";",
"}",
"$",
"m",
"=",
"null",
";",
"if",
"(",
"\\",
"preg_match",
"(",
"'/^(n(?: % \\d+)?) == (\\d+) && (n(?: % \\d+)?) != (\\d+)$/'",
",",
"$",
"formula",
",",
"$",
"m",
")",
")",
"{",
"return",
"\"{$m[1]} != {$m[2]} || {$m[3]} == {$m[4]}\"",
";",
"}",
"switch",
"(",
"$",
"formula",
")",
"{",
"case",
"'(n == 1 || n == 2 || n == 3) || n % 10 != 4 && n % 10 != 6 && n % 10 != 9'",
":",
"return",
"'n != 1 && n != 2 && n != 3 && (n % 10 == 4 || n % 10 == 6 || n % 10 == 9)'",
";",
"case",
"'(n == 0 || n == 1) || n >= 11 && n <= 99'",
":",
"return",
"'n >= 2 && (n < 11 || n > 99)'",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unable to reverse the formula '$formula'\"",
")",
";",
"}"
] | Reverse a formula.
@param string $formula
@throws \InvalidArgumentException
@return string | [
"Reverse",
"a",
"formula",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Languages/Language.php#L318-L340 |
35,088 | hail-framework/framework | src/I18n/Gettext/Languages/Language.php | Language.getUSAsciiClone | public function getUSAsciiClone()
{
$clone = clone $this;
$clone->name = Strings::toAscii($clone->name);
$clone->formula = Strings::toAscii($clone->formula);
$clone->categories = [];
foreach ($this->categories as $category) {
$categoryClone = clone $category;
$categoryClone->examples = Strings::toAscii($categoryClone->examples);
$clone->categories[] = $categoryClone;
}
return $clone;
} | php | public function getUSAsciiClone()
{
$clone = clone $this;
$clone->name = Strings::toAscii($clone->name);
$clone->formula = Strings::toAscii($clone->formula);
$clone->categories = [];
foreach ($this->categories as $category) {
$categoryClone = clone $category;
$categoryClone->examples = Strings::toAscii($categoryClone->examples);
$clone->categories[] = $categoryClone;
}
return $clone;
} | [
"public",
"function",
"getUSAsciiClone",
"(",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"name",
"=",
"Strings",
"::",
"toAscii",
"(",
"$",
"clone",
"->",
"name",
")",
";",
"$",
"clone",
"->",
"formula",
"=",
"Strings",
"::",
"toAscii",
"(",
"$",
"clone",
"->",
"formula",
")",
";",
"$",
"clone",
"->",
"categories",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"categories",
"as",
"$",
"category",
")",
"{",
"$",
"categoryClone",
"=",
"clone",
"$",
"category",
";",
"$",
"categoryClone",
"->",
"examples",
"=",
"Strings",
"::",
"toAscii",
"(",
"$",
"categoryClone",
"->",
"examples",
")",
";",
"$",
"clone",
"->",
"categories",
"[",
"]",
"=",
"$",
"categoryClone",
";",
"}",
"return",
"$",
"clone",
";",
"}"
] | Returns a clone of this instance with all the strings to US-ASCII.
@return Language | [
"Returns",
"a",
"clone",
"of",
"this",
"instance",
"with",
"all",
"the",
"strings",
"to",
"US",
"-",
"ASCII",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/I18n/Gettext/Languages/Language.php#L365-L378 |
35,089 | hail-framework/framework | src/Cache/Simple/Riak.php | Riak.isExpired | private function isExpired(Riak\Object $object)
{
$metadataMap = $object->getMetadataMap();
return isset($metadataMap[self::EXPIRES_HEADER])
&& $metadataMap[self::EXPIRES_HEADER] < \time();
} | php | private function isExpired(Riak\Object $object)
{
$metadataMap = $object->getMetadataMap();
return isset($metadataMap[self::EXPIRES_HEADER])
&& $metadataMap[self::EXPIRES_HEADER] < \time();
} | [
"private",
"function",
"isExpired",
"(",
"Riak",
"\\",
"Object",
"$",
"object",
")",
"{",
"$",
"metadataMap",
"=",
"$",
"object",
"->",
"getMetadataMap",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"metadataMap",
"[",
"self",
"::",
"EXPIRES_HEADER",
"]",
")",
"&&",
"$",
"metadataMap",
"[",
"self",
"::",
"EXPIRES_HEADER",
"]",
"<",
"\\",
"time",
"(",
")",
";",
"}"
] | Check if a given Riak Object have expired.
@param \Riak\Object $object
@return bool | [
"Check",
"if",
"a",
"given",
"Riak",
"Object",
"have",
"expired",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Cache/Simple/Riak.php#L201-L207 |
35,090 | Becklyn/RadBundle | src/Model/SortableHelper.php | SortableHelper.getNextSortOrder | public function getNextSortOrder (array $where = []) : int
{
$queryBuild = $this->repository->createQueryBuilder("t")
->select("MAX(t.sortOrder)");
// apply the where clauses
if (0 < \count($completeWhere = $this->getCompleteWhere($where)))
{
$queryParts = [];
$index = 0;
foreach ($completeWhere as $key => $value)
{
if (null === $value)
{
$queryParts[] = "t.{$key} IS NULL";
}
else
{
$queryParts[] = "t.{$key} = :where_value_{$index}";
$queryBuild->setParameter("where_value_{$index}", $value);
}
++$index;
}
$queryBuild->where(\implode(" AND ", $queryParts));
}
$currentMaxValue = $queryBuild
->getQuery()
->getSingleScalarResult();
return null !== $currentMaxValue
? 1 + (int) $currentMaxValue
: 0;
} | php | public function getNextSortOrder (array $where = []) : int
{
$queryBuild = $this->repository->createQueryBuilder("t")
->select("MAX(t.sortOrder)");
// apply the where clauses
if (0 < \count($completeWhere = $this->getCompleteWhere($where)))
{
$queryParts = [];
$index = 0;
foreach ($completeWhere as $key => $value)
{
if (null === $value)
{
$queryParts[] = "t.{$key} IS NULL";
}
else
{
$queryParts[] = "t.{$key} = :where_value_{$index}";
$queryBuild->setParameter("where_value_{$index}", $value);
}
++$index;
}
$queryBuild->where(\implode(" AND ", $queryParts));
}
$currentMaxValue = $queryBuild
->getQuery()
->getSingleScalarResult();
return null !== $currentMaxValue
? 1 + (int) $currentMaxValue
: 0;
} | [
"public",
"function",
"getNextSortOrder",
"(",
"array",
"$",
"where",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"queryBuild",
"=",
"$",
"this",
"->",
"repository",
"->",
"createQueryBuilder",
"(",
"\"t\"",
")",
"->",
"select",
"(",
"\"MAX(t.sortOrder)\"",
")",
";",
"// apply the where clauses",
"if",
"(",
"0",
"<",
"\\",
"count",
"(",
"$",
"completeWhere",
"=",
"$",
"this",
"->",
"getCompleteWhere",
"(",
"$",
"where",
")",
")",
")",
"{",
"$",
"queryParts",
"=",
"[",
"]",
";",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"completeWhere",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"\"t.{$key} IS NULL\"",
";",
"}",
"else",
"{",
"$",
"queryParts",
"[",
"]",
"=",
"\"t.{$key} = :where_value_{$index}\"",
";",
"$",
"queryBuild",
"->",
"setParameter",
"(",
"\"where_value_{$index}\"",
",",
"$",
"value",
")",
";",
"}",
"++",
"$",
"index",
";",
"}",
"$",
"queryBuild",
"->",
"where",
"(",
"\\",
"implode",
"(",
"\" AND \"",
",",
"$",
"queryParts",
")",
")",
";",
"}",
"$",
"currentMaxValue",
"=",
"$",
"queryBuild",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"return",
"null",
"!==",
"$",
"currentMaxValue",
"?",
"1",
"+",
"(",
"int",
")",
"$",
"currentMaxValue",
":",
"0",
";",
"}"
] | Returns the next sort order value.
@param array $where
@return int | [
"Returns",
"the",
"next",
"sort",
"order",
"value",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Model/SortableHelper.php#L42-L78 |
35,091 | Becklyn/RadBundle | src/Model/SortableHelper.php | SortableHelper.prependEntities | public function prependEntities (array $prepended, array $where = []) : void
{
$all = $this->getAllEntities($where);
$index = 0;
// first prepend
foreach ($prepended as $prependedEntity)
{
$prependedEntity->setSortOrder($index);
++$index;
}
// then sort the rest
foreach ($all as $entity)
{
if (\in_array($entity, $prepended, true))
{
continue;
}
$entity->setSortOrder($index);
++$index;
}
} | php | public function prependEntities (array $prepended, array $where = []) : void
{
$all = $this->getAllEntities($where);
$index = 0;
// first prepend
foreach ($prepended as $prependedEntity)
{
$prependedEntity->setSortOrder($index);
++$index;
}
// then sort the rest
foreach ($all as $entity)
{
if (\in_array($entity, $prepended, true))
{
continue;
}
$entity->setSortOrder($index);
++$index;
}
} | [
"public",
"function",
"prependEntities",
"(",
"array",
"$",
"prepended",
",",
"array",
"$",
"where",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"all",
"=",
"$",
"this",
"->",
"getAllEntities",
"(",
"$",
"where",
")",
";",
"$",
"index",
"=",
"0",
";",
"// first prepend",
"foreach",
"(",
"$",
"prepended",
"as",
"$",
"prependedEntity",
")",
"{",
"$",
"prependedEntity",
"->",
"setSortOrder",
"(",
"$",
"index",
")",
";",
"++",
"$",
"index",
";",
"}",
"// then sort the rest",
"foreach",
"(",
"$",
"all",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"entity",
",",
"$",
"prepended",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"$",
"entity",
"->",
"setSortOrder",
"(",
"$",
"index",
")",
";",
"++",
"$",
"index",
";",
"}",
"}"
] | Prepends the given entities to the list.
@param SortableEntityInterface[] $prepended
@param array $where | [
"Prepends",
"the",
"given",
"entities",
"to",
"the",
"list",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Model/SortableHelper.php#L111-L134 |
35,092 | Becklyn/RadBundle | src/Model/SortableHelper.php | SortableHelper.applySorting | public function applySorting ($sortMapping, array $where = []) : bool
{
if (!\is_array($sortMapping) || empty($sortMapping))
{
// if value is not in correct format or an empty array.
return false;
}
$all = $this->getAllEntities($where);
// check sort values
$possibleSortValues = \range(0, \count($all) - 1);
if (!$this->arraysAreIdentical($possibleSortValues, \array_values($sortMapping)))
{
// the given sort values are wrong
return false;
}
// check item ids
$allIds = \array_map(function (SortableEntityInterface $entity) { return $entity->getId(); }, $all);
if (!$this->arraysAreIdentical($allIds, \array_keys($sortMapping)))
{
// the given item ids are wrong
return false;
}
foreach ($all as $entity)
{
$entity->setSortOrder($sortMapping[$entity->getId()]);
}
return true;
} | php | public function applySorting ($sortMapping, array $where = []) : bool
{
if (!\is_array($sortMapping) || empty($sortMapping))
{
// if value is not in correct format or an empty array.
return false;
}
$all = $this->getAllEntities($where);
// check sort values
$possibleSortValues = \range(0, \count($all) - 1);
if (!$this->arraysAreIdentical($possibleSortValues, \array_values($sortMapping)))
{
// the given sort values are wrong
return false;
}
// check item ids
$allIds = \array_map(function (SortableEntityInterface $entity) { return $entity->getId(); }, $all);
if (!$this->arraysAreIdentical($allIds, \array_keys($sortMapping)))
{
// the given item ids are wrong
return false;
}
foreach ($all as $entity)
{
$entity->setSortOrder($sortMapping[$entity->getId()]);
}
return true;
} | [
"public",
"function",
"applySorting",
"(",
"$",
"sortMapping",
",",
"array",
"$",
"where",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"sortMapping",
")",
"||",
"empty",
"(",
"$",
"sortMapping",
")",
")",
"{",
"// if value is not in correct format or an empty array.",
"return",
"false",
";",
"}",
"$",
"all",
"=",
"$",
"this",
"->",
"getAllEntities",
"(",
"$",
"where",
")",
";",
"// check sort values",
"$",
"possibleSortValues",
"=",
"\\",
"range",
"(",
"0",
",",
"\\",
"count",
"(",
"$",
"all",
")",
"-",
"1",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"arraysAreIdentical",
"(",
"$",
"possibleSortValues",
",",
"\\",
"array_values",
"(",
"$",
"sortMapping",
")",
")",
")",
"{",
"// the given sort values are wrong",
"return",
"false",
";",
"}",
"// check item ids",
"$",
"allIds",
"=",
"\\",
"array_map",
"(",
"function",
"(",
"SortableEntityInterface",
"$",
"entity",
")",
"{",
"return",
"$",
"entity",
"->",
"getId",
"(",
")",
";",
"}",
",",
"$",
"all",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"arraysAreIdentical",
"(",
"$",
"allIds",
",",
"\\",
"array_keys",
"(",
"$",
"sortMapping",
")",
")",
")",
"{",
"// the given item ids are wrong",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"all",
"as",
"$",
"entity",
")",
"{",
"$",
"entity",
"->",
"setSortOrder",
"(",
"$",
"sortMapping",
"[",
"$",
"entity",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Applies the sorting.
Sort Mapping:
entity-id => position (0-based)
@param array $sortMapping
@param array $where
@return bool | [
"Applies",
"the",
"sorting",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Model/SortableHelper.php#L149-L183 |
35,093 | Becklyn/RadBundle | src/Model/SortableHelper.php | SortableHelper.arraysAreIdentical | private function arraysAreIdentical (array $array1, array $array2) : bool
{
return (0 === \count(\array_diff($array1, $array2)))
&& (0 === \count(\array_diff($array2, $array1)));
} | php | private function arraysAreIdentical (array $array1, array $array2) : bool
{
return (0 === \count(\array_diff($array1, $array2)))
&& (0 === \count(\array_diff($array2, $array1)));
} | [
"private",
"function",
"arraysAreIdentical",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
")",
":",
"bool",
"{",
"return",
"(",
"0",
"===",
"\\",
"count",
"(",
"\\",
"array_diff",
"(",
"$",
"array1",
",",
"$",
"array2",
")",
")",
")",
"&&",
"(",
"0",
"===",
"\\",
"count",
"(",
"\\",
"array_diff",
"(",
"$",
"array2",
",",
"$",
"array1",
")",
")",
")",
";",
"}"
] | Returns whether two arrays are identical.
@param array $array1
@param array $array2
@return bool | [
"Returns",
"whether",
"two",
"arrays",
"are",
"identical",
"."
] | 34d5887e13f5a4018843b77dcbefc2eb2f3169f4 | https://github.com/Becklyn/RadBundle/blob/34d5887e13f5a4018843b77dcbefc2eb2f3169f4/src/Model/SortableHelper.php#L209-L213 |
35,094 | hail-framework/framework | src/Console/Option/OptionPrinter.php | OptionPrinter.renderOption | public function renderOption(Option $opt): string
{
$columns = [];
if ($opt->short) {
$columns[] = $this->formatter->format('-' . $opt->short, 'strong_white')
. $this->renderOptionValueHint($opt, false);
}
if ($opt->long) {
$columns[] = $this->formatter->format('--' . $opt->long, 'strong_white')
. $this->renderOptionValueHint($opt, true);
}
return implode(', ', $columns);
} | php | public function renderOption(Option $opt): string
{
$columns = [];
if ($opt->short) {
$columns[] = $this->formatter->format('-' . $opt->short, 'strong_white')
. $this->renderOptionValueHint($opt, false);
}
if ($opt->long) {
$columns[] = $this->formatter->format('--' . $opt->long, 'strong_white')
. $this->renderOptionValueHint($opt, true);
}
return implode(', ', $columns);
} | [
"public",
"function",
"renderOption",
"(",
"Option",
"$",
"opt",
")",
":",
"string",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"opt",
"->",
"short",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"this",
"->",
"formatter",
"->",
"format",
"(",
"'-'",
".",
"$",
"opt",
"->",
"short",
",",
"'strong_white'",
")",
".",
"$",
"this",
"->",
"renderOptionValueHint",
"(",
"$",
"opt",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"opt",
"->",
"long",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"this",
"->",
"formatter",
"->",
"format",
"(",
"'--'",
".",
"$",
"opt",
"->",
"long",
",",
"'strong_white'",
")",
".",
"$",
"this",
"->",
"renderOptionValueHint",
"(",
"$",
"opt",
",",
"true",
")",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"columns",
")",
";",
"}"
] | Render readable spec
@param Option $opt
@return string | [
"Render",
"readable",
"spec"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Console/Option/OptionPrinter.php#L40-L53 |
35,095 | hail-framework/framework | src/Image/ImageManager.php | ImageManager.make | public function make($data)
{
$driver = $this->instance ?? $this->createDriver();
return $driver->init($data);
} | php | public function make($data)
{
$driver = $this->instance ?? $this->createDriver();
return $driver->init($data);
} | [
"public",
"function",
"make",
"(",
"$",
"data",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"instance",
"??",
"$",
"this",
"->",
"createDriver",
"(",
")",
";",
"return",
"$",
"driver",
"->",
"init",
"(",
"$",
"data",
")",
";",
"}"
] | Initiates an Image instance from different input types
@param mixed $data
@return \Hail\Image\Image | [
"Initiates",
"an",
"Image",
"instance",
"from",
"different",
"input",
"types"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/ImageManager.php#L81-L86 |
35,096 | hail-framework/framework | src/Image/ImageManager.php | ImageManager.cache | public function cache(Closure $callback, $lifetime = null, $returnObj = false)
{
if ($this->imageCache === null) {
// create imagecache
$this->imageCache = new ImageCache($this);
}
// run callback
if (\is_callable($callback)) {
$callback($this->imageCache);
}
return $this->imageCache->get($lifetime, $returnObj);
} | php | public function cache(Closure $callback, $lifetime = null, $returnObj = false)
{
if ($this->imageCache === null) {
// create imagecache
$this->imageCache = new ImageCache($this);
}
// run callback
if (\is_callable($callback)) {
$callback($this->imageCache);
}
return $this->imageCache->get($lifetime, $returnObj);
} | [
"public",
"function",
"cache",
"(",
"Closure",
"$",
"callback",
",",
"$",
"lifetime",
"=",
"null",
",",
"$",
"returnObj",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageCache",
"===",
"null",
")",
"{",
"// create imagecache",
"$",
"this",
"->",
"imageCache",
"=",
"new",
"ImageCache",
"(",
"$",
"this",
")",
";",
"}",
"// run callback",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
"->",
"imageCache",
")",
";",
"}",
"return",
"$",
"this",
"->",
"imageCache",
"->",
"get",
"(",
"$",
"lifetime",
",",
"$",
"returnObj",
")",
";",
"}"
] | Create new cached image and run callback
@param Closure $callback
@param int $lifetime
@param boolean $returnObj
@return Image
@throws MissingDependencyException | [
"Create",
"new",
"cached",
"image",
"and",
"run",
"callback"
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Image/ImageManager.php#L114-L127 |
35,097 | hail-framework/framework | src/Database/Migration/Generator.php | Generator.getSchemaFileData | public function getSchemaFileData($settings)
{
$schemaFile = $this->getSchemaFilename($settings);
$fileExt = pathinfo($schemaFile, PATHINFO_EXTENSION);
if (!file_exists($schemaFile)) {
return [];
}
if ($fileExt === 'php') {
$data = $this->read($schemaFile);
} elseif ($fileExt === 'json') {
$content = file_get_contents($schemaFile);
$data = json_decode($content, true);
} else {
throw new Exception(sprintf('Invalid schema file extension: %s', $fileExt));
}
return $data;
} | php | public function getSchemaFileData($settings)
{
$schemaFile = $this->getSchemaFilename($settings);
$fileExt = pathinfo($schemaFile, PATHINFO_EXTENSION);
if (!file_exists($schemaFile)) {
return [];
}
if ($fileExt === 'php') {
$data = $this->read($schemaFile);
} elseif ($fileExt === 'json') {
$content = file_get_contents($schemaFile);
$data = json_decode($content, true);
} else {
throw new Exception(sprintf('Invalid schema file extension: %s', $fileExt));
}
return $data;
} | [
"public",
"function",
"getSchemaFileData",
"(",
"$",
"settings",
")",
"{",
"$",
"schemaFile",
"=",
"$",
"this",
"->",
"getSchemaFilename",
"(",
"$",
"settings",
")",
";",
"$",
"fileExt",
"=",
"pathinfo",
"(",
"$",
"schemaFile",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"schemaFile",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"fileExt",
"===",
"'php'",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"schemaFile",
")",
";",
"}",
"elseif",
"(",
"$",
"fileExt",
"===",
"'json'",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"schemaFile",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Invalid schema file extension: %s'",
",",
"$",
"fileExt",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Get schema data.
@param array $settings
@return array
@throws Exception | [
"Get",
"schema",
"data",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Generator.php#L190-L209 |
35,098 | hail-framework/framework | src/Database/Migration/Generator.php | Generator.getSchemaFilename | public function getSchemaFilename($settings)
{
// Default
$schemaFile = sprintf('%s/%s', getcwd(), 'schema.php');
if (!empty($settings['schema_file'])) {
$schemaFile = $settings['schema_file'];
}
return $schemaFile;
} | php | public function getSchemaFilename($settings)
{
// Default
$schemaFile = sprintf('%s/%s', getcwd(), 'schema.php');
if (!empty($settings['schema_file'])) {
$schemaFile = $settings['schema_file'];
}
return $schemaFile;
} | [
"public",
"function",
"getSchemaFilename",
"(",
"$",
"settings",
")",
"{",
"// Default",
"$",
"schemaFile",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"getcwd",
"(",
")",
",",
"'schema.php'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
"[",
"'schema_file'",
"]",
")",
")",
"{",
"$",
"schemaFile",
"=",
"$",
"settings",
"[",
"'schema_file'",
"]",
";",
"}",
"return",
"$",
"schemaFile",
";",
"}"
] | Generate schema filename.
@param array $settings
@return string Schema filename | [
"Generate",
"schema",
"filename",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Generator.php#L218-L227 |
35,099 | hail-framework/framework | src/Database/Migration/Generator.php | Generator.compareSchema | public function compareSchema($newSchema, $oldSchema)
{
$this->getOutput()->writeln('Comparing schema file to the database.');
// To add or modify
$result = $this->diff($newSchema, $oldSchema);
// To remove
$result2 = $this->diff($oldSchema, $newSchema);
return [$result, $result2];
} | php | public function compareSchema($newSchema, $oldSchema)
{
$this->getOutput()->writeln('Comparing schema file to the database.');
// To add or modify
$result = $this->diff($newSchema, $oldSchema);
// To remove
$result2 = $this->diff($oldSchema, $newSchema);
return [$result, $result2];
} | [
"public",
"function",
"compareSchema",
"(",
"$",
"newSchema",
",",
"$",
"oldSchema",
")",
"{",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"'Comparing schema file to the database.'",
")",
";",
"// To add or modify",
"$",
"result",
"=",
"$",
"this",
"->",
"diff",
"(",
"$",
"newSchema",
",",
"$",
"oldSchema",
")",
";",
"// To remove",
"$",
"result2",
"=",
"$",
"this",
"->",
"diff",
"(",
"$",
"oldSchema",
",",
"$",
"newSchema",
")",
";",
"return",
"[",
"$",
"result",
",",
"$",
"result2",
"]",
";",
"}"
] | Compare database schemas.
@param array $newSchema
@param array $oldSchema
@return array Difference | [
"Compare",
"database",
"schemas",
"."
] | d419e6c098d29ef9b62192b74050e51985b94f90 | https://github.com/hail-framework/framework/blob/d419e6c098d29ef9b62192b74050e51985b94f90/src/Database/Migration/Generator.php#L249-L260 |
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.