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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,400
|
leedave/html
|
src/Html5.php
|
Html5.button
|
public static function button(
string $label,
string $type = "submit",
string $onclick = null,
array $attributes = []
) : string
{
$buttonPreAttributes = [
"type" => $type,
];
if ($onclick) {
$buttonPreAttributes["onclick"] = $onclick;
}
$buttonAttributes = array_merge($buttonPreAttributes, $attributes);
return self::tag("button", $label, $buttonAttributes);
}
|
php
|
public static function button(
string $label,
string $type = "submit",
string $onclick = null,
array $attributes = []
) : string
{
$buttonPreAttributes = [
"type" => $type,
];
if ($onclick) {
$buttonPreAttributes["onclick"] = $onclick;
}
$buttonAttributes = array_merge($buttonPreAttributes, $attributes);
return self::tag("button", $label, $buttonAttributes);
}
|
[
"public",
"static",
"function",
"button",
"(",
"string",
"$",
"label",
",",
"string",
"$",
"type",
"=",
"\"submit\"",
",",
"string",
"$",
"onclick",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"buttonPreAttributes",
"=",
"[",
"\"type\"",
"=>",
"$",
"type",
",",
"]",
";",
"if",
"(",
"$",
"onclick",
")",
"{",
"$",
"buttonPreAttributes",
"[",
"\"onclick\"",
"]",
"=",
"$",
"onclick",
";",
"}",
"$",
"buttonAttributes",
"=",
"array_merge",
"(",
"$",
"buttonPreAttributes",
",",
"$",
"attributes",
")",
";",
"return",
"self",
"::",
"tag",
"(",
"\"button\"",
",",
"$",
"label",
",",
"$",
"buttonAttributes",
")",
";",
"}"
] |
Create a Button Tag
@param string $label Button Content
@param string $type type attribute
@param string $onclick onclick attribute
@param array $attributes further attributes
@return string HTML Code
|
[
"Create",
"a",
"Button",
"Tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L207-L224
|
235,401
|
leedave/html
|
src/Html5.php
|
Html5.input
|
public static function input(
string $name,
string $type = "text",
string $value = null,
array $attributes = []
) : string
{
$preAttributesInput = [
"name" => $name,
"type" => $type,
];
if (!is_null($value)) {
$preAttributesInput["value"] = $value;
}
$attributesInput = array_merge($preAttributesInput, $attributes);
return self::tag("input", "", $attributesInput);
}
|
php
|
public static function input(
string $name,
string $type = "text",
string $value = null,
array $attributes = []
) : string
{
$preAttributesInput = [
"name" => $name,
"type" => $type,
];
if (!is_null($value)) {
$preAttributesInput["value"] = $value;
}
$attributesInput = array_merge($preAttributesInput, $attributes);
return self::tag("input", "", $attributesInput);
}
|
[
"public",
"static",
"function",
"input",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
"=",
"\"text\"",
",",
"string",
"$",
"value",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"preAttributesInput",
"=",
"[",
"\"name\"",
"=>",
"$",
"name",
",",
"\"type\"",
"=>",
"$",
"type",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"preAttributesInput",
"[",
"\"value\"",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"attributesInput",
"=",
"array_merge",
"(",
"$",
"preAttributesInput",
",",
"$",
"attributes",
")",
";",
"return",
"self",
"::",
"tag",
"(",
"\"input\"",
",",
"\"\"",
",",
"$",
"attributesInput",
")",
";",
"}"
] |
Create an input tag
@param string $name name attribute (always needed)
@param string $type type attribute (always needed)
@param string $value pre set value
@param array $attributes further attributes
@return string HTML Code
|
[
"Create",
"an",
"input",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L770-L786
|
235,402
|
leedave/html
|
src/Html5.php
|
Html5.label
|
public static function label(
string $label,
string $for,
array $attributes = []
) : string
{
$preAttributesLabel = [
"for" => $for,
];
$attributesLabel = array_merge($preAttributesLabel, $attributes);
return self::tag("label", $label, $attributesLabel);
}
|
php
|
public static function label(
string $label,
string $for,
array $attributes = []
) : string
{
$preAttributesLabel = [
"for" => $for,
];
$attributesLabel = array_merge($preAttributesLabel, $attributes);
return self::tag("label", $label, $attributesLabel);
}
|
[
"public",
"static",
"function",
"label",
"(",
"string",
"$",
"label",
",",
"string",
"$",
"for",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"preAttributesLabel",
"=",
"[",
"\"for\"",
"=>",
"$",
"for",
",",
"]",
";",
"$",
"attributesLabel",
"=",
"array_merge",
"(",
"$",
"preAttributesLabel",
",",
"$",
"attributes",
")",
";",
"return",
"self",
"::",
"tag",
"(",
"\"label\"",
",",
"$",
"label",
",",
"$",
"attributesLabel",
")",
";",
"}"
] |
Creates label Tag
@param string $label content of tag
@param string $for for attribute (always needed)
@param array $attributes further attributes
@return string HTML Code
|
[
"Creates",
"label",
"Tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L824-L835
|
235,403
|
leedave/html
|
src/Html5.php
|
Html5.span
|
public static function span(
string $content = null,
array $attributes = []
) : string
{
return self::tag("span", $content, $attributes);
}
|
php
|
public static function span(
string $content = null,
array $attributes = []
) : string
{
return self::tag("span", $content, $attributes);
}
|
[
"public",
"static",
"function",
"span",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"span\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Create span tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"Create",
"span",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1283-L1289
|
235,404
|
leedave/html
|
src/Html5.php
|
Html5.table
|
public static function table(
string $content = null,
array $attributes = []
) : string
{
return self::tag("table", $content, $attributes);
}
|
php
|
public static function table(
string $content = null,
array $attributes = []
) : string
{
return self::tag("table", $content, $attributes);
}
|
[
"public",
"static",
"function",
"table",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"table\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Create table tag
@param string $content content
@param array $attributes attributes
@return string HTML Code
|
[
"Create",
"table",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1368-L1374
|
235,405
|
leedave/html
|
src/Html5.php
|
Html5.tbody
|
public static function tbody(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tbody", $content, $attributes);
}
|
php
|
public static function tbody(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tbody", $content, $attributes);
}
|
[
"public",
"static",
"function",
"tbody",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"tbody\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
create tbody tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"create",
"tbody",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1383-L1389
|
235,406
|
leedave/html
|
src/Html5.php
|
Html5.td
|
public static function td(
string $content = null,
array $attributes = []
) : string
{
return self::tag("td", $content, $attributes);
}
|
php
|
public static function td(
string $content = null,
array $attributes = []
) : string
{
return self::tag("td", $content, $attributes);
}
|
[
"public",
"static",
"function",
"td",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"td\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
create td tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"create",
"td",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1398-L1404
|
235,407
|
leedave/html
|
src/Html5.php
|
Html5.th
|
public static function th(
string $content = null,
array $attributes = []
) : string
{
return self::tag("th", $content, $attributes);
}
|
php
|
public static function th(
string $content = null,
array $attributes = []
) : string
{
return self::tag("th", $content, $attributes);
}
|
[
"public",
"static",
"function",
"th",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"th\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Create th tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"Create",
"th",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1441-L1447
|
235,408
|
leedave/html
|
src/Html5.php
|
Html5.thead
|
public static function thead(
string $content = null,
array $attributes = []
) : string
{
return self::tag("thead", $content, $attributes);
}
|
php
|
public static function thead(
string $content = null,
array $attributes = []
) : string
{
return self::tag("thead", $content, $attributes);
}
|
[
"public",
"static",
"function",
"thead",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"thead\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Create thead tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"Create",
"thead",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1456-L1462
|
235,409
|
leedave/html
|
src/Html5.php
|
Html5.tr
|
public static function tr(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tr", $content, $attributes);
}
|
php
|
public static function tr(
string $content = null,
array $attributes = []
) : string
{
return self::tag("tr", $content, $attributes);
}
|
[
"public",
"static",
"function",
"tr",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"tr\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Create tr tag
@param string $content content
@param array $attributes further attributes
@return HTML Code
|
[
"Create",
"tr",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1497-L1503
|
235,410
|
leedave/html
|
src/Html5.php
|
Html5.ul
|
public static function ul(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ul", $content, $attributes);
}
|
php
|
public static function ul(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ul", $content, $attributes);
}
|
[
"public",
"static",
"function",
"ul",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"ul\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Render unordered list tag
@param string $content
@param array $attributes
@return string
|
[
"Render",
"unordered",
"list",
"tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1539-L1545
|
235,411
|
leedave/html
|
src/Html5.php
|
Html5.ol
|
public static function ol(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ol", $content, $attributes);
}
|
php
|
public static function ol(
string $content = null,
array $attributes = []
) : string
{
return self::tag("ol", $content, $attributes);
}
|
[
"public",
"static",
"function",
"ol",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"ol\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Render Ordered List
@param string $content
@param array $attributes
@return string
|
[
"Render",
"Ordered",
"List"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1581-L1587
|
235,412
|
leedave/html
|
src/Html5.php
|
Html5.li
|
public static function li(
string $content = null,
array $attributes = []
) : string
{
return self::tag("li", $content, $attributes);
}
|
php
|
public static function li(
string $content = null,
array $attributes = []
) : string
{
return self::tag("li", $content, $attributes);
}
|
[
"public",
"static",
"function",
"li",
"(",
"string",
"$",
"content",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"self",
"::",
"tag",
"(",
"\"li\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] |
Render List Item Tag
@param string $content
@param array $attributes
@return string
|
[
"Render",
"List",
"Item",
"Tag"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1595-L1601
|
235,413
|
leedave/html
|
src/Html5.php
|
Html5.renderTable
|
public static function renderTable(
array $head = [],
array $body = [],
array $attributes = []
) : string
{
$strHead = "";
$strBody = "";
foreach ($head as $thRow) {
$strHead .= self::renderTableHeaderRow($thRow);
}
if ($strHead != "") {
$strHead = self::thead($strHead);
}
foreach ($body as $tr) {
$strBody .= self::renderTableRow($tr);
}
if ($strBody != "") {
$strBody = self::tbody($strBody);
}
return self::tag("table", $strHead.$strBody, $attributes);
}
|
php
|
public static function renderTable(
array $head = [],
array $body = [],
array $attributes = []
) : string
{
$strHead = "";
$strBody = "";
foreach ($head as $thRow) {
$strHead .= self::renderTableHeaderRow($thRow);
}
if ($strHead != "") {
$strHead = self::thead($strHead);
}
foreach ($body as $tr) {
$strBody .= self::renderTableRow($tr);
}
if ($strBody != "") {
$strBody = self::tbody($strBody);
}
return self::tag("table", $strHead.$strBody, $attributes);
}
|
[
"public",
"static",
"function",
"renderTable",
"(",
"array",
"$",
"head",
"=",
"[",
"]",
",",
"array",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"strHead",
"=",
"\"\"",
";",
"$",
"strBody",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"head",
"as",
"$",
"thRow",
")",
"{",
"$",
"strHead",
".=",
"self",
"::",
"renderTableHeaderRow",
"(",
"$",
"thRow",
")",
";",
"}",
"if",
"(",
"$",
"strHead",
"!=",
"\"\"",
")",
"{",
"$",
"strHead",
"=",
"self",
"::",
"thead",
"(",
"$",
"strHead",
")",
";",
"}",
"foreach",
"(",
"$",
"body",
"as",
"$",
"tr",
")",
"{",
"$",
"strBody",
".=",
"self",
"::",
"renderTableRow",
"(",
"$",
"tr",
")",
";",
"}",
"if",
"(",
"$",
"strBody",
"!=",
"\"\"",
")",
"{",
"$",
"strBody",
"=",
"self",
"::",
"tbody",
"(",
"$",
"strBody",
")",
";",
"}",
"return",
"self",
"::",
"tag",
"(",
"\"table\"",
",",
"$",
"strHead",
".",
"$",
"strBody",
",",
"$",
"attributes",
")",
";",
"}"
] |
Put all elements together to form a standard table
@param array $head two dimensional rows and cells (no keys)
@param array $body two dimensional rows and cells (no keys)
@param array $attributes
@return string Compiled HTML Table
|
[
"Put",
"all",
"elements",
"together",
"to",
"form",
"a",
"standard",
"table"
] |
f0780b37c34defbbd92d29f4e1a41ce875b4d300
|
https://github.com/leedave/html/blob/f0780b37c34defbbd92d29f4e1a41ce875b4d300/src/Html5.php#L1656-L1680
|
235,414
|
AnonymPHP/Anonym-Library
|
src/Anonym/Application/RegisterProviders.php
|
RegisterProviders.register
|
public function register()
{
$app = $this->app;
foreach ($app->getProviders() as $provider) {
$provider = new $provider($app);
if (!$provider instanceof ServiceProvider) {
throw new ProviderException(sprintf('Your %s proiver must be a instance of ServiceProvider', get_class($provider)));
}
$provider->register();
$app = $provider->app();
}
}
|
php
|
public function register()
{
$app = $this->app;
foreach ($app->getProviders() as $provider) {
$provider = new $provider($app);
if (!$provider instanceof ServiceProvider) {
throw new ProviderException(sprintf('Your %s proiver must be a instance of ServiceProvider', get_class($provider)));
}
$provider->register();
$app = $provider->app();
}
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"foreach",
"(",
"$",
"app",
"->",
"getProviders",
"(",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"provider",
"=",
"new",
"$",
"provider",
"(",
"$",
"app",
")",
";",
"if",
"(",
"!",
"$",
"provider",
"instanceof",
"ServiceProvider",
")",
"{",
"throw",
"new",
"ProviderException",
"(",
"sprintf",
"(",
"'Your %s proiver must be a instance of ServiceProvider'",
",",
"get_class",
"(",
"$",
"provider",
")",
")",
")",
";",
"}",
"$",
"provider",
"->",
"register",
"(",
")",
";",
"$",
"app",
"=",
"$",
"provider",
"->",
"app",
"(",
")",
";",
"}",
"}"
] |
register the providers
@throws ProviderException
|
[
"register",
"the",
"providers"
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Application/RegisterProviders.php#L43-L61
|
235,415
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Driver.php
|
WebDriver_Driver.parseResponse
|
protected function parseResponse($rawResponse, $infoList, $command)
{
$httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
$messageList = [
"HTTP Response Status Code: {$httpStatusCode}",
WebDriver_Exception_Protocol::getCommandDescription($command)
];
switch ($httpStatusCode) {
case 0:
$message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
throw new WebDriver_NoSeleniumException($message);
case WebDriver_Http::SUCCESS_OK:
$decodedJsonList = json_decode($rawResponse, true);
if ($decodedJsonList === null) {
$errorList = ["Can't decode response JSON:", json_last_error_msg()];
$message = $this->buildResponseErrorMessage($errorList, $messageList);
throw new WebDriver_Exception_Protocol($message);
}
if (isset($decodedJsonList['status']) &&
!WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
throw WebDriver_Exception_FailedCommand::factory(
$command,
$infoList,
$rawResponse,
$decodedJsonList
);
}
return $decodedJsonList;
default:
if (WebDriver_Http::isError($httpStatusCode)) {
throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
}
$errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
$message = $this->buildResponseErrorMessage($errorMessage, $messageList);
throw new WebDriver_Exception($message);
}
}
|
php
|
protected function parseResponse($rawResponse, $infoList, $command)
{
$httpStatusCode = isset($infoList['http_code']) ? $infoList['http_code'] : 0;
$messageList = [
"HTTP Response Status Code: {$httpStatusCode}",
WebDriver_Exception_Protocol::getCommandDescription($command)
];
switch ($httpStatusCode) {
case 0:
$message = $this->buildResponseErrorMessage("No response or broken.", $messageList);
throw new WebDriver_NoSeleniumException($message);
case WebDriver_Http::SUCCESS_OK:
$decodedJsonList = json_decode($rawResponse, true);
if ($decodedJsonList === null) {
$errorList = ["Can't decode response JSON:", json_last_error_msg()];
$message = $this->buildResponseErrorMessage($errorList, $messageList);
throw new WebDriver_Exception_Protocol($message);
}
if (isset($decodedJsonList['status']) &&
!WebDriver_Exception_FailedCommand::isOk($decodedJsonList['status'])) {
throw WebDriver_Exception_FailedCommand::factory(
$command,
$infoList,
$rawResponse,
$decodedJsonList
);
}
return $decodedJsonList;
default:
if (WebDriver_Http::isError($httpStatusCode)) {
throw WebDriver_Exception_Protocol::factory($command, $infoList, $rawResponse);
}
$errorMessage = "Unexpected HTTP status code: {$httpStatusCode}";
$message = $this->buildResponseErrorMessage($errorMessage, $messageList);
throw new WebDriver_Exception($message);
}
}
|
[
"protected",
"function",
"parseResponse",
"(",
"$",
"rawResponse",
",",
"$",
"infoList",
",",
"$",
"command",
")",
"{",
"$",
"httpStatusCode",
"=",
"isset",
"(",
"$",
"infoList",
"[",
"'http_code'",
"]",
")",
"?",
"$",
"infoList",
"[",
"'http_code'",
"]",
":",
"0",
";",
"$",
"messageList",
"=",
"[",
"\"HTTP Response Status Code: {$httpStatusCode}\"",
",",
"WebDriver_Exception_Protocol",
"::",
"getCommandDescription",
"(",
"$",
"command",
")",
"]",
";",
"switch",
"(",
"$",
"httpStatusCode",
")",
"{",
"case",
"0",
":",
"$",
"message",
"=",
"$",
"this",
"->",
"buildResponseErrorMessage",
"(",
"\"No response or broken.\"",
",",
"$",
"messageList",
")",
";",
"throw",
"new",
"WebDriver_NoSeleniumException",
"(",
"$",
"message",
")",
";",
"case",
"WebDriver_Http",
"::",
"SUCCESS_OK",
":",
"$",
"decodedJsonList",
"=",
"json_decode",
"(",
"$",
"rawResponse",
",",
"true",
")",
";",
"if",
"(",
"$",
"decodedJsonList",
"===",
"null",
")",
"{",
"$",
"errorList",
"=",
"[",
"\"Can't decode response JSON:\"",
",",
"json_last_error_msg",
"(",
")",
"]",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"buildResponseErrorMessage",
"(",
"$",
"errorList",
",",
"$",
"messageList",
")",
";",
"throw",
"new",
"WebDriver_Exception_Protocol",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"decodedJsonList",
"[",
"'status'",
"]",
")",
"&&",
"!",
"WebDriver_Exception_FailedCommand",
"::",
"isOk",
"(",
"$",
"decodedJsonList",
"[",
"'status'",
"]",
")",
")",
"{",
"throw",
"WebDriver_Exception_FailedCommand",
"::",
"factory",
"(",
"$",
"command",
",",
"$",
"infoList",
",",
"$",
"rawResponse",
",",
"$",
"decodedJsonList",
")",
";",
"}",
"return",
"$",
"decodedJsonList",
";",
"default",
":",
"if",
"(",
"WebDriver_Http",
"::",
"isError",
"(",
"$",
"httpStatusCode",
")",
")",
"{",
"throw",
"WebDriver_Exception_Protocol",
"::",
"factory",
"(",
"$",
"command",
",",
"$",
"infoList",
",",
"$",
"rawResponse",
")",
";",
"}",
"$",
"errorMessage",
"=",
"\"Unexpected HTTP status code: {$httpStatusCode}\"",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"buildResponseErrorMessage",
"(",
"$",
"errorMessage",
",",
"$",
"messageList",
")",
";",
"throw",
"new",
"WebDriver_Exception",
"(",
"$",
"message",
")",
";",
"}",
"}"
] |
Returns parsed response.
@param string $rawResponse
@param array $infoList
@param WebDriver_Command $command
@throws WebDriver_Exception
@throws WebDriver_NoSeleniumException
@return array
|
[
"Returns",
"parsed",
"response",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Driver.php#L249-L285
|
235,416
|
ShortCirquit/LinkoScopeApi
|
ComLinkoScope.php
|
ComLinkoScope.updateFromPostCache
|
private function updateFromPostCache(Comment $comment, $c)
{
if ($comment->postId == null)
{
return;
}
if ($this->postCache == null || $this->postCache['ID'] != $comment->postId)
{
$this->postCache = $this->adminApi->getPost($comment->postId);
}
$comment->date = $this->getMetaKeyValue($this->postCache, "linkoscope_created_$comment->id") ?: $c['date'];
$comment->score =
$this->getMetaKeyValue($this->postCache, "linkoscope_score_$comment->id") ?: strtotime($c['date']);
}
|
php
|
private function updateFromPostCache(Comment $comment, $c)
{
if ($comment->postId == null)
{
return;
}
if ($this->postCache == null || $this->postCache['ID'] != $comment->postId)
{
$this->postCache = $this->adminApi->getPost($comment->postId);
}
$comment->date = $this->getMetaKeyValue($this->postCache, "linkoscope_created_$comment->id") ?: $c['date'];
$comment->score =
$this->getMetaKeyValue($this->postCache, "linkoscope_score_$comment->id") ?: strtotime($c['date']);
}
|
[
"private",
"function",
"updateFromPostCache",
"(",
"Comment",
"$",
"comment",
",",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"comment",
"->",
"postId",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"postCache",
"==",
"null",
"||",
"$",
"this",
"->",
"postCache",
"[",
"'ID'",
"]",
"!=",
"$",
"comment",
"->",
"postId",
")",
"{",
"$",
"this",
"->",
"postCache",
"=",
"$",
"this",
"->",
"adminApi",
"->",
"getPost",
"(",
"$",
"comment",
"->",
"postId",
")",
";",
"}",
"$",
"comment",
"->",
"date",
"=",
"$",
"this",
"->",
"getMetaKeyValue",
"(",
"$",
"this",
"->",
"postCache",
",",
"\"linkoscope_created_$comment->id\"",
")",
"?",
":",
"$",
"c",
"[",
"'date'",
"]",
";",
"$",
"comment",
"->",
"score",
"=",
"$",
"this",
"->",
"getMetaKeyValue",
"(",
"$",
"this",
"->",
"postCache",
",",
"\"linkoscope_score_$comment->id\"",
")",
"?",
":",
"strtotime",
"(",
"$",
"c",
"[",
"'date'",
"]",
")",
";",
"}"
] |
fetch associated post if it hasn't been fetched before, or if the incorrect post is cached.
|
[
"fetch",
"associated",
"post",
"if",
"it",
"hasn",
"t",
"been",
"fetched",
"before",
"or",
"if",
"the",
"incorrect",
"post",
"is",
"cached",
"."
] |
a25f2233a67eeb916cddb6ff80ba3297e4597d13
|
https://github.com/ShortCirquit/LinkoScopeApi/blob/a25f2233a67eeb916cddb6ff80ba3297e4597d13/ComLinkoScope.php#L342-L356
|
235,417
|
osflab/view
|
Helper/Tags/Link.php
|
Link.appendStylesheet
|
public function appendStylesheet($href, $media = null, array $attributes = [], $priority = false)
{
static $counter = 0;
$attributes['rel'] = 'stylesheet';
$attributes['href'] = $href;
//$attributes['type'] = 'text/css';
$media && $attributes['media'] = $media;
$this->links[$priority == 'high' ? $counter + 1000 : $counter] = Html::buildHtmlElement('link', $attributes);
$counter++;
return $this;
}
|
php
|
public function appendStylesheet($href, $media = null, array $attributes = [], $priority = false)
{
static $counter = 0;
$attributes['rel'] = 'stylesheet';
$attributes['href'] = $href;
//$attributes['type'] = 'text/css';
$media && $attributes['media'] = $media;
$this->links[$priority == 'high' ? $counter + 1000 : $counter] = Html::buildHtmlElement('link', $attributes);
$counter++;
return $this;
}
|
[
"public",
"function",
"appendStylesheet",
"(",
"$",
"href",
",",
"$",
"media",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"priority",
"=",
"false",
")",
"{",
"static",
"$",
"counter",
"=",
"0",
";",
"$",
"attributes",
"[",
"'rel'",
"]",
"=",
"'stylesheet'",
";",
"$",
"attributes",
"[",
"'href'",
"]",
"=",
"$",
"href",
";",
"//$attributes['type'] = 'text/css';",
"$",
"media",
"&&",
"$",
"attributes",
"[",
"'media'",
"]",
"=",
"$",
"media",
";",
"$",
"this",
"->",
"links",
"[",
"$",
"priority",
"==",
"'high'",
"?",
"$",
"counter",
"+",
"1000",
":",
"$",
"counter",
"]",
"=",
"Html",
"::",
"buildHtmlElement",
"(",
"'link'",
",",
"$",
"attributes",
")",
";",
"$",
"counter",
"++",
";",
"return",
"$",
"this",
";",
"}"
] |
Link to a CSS stylesheet
@param string $href
@param string $media
@param array $attributes
@return \Osf\View\Helper\HeadLink
|
[
"Link",
"to",
"a",
"CSS",
"stylesheet"
] |
e06601013e8ec86dc2055e000e58dffd963c78e2
|
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Tags/Link.php#L34-L45
|
235,418
|
studyportals/SQL
|
src/MySQLResultSet.php
|
MySQLResultSet.next
|
public function next(){
if(next($this->_fetched) instanceof SQLResultRow){
return current($this->_fetched);
}
else{
try{
$mySQLResultRow = new MySQLResultRow($this->_result);
}
catch(SQLResultRowException $e){
return false;
}
// Clear fetch buffer in case of an unbuffered result-set
if(!$this->_buffered){
$this->_fetched = [];
}
$this->_fetched[] = $mySQLResultRow;
return $mySQLResultRow;
}
}
|
php
|
public function next(){
if(next($this->_fetched) instanceof SQLResultRow){
return current($this->_fetched);
}
else{
try{
$mySQLResultRow = new MySQLResultRow($this->_result);
}
catch(SQLResultRowException $e){
return false;
}
// Clear fetch buffer in case of an unbuffered result-set
if(!$this->_buffered){
$this->_fetched = [];
}
$this->_fetched[] = $mySQLResultRow;
return $mySQLResultRow;
}
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"next",
"(",
"$",
"this",
"->",
"_fetched",
")",
"instanceof",
"SQLResultRow",
")",
"{",
"return",
"current",
"(",
"$",
"this",
"->",
"_fetched",
")",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"mySQLResultRow",
"=",
"new",
"MySQLResultRow",
"(",
"$",
"this",
"->",
"_result",
")",
";",
"}",
"catch",
"(",
"SQLResultRowException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"// Clear fetch buffer in case of an unbuffered result-set",
"if",
"(",
"!",
"$",
"this",
"->",
"_buffered",
")",
"{",
"$",
"this",
"->",
"_fetched",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"_fetched",
"[",
"]",
"=",
"$",
"mySQLResultRow",
";",
"return",
"$",
"mySQLResultRow",
";",
"}",
"}"
] |
Read next result-row from the result-set.
@return SQLResultRow|false
|
[
"Read",
"next",
"result",
"-",
"row",
"from",
"the",
"result",
"-",
"set",
"."
] |
4f038ced9a3738c1d4ad562f93547812931d9ed4
|
https://github.com/studyportals/SQL/blob/4f038ced9a3738c1d4ad562f93547812931d9ed4/src/MySQLResultSet.php#L61-L89
|
235,419
|
joegreen88/zf1-components-base
|
src/Zend/Loader.php
|
Zend_Loader.standardiseFile
|
public static function standardiseFile($file)
{
$fileName = ltrim($file, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($fileName, '\\')) {
$namespace = substr($fileName, 0, $lastNsPos);
$fileName = substr($fileName, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $fileName) . '.php';
return $file;
}
|
php
|
public static function standardiseFile($file)
{
$fileName = ltrim($file, '\\');
$file = '';
$namespace = '';
if ($lastNsPos = strripos($fileName, '\\')) {
$namespace = substr($fileName, 0, $lastNsPos);
$fileName = substr($fileName, $lastNsPos + 1);
$file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$file .= str_replace('_', DIRECTORY_SEPARATOR, $fileName) . '.php';
return $file;
}
|
[
"public",
"static",
"function",
"standardiseFile",
"(",
"$",
"file",
")",
"{",
"$",
"fileName",
"=",
"ltrim",
"(",
"$",
"file",
",",
"'\\\\'",
")",
";",
"$",
"file",
"=",
"''",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"$",
"lastNsPos",
"=",
"strripos",
"(",
"$",
"fileName",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"fileName",
",",
"0",
",",
"$",
"lastNsPos",
")",
";",
"$",
"fileName",
"=",
"substr",
"(",
"$",
"fileName",
",",
"$",
"lastNsPos",
"+",
"1",
")",
";",
"$",
"file",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"namespace",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"file",
".=",
"str_replace",
"(",
"'_'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"fileName",
")",
".",
"'.php'",
";",
"return",
"$",
"file",
";",
"}"
] |
Standardise the filename.
Convert the supplied filename into the namespace-aware standard,
based on the Framework Interop Group reference implementation:
http://groups.google.com/group/php-standards/web/psr-0-final-proposal
The filename must be formatted as "$file.php".
@param string $file - The file name to be loaded.
@return string
|
[
"Standardise",
"the",
"filename",
"."
] |
d4591a2234c2db3094b54c08bcdc4303f7bf4819
|
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader.php#L338-L350
|
235,420
|
milkyway-multimedia/ss-zen-forms
|
src/Extensions/Form.php
|
Form.saveToSession
|
function saveToSession($data, $name = '') {
if(!$name) $name = $this->owner->FormName();
\Session::set("FormInfo.{$name}.data", $data);
}
|
php
|
function saveToSession($data, $name = '') {
if(!$name) $name = $this->owner->FormName();
\Session::set("FormInfo.{$name}.data", $data);
}
|
[
"function",
"saveToSession",
"(",
"$",
"data",
",",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"\\",
"Session",
"::",
"set",
"(",
"\"FormInfo.{$name}.data\"",
",",
"$",
"data",
")",
";",
"}"
] |
save form data to session
|
[
"save",
"form",
"data",
"to",
"session"
] |
24098390d88fff016a6e6299fd2fda50f11be064
|
https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L22-L26
|
235,421
|
milkyway-multimedia/ss-zen-forms
|
src/Extensions/Form.php
|
Form.loadFromSession
|
function loadFromSession($name = '') {
if(!$name) $name = $this->owner->FormName();
$formSession = \Session::get("FormInfo.{$name}.data");
if($formSession) $this->owner->loadDataFrom($formSession);
}
|
php
|
function loadFromSession($name = '') {
if(!$name) $name = $this->owner->FormName();
$formSession = \Session::get("FormInfo.{$name}.data");
if($formSession) $this->owner->loadDataFrom($formSession);
}
|
[
"function",
"loadFromSession",
"(",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"$",
"formSession",
"=",
"\\",
"Session",
"::",
"get",
"(",
"\"FormInfo.{$name}.data\"",
")",
";",
"if",
"(",
"$",
"formSession",
")",
"$",
"this",
"->",
"owner",
"->",
"loadDataFrom",
"(",
"$",
"formSession",
")",
";",
"}"
] |
load form data from session
|
[
"load",
"form",
"data",
"from",
"session"
] |
24098390d88fff016a6e6299fd2fda50f11be064
|
https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L31-L36
|
235,422
|
milkyway-multimedia/ss-zen-forms
|
src/Extensions/Form.php
|
Form.clearSessionData
|
function clearSessionData($name = '', $clearErrors = true){
if(!$name) $name = $this->owner->FormName();
\Session::clear("FormInfo.{$name}.data");
if($clearErrors) \Session::clear("FormInfo.{$name}.errors");
}
|
php
|
function clearSessionData($name = '', $clearErrors = true){
if(!$name) $name = $this->owner->FormName();
\Session::clear("FormInfo.{$name}.data");
if($clearErrors) \Session::clear("FormInfo.{$name}.errors");
}
|
[
"function",
"clearSessionData",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"clearErrors",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"$",
"name",
"=",
"$",
"this",
"->",
"owner",
"->",
"FormName",
"(",
")",
";",
"\\",
"Session",
"::",
"clear",
"(",
"\"FormInfo.{$name}.data\"",
")",
";",
"if",
"(",
"$",
"clearErrors",
")",
"\\",
"Session",
"::",
"clear",
"(",
"\"FormInfo.{$name}.errors\"",
")",
";",
"}"
] |
clear current form data session
|
[
"clear",
"current",
"form",
"data",
"session"
] |
24098390d88fff016a6e6299fd2fda50f11be064
|
https://github.com/milkyway-multimedia/ss-zen-forms/blob/24098390d88fff016a6e6299fd2fda50f11be064/src/Extensions/Form.php#L41-L45
|
235,423
|
railsphp/framework
|
src/Rails/ActiveRecord/Base/Methods/ModelSchemaMethodsTrait.php
|
ModelSchemaMethodsTrait.tableName
|
public static function tableName()
{
if (static::TABLE_NAME) {
return static::TABLE_NAME;
} else {
$cn = str_replace('\\', '_', get_called_class());
$inf = self::services()->get('inflector');
$tableName = $inf->underscore($inf->pluralize($cn));
return static::tableNamePrefix() . $tableName . static::tableNameSuffix();
};
}
|
php
|
public static function tableName()
{
if (static::TABLE_NAME) {
return static::TABLE_NAME;
} else {
$cn = str_replace('\\', '_', get_called_class());
$inf = self::services()->get('inflector');
$tableName = $inf->underscore($inf->pluralize($cn));
return static::tableNamePrefix() . $tableName . static::tableNameSuffix();
};
}
|
[
"public",
"static",
"function",
"tableName",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"TABLE_NAME",
")",
"{",
"return",
"static",
"::",
"TABLE_NAME",
";",
"}",
"else",
"{",
"$",
"cn",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"get_called_class",
"(",
")",
")",
";",
"$",
"inf",
"=",
"self",
"::",
"services",
"(",
")",
"->",
"get",
"(",
"'inflector'",
")",
";",
"$",
"tableName",
"=",
"$",
"inf",
"->",
"underscore",
"(",
"$",
"inf",
"->",
"pluralize",
"(",
"$",
"cn",
")",
")",
";",
"return",
"static",
"::",
"tableNamePrefix",
"(",
")",
".",
"$",
"tableName",
".",
"static",
"::",
"tableNameSuffix",
"(",
")",
";",
"}",
";",
"}"
] |
Returns the value of the TABLE_NAME constant if not empty,
otherwise it figures out the name of the table out of the
name of the model class.
@return string
|
[
"Returns",
"the",
"value",
"of",
"the",
"TABLE_NAME",
"constant",
"if",
"not",
"empty",
"otherwise",
"it",
"figures",
"out",
"the",
"name",
"of",
"the",
"table",
"out",
"of",
"the",
"name",
"of",
"the",
"model",
"class",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Base/Methods/ModelSchemaMethodsTrait.php#L34-L46
|
235,424
|
jfortunato/fortune
|
src/Configuration/Configuration.php
|
Configuration.resourceConfigurationFor
|
public function resourceConfigurationFor($resourceName)
{
foreach ($this->resourceConfigurations as $config) {
if ($config->getResource() === $resourceName) {
return $config;
}
}
return null;
}
|
php
|
public function resourceConfigurationFor($resourceName)
{
foreach ($this->resourceConfigurations as $config) {
if ($config->getResource() === $resourceName) {
return $config;
}
}
return null;
}
|
[
"public",
"function",
"resourceConfigurationFor",
"(",
"$",
"resourceName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"resourceConfigurations",
"as",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getResource",
"(",
")",
"===",
"$",
"resourceName",
")",
"{",
"return",
"$",
"config",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get ResourceConfiguration from resource name.
@param mixed $resourceName
@return ResourceConfiguration|null
|
[
"Get",
"ResourceConfiguration",
"from",
"resource",
"name",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Configuration/Configuration.php#L104-L113
|
235,425
|
PentagonalProject/SlimService
|
src/Sanitizer.php
|
Sanitizer.fixDirectorySeparator
|
public static function fixDirectorySeparator(string $path, $useCleanPrefix = false) : string
{
/**
* Trimming path string
*/
if (($path = trim($path)) == '') {
return $path;
}
$path = preg_replace('`(\/|\\\)+`', DIRECTORY_SEPARATOR, $path);
if ($useCleanPrefix) {
$path = DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
}
return $path;
}
|
php
|
public static function fixDirectorySeparator(string $path, $useCleanPrefix = false) : string
{
/**
* Trimming path string
*/
if (($path = trim($path)) == '') {
return $path;
}
$path = preg_replace('`(\/|\\\)+`', DIRECTORY_SEPARATOR, $path);
if ($useCleanPrefix) {
$path = DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
}
return $path;
}
|
[
"public",
"static",
"function",
"fixDirectorySeparator",
"(",
"string",
"$",
"path",
",",
"$",
"useCleanPrefix",
"=",
"false",
")",
":",
"string",
"{",
"/**\n * Trimming path string\n */",
"if",
"(",
"(",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
")",
")",
"==",
"''",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"path",
"=",
"preg_replace",
"(",
"'`(\\/|\\\\\\)+`'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"useCleanPrefix",
")",
"{",
"$",
"path",
"=",
"DIRECTORY_SEPARATOR",
".",
"ltrim",
"(",
"$",
"path",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Fix Path Separator
@param string $path
@param bool $useCleanPrefix
@return string
|
[
"Fix",
"Path",
"Separator"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L43-L58
|
235,426
|
PentagonalProject/SlimService
|
src/Sanitizer.php
|
Sanitizer.normalizePath
|
public static function normalizePath($path) : string
{
$path = self::fixDirectorySeparator($path);
$path = preg_replace('|(?<=.)/+|', DIRECTORY_SEPARATOR, $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
if (Validator::isAbsolutePath($path) && strpos($path, '.')) {
$explode = explode(DIRECTORY_SEPARATOR, $path);
$array = [];
foreach ($explode as $key => $value) {
if ('.' == $value) {
continue;
}
if ('..' == $value) {
array_pop($array);
} else {
$array[] = $value;
}
}
$path = implode(DIRECTORY_SEPARATOR, $array);
}
return $path;
}
|
php
|
public static function normalizePath($path) : string
{
$path = self::fixDirectorySeparator($path);
$path = preg_replace('|(?<=.)/+|', DIRECTORY_SEPARATOR, $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
if (Validator::isAbsolutePath($path) && strpos($path, '.')) {
$explode = explode(DIRECTORY_SEPARATOR, $path);
$array = [];
foreach ($explode as $key => $value) {
if ('.' == $value) {
continue;
}
if ('..' == $value) {
array_pop($array);
} else {
$array[] = $value;
}
}
$path = implode(DIRECTORY_SEPARATOR, $array);
}
return $path;
}
|
[
"public",
"static",
"function",
"normalizePath",
"(",
"$",
"path",
")",
":",
"string",
"{",
"$",
"path",
"=",
"self",
"::",
"fixDirectorySeparator",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'|(?<=.)/+|'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"if",
"(",
"':'",
"===",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"1",
")",
")",
"{",
"$",
"path",
"=",
"ucfirst",
"(",
"$",
"path",
")",
";",
"}",
"if",
"(",
"Validator",
"::",
"isAbsolutePath",
"(",
"$",
"path",
")",
"&&",
"strpos",
"(",
"$",
"path",
",",
"'.'",
")",
")",
"{",
"$",
"explode",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"explode",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"'.'",
"==",
"$",
"value",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"'..'",
"==",
"$",
"value",
")",
"{",
"array_pop",
"(",
"$",
"array",
")",
";",
"}",
"else",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"path",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"array",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Normalize a filesystem path.
@param string $path Path to normalize.
@return string Normalized path.
|
[
"Normalize",
"a",
"filesystem",
"path",
"."
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L66-L92
|
235,427
|
PentagonalProject/SlimService
|
src/Sanitizer.php
|
Sanitizer.multiByteEntities
|
public static function multiByteEntities($mixed, $entity = false)
{
static $hasIconV;
static $limit;
if (!isset($hasIconV)) {
// safe resource check
$hasIconV = function_exists('iconv');
}
if (!isset($limit)) {
$limit = @ini_get('pcre.backtrack_limit');
$limit = ! is_numeric($limit) ? 4096 : abs($limit);
// minimum regex is 512 byte
$limit = $limit < 512 ? 512 : $limit;
// limit into 40 KB
$limit = $limit > 40960 ? 40960 : $limit;
}
if (! $hasIconV && ! $entity) {
return $mixed;
}
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::multiByteEntities($value, $entity);
}
} elseif (is_object($mixed)) {
foreach (get_object_vars($mixed) as $key => $value) {
$mixed->{$key} = self::multiByteEntities($value, $entity);
}
} /**
* Work Safe with Parse @uses @var $limit Bit
* | 4KB data split for regex callback & safe memory usage
* that maybe fail on very long string
*/
elseif (strlen($mixed) > $limit) {
return implode('', self::multiByteEntities(str_split($mixed, $limit), $entity));
}
if ($entity) {
$mixed = htmlentities(html_entity_decode($mixed));
}
return $hasIconV
? (
preg_replace_callback(
'/[\x{80}-\x{10FFFF}]/u',
function ($match) {
$char = current($match);
$utf = iconv('UTF-8', 'UCS-4//IGNORE', $char);
return sprintf("&#x%s;", ltrim(strtolower(bin2hex($utf)), "0"));
},
$mixed
) ?:$mixed
) : $mixed;
}
|
php
|
public static function multiByteEntities($mixed, $entity = false)
{
static $hasIconV;
static $limit;
if (!isset($hasIconV)) {
// safe resource check
$hasIconV = function_exists('iconv');
}
if (!isset($limit)) {
$limit = @ini_get('pcre.backtrack_limit');
$limit = ! is_numeric($limit) ? 4096 : abs($limit);
// minimum regex is 512 byte
$limit = $limit < 512 ? 512 : $limit;
// limit into 40 KB
$limit = $limit > 40960 ? 40960 : $limit;
}
if (! $hasIconV && ! $entity) {
return $mixed;
}
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = self::multiByteEntities($value, $entity);
}
} elseif (is_object($mixed)) {
foreach (get_object_vars($mixed) as $key => $value) {
$mixed->{$key} = self::multiByteEntities($value, $entity);
}
} /**
* Work Safe with Parse @uses @var $limit Bit
* | 4KB data split for regex callback & safe memory usage
* that maybe fail on very long string
*/
elseif (strlen($mixed) > $limit) {
return implode('', self::multiByteEntities(str_split($mixed, $limit), $entity));
}
if ($entity) {
$mixed = htmlentities(html_entity_decode($mixed));
}
return $hasIconV
? (
preg_replace_callback(
'/[\x{80}-\x{10FFFF}]/u',
function ($match) {
$char = current($match);
$utf = iconv('UTF-8', 'UCS-4//IGNORE', $char);
return sprintf("&#x%s;", ltrim(strtolower(bin2hex($utf)), "0"));
},
$mixed
) ?:$mixed
) : $mixed;
}
|
[
"public",
"static",
"function",
"multiByteEntities",
"(",
"$",
"mixed",
",",
"$",
"entity",
"=",
"false",
")",
"{",
"static",
"$",
"hasIconV",
";",
"static",
"$",
"limit",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"hasIconV",
")",
")",
"{",
"// safe resource check",
"$",
"hasIconV",
"=",
"function_exists",
"(",
"'iconv'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"limit",
")",
")",
"{",
"$",
"limit",
"=",
"@",
"ini_get",
"(",
"'pcre.backtrack_limit'",
")",
";",
"$",
"limit",
"=",
"!",
"is_numeric",
"(",
"$",
"limit",
")",
"?",
"4096",
":",
"abs",
"(",
"$",
"limit",
")",
";",
"// minimum regex is 512 byte",
"$",
"limit",
"=",
"$",
"limit",
"<",
"512",
"?",
"512",
":",
"$",
"limit",
";",
"// limit into 40 KB",
"$",
"limit",
"=",
"$",
"limit",
">",
"40960",
"?",
"40960",
":",
"$",
"limit",
";",
"}",
"if",
"(",
"!",
"$",
"hasIconV",
"&&",
"!",
"$",
"entity",
")",
"{",
"return",
"$",
"mixed",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"mixed",
")",
")",
"{",
"foreach",
"(",
"$",
"mixed",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"mixed",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"multiByteEntities",
"(",
"$",
"value",
",",
"$",
"entity",
")",
";",
"}",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"mixed",
")",
")",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"mixed",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"mixed",
"->",
"{",
"$",
"key",
"}",
"=",
"self",
"::",
"multiByteEntities",
"(",
"$",
"value",
",",
"$",
"entity",
")",
";",
"}",
"}",
"/**\n * Work Safe with Parse @uses @var $limit Bit\n * | 4KB data split for regex callback & safe memory usage\n * that maybe fail on very long string\n */",
"elseif",
"(",
"strlen",
"(",
"$",
"mixed",
")",
">",
"$",
"limit",
")",
"{",
"return",
"implode",
"(",
"''",
",",
"self",
"::",
"multiByteEntities",
"(",
"str_split",
"(",
"$",
"mixed",
",",
"$",
"limit",
")",
",",
"$",
"entity",
")",
")",
";",
"}",
"if",
"(",
"$",
"entity",
")",
"{",
"$",
"mixed",
"=",
"htmlentities",
"(",
"html_entity_decode",
"(",
"$",
"mixed",
")",
")",
";",
"}",
"return",
"$",
"hasIconV",
"?",
"(",
"preg_replace_callback",
"(",
"'/[\\x{80}-\\x{10FFFF}]/u'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"$",
"char",
"=",
"current",
"(",
"$",
"match",
")",
";",
"$",
"utf",
"=",
"iconv",
"(",
"'UTF-8'",
",",
"'UCS-4//IGNORE'",
",",
"$",
"char",
")",
";",
"return",
"sprintf",
"(",
"\"&#x%s;\"",
",",
"ltrim",
"(",
"strtolower",
"(",
"bin2hex",
"(",
"$",
"utf",
")",
")",
",",
"\"0\"",
")",
")",
";",
"}",
",",
"$",
"mixed",
")",
"?",
":",
"$",
"mixed",
")",
":",
"$",
"mixed",
";",
"}"
] |
Entities the Multi bytes deep string
@param mixed $mixed the string to detect multi bytes
@param bool $entity true if want to entity the output
@return mixed
|
[
"Entities",
"the",
"Multi",
"bytes",
"deep",
"string"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L102-L157
|
235,428
|
PentagonalProject/SlimService
|
src/Sanitizer.php
|
Sanitizer.maybeUnSerialize
|
public static function maybeUnSerialize($original)
{
if (! is_string($original) || trim($original) == '') {
return $original;
}
/**
* Check if serialized
* check with trim
*/
if (self::isSerialized($original)) {
/**
* use trim if possible
* Serialized value could not start & end with white space
*/
return @unserialize(trim($original));
}
return $original;
}
|
php
|
public static function maybeUnSerialize($original)
{
if (! is_string($original) || trim($original) == '') {
return $original;
}
/**
* Check if serialized
* check with trim
*/
if (self::isSerialized($original)) {
/**
* use trim if possible
* Serialized value could not start & end with white space
*/
return @unserialize(trim($original));
}
return $original;
}
|
[
"public",
"static",
"function",
"maybeUnSerialize",
"(",
"$",
"original",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"original",
")",
"||",
"trim",
"(",
"$",
"original",
")",
"==",
"''",
")",
"{",
"return",
"$",
"original",
";",
"}",
"/**\n * Check if serialized\n * check with trim\n */",
"if",
"(",
"self",
"::",
"isSerialized",
"(",
"$",
"original",
")",
")",
"{",
"/**\n * use trim if possible\n * Serialized value could not start & end with white space\n */",
"return",
"@",
"unserialize",
"(",
"trim",
"(",
"$",
"original",
")",
")",
";",
"}",
"return",
"$",
"original",
";",
"}"
] |
Un-serialize value only if it was serialized.
@param string $original Maybe un-serialized original, if is needed.
@return mixed Un-serialized data can be any type.
|
[
"Un",
"-",
"serialize",
"value",
"only",
"if",
"it",
"was",
"serialized",
"."
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Sanitizer.php#L241-L260
|
235,429
|
gielfeldt/shutdownhandler
|
src/ShutdownHandler.php
|
ShutdownHandler.run
|
public function run()
{
if ($this->unRegister() && empty(static::$keys[$this->getKey()])) {
call_user_func_array($this->callback, $this->arguments);
}
}
|
php
|
public function run()
{
if ($this->unRegister() && empty(static::$keys[$this->getKey()])) {
call_user_func_array($this->callback, $this->arguments);
}
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unRegister",
"(",
")",
"&&",
"empty",
"(",
"static",
"::",
"$",
"keys",
"[",
"$",
"this",
"->",
"getKey",
"(",
")",
"]",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"callback",
",",
"$",
"this",
"->",
"arguments",
")",
";",
"}",
"}"
] |
Run the shutdown handler.
|
[
"Run",
"the",
"shutdown",
"handler",
"."
] |
a31bf9a93ce1fe77110a5374ac07cce77dda7bda
|
https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L99-L104
|
235,430
|
gielfeldt/shutdownhandler
|
src/ShutdownHandler.php
|
ShutdownHandler.unRegister
|
public function unRegister()
{
if (isset(static::$handlers[$this->handlerId])) {
if (!is_null($this->getKey())) {
static::$keys[$this->getKey()]--;
}
unset(static::$handlers[$this->handlerId]);
return true;
}
return false;
}
|
php
|
public function unRegister()
{
if (isset(static::$handlers[$this->handlerId])) {
if (!is_null($this->getKey())) {
static::$keys[$this->getKey()]--;
}
unset(static::$handlers[$this->handlerId]);
return true;
}
return false;
}
|
[
"public",
"function",
"unRegister",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"handlers",
"[",
"$",
"this",
"->",
"handlerId",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
")",
"{",
"static",
"::",
"$",
"keys",
"[",
"$",
"this",
"->",
"getKey",
"(",
")",
"]",
"--",
";",
"}",
"unset",
"(",
"static",
"::",
"$",
"handlers",
"[",
"$",
"this",
"->",
"handlerId",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Unregister handler.
@return boolean
true if handler was unregistered (i.e. not already unregistered).
|
[
"Unregister",
"handler",
"."
] |
a31bf9a93ce1fe77110a5374ac07cce77dda7bda
|
https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L144-L154
|
235,431
|
gielfeldt/shutdownhandler
|
src/ShutdownHandler.php
|
ShutdownHandler.reRegister
|
public function reRegister($key = null)
{
// Set the key, and register the handler.
$this->setKey($key);
static::$handlers[$this->handlerId] = $this;
}
|
php
|
public function reRegister($key = null)
{
// Set the key, and register the handler.
$this->setKey($key);
static::$handlers[$this->handlerId] = $this;
}
|
[
"public",
"function",
"reRegister",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"// Set the key, and register the handler.",
"$",
"this",
"->",
"setKey",
"(",
"$",
"key",
")",
";",
"static",
"::",
"$",
"handlers",
"[",
"$",
"this",
"->",
"handlerId",
"]",
"=",
"$",
"this",
";",
"}"
] |
Reregister handler.
@param string $key
(Optional) The key of the handler.
|
[
"Reregister",
"handler",
"."
] |
a31bf9a93ce1fe77110a5374ac07cce77dda7bda
|
https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L183-L188
|
235,432
|
gielfeldt/shutdownhandler
|
src/ShutdownHandler.php
|
ShutdownHandler.setKey
|
protected function setKey($key)
{
// If a handler switches key, we need to decrement the counter for the old
// key, and increment the counter for the new key.
$this->removeKey();
// Set the new key, and increment the counter appropriately.
$this->key = $key;
if (isset($key)) {
static::$keys[$key] = isset(static::$keys[$key]) ? static::$keys[$key] + 1 : 1;
}
}
|
php
|
protected function setKey($key)
{
// If a handler switches key, we need to decrement the counter for the old
// key, and increment the counter for the new key.
$this->removeKey();
// Set the new key, and increment the counter appropriately.
$this->key = $key;
if (isset($key)) {
static::$keys[$key] = isset(static::$keys[$key]) ? static::$keys[$key] + 1 : 1;
}
}
|
[
"protected",
"function",
"setKey",
"(",
"$",
"key",
")",
"{",
"// If a handler switches key, we need to decrement the counter for the old",
"// key, and increment the counter for the new key.",
"$",
"this",
"->",
"removeKey",
"(",
")",
";",
"// Set the new key, and increment the counter appropriately.",
"$",
"this",
"->",
"key",
"=",
"$",
"key",
";",
"if",
"(",
"isset",
"(",
"$",
"key",
")",
")",
"{",
"static",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
"=",
"isset",
"(",
"static",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
")",
"?",
"static",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
"+",
"1",
":",
"1",
";",
"}",
"}"
] |
Set key for final nested destructor.
@param string $key
Name of key.
|
[
"Set",
"key",
"for",
"final",
"nested",
"destructor",
"."
] |
a31bf9a93ce1fe77110a5374ac07cce77dda7bda
|
https://github.com/gielfeldt/shutdownhandler/blob/a31bf9a93ce1fe77110a5374ac07cce77dda7bda/src/ShutdownHandler.php#L222-L233
|
235,433
|
teeebor/decoy-framework
|
base/ErrorController.php
|
ErrorController._Bootstrap
|
public function _Bootstrap()
{
$this->forward()->setResponse(new HtmlResponse());
$this->forward()->getCurrentRoute()->setDefault(new Route(array('action'=>'_error')));
}
|
php
|
public function _Bootstrap()
{
$this->forward()->setResponse(new HtmlResponse());
$this->forward()->getCurrentRoute()->setDefault(new Route(array('action'=>'_error')));
}
|
[
"public",
"function",
"_Bootstrap",
"(",
")",
"{",
"$",
"this",
"->",
"forward",
"(",
")",
"->",
"setResponse",
"(",
"new",
"HtmlResponse",
"(",
")",
")",
";",
"$",
"this",
"->",
"forward",
"(",
")",
"->",
"getCurrentRoute",
"(",
")",
"->",
"setDefault",
"(",
"new",
"Route",
"(",
"array",
"(",
"'action'",
"=>",
"'_error'",
")",
")",
")",
";",
"}"
] |
Bootstrapping the class
|
[
"Bootstrapping",
"the",
"class"
] |
3881ae63a7d13088efda5afd3932c1af1fc18b23
|
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/base/ErrorController.php#L27-L31
|
235,434
|
teeebor/decoy-framework
|
base/ErrorController.php
|
ErrorController._error
|
public function _error(){
$model = new ViewModel('application/error');
$model->addVariable('error_type','error');
$model->addVariable('error',ErrorController::$errors);
return $model;
}
|
php
|
public function _error(){
$model = new ViewModel('application/error');
$model->addVariable('error_type','error');
$model->addVariable('error',ErrorController::$errors);
return $model;
}
|
[
"public",
"function",
"_error",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"ViewModel",
"(",
"'application/error'",
")",
";",
"$",
"model",
"->",
"addVariable",
"(",
"'error_type'",
",",
"'error'",
")",
";",
"$",
"model",
"->",
"addVariable",
"(",
"'error'",
",",
"ErrorController",
"::",
"$",
"errors",
")",
";",
"return",
"$",
"model",
";",
"}"
] |
If there was an error, this method will display it
|
[
"If",
"there",
"was",
"an",
"error",
"this",
"method",
"will",
"display",
"it"
] |
3881ae63a7d13088efda5afd3932c1af1fc18b23
|
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/base/ErrorController.php#L35-L40
|
235,435
|
Opifer/ContentBundle
|
Controller/Api/ContentController.php
|
ContentController.idsAction
|
public function idsAction($ids)
{
$items = $this->get('opifer.content.content_manager')
->getRepository()
->findByIds($ids);
$contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());
$data = [
'results' => json_decode($contents, true),
'total_results' => count($items)
];
return new JsonResponse($data);
}
|
php
|
public function idsAction($ids)
{
$items = $this->get('opifer.content.content_manager')
->getRepository()
->findByIds($ids);
$contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks());
$data = [
'results' => json_decode($contents, true),
'total_results' => count($items)
];
return new JsonResponse($data);
}
|
[
"public",
"function",
"idsAction",
"(",
"$",
"ids",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"get",
"(",
"'opifer.content.content_manager'",
")",
"->",
"getRepository",
"(",
")",
"->",
"findByIds",
"(",
"$",
"ids",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"get",
"(",
"'jms_serializer'",
")",
"->",
"serialize",
"(",
"$",
"items",
",",
"'json'",
",",
"SerializationContext",
"::",
"create",
"(",
")",
"->",
"setGroups",
"(",
"[",
"'list'",
"]",
")",
"->",
"enableMaxDepthChecks",
"(",
")",
")",
";",
"$",
"data",
"=",
"[",
"'results'",
"=>",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
",",
"'total_results'",
"=>",
"count",
"(",
"$",
"items",
")",
"]",
";",
"return",
"new",
"JsonResponse",
"(",
"$",
"data",
")",
";",
"}"
] |
Get a content items by a list of ids
@param string $ids
@return JsonResponse
|
[
"Get",
"a",
"content",
"items",
"by",
"a",
"list",
"of",
"ids"
] |
df44ef36b81a839ce87ea9a92f7728618111541f
|
https://github.com/Opifer/ContentBundle/blob/df44ef36b81a839ce87ea9a92f7728618111541f/Controller/Api/ContentController.php#L45-L59
|
235,436
|
Kylob/Sitemap
|
src/Component.php
|
Component.add
|
public static function add($category, $content, array $save = array())
{
$page = Page::html();
if ($page->url['format'] != 'html') {
return;
}
$page->filter('response', function ($page, $response) use ($category, $content, $save) {
if (empty($page->url['query'])) {
$sitemap = new Component();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
}, array('html', 200));
}
|
php
|
public static function add($category, $content, array $save = array())
{
$page = Page::html();
if ($page->url['format'] != 'html') {
return;
}
$page->filter('response', function ($page, $response) use ($category, $content, $save) {
if (empty($page->url['query'])) {
$sitemap = new Component();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
}, array('html', 200));
}
|
[
"public",
"static",
"function",
"add",
"(",
"$",
"category",
",",
"$",
"content",
",",
"array",
"$",
"save",
"=",
"array",
"(",
")",
")",
"{",
"$",
"page",
"=",
"Page",
"::",
"html",
"(",
")",
";",
"if",
"(",
"$",
"page",
"->",
"url",
"[",
"'format'",
"]",
"!=",
"'html'",
")",
"{",
"return",
";",
"}",
"$",
"page",
"->",
"filter",
"(",
"'response'",
",",
"function",
"(",
"$",
"page",
",",
"$",
"response",
")",
"use",
"(",
"$",
"category",
",",
"$",
"content",
",",
"$",
"save",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"page",
"->",
"url",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"sitemap",
"=",
"new",
"Component",
"(",
")",
";",
"$",
"sitemap",
"->",
"upsert",
"(",
"$",
"category",
",",
"array_merge",
"(",
"array",
"(",
"'path'",
"=>",
"$",
"page",
"->",
"url",
"[",
"'path'",
"]",
",",
"'title'",
"=>",
"$",
"page",
"->",
"title",
",",
"'description'",
"=>",
"$",
"page",
"->",
"description",
",",
"'keywords'",
"=>",
"$",
"page",
"->",
"keywords",
",",
"'image'",
"=>",
"$",
"page",
"->",
"image",
",",
"'content'",
"=>",
"$",
"content",
",",
")",
",",
"$",
"save",
")",
")",
";",
"unset",
"(",
"$",
"sitemap",
")",
";",
"}",
"}",
",",
"array",
"(",
"'html'",
",",
"200",
")",
")",
";",
"}"
] |
Include the current page in the sitemap if it is an HTML page, and has no query string. Made static to save you the hassle of opening and closing the database.
Use this method when you want to "set it, and forget it". When adding (and updating) **$content** dynamically, then some of your links may be a bit outdated as we can only update them when they are accessed. If this is unacceptable to you, then use the '**reset**', '**upsert**', and '**delete**' methods to keep everything up-to-date. Using the static add method would be equivalent to the following code:
```php
if (empty($page->url['query'])) {
$sitemap = new Sitemap();
$sitemap->upsert($category, array_merge(array(
'path' => $page->url['path'],
'title' => $page->title,
'description' => $page->description,
'keywords' => $page->keywords,
'image' => $page->image,
'content' => $content,
), $save));
unset($sitemap);
}
```
@param string $category To group related links.
@param string $content The main body of your page.
@param array $save Any additional information that you consider to be important, and would like to include with your search results.
@example
```php
Sitemap::add('pages', $html);
```
|
[
"Include",
"the",
"current",
"page",
"in",
"the",
"sitemap",
"if",
"it",
"is",
"an",
"HTML",
"page",
"and",
"has",
"no",
"query",
"string",
".",
"Made",
"static",
"to",
"save",
"you",
"the",
"hassle",
"of",
"opening",
"and",
"closing",
"the",
"database",
"."
] |
19b31b6e8cc44497ac1101a00a32ec9711b86d43
|
https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L233-L253
|
235,437
|
Kylob/Sitemap
|
src/Component.php
|
Component.where
|
private function where($category, $and = '')
{
if (!empty($category)) {
$sql = array();
foreach ((array) $category as $like) {
$sql[] = "c.category LIKE '{$like}%'";
}
$category = 'AND '.implode(' OR ', $sql);
}
return trim('INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '.$category.' '.$and);
}
|
php
|
private function where($category, $and = '')
{
if (!empty($category)) {
$sql = array();
foreach ((array) $category as $like) {
$sql[] = "c.category LIKE '{$like}%'";
}
$category = 'AND '.implode(' OR ', $sql);
}
return trim('INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '.$category.' '.$and);
}
|
[
"private",
"function",
"where",
"(",
"$",
"category",
",",
"$",
"and",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"category",
")",
")",
"{",
"$",
"sql",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"category",
"as",
"$",
"like",
")",
"{",
"$",
"sql",
"[",
"]",
"=",
"\"c.category LIKE '{$like}%'\"",
";",
"}",
"$",
"category",
"=",
"'AND '",
".",
"implode",
"(",
"' OR '",
",",
"$",
"sql",
")",
";",
"}",
"return",
"trim",
"(",
"'INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id '",
".",
"$",
"category",
".",
"' '",
".",
"$",
"and",
")",
";",
"}"
] |
Adds the category and additional parameters to a query string.
@param string $category
@param string $and
@return string
|
[
"Adds",
"the",
"category",
"and",
"additional",
"parameters",
"to",
"a",
"query",
"string",
"."
] |
19b31b6e8cc44497ac1101a00a32ec9711b86d43
|
https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L461-L472
|
235,438
|
Kylob/Sitemap
|
src/Component.php
|
Component.id
|
private function id($category)
{
if (is_null($this->ids)) {
$this->ids = array();
$categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
foreach ($categories as $row) {
$this->ids[$row['category']] = $row['id'];
}
}
if (!isset($this->ids[$category])) {
$parent = 0;
$previous = '';
foreach (explode('/', $category) as $path) {
if (!isset($this->ids[$previous.$path])) {
$this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
}
$parent = $this->ids[$previous.$path];
$previous .= $path.'/';
}
}
return $this->ids[$category];
}
|
php
|
private function id($category)
{
if (is_null($this->ids)) {
$this->ids = array();
$categories = $this->db->all('SELECT category, id FROM categories', '', 'assoc');
foreach ($categories as $row) {
$this->ids[$row['category']] = $row['id'];
}
}
if (!isset($this->ids[$category])) {
$parent = 0;
$previous = '';
foreach (explode('/', $category) as $path) {
if (!isset($this->ids[$previous.$path])) {
$this->ids[$previous.$path] = $this->exec('INSERT', 'categories', array($previous.$path, $parent));
}
$parent = $this->ids[$previous.$path];
$previous .= $path.'/';
}
}
return $this->ids[$category];
}
|
[
"private",
"function",
"id",
"(",
"$",
"category",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"ids",
")",
")",
"{",
"$",
"this",
"->",
"ids",
"=",
"array",
"(",
")",
";",
"$",
"categories",
"=",
"$",
"this",
"->",
"db",
"->",
"all",
"(",
"'SELECT category, id FROM categories'",
",",
"''",
",",
"'assoc'",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"ids",
"[",
"$",
"row",
"[",
"'category'",
"]",
"]",
"=",
"$",
"row",
"[",
"'id'",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ids",
"[",
"$",
"category",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"0",
";",
"$",
"previous",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"'/'",
",",
"$",
"category",
")",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ids",
"[",
"$",
"previous",
".",
"$",
"path",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ids",
"[",
"$",
"previous",
".",
"$",
"path",
"]",
"=",
"$",
"this",
"->",
"exec",
"(",
"'INSERT'",
",",
"'categories'",
",",
"array",
"(",
"$",
"previous",
".",
"$",
"path",
",",
"$",
"parent",
")",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"ids",
"[",
"$",
"previous",
".",
"$",
"path",
"]",
";",
"$",
"previous",
".=",
"$",
"path",
".",
"'/'",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"ids",
"[",
"$",
"category",
"]",
";",
"}"
] |
Converts a category string into it's id.
@param string $category
@return int
|
[
"Converts",
"a",
"category",
"string",
"into",
"it",
"s",
"id",
"."
] |
19b31b6e8cc44497ac1101a00a32ec9711b86d43
|
https://github.com/Kylob/Sitemap/blob/19b31b6e8cc44497ac1101a00a32ec9711b86d43/src/Component.php#L481-L503
|
235,439
|
subcosm-probe/primitives
|
src/Traits/Uri/MarshalTrait.php
|
MarshalTrait.marshalScheme
|
protected function marshalScheme($scheme): ? string
{
if ( null === $scheme ) {
return null;
}
if ( ! is_string($scheme) ) {
throw new UriException(
'Scheme must be a string'
);
}
return strtolower($scheme);
}
|
php
|
protected function marshalScheme($scheme): ? string
{
if ( null === $scheme ) {
return null;
}
if ( ! is_string($scheme) ) {
throw new UriException(
'Scheme must be a string'
);
}
return strtolower($scheme);
}
|
[
"protected",
"function",
"marshalScheme",
"(",
"$",
"scheme",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"scheme",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"scheme",
")",
")",
"{",
"throw",
"new",
"UriException",
"(",
"'Scheme must be a string'",
")",
";",
"}",
"return",
"strtolower",
"(",
"$",
"scheme",
")",
";",
"}"
] |
marshals the scheme.
@param $scheme
@return null|string
@throws UriException
|
[
"marshals",
"the",
"scheme",
"."
] |
3b21293e88e9c08185237ff9ac707e4be6031776
|
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L28-L41
|
235,440
|
subcosm-probe/primitives
|
src/Traits/Uri/MarshalTrait.php
|
MarshalTrait.marshalPort
|
protected function marshalPort($port): ? int
{
if ( null === $port ) {
return null;
}
$port = (int) $port;
if ( 0 > $port || 65535 < $port ) {
throw new UriException(
sprintf('Invalid port: %s, value must be between 0 and 65535', $port)
);
}
return $port;
}
|
php
|
protected function marshalPort($port): ? int
{
if ( null === $port ) {
return null;
}
$port = (int) $port;
if ( 0 > $port || 65535 < $port ) {
throw new UriException(
sprintf('Invalid port: %s, value must be between 0 and 65535', $port)
);
}
return $port;
}
|
[
"protected",
"function",
"marshalPort",
"(",
"$",
"port",
")",
":",
"?",
"int",
"{",
"if",
"(",
"null",
"===",
"$",
"port",
")",
"{",
"return",
"null",
";",
"}",
"$",
"port",
"=",
"(",
"int",
")",
"$",
"port",
";",
"if",
"(",
"0",
">",
"$",
"port",
"||",
"65535",
"<",
"$",
"port",
")",
"{",
"throw",
"new",
"UriException",
"(",
"sprintf",
"(",
"'Invalid port: %s, value must be between 0 and 65535'",
",",
"$",
"port",
")",
")",
";",
"}",
"return",
"$",
"port",
";",
"}"
] |
marshals the port.
@param $port
@return int|null
@throws UriException
|
[
"marshals",
"the",
"port",
"."
] |
3b21293e88e9c08185237ff9ac707e4be6031776
|
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L68-L83
|
235,441
|
subcosm-probe/primitives
|
src/Traits/Uri/MarshalTrait.php
|
MarshalTrait.marshalPath
|
protected function marshalPath($path): string
{
if ( null === $path ) {
$path = '/';
}
if ( ! is_string($path) ) {
throw new UriException(
'Path must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$path
);
}
|
php
|
protected function marshalPath($path): string
{
if ( null === $path ) {
$path = '/';
}
if ( ! is_string($path) ) {
throw new UriException(
'Path must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$path
);
}
|
[
"protected",
"function",
"marshalPath",
"(",
"$",
"path",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"'/'",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"UriException",
"(",
"'Path must be a string or null'",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"'/(?:[^'",
".",
"self",
"::",
"$",
"unreservedCharacters",
".",
"self",
"::",
"$",
"subDelimitedCharacters",
".",
"'%:@\\/]++|%(?![A-Fa-f0-9]{2}))/'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"rawurlencode",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"path",
")",
";",
"}"
] |
marshals the path.
@param $path
@return string
@throws UriException
|
[
"marshals",
"the",
"path",
"."
] |
3b21293e88e9c08185237ff9ac707e4be6031776
|
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L92-L111
|
235,442
|
subcosm-probe/primitives
|
src/Traits/Uri/MarshalTrait.php
|
MarshalTrait.marshalQueryAndFragment
|
protected function marshalQueryAndFragment($string): string
{
if ( ! is_string($string) ) {
throw new UriException(
'Query and Fragment must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$string
);
}
|
php
|
protected function marshalQueryAndFragment($string): string
{
if ( ! is_string($string) ) {
throw new UriException(
'Query and Fragment must be a string or null'
);
}
return preg_replace_callback(
'/(?:[^'.self::$unreservedCharacters.self::$subDelimitedCharacters.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
function($match) {
return rawurlencode($match[0]);
},
$string
);
}
|
[
"protected",
"function",
"marshalQueryAndFragment",
"(",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"UriException",
"(",
"'Query and Fragment must be a string or null'",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"'/(?:[^'",
".",
"self",
"::",
"$",
"unreservedCharacters",
".",
"self",
"::",
"$",
"subDelimitedCharacters",
".",
"'%:@\\/]++|%(?![A-Fa-f0-9]{2}))/'",
",",
"function",
"(",
"$",
"match",
")",
"{",
"return",
"rawurlencode",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"}",
",",
"$",
"string",
")",
";",
"}"
] |
marshals the query and fragment.
@param $string
@return string
@throws UriException
|
[
"marshals",
"the",
"query",
"and",
"fragment",
"."
] |
3b21293e88e9c08185237ff9ac707e4be6031776
|
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Uri/MarshalTrait.php#L120-L135
|
235,443
|
gorriecoe/silverstripe-dbstringextras
|
src/DBStringExtras.php
|
DBStringExtras.StrReplace
|
public function StrReplace($search = ' ', $replace = '')
{
$owner = $this->owner;
$owner->value = str_replace(
$search,
$replace,
$owner->value
);
return $owner;
}
|
php
|
public function StrReplace($search = ' ', $replace = '')
{
$owner = $this->owner;
$owner->value = str_replace(
$search,
$replace,
$owner->value
);
return $owner;
}
|
[
"public",
"function",
"StrReplace",
"(",
"$",
"search",
"=",
"' '",
",",
"$",
"replace",
"=",
"''",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"owner",
"->",
"value",
"=",
"str_replace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"owner",
"->",
"value",
")",
";",
"return",
"$",
"owner",
";",
"}"
] |
Replace all occurrences of the search string with the replacement string.
@return string
|
[
"Replace",
"all",
"occurrences",
"of",
"the",
"search",
"string",
"with",
"the",
"replacement",
"string",
"."
] |
e1a68adc6af95e8b887c1624c9144e10dc87b40c
|
https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L31-L40
|
235,444
|
gorriecoe/silverstripe-dbstringextras
|
src/DBStringExtras.php
|
DBStringExtras.Nice
|
public function Nice()
{
$owner = $this->owner;
$value = preg_replace('/([a-z)([A-Z0-9]])/', '$1 $2', $owner->value);
$value = preg_replace('/([a-zA-Z])-([a-zA-Z0-9])/', '$1 $2', $value);
$value = str_replace('_', ' ', $value);
$owner->value = trim($value);
return $owner;
}
|
php
|
public function Nice()
{
$owner = $this->owner;
$value = preg_replace('/([a-z)([A-Z0-9]])/', '$1 $2', $owner->value);
$value = preg_replace('/([a-zA-Z])-([a-zA-Z0-9])/', '$1 $2', $value);
$value = str_replace('_', ' ', $value);
$owner->value = trim($value);
return $owner;
}
|
[
"public",
"function",
"Nice",
"(",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/([a-z)([A-Z0-9]])/'",
",",
"'$1 $2'",
",",
"$",
"owner",
"->",
"value",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/([a-zA-Z])-([a-zA-Z0-9])/'",
",",
"'$1 $2'",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"value",
")",
";",
"$",
"owner",
"->",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"return",
"$",
"owner",
";",
"}"
] |
Converts this camel case and hyphenated string to a space separated string.
@return string
|
[
"Converts",
"this",
"camel",
"case",
"and",
"hyphenated",
"string",
"to",
"a",
"space",
"separated",
"string",
"."
] |
e1a68adc6af95e8b887c1624c9144e10dc87b40c
|
https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L46-L54
|
235,445
|
gorriecoe/silverstripe-dbstringextras
|
src/DBStringExtras.php
|
DBStringExtras.Hyphenate
|
public function Hyphenate()
{
$value = preg_replace('/([A-Z])/', '-$1', $this->owner->value);
$value = trim($value);
return Convert::raw2url($value);
}
|
php
|
public function Hyphenate()
{
$value = preg_replace('/([A-Z])/', '-$1', $this->owner->value);
$value = trim($value);
return Convert::raw2url($value);
}
|
[
"public",
"function",
"Hyphenate",
"(",
")",
"{",
"$",
"value",
"=",
"preg_replace",
"(",
"'/([A-Z])/'",
",",
"'-$1'",
",",
"$",
"this",
"->",
"owner",
"->",
"value",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"return",
"Convert",
"::",
"raw2url",
"(",
"$",
"value",
")",
";",
"}"
] |
Converts this camel case string to a hyphenated, kebab or spinal case string.
|
[
"Converts",
"this",
"camel",
"case",
"string",
"to",
"a",
"hyphenated",
"kebab",
"or",
"spinal",
"case",
"string",
"."
] |
e1a68adc6af95e8b887c1624c9144e10dc87b40c
|
https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L59-L64
|
235,446
|
gorriecoe/silverstripe-dbstringextras
|
src/DBStringExtras.php
|
DBStringExtras.RemoveSpaces
|
public function RemoveSpaces()
{
$owner = $this->owner;
$owner->value = str_replace(
[' ', ' '],
'',
$owner->value
);
return $owner;
}
|
php
|
public function RemoveSpaces()
{
$owner = $this->owner;
$owner->value = str_replace(
[' ', ' '],
'',
$owner->value
);
return $owner;
}
|
[
"public",
"function",
"RemoveSpaces",
"(",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"owner",
"->",
"value",
"=",
"str_replace",
"(",
"[",
"' '",
",",
"' '",
"]",
",",
"''",
",",
"$",
"owner",
"->",
"value",
")",
";",
"return",
"$",
"owner",
";",
"}"
] |
Removes spaces from this string.
@return string
|
[
"Removes",
"spaces",
"from",
"this",
"string",
"."
] |
e1a68adc6af95e8b887c1624c9144e10dc87b40c
|
https://github.com/gorriecoe/silverstripe-dbstringextras/blob/e1a68adc6af95e8b887c1624c9144e10dc87b40c/src/DBStringExtras.php#L70-L79
|
235,447
|
razielsd/webdriverlib
|
WebDriver/WebDriver/Object/Timeout.php
|
WebDriver_Object_Timeout.implicitWait
|
public function implicitWait($timeout)
{
$timeoutNormalize = intval(ceil($timeout / 100));
if ($this->cache[self::WAIT_IMPLICIT] === $timeoutNormalize) {
return null;
}
$this->cache[self::WAIT_IMPLICIT] = $timeout;
$param = ['ms' => intval($timeout)];
$command = $this->driver->factoryCommand('timeouts/implicit_wait', WebDriver_Command::METHOD_POST, $param);
return $this->driver->curl($command)['value'];
}
|
php
|
public function implicitWait($timeout)
{
$timeoutNormalize = intval(ceil($timeout / 100));
if ($this->cache[self::WAIT_IMPLICIT] === $timeoutNormalize) {
return null;
}
$this->cache[self::WAIT_IMPLICIT] = $timeout;
$param = ['ms' => intval($timeout)];
$command = $this->driver->factoryCommand('timeouts/implicit_wait', WebDriver_Command::METHOD_POST, $param);
return $this->driver->curl($command)['value'];
}
|
[
"public",
"function",
"implicitWait",
"(",
"$",
"timeout",
")",
"{",
"$",
"timeoutNormalize",
"=",
"intval",
"(",
"ceil",
"(",
"$",
"timeout",
"/",
"100",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"[",
"self",
"::",
"WAIT_IMPLICIT",
"]",
"===",
"$",
"timeoutNormalize",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"cache",
"[",
"self",
"::",
"WAIT_IMPLICIT",
"]",
"=",
"$",
"timeout",
";",
"$",
"param",
"=",
"[",
"'ms'",
"=>",
"intval",
"(",
"$",
"timeout",
")",
"]",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"driver",
"->",
"factoryCommand",
"(",
"'timeouts/implicit_wait'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
",",
"$",
"param",
")",
";",
"return",
"$",
"this",
"->",
"driver",
"->",
"curl",
"(",
"$",
"command",
")",
"[",
"'value'",
"]",
";",
"}"
] |
Set the amount of time the driver should wait when searching for elements.
@param $timeout - The amount of time to wait, in milliseconds. This value has a lower bound of 0.
@return mixed
|
[
"Set",
"the",
"amount",
"of",
"time",
"the",
"driver",
"should",
"wait",
"when",
"searching",
"for",
"elements",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver/Object/Timeout.php#L42-L52
|
235,448
|
dlabas/DlcUseCase
|
src/DlcUseCase/Service/UseCase.php
|
UseCase.createUseCaseDiagramm
|
public function createUseCaseDiagramm()
{
$nodes = $this->findAll();
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes($nodes, UseCaseDiagramm::TYPE_USE_CASE);
}
|
php
|
public function createUseCaseDiagramm()
{
$nodes = $this->findAll();
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes($nodes, UseCaseDiagramm::TYPE_USE_CASE);
}
|
[
"public",
"function",
"createUseCaseDiagramm",
"(",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"findAll",
"(",
")",
";",
"$",
"diagrammService",
"=",
"$",
"this",
"->",
"getDiagrammService",
"(",
")",
";",
"return",
"$",
"diagrammService",
"->",
"createDiagrammFromNodes",
"(",
"$",
"nodes",
",",
"UseCaseDiagramm",
"::",
"TYPE_USE_CASE",
")",
";",
"}"
] |
Creates an use case diagramm from all entities
@return UseCaseDiagramm
|
[
"Creates",
"an",
"use",
"case",
"diagramm",
"from",
"all",
"entities"
] |
6a15aa7628594c343c334dabf0253ce2ae5d7f0b
|
https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Service/UseCase.php#L93-L100
|
235,449
|
dlabas/DlcUseCase
|
src/DlcUseCase/Service/UseCase.php
|
UseCase.createUseCaseDiagrammFor
|
public function createUseCaseDiagrammFor($entity)
{
if (is_int($entity)) {
$entity = $this->getById($entity);
} elseif (!$entity instanceof UseCaseEntity) {
throw new \InvalidArgumentException('Unkown entity data type "' . gettype($entity) . '"');
}
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes(array($entity), UseCaseDiagramm::TYPE_USE_CASE);
}
|
php
|
public function createUseCaseDiagrammFor($entity)
{
if (is_int($entity)) {
$entity = $this->getById($entity);
} elseif (!$entity instanceof UseCaseEntity) {
throw new \InvalidArgumentException('Unkown entity data type "' . gettype($entity) . '"');
}
$diagrammService = $this->getDiagrammService();
return $diagrammService->createDiagrammFromNodes(array($entity), UseCaseDiagramm::TYPE_USE_CASE);
}
|
[
"public",
"function",
"createUseCaseDiagrammFor",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"entity",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"entity",
"instanceof",
"UseCaseEntity",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unkown entity data type \"'",
".",
"gettype",
"(",
"$",
"entity",
")",
".",
"'\"'",
")",
";",
"}",
"$",
"diagrammService",
"=",
"$",
"this",
"->",
"getDiagrammService",
"(",
")",
";",
"return",
"$",
"diagrammService",
"->",
"createDiagrammFromNodes",
"(",
"array",
"(",
"$",
"entity",
")",
",",
"UseCaseDiagramm",
"::",
"TYPE_USE_CASE",
")",
";",
"}"
] |
Creates an use case diagramm from an single entity
@param int|\DlcUseCase\Entity\UseCase $entity
@return UseCaseDiagramm
|
[
"Creates",
"an",
"use",
"case",
"diagramm",
"from",
"an",
"single",
"entity"
] |
6a15aa7628594c343c334dabf0253ce2ae5d7f0b
|
https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Service/UseCase.php#L108-L119
|
235,450
|
jayaregalinada/chikka
|
src/Sender.php
|
Sender.sendAsync
|
public function sendAsync($mobileNumber, $message, $messageId = null)
{
$this->requestForm = new SenderForm($mobileNumber, $message, $messageId);
return $this->client->requestAsync('POST', '', ['form_params' => $this->requestForm->get()]);
}
|
php
|
public function sendAsync($mobileNumber, $message, $messageId = null)
{
$this->requestForm = new SenderForm($mobileNumber, $message, $messageId);
return $this->client->requestAsync('POST', '', ['form_params' => $this->requestForm->get()]);
}
|
[
"public",
"function",
"sendAsync",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"requestForm",
"=",
"new",
"SenderForm",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"requestAsync",
"(",
"'POST'",
",",
"''",
",",
"[",
"'form_params'",
"=>",
"$",
"this",
"->",
"requestForm",
"->",
"get",
"(",
")",
"]",
")",
";",
"}"
] |
Send a message and return a promise.
@param string $mobileNumber
@param string $message
@param string $messageId
@return \GuzzleHttp\Promise\Promise
|
[
"Send",
"a",
"message",
"and",
"return",
"a",
"promise",
"."
] |
eefd52c6a7c0e22fe82cef00c52874865456dddf
|
https://github.com/jayaregalinada/chikka/blob/eefd52c6a7c0e22fe82cef00c52874865456dddf/src/Sender.php#L61-L66
|
235,451
|
jayaregalinada/chikka
|
src/Sender.php
|
Sender.send
|
public function send($mobileNumber, $message, $messageId = null)
{
return $this->sendAsync($mobileNumber, $message, $messageId)
->then(
function (ResponseInterface $response) {
return new SentResponse($response, $this->requestForm);
},
function ($exception) {
return $this->throwError($exception);
}
)->wait();
}
|
php
|
public function send($mobileNumber, $message, $messageId = null)
{
return $this->sendAsync($mobileNumber, $message, $messageId)
->then(
function (ResponseInterface $response) {
return new SentResponse($response, $this->requestForm);
},
function ($exception) {
return $this->throwError($exception);
}
)->wait();
}
|
[
"public",
"function",
"send",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"mobileNumber",
",",
"$",
"message",
",",
"$",
"messageId",
")",
"->",
"then",
"(",
"function",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"return",
"new",
"SentResponse",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"requestForm",
")",
";",
"}",
",",
"function",
"(",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"throwError",
"(",
"$",
"exception",
")",
";",
"}",
")",
"->",
"wait",
"(",
")",
";",
"}"
] |
Send a message immediately.
@param string $mobileNumber
@param string $message
@param string $messageId
@throws inherits \Jag\Chikka\Exceptions\Exception
@return \Jag\Chikka\Responses\SentResponse
|
[
"Send",
"a",
"message",
"immediately",
"."
] |
eefd52c6a7c0e22fe82cef00c52874865456dddf
|
https://github.com/jayaregalinada/chikka/blob/eefd52c6a7c0e22fe82cef00c52874865456dddf/src/Sender.php#L79-L90
|
235,452
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.queryPosts
|
public static function queryPosts($args)
{
$query = new WP_Query($args);
// Set default return to false
$posts = false;
// Iterate and build the array of instances instances
if ($query->have_posts()) {
global $post;
// Create the array
$posts = array();
while ($query->have_posts()) {
$query->the_post();
$thePost = static::create($post);
array_push($posts, $thePost);
}
}
return $posts;
}
|
php
|
public static function queryPosts($args)
{
$query = new WP_Query($args);
// Set default return to false
$posts = false;
// Iterate and build the array of instances instances
if ($query->have_posts()) {
global $post;
// Create the array
$posts = array();
while ($query->have_posts()) {
$query->the_post();
$thePost = static::create($post);
array_push($posts, $thePost);
}
}
return $posts;
}
|
[
"public",
"static",
"function",
"queryPosts",
"(",
"$",
"args",
")",
"{",
"$",
"query",
"=",
"new",
"WP_Query",
"(",
"$",
"args",
")",
";",
"// Set default return to false",
"$",
"posts",
"=",
"false",
";",
"// Iterate and build the array of instances instances",
"if",
"(",
"$",
"query",
"->",
"have_posts",
"(",
")",
")",
"{",
"global",
"$",
"post",
";",
"// Create the array",
"$",
"posts",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"query",
"->",
"have_posts",
"(",
")",
")",
"{",
"$",
"query",
"->",
"the_post",
"(",
")",
";",
"$",
"thePost",
"=",
"static",
"::",
"create",
"(",
"$",
"post",
")",
";",
"array_push",
"(",
"$",
"posts",
",",
"$",
"thePost",
")",
";",
"}",
"}",
"return",
"$",
"posts",
";",
"}"
] |
Query for posts and returns an array of the model
@access public
@static
@return array|bool
|
[
"Query",
"for",
"posts",
"and",
"returns",
"an",
"array",
"of",
"the",
"model"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L70-L87
|
235,453
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.create
|
public static function create($post)
{
// If numeric, create the post
if (is_numeric($post)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)', $post);
$storedData = WP::getTransient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the post object
$post = WP::getPost(intval($post));
// Store the transient
WP::setTransient($transientKey, $post, static::$transientTimeout);
} else {
$post = $storedData;
}
} elseif (is_array($post)) {
// Convert array into object
$post = (object) $post;
}
return new static($post);
}
|
php
|
public static function create($post)
{
// If numeric, create the post
if (is_numeric($post)) {
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)', $post);
$storedData = WP::getTransient($transientKey);
// If the transient doesn't yet exist, query for it!
if ($storedData === false) {
// Retrieve the post object
$post = WP::getPost(intval($post));
// Store the transient
WP::setTransient($transientKey, $post, static::$transientTimeout);
} else {
$post = $storedData;
}
} elseif (is_array($post)) {
// Convert array into object
$post = (object) $post;
}
return new static($post);
}
|
[
"public",
"static",
"function",
"create",
"(",
"$",
"post",
")",
"{",
"// If numeric, create the post",
"if",
"(",
"is_numeric",
"(",
"$",
"post",
")",
")",
"{",
"// Retrieve the transient",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post(%d)'",
",",
"$",
"post",
")",
";",
"$",
"storedData",
"=",
"WP",
"::",
"getTransient",
"(",
"$",
"transientKey",
")",
";",
"// If the transient doesn't yet exist, query for it!",
"if",
"(",
"$",
"storedData",
"===",
"false",
")",
"{",
"// Retrieve the post object",
"$",
"post",
"=",
"WP",
"::",
"getPost",
"(",
"intval",
"(",
"$",
"post",
")",
")",
";",
"// Store the transient",
"WP",
"::",
"setTransient",
"(",
"$",
"transientKey",
",",
"$",
"post",
",",
"static",
"::",
"$",
"transientTimeout",
")",
";",
"}",
"else",
"{",
"$",
"post",
"=",
"$",
"storedData",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"post",
")",
")",
"{",
"// Convert array into object",
"$",
"post",
"=",
"(",
"object",
")",
"$",
"post",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"post",
")",
";",
"}"
] |
Creates a new instance by the post ID
@access public
@param array|int|WP_Post $postId
@return static
|
[
"Creates",
"a",
"new",
"instance",
"by",
"the",
"post",
"ID"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L109-L130
|
235,454
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.loadMetaData
|
protected function loadMetaData()
{
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
$metaData = WP::getTransient($transientKey);
// If it doesn't exist
if (!$metaData) {
$keys = WP::getPostCustom($this->id());
$metaData = array();
if ($keys && is_array($keys) && count($keys)) {
foreach ($keys as $key => $value) {
// If only 1 value, it's a string
if (is_array($value) && count($value) == 1) {
$metaData[$key] = $value[0];
} else {
$metaData[$key] = $value;
}
}
}
WP::setTransient($transientKey, $metaData, static::$transientTimeout);
}
$this->metaData = $metaData;
}
|
php
|
protected function loadMetaData()
{
// Retrieve the transient
$transientKey = sprintf('WPMVC\Models\Post(%d)::loadMetaData', $this->id());
$metaData = WP::getTransient($transientKey);
// If it doesn't exist
if (!$metaData) {
$keys = WP::getPostCustom($this->id());
$metaData = array();
if ($keys && is_array($keys) && count($keys)) {
foreach ($keys as $key => $value) {
// If only 1 value, it's a string
if (is_array($value) && count($value) == 1) {
$metaData[$key] = $value[0];
} else {
$metaData[$key] = $value;
}
}
}
WP::setTransient($transientKey, $metaData, static::$transientTimeout);
}
$this->metaData = $metaData;
}
|
[
"protected",
"function",
"loadMetaData",
"(",
")",
"{",
"// Retrieve the transient",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post(%d)::loadMetaData'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"metaData",
"=",
"WP",
"::",
"getTransient",
"(",
"$",
"transientKey",
")",
";",
"// If it doesn't exist",
"if",
"(",
"!",
"$",
"metaData",
")",
"{",
"$",
"keys",
"=",
"WP",
"::",
"getPostCustom",
"(",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"metaData",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"keys",
"&&",
"is_array",
"(",
"$",
"keys",
")",
"&&",
"count",
"(",
"$",
"keys",
")",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// If only 1 value, it's a string",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"count",
"(",
"$",
"value",
")",
"==",
"1",
")",
"{",
"$",
"metaData",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"metaData",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"WP",
"::",
"setTransient",
"(",
"$",
"transientKey",
",",
"$",
"metaData",
",",
"static",
"::",
"$",
"transientTimeout",
")",
";",
"}",
"$",
"this",
"->",
"metaData",
"=",
"$",
"metaData",
";",
"}"
] |
Loads the post's meta data
@access protected
@return void
|
[
"Loads",
"the",
"post",
"s",
"meta",
"data"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L157-L179
|
235,455
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.hasMeta
|
public function hasMeta($option)
{
return (isset($this->metaData[$option])) ? $this->metaData[$option] : false;
}
|
php
|
public function hasMeta($option)
{
return (isset($this->metaData[$option])) ? $this->metaData[$option] : false;
}
|
[
"public",
"function",
"hasMeta",
"(",
"$",
"option",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"metaData",
"[",
"$",
"option",
"]",
")",
")",
"?",
"$",
"this",
"->",
"metaData",
"[",
"$",
"option",
"]",
":",
"false",
";",
"}"
] |
Checks if the post has a meta key
@access public
@return bool
|
[
"Checks",
"if",
"the",
"post",
"has",
"a",
"meta",
"key"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L210-L213
|
235,456
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.content
|
public function content($moreLinkText = null, $stripTeaser = false)
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
$content = get_the_content($moreLinkText, $stripTeaser);
// Apply filter
$content = WP::applyFilters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $content;
}
|
php
|
public function content($moreLinkText = null, $stripTeaser = false)
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
$content = get_the_content($moreLinkText, $stripTeaser);
// Apply filter
$content = WP::applyFilters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $content;
}
|
[
"public",
"function",
"content",
"(",
"$",
"moreLinkText",
"=",
"null",
",",
"$",
"stripTeaser",
"=",
"false",
")",
"{",
"global",
"$",
"post",
";",
"// Store current post into temp variable",
"$",
"_p",
"=",
"$",
"post",
";",
"$",
"post",
"=",
"$",
"this",
"->",
"post",
";",
"setup_postdata",
"(",
"$",
"post",
")",
";",
"$",
"content",
"=",
"get_the_content",
"(",
"$",
"moreLinkText",
",",
"$",
"stripTeaser",
")",
";",
"// Apply filter",
"$",
"content",
"=",
"WP",
"::",
"applyFilters",
"(",
"'the_content'",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
"']]>'",
",",
"']]>'",
",",
"$",
"content",
")",
";",
"// Restore the post",
"$",
"post",
"=",
"$",
"_p",
";",
"if",
"(",
"$",
"_p",
")",
"{",
"setup_postdata",
"(",
"$",
"post",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] |
Retrieve the post's content
Note: Temporarily sets the global $post object to the event post and resets it
@access public
@link http://codex.wordpress.org/Function_Reference/get_the_title
@global WP_Post $post
@param string $moreLinkText (default: null)
@param string $stripTeaser boolean (default: false)
@return string
|
[
"Retrieve",
"the",
"post",
"s",
"content"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L290-L307
|
235,457
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.excerpt
|
public function excerpt($wordCount = 20, $delimiter = '...')
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
// Do the magic!
$limit = $wordCount + 1;
$full_excerpt = get_the_excerpt();
$full_excerpt_count = count(explode(' ', $full_excerpt)); /* Correct Word Count */
$new_excerpt = explode(' ', $full_excerpt, $limit);
if ($full_excerpt_count <= $wordCount) {
$delimiter = '';
} else {
array_pop($new_excerpt);
}
$new_excerpt = implode(' ', $new_excerpt) . $delimiter;
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $new_excerpt;
}
|
php
|
public function excerpt($wordCount = 20, $delimiter = '...')
{
global $post;
// Store current post into temp variable
$_p = $post;
$post = $this->post;
setup_postdata($post);
// Do the magic!
$limit = $wordCount + 1;
$full_excerpt = get_the_excerpt();
$full_excerpt_count = count(explode(' ', $full_excerpt)); /* Correct Word Count */
$new_excerpt = explode(' ', $full_excerpt, $limit);
if ($full_excerpt_count <= $wordCount) {
$delimiter = '';
} else {
array_pop($new_excerpt);
}
$new_excerpt = implode(' ', $new_excerpt) . $delimiter;
// Restore the post
$post = $_p;
if ($_p) {
setup_postdata($post);
}
return $new_excerpt;
}
|
[
"public",
"function",
"excerpt",
"(",
"$",
"wordCount",
"=",
"20",
",",
"$",
"delimiter",
"=",
"'...'",
")",
"{",
"global",
"$",
"post",
";",
"// Store current post into temp variable",
"$",
"_p",
"=",
"$",
"post",
";",
"$",
"post",
"=",
"$",
"this",
"->",
"post",
";",
"setup_postdata",
"(",
"$",
"post",
")",
";",
"// Do the magic!",
"$",
"limit",
"=",
"$",
"wordCount",
"+",
"1",
";",
"$",
"full_excerpt",
"=",
"get_the_excerpt",
"(",
")",
";",
"$",
"full_excerpt_count",
"=",
"count",
"(",
"explode",
"(",
"' '",
",",
"$",
"full_excerpt",
")",
")",
";",
"/* Correct Word Count */",
"$",
"new_excerpt",
"=",
"explode",
"(",
"' '",
",",
"$",
"full_excerpt",
",",
"$",
"limit",
")",
";",
"if",
"(",
"$",
"full_excerpt_count",
"<=",
"$",
"wordCount",
")",
"{",
"$",
"delimiter",
"=",
"''",
";",
"}",
"else",
"{",
"array_pop",
"(",
"$",
"new_excerpt",
")",
";",
"}",
"$",
"new_excerpt",
"=",
"implode",
"(",
"' '",
",",
"$",
"new_excerpt",
")",
".",
"$",
"delimiter",
";",
"// Restore the post",
"$",
"post",
"=",
"$",
"_p",
";",
"if",
"(",
"$",
"_p",
")",
"{",
"setup_postdata",
"(",
"$",
"post",
")",
";",
"}",
"return",
"$",
"new_excerpt",
";",
"}"
] |
Retrieve the post's excerpt
Note: Temporarily sets the global $post object to the event post and resets it
@access public
@link http://codex.wordpress.org/Function_Reference/get_the_excerpt
@global WP_Post $post
@param int $wordCount (default: 20)
@param string $delimiter (default: '...')
@return string
|
[
"Retrieve",
"the",
"post",
"s",
"excerpt"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L321-L345
|
235,458
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.getTerms
|
public function getTerms($taxonomy)
{
// If terms isn't set
if (!$this->terms) {
// Retrieve the transient value
$transientKey = sprintf('WPMVC\Models\Post::getTerms(%s)', $this->id(), $taxonomy);
$terms = WP::getTransient($transientKey);
// If the terms isn't found in the cache
if (!$terms) {
// Query for the terms
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
// Retrieve and set the terms
$terms = wp_get_post_terms($this->id(), $taxonomy, $args);
// Store into the cache
WP::setTransient($transientKey, $terms, static::$transientTimeout);
}
// Set the terms
$this->terms[$taxonomy] = $terms;
}
return $this->terms[$taxonomy];
}
|
php
|
public function getTerms($taxonomy)
{
// If terms isn't set
if (!$this->terms) {
// Retrieve the transient value
$transientKey = sprintf('WPMVC\Models\Post::getTerms(%s)', $this->id(), $taxonomy);
$terms = WP::getTransient($transientKey);
// If the terms isn't found in the cache
if (!$terms) {
// Query for the terms
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
// Retrieve and set the terms
$terms = wp_get_post_terms($this->id(), $taxonomy, $args);
// Store into the cache
WP::setTransient($transientKey, $terms, static::$transientTimeout);
}
// Set the terms
$this->terms[$taxonomy] = $terms;
}
return $this->terms[$taxonomy];
}
|
[
"public",
"function",
"getTerms",
"(",
"$",
"taxonomy",
")",
"{",
"// If terms isn't set",
"if",
"(",
"!",
"$",
"this",
"->",
"terms",
")",
"{",
"// Retrieve the transient value",
"$",
"transientKey",
"=",
"sprintf",
"(",
"'WPMVC\\Models\\Post::getTerms(%s)'",
",",
"$",
"this",
"->",
"id",
"(",
")",
",",
"$",
"taxonomy",
")",
";",
"$",
"terms",
"=",
"WP",
"::",
"getTransient",
"(",
"$",
"transientKey",
")",
";",
"// If the terms isn't found in the cache",
"if",
"(",
"!",
"$",
"terms",
")",
"{",
"// Query for the terms",
"$",
"args",
"=",
"array",
"(",
"'orderby'",
"=>",
"'name'",
",",
"'order'",
"=>",
"'ASC'",
")",
";",
"// Retrieve and set the terms",
"$",
"terms",
"=",
"wp_get_post_terms",
"(",
"$",
"this",
"->",
"id",
"(",
")",
",",
"$",
"taxonomy",
",",
"$",
"args",
")",
";",
"// Store into the cache",
"WP",
"::",
"setTransient",
"(",
"$",
"transientKey",
",",
"$",
"terms",
",",
"static",
"::",
"$",
"transientTimeout",
")",
";",
"}",
"// Set the terms",
"$",
"this",
"->",
"terms",
"[",
"$",
"taxonomy",
"]",
"=",
"$",
"terms",
";",
"}",
"return",
"$",
"this",
"->",
"terms",
"[",
"$",
"taxonomy",
"]",
";",
"}"
] |
Retrieves the taxonomy terms for the post
@access public
@return object
|
[
"Retrieves",
"the",
"taxonomy",
"terms",
"for",
"the",
"post"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L387-L410
|
235,459
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.thumbnail
|
public function thumbnail($size = 'full')
{
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($this->id()), $size);
return isset($thumb[0]) ? $thumb[0] : '';
}
|
php
|
public function thumbnail($size = 'full')
{
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($this->id()), $size);
return isset($thumb[0]) ? $thumb[0] : '';
}
|
[
"public",
"function",
"thumbnail",
"(",
"$",
"size",
"=",
"'full'",
")",
"{",
"$",
"thumb",
"=",
"wp_get_attachment_image_src",
"(",
"get_post_thumbnail_id",
"(",
"$",
"this",
"->",
"id",
"(",
")",
")",
",",
"$",
"size",
")",
";",
"return",
"isset",
"(",
"$",
"thumb",
"[",
"0",
"]",
")",
"?",
"$",
"thumb",
"[",
"0",
"]",
":",
"''",
";",
"}"
] |
Retrieve the post's thumbnail
@access public
@global object $post
@param string $size (default: "full")
@return string
|
[
"Retrieve",
"the",
"post",
"s",
"thumbnail"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L453-L457
|
235,460
|
vutran/wpmvc-core
|
src/Models/Post.php
|
Post.loadAdjacentPost
|
protected function loadAdjacentPost($direction = null)
{
$loadPrev = $loadNext = false;
switch ($direction) {
case 'prev':
$loadPrev = true;
break;
case 'next':
$loadNext = true;
break;
default:
$loadPrev = $loadNext = true;
break;
}
if ($loadPrev && !$this->prevPost) {
$this->prevPost = $this->getAdjacentPost('prev', $this->get('post_type'));
}
if ($loadNext && !$this->nextPost) {
$this->nextPost = $this->getAdjacentPost('next', $this->get('post_type'));
}
}
|
php
|
protected function loadAdjacentPost($direction = null)
{
$loadPrev = $loadNext = false;
switch ($direction) {
case 'prev':
$loadPrev = true;
break;
case 'next':
$loadNext = true;
break;
default:
$loadPrev = $loadNext = true;
break;
}
if ($loadPrev && !$this->prevPost) {
$this->prevPost = $this->getAdjacentPost('prev', $this->get('post_type'));
}
if ($loadNext && !$this->nextPost) {
$this->nextPost = $this->getAdjacentPost('next', $this->get('post_type'));
}
}
|
[
"protected",
"function",
"loadAdjacentPost",
"(",
"$",
"direction",
"=",
"null",
")",
"{",
"$",
"loadPrev",
"=",
"$",
"loadNext",
"=",
"false",
";",
"switch",
"(",
"$",
"direction",
")",
"{",
"case",
"'prev'",
":",
"$",
"loadPrev",
"=",
"true",
";",
"break",
";",
"case",
"'next'",
":",
"$",
"loadNext",
"=",
"true",
";",
"break",
";",
"default",
":",
"$",
"loadPrev",
"=",
"$",
"loadNext",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"$",
"loadPrev",
"&&",
"!",
"$",
"this",
"->",
"prevPost",
")",
"{",
"$",
"this",
"->",
"prevPost",
"=",
"$",
"this",
"->",
"getAdjacentPost",
"(",
"'prev'",
",",
"$",
"this",
"->",
"get",
"(",
"'post_type'",
")",
")",
";",
"}",
"if",
"(",
"$",
"loadNext",
"&&",
"!",
"$",
"this",
"->",
"nextPost",
")",
"{",
"$",
"this",
"->",
"nextPost",
"=",
"$",
"this",
"->",
"getAdjacentPost",
"(",
"'next'",
",",
"$",
"this",
"->",
"get",
"(",
"'post_type'",
")",
")",
";",
"}",
"}"
] |
Loads the adjacent posts
@access public
@param string $direction (default: null)
@return void
|
[
"Loads",
"the",
"adjacent",
"posts"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/Post.php#L561-L581
|
235,461
|
fabsgc/framework
|
Core/General/Resolver.php
|
Resolver.resolveStatic
|
protected static function resolveStatic($type, $data) {
$request = Request::instance();
$config = Config::instance();
if ($type == RESOLVE_ROUTE || $type == RESOLVE_LANG) {
if (preg_match('#^((\.)([a-zA-Z0-9_-]+)(\.)(.+))#', $data, $matches)) {
$src = $matches[3];
$data = preg_replace('#^(\.)(' . preg_quote($src) . ')(\.)#isU', '', $data);
}
else {
$src = $request->src;
}
return [$config->config[$type][$src], $data];
}
else {
if (preg_match('#^((\.)([^(\/)]+)([(\/)]*)(.*))#', $data, $matches)) {
$src = $matches[3];
$data = $matches[5];
}
else {
if ($request->src != '') {
$src = $request->src;
}
else {
$src = 'app';
}
}
if ($src == 'vendor') {
return VENDOR_PATH . $data;
}
else {
if (!isset($config->config[$type][$src])) {
throw new MissingConfigException('The section "' . $type . '/' . $src . '" does not exist in configuration');
}
}
return $config->config[$type][$src] . $data;
}
}
|
php
|
protected static function resolveStatic($type, $data) {
$request = Request::instance();
$config = Config::instance();
if ($type == RESOLVE_ROUTE || $type == RESOLVE_LANG) {
if (preg_match('#^((\.)([a-zA-Z0-9_-]+)(\.)(.+))#', $data, $matches)) {
$src = $matches[3];
$data = preg_replace('#^(\.)(' . preg_quote($src) . ')(\.)#isU', '', $data);
}
else {
$src = $request->src;
}
return [$config->config[$type][$src], $data];
}
else {
if (preg_match('#^((\.)([^(\/)]+)([(\/)]*)(.*))#', $data, $matches)) {
$src = $matches[3];
$data = $matches[5];
}
else {
if ($request->src != '') {
$src = $request->src;
}
else {
$src = 'app';
}
}
if ($src == 'vendor') {
return VENDOR_PATH . $data;
}
else {
if (!isset($config->config[$type][$src])) {
throw new MissingConfigException('The section "' . $type . '/' . $src . '" does not exist in configuration');
}
}
return $config->config[$type][$src] . $data;
}
}
|
[
"protected",
"static",
"function",
"resolveStatic",
"(",
"$",
"type",
",",
"$",
"data",
")",
"{",
"$",
"request",
"=",
"Request",
"::",
"instance",
"(",
")",
";",
"$",
"config",
"=",
"Config",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"type",
"==",
"RESOLVE_ROUTE",
"||",
"$",
"type",
"==",
"RESOLVE_LANG",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^((\\.)([a-zA-Z0-9_-]+)(\\.)(.+))#'",
",",
"$",
"data",
",",
"$",
"matches",
")",
")",
"{",
"$",
"src",
"=",
"$",
"matches",
"[",
"3",
"]",
";",
"$",
"data",
"=",
"preg_replace",
"(",
"'#^(\\.)('",
".",
"preg_quote",
"(",
"$",
"src",
")",
".",
"')(\\.)#isU'",
",",
"''",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"src",
"=",
"$",
"request",
"->",
"src",
";",
"}",
"return",
"[",
"$",
"config",
"->",
"config",
"[",
"$",
"type",
"]",
"[",
"$",
"src",
"]",
",",
"$",
"data",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"preg_match",
"(",
"'#^((\\.)([^(\\/)]+)([(\\/)]*)(.*))#'",
",",
"$",
"data",
",",
"$",
"matches",
")",
")",
"{",
"$",
"src",
"=",
"$",
"matches",
"[",
"3",
"]",
";",
"$",
"data",
"=",
"$",
"matches",
"[",
"5",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"request",
"->",
"src",
"!=",
"''",
")",
"{",
"$",
"src",
"=",
"$",
"request",
"->",
"src",
";",
"}",
"else",
"{",
"$",
"src",
"=",
"'app'",
";",
"}",
"}",
"if",
"(",
"$",
"src",
"==",
"'vendor'",
")",
"{",
"return",
"VENDOR_PATH",
".",
"$",
"data",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"->",
"config",
"[",
"$",
"type",
"]",
"[",
"$",
"src",
"]",
")",
")",
"{",
"throw",
"new",
"MissingConfigException",
"(",
"'The section \"'",
".",
"$",
"type",
".",
"'/'",
".",
"$",
"src",
".",
"'\" does not exist in configuration'",
")",
";",
"}",
"}",
"return",
"$",
"config",
"->",
"config",
"[",
"$",
"type",
"]",
"[",
"$",
"src",
"]",
".",
"$",
"data",
";",
"}",
"}"
] |
when you want to use a lang, route, image, template, this method is used to resolve the right path
the method use the instance of \Gcs\Framework\Core\Config\Config
@access public
@param $type string : type of the config
@param $data string : ".gcs.lang" ".gcs/template/" "template"
@throws MissingConfigException
@return mixed
@since 3.0
@package Gcs\Framework\Core\General
|
[
"when",
"you",
"want",
"to",
"use",
"a",
"lang",
"route",
"image",
"template",
"this",
"method",
"is",
"used",
"to",
"resolve",
"the",
"right",
"path",
"the",
"method",
"use",
"the",
"instance",
"of",
"\\",
"Gcs",
"\\",
"Framework",
"\\",
"Core",
"\\",
"Config",
"\\",
"Config"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/General/Resolver.php#L68-L108
|
235,462
|
phlexible/phlexible
|
src/Phlexible/Bundle/TeaserBundle/Controller/RenderController.php
|
RenderController.htmlAction
|
public function htmlAction(Request $request, $teaserId)
{
$requestStack = $this->get('request_stack');
$masterRequest = $requestStack->getMasterRequest();
if ($request->get('preview') || $request->get('_preview')) {
$request->attributes->set('_preview', true);
} elseif ($masterRequest !== $request && $masterRequest->attributes->get('_preview')) {
$request->attributes->set('_preview', true);
}
$teaser = $this->get('phlexible_teaser.teaser_service')->find($teaserId);
$request->attributes->set('contentDocument', $teaser);
$renderConfigurator = $this->get('phlexible_element_renderer.configurator');
$renderConfig = $renderConfigurator->configure($request);
if ($renderConfig->getResponse()) {
return $renderConfig->getResponse();
}
if ($request->get('template')) {
$renderConfig->set('template', $request->get('template', 'teaser'));
}
$data = $renderConfig->getVariables();
return $this->render($data['template'], (array) $data);
}
|
php
|
public function htmlAction(Request $request, $teaserId)
{
$requestStack = $this->get('request_stack');
$masterRequest = $requestStack->getMasterRequest();
if ($request->get('preview') || $request->get('_preview')) {
$request->attributes->set('_preview', true);
} elseif ($masterRequest !== $request && $masterRequest->attributes->get('_preview')) {
$request->attributes->set('_preview', true);
}
$teaser = $this->get('phlexible_teaser.teaser_service')->find($teaserId);
$request->attributes->set('contentDocument', $teaser);
$renderConfigurator = $this->get('phlexible_element_renderer.configurator');
$renderConfig = $renderConfigurator->configure($request);
if ($renderConfig->getResponse()) {
return $renderConfig->getResponse();
}
if ($request->get('template')) {
$renderConfig->set('template', $request->get('template', 'teaser'));
}
$data = $renderConfig->getVariables();
return $this->render($data['template'], (array) $data);
}
|
[
"public",
"function",
"htmlAction",
"(",
"Request",
"$",
"request",
",",
"$",
"teaserId",
")",
"{",
"$",
"requestStack",
"=",
"$",
"this",
"->",
"get",
"(",
"'request_stack'",
")",
";",
"$",
"masterRequest",
"=",
"$",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"get",
"(",
"'preview'",
")",
"||",
"$",
"request",
"->",
"get",
"(",
"'_preview'",
")",
")",
"{",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'_preview'",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"masterRequest",
"!==",
"$",
"request",
"&&",
"$",
"masterRequest",
"->",
"attributes",
"->",
"get",
"(",
"'_preview'",
")",
")",
"{",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'_preview'",
",",
"true",
")",
";",
"}",
"$",
"teaser",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_teaser.teaser_service'",
")",
"->",
"find",
"(",
"$",
"teaserId",
")",
";",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'contentDocument'",
",",
"$",
"teaser",
")",
";",
"$",
"renderConfigurator",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element_renderer.configurator'",
")",
";",
"$",
"renderConfig",
"=",
"$",
"renderConfigurator",
"->",
"configure",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"renderConfig",
"->",
"getResponse",
"(",
")",
")",
"{",
"return",
"$",
"renderConfig",
"->",
"getResponse",
"(",
")",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"get",
"(",
"'template'",
")",
")",
"{",
"$",
"renderConfig",
"->",
"set",
"(",
"'template'",
",",
"$",
"request",
"->",
"get",
"(",
"'template'",
",",
"'teaser'",
")",
")",
";",
"}",
"$",
"data",
"=",
"$",
"renderConfig",
"->",
"getVariables",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"data",
"[",
"'template'",
"]",
",",
"(",
"array",
")",
"$",
"data",
")",
";",
"}"
] |
Render action.
@param Request $request
@param int $teaserId
@return Response
@Route("/{_locale}/{teaserId}", name="teaser_render")
|
[
"Render",
"action",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/RenderController.php#L36-L65
|
235,463
|
yani-/zip-factory
|
lib/ArchiverPclZip.php
|
ArchiverPclZip.addFromString
|
public function addFromString($localname , $contents)
{
return $this->pclZip->add(
array(
array(
PCLZIP_ATT_FILE_NAME => $localname,
PCLZIP_ATT_FILE_CONTENT => $contents,
)
)
);
}
|
php
|
public function addFromString($localname , $contents)
{
return $this->pclZip->add(
array(
array(
PCLZIP_ATT_FILE_NAME => $localname,
PCLZIP_ATT_FILE_CONTENT => $contents,
)
)
);
}
|
[
"public",
"function",
"addFromString",
"(",
"$",
"localname",
",",
"$",
"contents",
")",
"{",
"return",
"$",
"this",
"->",
"pclZip",
"->",
"add",
"(",
"array",
"(",
"array",
"(",
"PCLZIP_ATT_FILE_NAME",
"=>",
"$",
"localname",
",",
"PCLZIP_ATT_FILE_CONTENT",
"=>",
"$",
"contents",
",",
")",
")",
")",
";",
"}"
] |
Add a file to a ZIP archive using its contents
@param string $localname The name of the entry to create.
@param string $contents The contents to use to create the entry. It is used in a binary safe mode.
@return boolean
|
[
"Add",
"a",
"file",
"to",
"a",
"ZIP",
"archive",
"using",
"its",
"contents"
] |
bbf202f9c183d5885aa5cce905fc50782eea10b9
|
https://github.com/yani-/zip-factory/blob/bbf202f9c183d5885aa5cce905fc50782eea10b9/lib/ArchiverPclZip.php#L128-L138
|
235,464
|
tekton-php/support
|
src/Manifest/FileFormat.php
|
FileFormat.write
|
public function write(string $uri, $data)
{
// Create directory recursively if it doesn't exist
if ( ! file_exists(dirname($uri))) {
mkdir(dirname($uri), 0755, true);
}
// Write file to target directory
if ( ! file_put_contents($uri, $data)) {
throw new ErrorException("Failed to write output to file: ".$uri);
}
return true;
}
|
php
|
public function write(string $uri, $data)
{
// Create directory recursively if it doesn't exist
if ( ! file_exists(dirname($uri))) {
mkdir(dirname($uri), 0755, true);
}
// Write file to target directory
if ( ! file_put_contents($uri, $data)) {
throw new ErrorException("Failed to write output to file: ".$uri);
}
return true;
}
|
[
"public",
"function",
"write",
"(",
"string",
"$",
"uri",
",",
"$",
"data",
")",
"{",
"// Create directory recursively if it doesn't exist",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"uri",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"uri",
")",
",",
"0755",
",",
"true",
")",
";",
"}",
"// Write file to target directory",
"if",
"(",
"!",
"file_put_contents",
"(",
"$",
"uri",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"ErrorException",
"(",
"\"Failed to write output to file: \"",
".",
"$",
"uri",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Write the data to the storage engine
@param string $uri The URI handle
@param mixed $data The data in whatever format encode outputted
@return boolean Whether it was a successful write or not
|
[
"Write",
"the",
"data",
"to",
"the",
"storage",
"engine"
] |
615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5
|
https://github.com/tekton-php/support/blob/615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5/src/Manifest/FileFormat.php#L34-L47
|
235,465
|
easy-system/es-system
|
src/Components/Components.php
|
Components.register
|
public function register($class)
{
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
if (! class_exists($class)) {
throw new RuntimeException(sprintf(
'The component "%s" not exists.',
$class
));
}
$component = new $class();
if (! $component instanceof ComponentInterface) {
throw new InvalidArgumentException(sprintf(
'The component "%s" must implement "%s".',
$class,
ComponentInterface::CLASS
));
}
$this->container[$class] = $component;
return md5($class . $component->getVersion());
}
|
php
|
public function register($class)
{
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
if (! class_exists($class)) {
throw new RuntimeException(sprintf(
'The component "%s" not exists.',
$class
));
}
$component = new $class();
if (! $component instanceof ComponentInterface) {
throw new InvalidArgumentException(sprintf(
'The component "%s" must implement "%s".',
$class,
ComponentInterface::CLASS
));
}
$this->container[$class] = $component;
return md5($class . $component->getVersion());
}
|
[
"public",
"function",
"register",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'The components have already been initialized.'",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The component \"%s\" not exists.'",
",",
"$",
"class",
")",
")",
";",
"}",
"$",
"component",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"!",
"$",
"component",
"instanceof",
"ComponentInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The component \"%s\" must implement \"%s\".'",
",",
"$",
"class",
",",
"ComponentInterface",
"::",
"CLASS",
")",
")",
";",
"}",
"$",
"this",
"->",
"container",
"[",
"$",
"class",
"]",
"=",
"$",
"component",
";",
"return",
"md5",
"(",
"$",
"class",
".",
"$",
"component",
"->",
"getVersion",
"(",
")",
")",
";",
"}"
] |
Register the component.
@param string $class The class of component
@throws \InvalidArgumentException If the specified class not implements
the Es\Component\ComponentInterface
@throws \RuntimeException
- If If the components have already been initialized
- If the specified class of component does not exists
@return string The hash of component state
|
[
"Register",
"the",
"component",
"."
] |
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
|
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Components/Components.php#L51-L76
|
235,466
|
easy-system/es-system
|
src/Components/Components.php
|
Components.init
|
public function init(
ServicesInterface $services,
ListenersInterface $listeners,
EventsInterface $events,
ConfigInterface $config
) {
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
$this->initialized = true;
foreach ($this->container as $component) {
if (method_exists($component, 'getServicesConfig')) {
$services->add($component->getServicesConfig());
}
if (method_exists($component, 'getListenersConfig')) {
$listeners->add($component->getListenersConfig());
}
if (method_exists($component, 'getEventsConfig')) {
foreach ($component->getEventsConfig() as $item) {
call_user_func_array([$events, 'attach'], $item);
}
}
if (method_exists($component, 'getSystemConfig')) {
$config->merge($component->getSystemConfig());
}
}
}
|
php
|
public function init(
ServicesInterface $services,
ListenersInterface $listeners,
EventsInterface $events,
ConfigInterface $config
) {
if ($this->initialized) {
throw new RuntimeException(
'The components have already been initialized.'
);
}
$this->initialized = true;
foreach ($this->container as $component) {
if (method_exists($component, 'getServicesConfig')) {
$services->add($component->getServicesConfig());
}
if (method_exists($component, 'getListenersConfig')) {
$listeners->add($component->getListenersConfig());
}
if (method_exists($component, 'getEventsConfig')) {
foreach ($component->getEventsConfig() as $item) {
call_user_func_array([$events, 'attach'], $item);
}
}
if (method_exists($component, 'getSystemConfig')) {
$config->merge($component->getSystemConfig());
}
}
}
|
[
"public",
"function",
"init",
"(",
"ServicesInterface",
"$",
"services",
",",
"ListenersInterface",
"$",
"listeners",
",",
"EventsInterface",
"$",
"events",
",",
"ConfigInterface",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'The components have already been initialized.'",
")",
";",
"}",
"$",
"this",
"->",
"initialized",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"container",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'getServicesConfig'",
")",
")",
"{",
"$",
"services",
"->",
"add",
"(",
"$",
"component",
"->",
"getServicesConfig",
"(",
")",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'getListenersConfig'",
")",
")",
"{",
"$",
"listeners",
"->",
"add",
"(",
"$",
"component",
"->",
"getListenersConfig",
"(",
")",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'getEventsConfig'",
")",
")",
"{",
"foreach",
"(",
"$",
"component",
"->",
"getEventsConfig",
"(",
")",
"as",
"$",
"item",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"events",
",",
"'attach'",
"]",
",",
"$",
"item",
")",
";",
"}",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'getSystemConfig'",
")",
")",
"{",
"$",
"config",
"->",
"merge",
"(",
"$",
"component",
"->",
"getSystemConfig",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Initializes components.
@param \Es\Services\ServicesInterface $services The services
@param \Es\Events\ListenersInterface $listeners The listeners
@param \Es\Events\EventsInterface $events The events
@param \Es\System\ConfigInterface $config The system configuration
@throws \RuntimeException If the components have already been initialized
|
[
"Initializes",
"components",
"."
] |
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
|
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/Components/Components.php#L133-L162
|
235,467
|
ironedgesoftware/file-utils
|
src/File/Factory.php
|
Factory.createInstance
|
public function createInstance($file, $type = null, array $options = array())
{
if (!is_file($file) && $type === null) {
throw new \InvalidArgumentException(
'You must enter a $type if the file does not exist yet.'
);
}
$type = pathinfo($file, PATHINFO_EXTENSION);
switch ($type) {
case self::JSON_TYPE:
$file = new Json($file, $options);
break;
case self::YAML_TYPE:
$file = new Yaml($file, $options);
break;
default:
throw UnsupportedFileTypeException::create($type);
}
return $file;
}
|
php
|
public function createInstance($file, $type = null, array $options = array())
{
if (!is_file($file) && $type === null) {
throw new \InvalidArgumentException(
'You must enter a $type if the file does not exist yet.'
);
}
$type = pathinfo($file, PATHINFO_EXTENSION);
switch ($type) {
case self::JSON_TYPE:
$file = new Json($file, $options);
break;
case self::YAML_TYPE:
$file = new Yaml($file, $options);
break;
default:
throw UnsupportedFileTypeException::create($type);
}
return $file;
}
|
[
"public",
"function",
"createInstance",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
"&&",
"$",
"type",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You must enter a $type if the file does not exist yet.'",
")",
";",
"}",
"$",
"type",
"=",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_EXTENSION",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"JSON_TYPE",
":",
"$",
"file",
"=",
"new",
"Json",
"(",
"$",
"file",
",",
"$",
"options",
")",
";",
"break",
";",
"case",
"self",
"::",
"YAML_TYPE",
":",
"$",
"file",
"=",
"new",
"Yaml",
"(",
"$",
"file",
",",
"$",
"options",
")",
";",
"break",
";",
"default",
":",
"throw",
"UnsupportedFileTypeException",
"::",
"create",
"(",
"$",
"type",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Creates an instance of a file.
@param string $file - File.
@param null|string $type - Type.
@param array $options - Options.
@throws UnsupportedFileTypeException - If the file type cannot be handled.
@return \IronEdge\Component\FileUtils\File\Base
|
[
"Creates",
"an",
"instance",
"of",
"a",
"file",
"."
] |
d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb
|
https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Factory.php#L36-L60
|
235,468
|
MarcusFulbright/represent
|
src/Represent/Factory/PaginationFactory.php
|
PaginationFactory.makePagerFromArray
|
protected function makePagerFromArray($data, $page = 1, $limit = 10)
{
$adapter = new ArrayAdapter($data);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage($limit);
$pager->setCurrentPage($page);
return $pager;
}
|
php
|
protected function makePagerFromArray($data, $page = 1, $limit = 10)
{
$adapter = new ArrayAdapter($data);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage($limit);
$pager->setCurrentPage($page);
return $pager;
}
|
[
"protected",
"function",
"makePagerFromArray",
"(",
"$",
"data",
",",
"$",
"page",
"=",
"1",
",",
"$",
"limit",
"=",
"10",
")",
"{",
"$",
"adapter",
"=",
"new",
"ArrayAdapter",
"(",
"$",
"data",
")",
";",
"$",
"pager",
"=",
"new",
"Pagerfanta",
"(",
"$",
"adapter",
")",
";",
"$",
"pager",
"->",
"setMaxPerPage",
"(",
"$",
"limit",
")",
";",
"$",
"pager",
"->",
"setCurrentPage",
"(",
"$",
"page",
")",
";",
"return",
"$",
"pager",
";",
"}"
] |
Creates a pager from an array
@param $data
@param int $page
@param int $limit
@return Pagerfanta
|
[
"Creates",
"a",
"pager",
"from",
"an",
"array"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Factory/PaginationFactory.php#L35-L43
|
235,469
|
MarcusFulbright/represent
|
src/Represent/Factory/PaginationFactory.php
|
PaginationFactory.paginate
|
public function paginate(array $data, $page, $limit , $url, $params = array())
{
$pager = $this->makePagerFromArray($data, $page, $limit);
return $this->factory->createCollectionFromPager($pager, $url, $params);
}
|
php
|
public function paginate(array $data, $page, $limit , $url, $params = array())
{
$pager = $this->makePagerFromArray($data, $page, $limit);
return $this->factory->createCollectionFromPager($pager, $url, $params);
}
|
[
"public",
"function",
"paginate",
"(",
"array",
"$",
"data",
",",
"$",
"page",
",",
"$",
"limit",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"pager",
"=",
"$",
"this",
"->",
"makePagerFromArray",
"(",
"$",
"data",
",",
"$",
"page",
",",
"$",
"limit",
")",
";",
"return",
"$",
"this",
"->",
"factory",
"->",
"createCollectionFromPager",
"(",
"$",
"pager",
",",
"$",
"url",
",",
"$",
"params",
")",
";",
"}"
] |
Handles creating a pager and turning it into a collection representation
@param $data
@param $page
@param $limit
@param $url
@param array $params
@return PaginatedCollection
|
[
"Handles",
"creating",
"a",
"pager",
"and",
"turning",
"it",
"into",
"a",
"collection",
"representation"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Factory/PaginationFactory.php#L55-L60
|
235,470
|
fabsgc/framework
|
Core/Lang/Langs.php
|
Langs.getLangClient
|
public function getLangClient() {
if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) || !$_SERVER['HTTP_ACCEPT_LANGUAGE']) {
return Config::config()['user']['output']['lang'];
}
else {
$langcode = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$langcode = (!empty($langcode)) ? explode(";", $langcode) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode(",", $langcode['0']) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode("-", $langcode['0']) : $langcode;
return $langcode['0'];
}
}
|
php
|
public function getLangClient() {
if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) || !$_SERVER['HTTP_ACCEPT_LANGUAGE']) {
return Config::config()['user']['output']['lang'];
}
else {
$langcode = (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$langcode = (!empty($langcode)) ? explode(";", $langcode) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode(",", $langcode['0']) : $langcode;
$langcode = (!empty($langcode['0'])) ? explode("-", $langcode['0']) : $langcode;
return $langcode['0'];
}
}
|
[
"public",
"function",
"getLangClient",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'HTTP_ACCEPT_LANGUAGE'",
",",
"$",
"_SERVER",
")",
"||",
"!",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT_LANGUAGE'",
"]",
")",
"{",
"return",
"Config",
"::",
"config",
"(",
")",
"[",
"'user'",
"]",
"[",
"'output'",
"]",
"[",
"'lang'",
"]",
";",
"}",
"else",
"{",
"$",
"langcode",
"=",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT_LANGUAGE'",
"]",
")",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT_LANGUAGE'",
"]",
":",
"''",
";",
"$",
"langcode",
"=",
"(",
"!",
"empty",
"(",
"$",
"langcode",
")",
")",
"?",
"explode",
"(",
"\";\"",
",",
"$",
"langcode",
")",
":",
"$",
"langcode",
";",
"$",
"langcode",
"=",
"(",
"!",
"empty",
"(",
"$",
"langcode",
"[",
"'0'",
"]",
")",
")",
"?",
"explode",
"(",
"\",\"",
",",
"$",
"langcode",
"[",
"'0'",
"]",
")",
":",
"$",
"langcode",
";",
"$",
"langcode",
"=",
"(",
"!",
"empty",
"(",
"$",
"langcode",
"[",
"'0'",
"]",
")",
")",
"?",
"explode",
"(",
"\"-\"",
",",
"$",
"langcode",
"[",
"'0'",
"]",
")",
":",
"$",
"langcode",
";",
"return",
"$",
"langcode",
"[",
"'0'",
"]",
";",
"}",
"}"
] |
get the client language
@access public
@return string
@since 3.0
@package Gcs\Framework\Core\Lang
|
[
"get",
"the",
"client",
"language"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Lang/Langs.php#L36-L48
|
235,471
|
cmdweb/cache
|
Cache/Cache.php
|
Cache.delete
|
public function delete($key){
$file = $this->generateFileLocation($key);
if(file_exists($file))
unlink($file);
}
|
php
|
public function delete($key){
$file = $this->generateFileLocation($key);
if(file_exists($file))
unlink($file);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"generateFileLocation",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"unlink",
"(",
"$",
"file",
")",
";",
"}"
] |
Limpa um cache
|
[
"Limpa",
"um",
"cache"
] |
b1ca4249596bffe93d23b46ba298785d17fa1e10
|
https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L99-L104
|
235,472
|
cmdweb/cache
|
Cache/Cache.php
|
Cache.set
|
public function set($key, $content, $time = null) {
$time = strtotime(!is_null($time) ? $time : self::$time);
$content = serialize(array(
'expires' => $time,
'content' => $content));
return $this->createCacheFile($key, $content);
}
|
php
|
public function set($key, $content, $time = null) {
$time = strtotime(!is_null($time) ? $time : self::$time);
$content = serialize(array(
'expires' => $time,
'content' => $content));
return $this->createCacheFile($key, $content);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"content",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"!",
"is_null",
"(",
"$",
"time",
")",
"?",
"$",
"time",
":",
"self",
"::",
"$",
"time",
")",
";",
"$",
"content",
"=",
"serialize",
"(",
"array",
"(",
"'expires'",
"=>",
"$",
"time",
",",
"'content'",
"=>",
"$",
"content",
")",
")",
";",
"return",
"$",
"this",
"->",
"createCacheFile",
"(",
"$",
"key",
",",
"$",
"content",
")",
";",
"}"
] |
Salva um valor no cache
@uses Cache::createCacheFile() para criar o arquivo com o cache
@param string $key Uma chave para identificar o valor cacheado
@param mixed $content Conteúdo/variável a ser salvo(a) no cache
@param string $time Quanto tempo até o cache expirar (opcional)
@return boolean Se o cache foi salvo
|
[
"Salva",
"um",
"valor",
"no",
"cache"
] |
b1ca4249596bffe93d23b46ba298785d17fa1e10
|
https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L117-L125
|
235,473
|
cmdweb/cache
|
Cache/Cache.php
|
Cache.get
|
public function get($key) {
$filename = $this->generateFileLocation($key);
if (file_exists($filename) && is_readable($filename)) {
$cache = unserialize(file_get_contents($filename));
if ($cache['expires'] > time()) {
return $cache['content'];
} else {
unlink($filename);
}
}
return null;
}
|
php
|
public function get($key) {
$filename = $this->generateFileLocation($key);
if (file_exists($filename) && is_readable($filename)) {
$cache = unserialize(file_get_contents($filename));
if ($cache['expires'] > time()) {
return $cache['content'];
} else {
unlink($filename);
}
}
return null;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"generateFileLocation",
"(",
"$",
"key",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
"&&",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"cache",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
";",
"if",
"(",
"$",
"cache",
"[",
"'expires'",
"]",
">",
"time",
"(",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"'content'",
"]",
";",
"}",
"else",
"{",
"unlink",
"(",
"$",
"filename",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Salva um valor do cache
@uses Cache::generateFileLocation() para gerar o local do arquivo de cache
@param string $key Uma chave para identificar o valor cacheado
@return mixed Se o cache foi encontrado retorna o seu valor, caso contrário retorna NULL
|
[
"Salva",
"um",
"valor",
"do",
"cache"
] |
b1ca4249596bffe93d23b46ba298785d17fa1e10
|
https://github.com/cmdweb/cache/blob/b1ca4249596bffe93d23b46ba298785d17fa1e10/Cache/Cache.php#L137-L148
|
235,474
|
pablodip/PablodipModuleBundle
|
Field/Guesser/FieldGuesserFactory.php
|
FieldGuesserFactory.addFieldGuessers
|
public function addFieldGuessers(array $fieldGuessers)
{
foreach ($fieldGuessers as $name => $fieldGuesser) {
$this->add($name, $fieldGuesser);
}
}
|
php
|
public function addFieldGuessers(array $fieldGuessers)
{
foreach ($fieldGuessers as $name => $fieldGuesser) {
$this->add($name, $fieldGuesser);
}
}
|
[
"public",
"function",
"addFieldGuessers",
"(",
"array",
"$",
"fieldGuessers",
")",
"{",
"foreach",
"(",
"$",
"fieldGuessers",
"as",
"$",
"name",
"=>",
"$",
"fieldGuesser",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"fieldGuesser",
")",
";",
"}",
"}"
] |
Adds an array of field guessers.
@param array $fieldGuessers An array of field guessers.
|
[
"Adds",
"an",
"array",
"of",
"field",
"guessers",
"."
] |
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
|
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Field/Guesser/FieldGuesserFactory.php#L50-L55
|
235,475
|
pablodip/PablodipModuleBundle
|
Field/Guesser/FieldGuesserFactory.php
|
FieldGuesserFactory.get
|
public function get($name)
{
if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The field guesser "%s" does not exist.', $name));
}
return $this->fieldGuessers[$name];
}
|
php
|
public function get($name)
{
if (!$this->has($name)) {
throw new \InvalidArgumentException(sprintf('The field guesser "%s" does not exist.', $name));
}
return $this->fieldGuessers[$name];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The field guesser \"%s\" does not exist.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fieldGuessers",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns a field guesser by name.
@param string $name The name.
@return FieldGuesserInterface The field guesser.
@throws \InvalidArgumentException If the field guesser does not exist.
|
[
"Returns",
"a",
"field",
"guesser",
"by",
"name",
"."
] |
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
|
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Field/Guesser/FieldGuesserFactory.php#L78-L85
|
235,476
|
dlapps/consul-php-envvar
|
src/Builder/ConsulEnvManagerBuilder.php
|
ConsulEnvManagerBuilder.build
|
public function build(): ConsulEnvManager
{
$kv = (new ServiceFactory([
'base_uri' => $this->consulServer
]))->get('kv');
$manager = new ConsulEnvManager(
$kv,
$this->overwriteEvenIfDefined
);
$this->clear();
return $manager;
}
|
php
|
public function build(): ConsulEnvManager
{
$kv = (new ServiceFactory([
'base_uri' => $this->consulServer
]))->get('kv');
$manager = new ConsulEnvManager(
$kv,
$this->overwriteEvenIfDefined
);
$this->clear();
return $manager;
}
|
[
"public",
"function",
"build",
"(",
")",
":",
"ConsulEnvManager",
"{",
"$",
"kv",
"=",
"(",
"new",
"ServiceFactory",
"(",
"[",
"'base_uri'",
"=>",
"$",
"this",
"->",
"consulServer",
"]",
")",
")",
"->",
"get",
"(",
"'kv'",
")",
";",
"$",
"manager",
"=",
"new",
"ConsulEnvManager",
"(",
"$",
"kv",
",",
"$",
"this",
"->",
"overwriteEvenIfDefined",
")",
";",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"return",
"$",
"manager",
";",
"}"
] |
Build the manager with the properties that have been defined.
@return ConsulEnvManager
|
[
"Build",
"the",
"manager",
"with",
"the",
"properties",
"that",
"have",
"been",
"defined",
"."
] |
e5da3a3e56536c1108c32c1148cda0b589ad7773
|
https://github.com/dlapps/consul-php-envvar/blob/e5da3a3e56536c1108c32c1148cda0b589ad7773/src/Builder/ConsulEnvManagerBuilder.php#L33-L47
|
235,477
|
jmpantoja/planb-utils
|
src/Beautifier/Parser/ParserFactory.php
|
ParserFactory.factory
|
public static function factory(?Enviroment $environment = null): Parser
{
$environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);
return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
}
|
php
|
public static function factory(?Enviroment $environment = null): Parser
{
$environment = $environment ?? Enviroment::getFromSapi(PHP_SAPI);
return self::evaluate($environment)->isInstanceOf(Parser::class)->getValue();
}
|
[
"public",
"static",
"function",
"factory",
"(",
"?",
"Enviroment",
"$",
"environment",
"=",
"null",
")",
":",
"Parser",
"{",
"$",
"environment",
"=",
"$",
"environment",
"??",
"Enviroment",
"::",
"getFromSapi",
"(",
"PHP_SAPI",
")",
";",
"return",
"self",
"::",
"evaluate",
"(",
"$",
"environment",
")",
"->",
"isInstanceOf",
"(",
"Parser",
"::",
"class",
")",
"->",
"getValue",
"(",
")",
";",
"}"
] |
Devuelve el parser asociado a un nombre
@param null|\PlanB\Beautifier\Enviroment $environment
@return \PlanB\Beautifier\Parser\Parser
|
[
"Devuelve",
"el",
"parser",
"asociado",
"a",
"un",
"nombre"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L37-L42
|
235,478
|
jmpantoja/planb-utils
|
src/Beautifier/Parser/ParserFactory.php
|
ParserFactory.makeHtml
|
public function makeHtml(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isHtml()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(HtmlTagDecorator::make())
->addDecorator(MarginDecorator::make());
}
|
php
|
public function makeHtml(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isHtml()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(HtmlTagDecorator::make())
->addDecorator(MarginDecorator::make());
}
|
[
"public",
"function",
"makeHtml",
"(",
"Enviroment",
"$",
"enviroment",
")",
":",
"?",
"Parser",
"{",
"if",
"(",
"!",
"$",
"enviroment",
"->",
"isHtml",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Parser",
"::",
"make",
"(",
")",
"->",
"addDecorator",
"(",
"PaddingDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"LineWidthDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"HtmlTagDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"MarginDecorator",
"::",
"make",
"(",
")",
")",
";",
"}"
] |
Crea un objeto Html Parser
@param \PlanB\Beautifier\Enviroment $enviroment
@return null| \PlanB\Beautifier\Parser\Parser
|
[
"Crea",
"un",
"objeto",
"Html",
"Parser"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L62-L74
|
235,479
|
jmpantoja/planb-utils
|
src/Beautifier/Parser/ParserFactory.php
|
ParserFactory.makeConsole
|
public function makeConsole(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isConsole()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(ConsoleTagDecorator::make())
->addDecorator(MarginDecorator::make());
}
|
php
|
public function makeConsole(Enviroment $enviroment): ?Parser
{
if (!$enviroment->isConsole()) {
return null;
}
return Parser::make()
->addDecorator(PaddingDecorator::make())
->addDecorator(LineWidthDecorator::make())
->addDecorator(ConsoleTagDecorator::make())
->addDecorator(MarginDecorator::make());
}
|
[
"public",
"function",
"makeConsole",
"(",
"Enviroment",
"$",
"enviroment",
")",
":",
"?",
"Parser",
"{",
"if",
"(",
"!",
"$",
"enviroment",
"->",
"isConsole",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Parser",
"::",
"make",
"(",
")",
"->",
"addDecorator",
"(",
"PaddingDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"LineWidthDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"ConsoleTagDecorator",
"::",
"make",
"(",
")",
")",
"->",
"addDecorator",
"(",
"MarginDecorator",
"::",
"make",
"(",
")",
")",
";",
"}"
] |
Crea un objeto Console Parser
@param \PlanB\Beautifier\Enviroment $enviroment
@return null|\PlanB\Beautifier\Parser\Parser
|
[
"Crea",
"un",
"objeto",
"Console",
"Parser"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/ParserFactory.php#L83-L94
|
235,480
|
ExSituMarketing/EXS-LanderTrackingHouseBundle
|
Service/TrackingParameterExtracter.php
|
TrackingParameterExtracter.setup
|
public function setup(array $extracters)
{
foreach ($extracters as $extracter) {
if (
(false === ($extracter['reference'] instanceof TrackingParameterQueryExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterCookieExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterInitializerInterface))
) {
throw new InvalidConfigurationException(sprintf(
'Invalid tracking parameter extracter "%s".',
$extracter['name']
));
}
$this->extracters[$extracter['name']] = $extracter['reference'];
}
}
|
php
|
public function setup(array $extracters)
{
foreach ($extracters as $extracter) {
if (
(false === ($extracter['reference'] instanceof TrackingParameterQueryExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterCookieExtracterInterface))
&& (false === ($extracter['reference'] instanceof TrackingParameterInitializerInterface))
) {
throw new InvalidConfigurationException(sprintf(
'Invalid tracking parameter extracter "%s".',
$extracter['name']
));
}
$this->extracters[$extracter['name']] = $extracter['reference'];
}
}
|
[
"public",
"function",
"setup",
"(",
"array",
"$",
"extracters",
")",
"{",
"foreach",
"(",
"$",
"extracters",
"as",
"$",
"extracter",
")",
"{",
"if",
"(",
"(",
"false",
"===",
"(",
"$",
"extracter",
"[",
"'reference'",
"]",
"instanceof",
"TrackingParameterQueryExtracterInterface",
")",
")",
"&&",
"(",
"false",
"===",
"(",
"$",
"extracter",
"[",
"'reference'",
"]",
"instanceof",
"TrackingParameterCookieExtracterInterface",
")",
")",
"&&",
"(",
"false",
"===",
"(",
"$",
"extracter",
"[",
"'reference'",
"]",
"instanceof",
"TrackingParameterInitializerInterface",
")",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"sprintf",
"(",
"'Invalid tracking parameter extracter \"%s\".'",
",",
"$",
"extracter",
"[",
"'name'",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"extracters",
"[",
"$",
"extracter",
"[",
"'name'",
"]",
"]",
"=",
"$",
"extracter",
"[",
"'reference'",
"]",
";",
"}",
"}"
] |
Set all formatters available.
@param array $extracters
@throws InvalidConfigurationException
|
[
"Set",
"all",
"formatters",
"available",
"."
] |
404ce51ec1ee0bf5e669eb1f4cd04746e244f61a
|
https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterExtracter.php#L39-L55
|
235,481
|
ExSituMarketing/EXS-LanderTrackingHouseBundle
|
Service/TrackingParameterExtracter.php
|
TrackingParameterExtracter.extract
|
public function extract(Request $request)
{
$trackingParameters = new ParameterBag();
/** Get value from cookies. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterCookieExtracterInterface) {
$trackingParameters->add($extracter->extractFromCookies($request->cookies));
}
}
/** Override cookies' value by query's value if set. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterQueryExtracterInterface) {
$trackingParameters->add($extracter->extractFromQuery($request->query));
}
}
return $trackingParameters;
}
|
php
|
public function extract(Request $request)
{
$trackingParameters = new ParameterBag();
/** Get value from cookies. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterCookieExtracterInterface) {
$trackingParameters->add($extracter->extractFromCookies($request->cookies));
}
}
/** Override cookies' value by query's value if set. */
foreach ($this->extracters as $extracter) {
if ($extracter instanceof TrackingParameterQueryExtracterInterface) {
$trackingParameters->add($extracter->extractFromQuery($request->query));
}
}
return $trackingParameters;
}
|
[
"public",
"function",
"extract",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"trackingParameters",
"=",
"new",
"ParameterBag",
"(",
")",
";",
"/** Get value from cookies. */",
"foreach",
"(",
"$",
"this",
"->",
"extracters",
"as",
"$",
"extracter",
")",
"{",
"if",
"(",
"$",
"extracter",
"instanceof",
"TrackingParameterCookieExtracterInterface",
")",
"{",
"$",
"trackingParameters",
"->",
"add",
"(",
"$",
"extracter",
"->",
"extractFromCookies",
"(",
"$",
"request",
"->",
"cookies",
")",
")",
";",
"}",
"}",
"/** Override cookies' value by query's value if set. */",
"foreach",
"(",
"$",
"this",
"->",
"extracters",
"as",
"$",
"extracter",
")",
"{",
"if",
"(",
"$",
"extracter",
"instanceof",
"TrackingParameterQueryExtracterInterface",
")",
"{",
"$",
"trackingParameters",
"->",
"add",
"(",
"$",
"extracter",
"->",
"extractFromQuery",
"(",
"$",
"request",
"->",
"query",
")",
")",
";",
"}",
"}",
"return",
"$",
"trackingParameters",
";",
"}"
] |
Extract tracking parameters from query or from cookies.
@param Request $request
@return ParameterBag
|
[
"Extract",
"tracking",
"parameters",
"from",
"query",
"or",
"from",
"cookies",
"."
] |
404ce51ec1ee0bf5e669eb1f4cd04746e244f61a
|
https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterExtracter.php#L64-L83
|
235,482
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.status
|
public function status($id)
{
$url = self::HOST . self::STATUS;
$params = $this->get_default_params();
$params['id'] = $id;
$result = $this->request($url, $params);
return $result;
}
|
php
|
public function status($id)
{
$url = self::HOST . self::STATUS;
$params = $this->get_default_params();
$params['id'] = $id;
$result = $this->request($url, $params);
return $result;
}
|
[
"public",
"function",
"status",
"(",
"$",
"id",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"STATUS",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"params",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Check message status
@param type $id
@return type
|
[
"Check",
"message",
"status"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L83-L92
|
235,483
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.balance
|
public function balance()
{
$url = self::HOST . self::BALANCE;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'balance' => $result[1]
);
}
|
php
|
public function balance()
{
$url = self::HOST . self::BALANCE;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'balance' => $result[1]
);
}
|
[
"public",
"function",
"balance",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"BALANCE",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"$",
"result",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"return",
"array",
"(",
"'code'",
"=>",
"$",
"result",
"[",
"0",
"]",
",",
"'balance'",
"=>",
"$",
"result",
"[",
"1",
"]",
")",
";",
"}"
] |
Check user balance
@return array
|
[
"Check",
"user",
"balance"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L98-L110
|
235,484
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.limit
|
public function limit()
{
$url = self::HOST . self::LIMIT;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'total' => $result[1],
'current' => $result[2]
);
}
|
php
|
public function limit()
{
$url = self::HOST . self::LIMIT;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'total' => $result[1],
'current' => $result[2]
);
}
|
[
"public",
"function",
"limit",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"LIMIT",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"$",
"result",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"return",
"array",
"(",
"'code'",
"=>",
"$",
"result",
"[",
"0",
"]",
",",
"'total'",
"=>",
"$",
"result",
"[",
"1",
"]",
",",
"'current'",
"=>",
"$",
"result",
"[",
"2",
"]",
")",
";",
"}"
] |
Check day limit
@return array
|
[
"Check",
"day",
"limit"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L117-L130
|
235,485
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.cost
|
public function cost($to, $text)
{
$url = self::HOST . self::COST;
$this->id = null;
$params = $this->get_default_params();
$params['to'] = $to;
$params['text'] = $text;
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'price' => $result[1],
'number' => $result[2]
);
}
|
php
|
public function cost($to, $text)
{
$url = self::HOST . self::COST;
$this->id = null;
$params = $this->get_default_params();
$params['to'] = $to;
$params['text'] = $text;
$result = $this->request($url, $params);
$result = explode("\n", $result);
return array(
'code' => $result[0],
'price' => $result[1],
'number' => $result[2]
);
}
|
[
"public",
"function",
"cost",
"(",
"$",
"to",
",",
"$",
"text",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"COST",
";",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"params",
"[",
"'to'",
"]",
"=",
"$",
"to",
";",
"$",
"params",
"[",
"'text'",
"]",
"=",
"$",
"text",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"$",
"result",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"result",
")",
";",
"return",
"array",
"(",
"'code'",
"=>",
"$",
"result",
"[",
"0",
"]",
",",
"'price'",
"=>",
"$",
"result",
"[",
"1",
"]",
",",
"'number'",
"=>",
"$",
"result",
"[",
"2",
"]",
")",
";",
"}"
] |
Get message cost
@param type $to
@param type $text
@return type
|
[
"Get",
"message",
"cost"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L139-L156
|
235,486
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.senders
|
public function senders()
{
$url = self::HOST . self::SENDERS;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", rtrim($result));
$response = array(
'code' => $result[0],
'senders' => $result
);
unset($response['senders'][0]);
$response['senders'] = array_values($response['senders']);
return $response;
}
|
php
|
public function senders()
{
$url = self::HOST . self::SENDERS;
$params = $this->get_default_params();
$result = $this->request($url, $params);
$result = explode("\n", rtrim($result));
$response = array(
'code' => $result[0],
'senders' => $result
);
unset($response['senders'][0]);
$response['senders'] = array_values($response['senders']);
return $response;
}
|
[
"public",
"function",
"senders",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"SENDERS",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"$",
"result",
"=",
"explode",
"(",
"\"\\n\"",
",",
"rtrim",
"(",
"$",
"result",
")",
")",
";",
"$",
"response",
"=",
"array",
"(",
"'code'",
"=>",
"$",
"result",
"[",
"0",
"]",
",",
"'senders'",
"=>",
"$",
"result",
")",
";",
"unset",
"(",
"$",
"response",
"[",
"'senders'",
"]",
"[",
"0",
"]",
")",
";",
"$",
"response",
"[",
"'senders'",
"]",
"=",
"array_values",
"(",
"$",
"response",
"[",
"'senders'",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Get my senders list
@return array
|
[
"Get",
"my",
"senders",
"list"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L163-L178
|
235,487
|
ruxon/framework
|
src/Sms/BaseSmsSms.class.php
|
BaseSmsSms.check
|
public function check()
{
$url = self::HOST . self::CHECK;
$params = $this->get_default_params();
$result = $this->request($url, $params);
return $result;
}
|
php
|
public function check()
{
$url = self::HOST . self::CHECK;
$params = $this->get_default_params();
$result = $this->request($url, $params);
return $result;
}
|
[
"public",
"function",
"check",
"(",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"HOST",
".",
"self",
"::",
"CHECK",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"get_default_params",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Check user auth
@return type
|
[
"Check",
"user",
"auth"
] |
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
|
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L185-L192
|
235,488
|
frostnode/frostnode-cms
|
modules/Page/Http/Controllers/PageController.php
|
PageController.trashed
|
public function trashed(Request $request)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
$pages = Page::onlyTrashed()
->orderBy('updated_at', 'desc')
->orderBy('created_at', 'desc')
->with('pagetype')
->paginate(self::PAGINATION_ITEMS);
return view('page::pages.trashed', ['pages' => $pages]);
}
|
php
|
public function trashed(Request $request)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
$pages = Page::onlyTrashed()
->orderBy('updated_at', 'desc')
->orderBy('created_at', 'desc')
->with('pagetype')
->paginate(self::PAGINATION_ITEMS);
return view('page::pages.trashed', ['pages' => $pages]);
}
|
[
"public",
"function",
"trashed",
"(",
"Request",
"$",
"request",
")",
"{",
"// Set roles that have access",
"$",
"request",
"->",
"user",
"(",
")",
"->",
"authorizeRoles",
"(",
"[",
"'admin'",
",",
"'editor'",
"]",
")",
";",
"$",
"pages",
"=",
"Page",
"::",
"onlyTrashed",
"(",
")",
"->",
"orderBy",
"(",
"'updated_at'",
",",
"'desc'",
")",
"->",
"orderBy",
"(",
"'created_at'",
",",
"'desc'",
")",
"->",
"with",
"(",
"'pagetype'",
")",
"->",
"paginate",
"(",
"self",
"::",
"PAGINATION_ITEMS",
")",
";",
"return",
"view",
"(",
"'page::pages.trashed'",
",",
"[",
"'pages'",
"=>",
"$",
"pages",
"]",
")",
";",
"}"
] |
Display a listing of trashed resources.
@param Request $request
@return Response
@todo: This should be merged into index method
|
[
"Display",
"a",
"listing",
"of",
"trashed",
"resources",
"."
] |
486db24bb8ebd73dcc1ef71f79509817d23fbf45
|
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L85-L97
|
235,489
|
frostnode/frostnode-cms
|
modules/Page/Http/Controllers/PageController.php
|
PageController.select
|
public function select(Request $request)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
// Get all pagetypes
$pagetypes = PageType::all();
return view('page::pages.select', ['pagetypes' => $pagetypes]);
}
|
php
|
public function select(Request $request)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
// Get all pagetypes
$pagetypes = PageType::all();
return view('page::pages.select', ['pagetypes' => $pagetypes]);
}
|
[
"public",
"function",
"select",
"(",
"Request",
"$",
"request",
")",
"{",
"// Set roles that have access",
"$",
"request",
"->",
"user",
"(",
")",
"->",
"authorizeRoles",
"(",
"[",
"'admin'",
",",
"'editor'",
"]",
")",
";",
"// Get all pagetypes",
"$",
"pagetypes",
"=",
"PageType",
"::",
"all",
"(",
")",
";",
"return",
"view",
"(",
"'page::pages.select'",
",",
"[",
"'pagetypes'",
"=>",
"$",
"pagetypes",
"]",
")",
";",
"}"
] |
Show the form for selecting a new resource.
@param Request $request
@return Response
|
[
"Show",
"the",
"form",
"for",
"selecting",
"a",
"new",
"resource",
"."
] |
486db24bb8ebd73dcc1ef71f79509817d23fbf45
|
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L104-L112
|
235,490
|
frostnode/frostnode-cms
|
modules/Page/Http/Controllers/PageController.php
|
PageController.delete
|
public function delete(Request $request, $page)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
$page = Page::withTrashed()->findOrFail($page);
return view('page::pages.delete', ['page' => $page]);
}
|
php
|
public function delete(Request $request, $page)
{
// Set roles that have access
$request->user()->authorizeRoles(['admin', 'editor']);
$page = Page::withTrashed()->findOrFail($page);
return view('page::pages.delete', ['page' => $page]);
}
|
[
"public",
"function",
"delete",
"(",
"Request",
"$",
"request",
",",
"$",
"page",
")",
"{",
"// Set roles that have access",
"$",
"request",
"->",
"user",
"(",
")",
"->",
"authorizeRoles",
"(",
"[",
"'admin'",
",",
"'editor'",
"]",
")",
";",
"$",
"page",
"=",
"Page",
"::",
"withTrashed",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"page",
")",
";",
"return",
"view",
"(",
"'page::pages.delete'",
",",
"[",
"'page'",
"=>",
"$",
"page",
"]",
")",
";",
"}"
] |
Display a delete page.
@param Request $request
@param $page
@return View
|
[
"Display",
"a",
"delete",
"page",
"."
] |
486db24bb8ebd73dcc1ef71f79509817d23fbf45
|
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L310-L317
|
235,491
|
xobotyi/dotarray
|
src/A.php
|
A.splitPath
|
public static function splitPath(string $path, bool $safe = null): array
{
if ($path === '') {
return [];
}
$safe = ($safe === null ? self::$safeSeparationMode : $safe);
if ($safe) {
$segments = preg_split('~\\\\' . self::$separator . '(*SKIP)(*F)|\.~s', $path, -1, PREG_SPLIT_NO_EMPTY);
if ($segments === false) {
// actually this code can't be covered with tests, because i don't know how to make preg_split()
// return a FALSE value but handling it in case some one will %)
trigger_error('Path splitting failed, received path: ' . $path);
$segments = [];
}
foreach ($segments as &$segment) {
$segment = stripslashes($segment);
}
return $segments;
}
return explode(self::$separator, $path);
}
|
php
|
public static function splitPath(string $path, bool $safe = null): array
{
if ($path === '') {
return [];
}
$safe = ($safe === null ? self::$safeSeparationMode : $safe);
if ($safe) {
$segments = preg_split('~\\\\' . self::$separator . '(*SKIP)(*F)|\.~s', $path, -1, PREG_SPLIT_NO_EMPTY);
if ($segments === false) {
// actually this code can't be covered with tests, because i don't know how to make preg_split()
// return a FALSE value but handling it in case some one will %)
trigger_error('Path splitting failed, received path: ' . $path);
$segments = [];
}
foreach ($segments as &$segment) {
$segment = stripslashes($segment);
}
return $segments;
}
return explode(self::$separator, $path);
}
|
[
"public",
"static",
"function",
"splitPath",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"safe",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"$",
"path",
"===",
"''",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"safe",
"=",
"(",
"$",
"safe",
"===",
"null",
"?",
"self",
"::",
"$",
"safeSeparationMode",
":",
"$",
"safe",
")",
";",
"if",
"(",
"$",
"safe",
")",
"{",
"$",
"segments",
"=",
"preg_split",
"(",
"'~\\\\\\\\'",
".",
"self",
"::",
"$",
"separator",
".",
"'(*SKIP)(*F)|\\.~s'",
",",
"$",
"path",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"if",
"(",
"$",
"segments",
"===",
"false",
")",
"{",
"// actually this code can't be covered with tests, because i don't know how to make preg_split()",
"// return a FALSE value but handling it in case some one will %)",
"trigger_error",
"(",
"'Path splitting failed, received path: '",
".",
"$",
"path",
")",
";",
"$",
"segments",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"segments",
"as",
"&",
"$",
"segment",
")",
"{",
"$",
"segment",
"=",
"stripslashes",
"(",
"$",
"segment",
")",
";",
"}",
"return",
"$",
"segments",
";",
"}",
"return",
"explode",
"(",
"self",
"::",
"$",
"separator",
",",
"$",
"path",
")",
";",
"}"
] |
Split given string to it's segments according to dot notation.
Empty segments will be ignored.
Supports escaping.
@param string $path
@param bool $safe
@return array
|
[
"Split",
"given",
"string",
"to",
"it",
"s",
"segments",
"according",
"to",
"dot",
"notation",
".",
"Empty",
"segments",
"will",
"be",
"ignored",
".",
"Supports",
"escaping",
"."
] |
5781c1e2752fa6be7bb88b575b901a00788bfe70
|
https://github.com/xobotyi/dotarray/blob/5781c1e2752fa6be7bb88b575b901a00788bfe70/src/A.php#L191-L218
|
235,492
|
xobotyi/dotarray
|
src/A.php
|
A.set
|
public static function set(array $array, ...$args): array
{
if (empty($args)) {
throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 1 passed, at least 2 expected');
}
if (is_string($args[0]) || is_numeric($args[0])) {
if (!isset($args[1]) && !\array_key_exists(1, $args)) {
throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 2 passed, at least 3 expected when second is string');
}
$args = [$args[0] => $args[1]];
} else if (\is_array($args[0])) {
$args = $args[0];
} else {
throw new \TypeError("Argument 2 passed to xobotyi\A::set() must be of the type array or string, " . gettype($args[0]) . " given");
}
foreach ($args as $path => &$value) {
if ($path === '') {
continue;
}
$path = self::splitPath($path);
if (empty($path)) {
continue;
}
$scope = &$array;
for ($i = 0; $i < count($path) - 1; $i++) {
if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) {
$scope[$path[$i]] = [];
}
$scope = &$scope[$path[$i]];
}
$scope[$path[$i]] = $value;
}
return $array;
}
|
php
|
public static function set(array $array, ...$args): array
{
if (empty($args)) {
throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 1 passed, at least 2 expected');
}
if (is_string($args[0]) || is_numeric($args[0])) {
if (!isset($args[1]) && !\array_key_exists(1, $args)) {
throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 2 passed, at least 3 expected when second is string');
}
$args = [$args[0] => $args[1]];
} else if (\is_array($args[0])) {
$args = $args[0];
} else {
throw new \TypeError("Argument 2 passed to xobotyi\A::set() must be of the type array or string, " . gettype($args[0]) . " given");
}
foreach ($args as $path => &$value) {
if ($path === '') {
continue;
}
$path = self::splitPath($path);
if (empty($path)) {
continue;
}
$scope = &$array;
for ($i = 0; $i < count($path) - 1; $i++) {
if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) {
$scope[$path[$i]] = [];
}
$scope = &$scope[$path[$i]];
}
$scope[$path[$i]] = $value;
}
return $array;
}
|
[
"public",
"static",
"function",
"set",
"(",
"array",
"$",
"array",
",",
"...",
"$",
"args",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"\\",
"ArgumentCountError",
"(",
"'Too few arguments to function xobotyi\\A::set(), 1 passed, at least 2 expected'",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"||",
"is_numeric",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"&&",
"!",
"\\",
"array_key_exists",
"(",
"1",
",",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"\\",
"ArgumentCountError",
"(",
"'Too few arguments to function xobotyi\\A::set(), 2 passed, at least 3 expected when second is string'",
")",
";",
"}",
"$",
"args",
"=",
"[",
"$",
"args",
"[",
"0",
"]",
"=>",
"$",
"args",
"[",
"1",
"]",
"]",
";",
"}",
"else",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"TypeError",
"(",
"\"Argument 2 passed to xobotyi\\A::set() must be of the type array or string, \"",
".",
"gettype",
"(",
"$",
"args",
"[",
"0",
"]",
")",
".",
"\" given\"",
")",
";",
"}",
"foreach",
"(",
"$",
"args",
"as",
"$",
"path",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"$",
"path",
"=",
"self",
"::",
"splitPath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"continue",
";",
"}",
"$",
"scope",
"=",
"&",
"$",
"array",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"path",
")",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"scope",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
")",
"||",
"!",
"\\",
"is_array",
"(",
"$",
"scope",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
")",
")",
"{",
"$",
"scope",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"scope",
"=",
"&",
"$",
"scope",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
";",
"}",
"$",
"scope",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Set the value passed with 3'rd argument on the path passed with 2'nd argument.
If 2'nd argument is array, it's keys will be used as paths and items as values.
Empty paths will be processed as non-existent.
@param array $array
@param array ...$args
@return array
@throws \ArgumentCountError
@throws \TypeError
|
[
"Set",
"the",
"value",
"passed",
"with",
"3",
"rd",
"argument",
"on",
"the",
"path",
"passed",
"with",
"2",
"nd",
"argument",
".",
"If",
"2",
"nd",
"argument",
"is",
"array",
"it",
"s",
"keys",
"will",
"be",
"used",
"as",
"paths",
"and",
"items",
"as",
"values",
".",
"Empty",
"paths",
"will",
"be",
"processed",
"as",
"non",
"-",
"existent",
"."
] |
5781c1e2752fa6be7bb88b575b901a00788bfe70
|
https://github.com/xobotyi/dotarray/blob/5781c1e2752fa6be7bb88b575b901a00788bfe70/src/A.php#L419-L462
|
235,493
|
leedave/resource-mysql
|
src/Tools/Update.php
|
Update.updateDb
|
public function updateDb()
{
$this->createUpdateTableIfNotExists();
$this->getProcessedFiles();
$path = leedch_resourceMysqlUpdateFolder;
$files = $this->findNewFiles($path);
$this->processNewFiles($files);
}
|
php
|
public function updateDb()
{
$this->createUpdateTableIfNotExists();
$this->getProcessedFiles();
$path = leedch_resourceMysqlUpdateFolder;
$files = $this->findNewFiles($path);
$this->processNewFiles($files);
}
|
[
"public",
"function",
"updateDb",
"(",
")",
"{",
"$",
"this",
"->",
"createUpdateTableIfNotExists",
"(",
")",
";",
"$",
"this",
"->",
"getProcessedFiles",
"(",
")",
";",
"$",
"path",
"=",
"leedch_resourceMysqlUpdateFolder",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"findNewFiles",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"processNewFiles",
"(",
"$",
"files",
")",
";",
"}"
] |
This method is triggered in Bash to process DB Update Files
|
[
"This",
"method",
"is",
"triggered",
"in",
"Bash",
"to",
"process",
"DB",
"Update",
"Files"
] |
68305dac50b1b956f08f41267d0b2912850d8232
|
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L32-L41
|
235,494
|
leedave/resource-mysql
|
src/Tools/Update.php
|
Update.processNewFiles
|
protected function processNewFiles(array $files)
{
foreach ($files as $file) {
if (!file_exists($file)) {
//This is bad
throw new Exception('Cant find File: '.$file);
}
include $file;
if (!isset($arrUpdate)) {
throw new Exception('Array $arrUpdate does not exist in '.$file);
}
try {
$this->processArray($arrUpdate);
$this->addFileToProcessedList($file);
} catch (Exception $ex) {
echo $ex->getMessage();
}
unset($arrUpdate);
}
}
|
php
|
protected function processNewFiles(array $files)
{
foreach ($files as $file) {
if (!file_exists($file)) {
//This is bad
throw new Exception('Cant find File: '.$file);
}
include $file;
if (!isset($arrUpdate)) {
throw new Exception('Array $arrUpdate does not exist in '.$file);
}
try {
$this->processArray($arrUpdate);
$this->addFileToProcessedList($file);
} catch (Exception $ex) {
echo $ex->getMessage();
}
unset($arrUpdate);
}
}
|
[
"protected",
"function",
"processNewFiles",
"(",
"array",
"$",
"files",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"//This is bad",
"throw",
"new",
"Exception",
"(",
"'Cant find File: '",
".",
"$",
"file",
")",
";",
"}",
"include",
"$",
"file",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"arrUpdate",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Array $arrUpdate does not exist in '",
".",
"$",
"file",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"processArray",
"(",
"$",
"arrUpdate",
")",
";",
"$",
"this",
"->",
"addFileToProcessedList",
"(",
"$",
"file",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"echo",
"$",
"ex",
"->",
"getMessage",
"(",
")",
";",
"}",
"unset",
"(",
"$",
"arrUpdate",
")",
";",
"}",
"}"
] |
Reads the Update Files and triggers the Update
@param array $files
@throws Exception
|
[
"Reads",
"the",
"Update",
"Files",
"and",
"triggers",
"the",
"Update"
] |
68305dac50b1b956f08f41267d0b2912850d8232
|
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L59-L81
|
235,495
|
leedave/resource-mysql
|
src/Tools/Update.php
|
Update.addFileToProcessedList
|
protected function addFileToProcessedList(string $filePath)
{
$arrFile = explode(DIRECTORY_SEPARATOR, $filePath);
$fileName = array_pop($arrFile);
$folder = implode(DIRECTORY_SEPARATOR, $arrFile).DIRECTORY_SEPARATOR;
$tmp = new Update();
$tmp->name = $fileName;
$tmp->folder = $folder;
$tmp->createDate = strftime("%Y-%m-%d %H:%M:%S");
$tmp->save();
echo "Processed: ".$fileName."\n";
unset($tmp);
}
|
php
|
protected function addFileToProcessedList(string $filePath)
{
$arrFile = explode(DIRECTORY_SEPARATOR, $filePath);
$fileName = array_pop($arrFile);
$folder = implode(DIRECTORY_SEPARATOR, $arrFile).DIRECTORY_SEPARATOR;
$tmp = new Update();
$tmp->name = $fileName;
$tmp->folder = $folder;
$tmp->createDate = strftime("%Y-%m-%d %H:%M:%S");
$tmp->save();
echo "Processed: ".$fileName."\n";
unset($tmp);
}
|
[
"protected",
"function",
"addFileToProcessedList",
"(",
"string",
"$",
"filePath",
")",
"{",
"$",
"arrFile",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"filePath",
")",
";",
"$",
"fileName",
"=",
"array_pop",
"(",
"$",
"arrFile",
")",
";",
"$",
"folder",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"arrFile",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"tmp",
"=",
"new",
"Update",
"(",
")",
";",
"$",
"tmp",
"->",
"name",
"=",
"$",
"fileName",
";",
"$",
"tmp",
"->",
"folder",
"=",
"$",
"folder",
";",
"$",
"tmp",
"->",
"createDate",
"=",
"strftime",
"(",
"\"%Y-%m-%d %H:%M:%S\"",
")",
";",
"$",
"tmp",
"->",
"save",
"(",
")",
";",
"echo",
"\"Processed: \"",
".",
"$",
"fileName",
".",
"\"\\n\"",
";",
"unset",
"(",
"$",
"tmp",
")",
";",
"}"
] |
Puts the Filename into the update table
@param string $filePath
|
[
"Puts",
"the",
"Filename",
"into",
"the",
"update",
"table"
] |
68305dac50b1b956f08f41267d0b2912850d8232
|
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L87-L101
|
235,496
|
leedave/resource-mysql
|
src/Tools/Update.php
|
Update.getProcessedFiles
|
protected function getProcessedFiles()
{
$sql = "SELECT * FROM `".$this->tableName."` ORDER BY `id` ASC;";
try {
$arrResult = $this->getAllRows();
} catch (PDOException $ex) {
echo $ex->getMessage().PHP_EOL;
return;
}
foreach ($arrResult as $row) {
$this->knownUpdateFiles[$row['id']] = $row['folder'].$row['name'];
}
}
|
php
|
protected function getProcessedFiles()
{
$sql = "SELECT * FROM `".$this->tableName."` ORDER BY `id` ASC;";
try {
$arrResult = $this->getAllRows();
} catch (PDOException $ex) {
echo $ex->getMessage().PHP_EOL;
return;
}
foreach ($arrResult as $row) {
$this->knownUpdateFiles[$row['id']] = $row['folder'].$row['name'];
}
}
|
[
"protected",
"function",
"getProcessedFiles",
"(",
")",
"{",
"$",
"sql",
"=",
"\"SELECT * FROM `\"",
".",
"$",
"this",
"->",
"tableName",
".",
"\"` ORDER BY `id` ASC;\"",
";",
"try",
"{",
"$",
"arrResult",
"=",
"$",
"this",
"->",
"getAllRows",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"ex",
")",
"{",
"echo",
"$",
"ex",
"->",
"getMessage",
"(",
")",
".",
"PHP_EOL",
";",
"return",
";",
"}",
"foreach",
"(",
"$",
"arrResult",
"as",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"knownUpdateFiles",
"[",
"$",
"row",
"[",
"'id'",
"]",
"]",
"=",
"$",
"row",
"[",
"'folder'",
"]",
".",
"$",
"row",
"[",
"'name'",
"]",
";",
"}",
"}"
] |
Get List of processed files, catches exception if db_update does not exist
@return void
|
[
"Get",
"List",
"of",
"processed",
"files",
"catches",
"exception",
"if",
"db_update",
"does",
"not",
"exist"
] |
68305dac50b1b956f08f41267d0b2912850d8232
|
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L121-L134
|
235,497
|
leedave/resource-mysql
|
src/Tools/Update.php
|
Update.findNewFiles
|
protected function findNewFiles(string $path) : array
{
$arrReturn = [];
$arrFolders = scandir($path);
$arrSkip = [
'.',
'..',
];
foreach ($arrFolders as $file) {
//No Folder Defaults
if (in_array($file, $arrSkip)) {
continue;
}
//Process Subfolders
if (is_dir($path.$file)) {
$arrSubFolderFiles = $this->findNewFiles($path.$file."/");
$arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn);
continue;
}
$arrReturn[] = $path.$file;
}
//Remove file from list if already processed
foreach($arrReturn as $key => $file) {
if (in_array($file, $this->knownUpdateFiles)) {
unset($arrReturn[$key]);
}
}
return $arrReturn;
}
|
php
|
protected function findNewFiles(string $path) : array
{
$arrReturn = [];
$arrFolders = scandir($path);
$arrSkip = [
'.',
'..',
];
foreach ($arrFolders as $file) {
//No Folder Defaults
if (in_array($file, $arrSkip)) {
continue;
}
//Process Subfolders
if (is_dir($path.$file)) {
$arrSubFolderFiles = $this->findNewFiles($path.$file."/");
$arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn);
continue;
}
$arrReturn[] = $path.$file;
}
//Remove file from list if already processed
foreach($arrReturn as $key => $file) {
if (in_array($file, $this->knownUpdateFiles)) {
unset($arrReturn[$key]);
}
}
return $arrReturn;
}
|
[
"protected",
"function",
"findNewFiles",
"(",
"string",
"$",
"path",
")",
":",
"array",
"{",
"$",
"arrReturn",
"=",
"[",
"]",
";",
"$",
"arrFolders",
"=",
"scandir",
"(",
"$",
"path",
")",
";",
"$",
"arrSkip",
"=",
"[",
"'.'",
",",
"'..'",
",",
"]",
";",
"foreach",
"(",
"$",
"arrFolders",
"as",
"$",
"file",
")",
"{",
"//No Folder Defaults",
"if",
"(",
"in_array",
"(",
"$",
"file",
",",
"$",
"arrSkip",
")",
")",
"{",
"continue",
";",
"}",
"//Process Subfolders",
"if",
"(",
"is_dir",
"(",
"$",
"path",
".",
"$",
"file",
")",
")",
"{",
"$",
"arrSubFolderFiles",
"=",
"$",
"this",
"->",
"findNewFiles",
"(",
"$",
"path",
".",
"$",
"file",
".",
"\"/\"",
")",
";",
"$",
"arrReturn",
"=",
"$",
"this",
"->",
"addArrayToNewFiles",
"(",
"$",
"arrSubFolderFiles",
",",
"$",
"arrReturn",
")",
";",
"continue",
";",
"}",
"$",
"arrReturn",
"[",
"]",
"=",
"$",
"path",
".",
"$",
"file",
";",
"}",
"//Remove file from list if already processed",
"foreach",
"(",
"$",
"arrReturn",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"knownUpdateFiles",
")",
")",
"{",
"unset",
"(",
"$",
"arrReturn",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"arrReturn",
";",
"}"
] |
Creates an array of Update Files that were not yet processed
@param string $path
@return array
|
[
"Creates",
"an",
"array",
"of",
"Update",
"Files",
"that",
"were",
"not",
"yet",
"processed"
] |
68305dac50b1b956f08f41267d0b2912850d8232
|
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L141-L171
|
235,498
|
liftkit/document
|
src/Document/Html.php
|
Html.addHeader
|
public function addHeader ($string, $prepend = false)
{
if ($prepend) {
$this->prependHeader($string);
} else {
$this->headers[] = $string;
}
}
|
php
|
public function addHeader ($string, $prepend = false)
{
if ($prepend) {
$this->prependHeader($string);
} else {
$this->headers[] = $string;
}
}
|
[
"public",
"function",
"addHeader",
"(",
"$",
"string",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"$",
"this",
"->",
"prependHeader",
"(",
"$",
"string",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"headers",
"[",
"]",
"=",
"$",
"string",
";",
"}",
"}"
] |
addHeader function.
@access public
@param string $string
@return void
|
[
"addHeader",
"function",
"."
] |
1f6d409c780e42f1c1d177e70039b039e28e2c53
|
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L53-L60
|
235,499
|
liftkit/document
|
src/Document/Html.php
|
Html.addMeta
|
public function addMeta ($name, $content, $attributes = array())
{
$html = '<meta name="' . $this->sanitize($name) . '" content="' . $this->sanitize($content) . '"';
foreach ($attributes as $key => $value) {
$html .= ' ' . $this->sanitize($key) . '="' . $this->sanitize($value) . '"';
}
$html .= ' />';
$this->addHeader($html);
}
|
php
|
public function addMeta ($name, $content, $attributes = array())
{
$html = '<meta name="' . $this->sanitize($name) . '" content="' . $this->sanitize($content) . '"';
foreach ($attributes as $key => $value) {
$html .= ' ' . $this->sanitize($key) . '="' . $this->sanitize($value) . '"';
}
$html .= ' />';
$this->addHeader($html);
}
|
[
"public",
"function",
"addMeta",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"'<meta name=\"'",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"name",
")",
".",
"'\" content=\"'",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"content",
")",
".",
"'\"'",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"html",
".=",
"' '",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"key",
")",
".",
"'=\"'",
".",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"}",
"$",
"html",
".=",
"' />'",
";",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"html",
")",
";",
"}"
] |
addMeta function.
Add meta tags to head.
@access public
@param string $name
@param string $content
@param array $attributes (default: array())
@return void
|
[
"addMeta",
"function",
"."
] |
1f6d409c780e42f1c1d177e70039b039e28e2c53
|
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L93-L104
|
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.