repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
gregoryv/php-logger | src/Logger.php | Logger.infof | public function infof()
{
$args = func_get_args();
$format = array_shift($args);
$this->info(vsprintf($format, $args));
} | php | public function infof()
{
$args = func_get_args();
$format = array_shift($args);
$this->info(vsprintf($format, $args));
} | [
"public",
"function",
"infof",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"info",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as info(sprintf($format, $args...)) | [
"Same",
"as",
"info",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L117-L122 |
gregoryv/php-logger | src/Logger.php | Logger.notice | public function notice($value='')
{
if($this->sieve->notice) {
self::$writer->swrite(LOG_NOTICE, sprintf($this->template, 'NOTICE', $value));
}
} | php | public function notice($value='')
{
if($this->sieve->notice) {
self::$writer->swrite(LOG_NOTICE, sprintf($this->template, 'NOTICE', $value));
}
} | [
"public",
"function",
"notice",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"notice",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_NOTICE",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'NOTICE'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Notice (severity 5): normal but significant condition | [
"Notice",
"(",
"severity",
"5",
")",
":",
"normal",
"but",
"significant",
"condition"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L127-L132 |
gregoryv/php-logger | src/Logger.php | Logger.noticef | public function noticef()
{
$args = func_get_args();
$format = array_shift($args);
$this->notice(vsprintf($format, $args));
} | php | public function noticef()
{
$args = func_get_args();
$format = array_shift($args);
$this->notice(vsprintf($format, $args));
} | [
"public",
"function",
"noticef",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"notice",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as notice(sprintf($format, $args...)) | [
"Same",
"as",
"notice",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L137-L142 |
gregoryv/php-logger | src/Logger.php | Logger.warn | public function warn($value='')
{
if($this->sieve->warn) {
self::$writer->swrite(LOG_WARNING, sprintf($this->template, 'WARNING', $value));
}
} | php | public function warn($value='')
{
if($this->sieve->warn) {
self::$writer->swrite(LOG_WARNING, sprintf($this->template, 'WARNING', $value));
}
} | [
"public",
"function",
"warn",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"warn",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_WARNING",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'WARNING'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Warning (severity 4): warning conditions | [
"Warning",
"(",
"severity",
"4",
")",
":",
"warning",
"conditions"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L147-L152 |
gregoryv/php-logger | src/Logger.php | Logger.warnf | public function warnf()
{
$args = func_get_args();
$format = array_shift($args);
$this->warn(vsprintf($format, $args));
} | php | public function warnf()
{
$args = func_get_args();
$format = array_shift($args);
$this->warn(vsprintf($format, $args));
} | [
"public",
"function",
"warnf",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as warn(sprintf($format, $args...)) | [
"Same",
"as",
"warn",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L157-L162 |
gregoryv/php-logger | src/Logger.php | Logger.error | public function error($value='')
{
if($this->sieve->error) {
self::$writer->swrite(LOG_ERR, sprintf($this->template, 'ERROR', $value));
}
} | php | public function error($value='')
{
if($this->sieve->error) {
self::$writer->swrite(LOG_ERR, sprintf($this->template, 'ERROR', $value));
}
} | [
"public",
"function",
"error",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"error",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_ERR",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'ERROR'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Error (severity 3): error conditions | [
"Error",
"(",
"severity",
"3",
")",
":",
"error",
"conditions"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L167-L172 |
gregoryv/php-logger | src/Logger.php | Logger.errorf | public function errorf()
{
$args = func_get_args();
$format = array_shift($args);
$this->error(vsprintf($format, $args));
} | php | public function errorf()
{
$args = func_get_args();
$format = array_shift($args);
$this->error(vsprintf($format, $args));
} | [
"public",
"function",
"errorf",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"error",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as error(sprintf($format, $args...)) | [
"Same",
"as",
"error",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L177-L182 |
gregoryv/php-logger | src/Logger.php | Logger.critical | public function critical($value='')
{
if($this->sieve->critical) {
self::$writer->swrite(LOG_CRIT, sprintf($this->template, 'CRITICAL', $value));
}
} | php | public function critical($value='')
{
if($this->sieve->critical) {
self::$writer->swrite(LOG_CRIT, sprintf($this->template, 'CRITICAL', $value));
}
} | [
"public",
"function",
"critical",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"critical",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_CRIT",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'CRITICAL'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Critical (severity 2): critical conditions | [
"Critical",
"(",
"severity",
"2",
")",
":",
"critical",
"conditions"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L187-L192 |
gregoryv/php-logger | src/Logger.php | Logger.criticalf | public function criticalf()
{
$args = func_get_args();
$format = array_shift($args);
$this->critical(vsprintf($format, $args));
} | php | public function criticalf()
{
$args = func_get_args();
$format = array_shift($args);
$this->critical(vsprintf($format, $args));
} | [
"public",
"function",
"criticalf",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"critical",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as critical(sprintf($format, $args...)) | [
"Same",
"as",
"critical",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L197-L202 |
gregoryv/php-logger | src/Logger.php | Logger.alert | public function alert($value='')
{
if($this->sieve->alert) {
self::$writer->swrite(LOG_ALERT, sprintf($this->template, 'ALERT', $value));
}
} | php | public function alert($value='')
{
if($this->sieve->alert) {
self::$writer->swrite(LOG_ALERT, sprintf($this->template, 'ALERT', $value));
}
} | [
"public",
"function",
"alert",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"alert",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_ALERT",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'ALERT'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Alert (severity 1): action must be taken immediately | [
"Alert",
"(",
"severity",
"1",
")",
":",
"action",
"must",
"be",
"taken",
"immediately"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L207-L212 |
gregoryv/php-logger | src/Logger.php | Logger.alertf | public function alertf()
{
$args = func_get_args();
$format = array_shift($args);
$this->alert(vsprintf($format, $args));
} | php | public function alertf()
{
$args = func_get_args();
$format = array_shift($args);
$this->alert(vsprintf($format, $args));
} | [
"public",
"function",
"alertf",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"alert",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as alert(sprintf($format, $args...)) | [
"Same",
"as",
"alert",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L217-L222 |
gregoryv/php-logger | src/Logger.php | Logger.emergency | public function emergency($value='')
{
if($this->sieve->emergency) {
self::$writer->swrite(LOG_EMERG, sprintf($this->template, 'EMERGENCY', $value));
}
} | php | public function emergency($value='')
{
if($this->sieve->emergency) {
self::$writer->swrite(LOG_EMERG, sprintf($this->template, 'EMERGENCY', $value));
}
} | [
"public",
"function",
"emergency",
"(",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sieve",
"->",
"emergency",
")",
"{",
"self",
"::",
"$",
"writer",
"->",
"swrite",
"(",
"LOG_EMERG",
",",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'EMERGENCY'",
",",
"$",
"value",
")",
")",
";",
"}",
"}"
] | Emergency (severity 0): system is unusable | [
"Emergency",
"(",
"severity",
"0",
")",
":",
"system",
"is",
"unusable"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L227-L232 |
gregoryv/php-logger | src/Logger.php | Logger.emergencyf | public function emergencyf()
{
$args = func_get_args();
$format = array_shift($args);
$this->emergency(vsprintf($format, $args));
} | php | public function emergencyf()
{
$args = func_get_args();
$format = array_shift($args);
$this->emergency(vsprintf($format, $args));
} | [
"public",
"function",
"emergencyf",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"emergency",
"(",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
] | Same as emergency(sprintf($format, $args...)) | [
"Same",
"as",
"emergency",
"(",
"sprintf",
"(",
"$format",
"$args",
"...",
"))"
] | train | https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L237-L242 |
zhouyl/mellivora | Mellivora/Support/Collection.php | Collection.mode | public function mode($key = null)
{
$count = $this->count();
if ($count === 0) {
return;
}
$collection = isset($key) ? $this->pluck($key) : $this;
$counts = new self;
$collection->each(function ($value) use ($counts) {
$counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
});
$sorted = $counts->sort();
$highestValue = $sorted->last();
return $sorted->filter(function ($value) use ($highestValue) {
return $value === $highestValue;
})->sort()->keys()->all();
} | php | public function mode($key = null)
{
$count = $this->count();
if ($count === 0) {
return;
}
$collection = isset($key) ? $this->pluck($key) : $this;
$counts = new self;
$collection->each(function ($value) use ($counts) {
$counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1;
});
$sorted = $counts->sort();
$highestValue = $sorted->last();
return $sorted->filter(function ($value) use ($highestValue) {
return $value === $highestValue;
})->sort()->keys()->all();
} | [
"public",
"function",
"mode",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
"collection",
"=",
"isset",
"(",
"$",
"key",
")",
"?",
"$",
"this",
"->",
"pluck",
"(",
"$",
"key",
")",
":",
"$",
"this",
";",
"$",
"counts",
"=",
"new",
"self",
";",
"$",
"collection",
"->",
"each",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"counts",
")",
"{",
"$",
"counts",
"[",
"$",
"value",
"]",
"=",
"isset",
"(",
"$",
"counts",
"[",
"$",
"value",
"]",
")",
"?",
"$",
"counts",
"[",
"$",
"value",
"]",
"+",
"1",
":",
"1",
";",
"}",
")",
";",
"$",
"sorted",
"=",
"$",
"counts",
"->",
"sort",
"(",
")",
";",
"$",
"highestValue",
"=",
"$",
"sorted",
"->",
"last",
"(",
")",
";",
"return",
"$",
"sorted",
"->",
"filter",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"highestValue",
")",
"{",
"return",
"$",
"value",
"===",
"$",
"highestValue",
";",
"}",
")",
"->",
"sort",
"(",
")",
"->",
"keys",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] | Get the mode of a given key.
@param mixed $key
@return null|array | [
"Get",
"the",
"mode",
"of",
"a",
"given",
"key",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L152-L175 |
zhouyl/mellivora | Mellivora/Support/Collection.php | Collection.every | public function every($key, $operator = null, $value = null)
{
if (func_num_args() === 1) {
$callback = $this->valueRetriever($key);
foreach ($this->items as $k => $v) {
if (!$callback($v, $k)) {
return false;
}
}
return true;
}
if (func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return $this->every($this->operatorForWhere($key, $operator, $value));
} | php | public function every($key, $operator = null, $value = null)
{
if (func_num_args() === 1) {
$callback = $this->valueRetriever($key);
foreach ($this->items as $k => $v) {
if (!$callback($v, $k)) {
return false;
}
}
return true;
}
if (func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return $this->every($this->operatorForWhere($key, $operator, $value));
} | [
"public",
"function",
"every",
"(",
"$",
"key",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"valueRetriever",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"(",
"$",
"v",
",",
"$",
"k",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"2",
")",
"{",
"$",
"value",
"=",
"$",
"operator",
";",
"$",
"operator",
"=",
"'='",
";",
"}",
"return",
"$",
"this",
"->",
"every",
"(",
"$",
"this",
"->",
"operatorForWhere",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
")",
";",
"}"
] | Determine if all items in the collection pass the given test.
@param callable|string $key
@param mixed $operator
@param mixed $value
@return bool | [
"Determine",
"if",
"all",
"items",
"in",
"the",
"collection",
"pass",
"the",
"given",
"test",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L289-L310 |
zhouyl/mellivora | Mellivora/Support/Collection.php | Collection.groupBy | public function groupBy($groupBy, $preserveKeys = false)
{
$groupBy = $this->valueRetriever($groupBy);
$results = [];
foreach ($this->items as $key => $value) {
$groupKeys = $groupBy($value, $key);
if (!is_array($groupKeys)) {
$groupKeys = [$groupKeys];
}
foreach ($groupKeys as $groupKey) {
$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
if (!array_key_exists($groupKey, $results)) {
$results[$groupKey] = new static;
}
$results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
}
}
return new static($results);
} | php | public function groupBy($groupBy, $preserveKeys = false)
{
$groupBy = $this->valueRetriever($groupBy);
$results = [];
foreach ($this->items as $key => $value) {
$groupKeys = $groupBy($value, $key);
if (!is_array($groupKeys)) {
$groupKeys = [$groupKeys];
}
foreach ($groupKeys as $groupKey) {
$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
if (!array_key_exists($groupKey, $results)) {
$results[$groupKey] = new static;
}
$results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
}
}
return new static($results);
} | [
"public",
"function",
"groupBy",
"(",
"$",
"groupBy",
",",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"$",
"groupBy",
"=",
"$",
"this",
"->",
"valueRetriever",
"(",
"$",
"groupBy",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"groupKeys",
"=",
"$",
"groupBy",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"groupKeys",
")",
")",
"{",
"$",
"groupKeys",
"=",
"[",
"$",
"groupKeys",
"]",
";",
"}",
"foreach",
"(",
"$",
"groupKeys",
"as",
"$",
"groupKey",
")",
"{",
"$",
"groupKey",
"=",
"is_bool",
"(",
"$",
"groupKey",
")",
"?",
"(",
"int",
")",
"$",
"groupKey",
":",
"$",
"groupKey",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"groupKey",
",",
"$",
"results",
")",
")",
"{",
"$",
"results",
"[",
"$",
"groupKey",
"]",
"=",
"new",
"static",
";",
"}",
"$",
"results",
"[",
"$",
"groupKey",
"]",
"->",
"offsetSet",
"(",
"$",
"preserveKeys",
"?",
"$",
"key",
":",
"null",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"results",
")",
";",
"}"
] | Group an associative array by a field or using a callback.
@param callable|string $groupBy
@param bool $preserveKeys
@return static | [
"Group",
"an",
"associative",
"array",
"by",
"a",
"field",
"or",
"using",
"a",
"callback",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L570-L595 |
zhouyl/mellivora | Mellivora/Support/Collection.php | Collection.mapToGroups | public function mapToGroups(callable $callback)
{
$groups = $this->map($callback)->reduce(function ($groups, $pair) {
$groups[key($pair)][] = reset($pair);
return $groups;
}, []);
return (new static($groups))->map([$this, 'make']);
} | php | public function mapToGroups(callable $callback)
{
$groups = $this->map($callback)->reduce(function ($groups, $pair) {
$groups[key($pair)][] = reset($pair);
return $groups;
}, []);
return (new static($groups))->map([$this, 'make']);
} | [
"public",
"function",
"mapToGroups",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"map",
"(",
"$",
"callback",
")",
"->",
"reduce",
"(",
"function",
"(",
"$",
"groups",
",",
"$",
"pair",
")",
"{",
"$",
"groups",
"[",
"key",
"(",
"$",
"pair",
")",
"]",
"[",
"]",
"=",
"reset",
"(",
"$",
"pair",
")",
";",
"return",
"$",
"groups",
";",
"}",
",",
"[",
"]",
")",
";",
"return",
"(",
"new",
"static",
"(",
"$",
"groups",
")",
")",
"->",
"map",
"(",
"[",
"$",
"this",
",",
"'make'",
"]",
")",
";",
"}"
] | Run a grouping map over the items.
The callback should return an associative array with a single key/value pair.
@param callable $callback
@return static | [
"Run",
"a",
"grouping",
"map",
"over",
"the",
"items",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L771-L780 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.register_namespace | public function register_namespace( $namespace = '', $base = '' ) {
if ( $namespace && is_dir( $base ) ) {
$base = rtrim( $base, DIRECTORY_SEPARATOR );
$this->namespaces[ $namespace ] = $base;
}
} | php | public function register_namespace( $namespace = '', $base = '' ) {
if ( $namespace && is_dir( $base ) ) {
$base = rtrim( $base, DIRECTORY_SEPARATOR );
$this->namespaces[ $namespace ] = $base;
}
} | [
"public",
"function",
"register_namespace",
"(",
"$",
"namespace",
"=",
"''",
",",
"$",
"base",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"namespace",
"&&",
"is_dir",
"(",
"$",
"base",
")",
")",
"{",
"$",
"base",
"=",
"rtrim",
"(",
"$",
"base",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"namespace",
"]",
"=",
"$",
"base",
";",
"}",
"}"
] | Register namespace
@param string $namespace
@param string $base | [
"Register",
"namespace"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L113-L118 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.setup | public function setup() {
/**
* wpametu_autoloaded_classes
*
* Default class names which will be initialized after frameworks' bootstrap.
*
* @param array $classes
*
* @return array
*/
$class_names = apply_filters( 'wpametu_autoloaded_classes', $this->default_classes );
foreach ( $class_names as $class_name ) {
if ( $this->is_singleton( $class_name ) ) {
$class_name::get_instance();
}
}
// Register auto loader for each namespace
$errors = new \WP_Error();
$autoloaded_classes = [
'Ajax' => AjaxBase::class,
'QueryHighJack' => QueryHighJack::class,
'Rest' => RestBase::class,
'WpApi' => WpApi::class,
'Widget' => Widget::class,
'MetaBoxes' => MetaBox::class,
'Admin/Screens' => Screen::class,
'Admin/MetaBox' => EmptyMetaBox::class,
'Cron' => CronBase::class,
];
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$autoloaded_classes['Commands'] = Command::class;
}
foreach ( $this->namespaces as $ns => $base_dir ) {
foreach ( $autoloaded_classes as $base => $sub_class ) {
$sub_base = $base_dir . '/' . $ns . '/' . $base;
// Skip if directory doesn't exist
if ( ! is_dir( $sub_base ) ) {
continue;
}
// Scan directory
foreach ( scandir( $sub_base ) as $file ) {
// Parse only PHP
if ( ! preg_match( '/\.php$/u', $file ) ) {
continue;
}
// Build class name
$class_name = $ns . '\\' . str_replace( '/', '\\', $base ) . '\\' . preg_replace( '/\.php$/u', '', basename( $file ) );
// Check class exitence
if ( ! class_exists( $class_name ) ) {
$errors->add( 404, sprintf( 'Class %s doesn\'t exist.', $class_name ) );
continue;
}
// Check requirements
if ( $this->is_sub_class_of( $class_name, $sub_class, true ) ) {
// If this is singleton, call get_instance()
if ( $this->is_sub_class_of( $class_name, Singleton::class ) ) {
$class_name::get_instance();
switch ( $sub_class ) {
case AjaxBase::class:
$this->ajax_controllers[] = $class_name;
break;
case RestBase::class:
Rewrite::register_class( $class_name );
break;
default:
// Do nothing
break;
}
} else {
switch ( $sub_class ) {
case Widget::class:
$this->widgets[] = $class_name;
break;
case Command::class:
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$this->commands[] = $class_name;
}
break;
default:
break;
}
}
}
}
}
}
// Show error messages
if ( $errors->get_error_messages() ) {
add_action( 'admin_notices', function () use ( $errors ) {
printf( '<div class="error"><p>%s</p></div>', implode( '<br />', $errors->get_error_messages() ) );
} );
}
// Register WP_CLI commands
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$this->register_commands();
}
} | php | public function setup() {
/**
* wpametu_autoloaded_classes
*
* Default class names which will be initialized after frameworks' bootstrap.
*
* @param array $classes
*
* @return array
*/
$class_names = apply_filters( 'wpametu_autoloaded_classes', $this->default_classes );
foreach ( $class_names as $class_name ) {
if ( $this->is_singleton( $class_name ) ) {
$class_name::get_instance();
}
}
// Register auto loader for each namespace
$errors = new \WP_Error();
$autoloaded_classes = [
'Ajax' => AjaxBase::class,
'QueryHighJack' => QueryHighJack::class,
'Rest' => RestBase::class,
'WpApi' => WpApi::class,
'Widget' => Widget::class,
'MetaBoxes' => MetaBox::class,
'Admin/Screens' => Screen::class,
'Admin/MetaBox' => EmptyMetaBox::class,
'Cron' => CronBase::class,
];
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$autoloaded_classes['Commands'] = Command::class;
}
foreach ( $this->namespaces as $ns => $base_dir ) {
foreach ( $autoloaded_classes as $base => $sub_class ) {
$sub_base = $base_dir . '/' . $ns . '/' . $base;
// Skip if directory doesn't exist
if ( ! is_dir( $sub_base ) ) {
continue;
}
// Scan directory
foreach ( scandir( $sub_base ) as $file ) {
// Parse only PHP
if ( ! preg_match( '/\.php$/u', $file ) ) {
continue;
}
// Build class name
$class_name = $ns . '\\' . str_replace( '/', '\\', $base ) . '\\' . preg_replace( '/\.php$/u', '', basename( $file ) );
// Check class exitence
if ( ! class_exists( $class_name ) ) {
$errors->add( 404, sprintf( 'Class %s doesn\'t exist.', $class_name ) );
continue;
}
// Check requirements
if ( $this->is_sub_class_of( $class_name, $sub_class, true ) ) {
// If this is singleton, call get_instance()
if ( $this->is_sub_class_of( $class_name, Singleton::class ) ) {
$class_name::get_instance();
switch ( $sub_class ) {
case AjaxBase::class:
$this->ajax_controllers[] = $class_name;
break;
case RestBase::class:
Rewrite::register_class( $class_name );
break;
default:
// Do nothing
break;
}
} else {
switch ( $sub_class ) {
case Widget::class:
$this->widgets[] = $class_name;
break;
case Command::class:
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$this->commands[] = $class_name;
}
break;
default:
break;
}
}
}
}
}
}
// Show error messages
if ( $errors->get_error_messages() ) {
add_action( 'admin_notices', function () use ( $errors ) {
printf( '<div class="error"><p>%s</p></div>', implode( '<br />', $errors->get_error_messages() ) );
} );
}
// Register WP_CLI commands
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$this->register_commands();
}
} | [
"public",
"function",
"setup",
"(",
")",
"{",
"/**\n\t\t * wpametu_autoloaded_classes\n\t\t *\n\t\t * Default class names which will be initialized after frameworks' bootstrap.\n\t\t *\n\t\t * @param array $classes\n\t\t *\n\t\t * @return array\n\t\t */",
"$",
"class_names",
"=",
"apply_filters",
"(",
"'wpametu_autoloaded_classes'",
",",
"$",
"this",
"->",
"default_classes",
")",
";",
"foreach",
"(",
"$",
"class_names",
"as",
"$",
"class_name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_singleton",
"(",
"$",
"class_name",
")",
")",
"{",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"}",
"}",
"// Register auto loader for each namespace",
"$",
"errors",
"=",
"new",
"\\",
"WP_Error",
"(",
")",
";",
"$",
"autoloaded_classes",
"=",
"[",
"'Ajax'",
"=>",
"AjaxBase",
"::",
"class",
",",
"'QueryHighJack'",
"=>",
"QueryHighJack",
"::",
"class",
",",
"'Rest'",
"=>",
"RestBase",
"::",
"class",
",",
"'WpApi'",
"=>",
"WpApi",
"::",
"class",
",",
"'Widget'",
"=>",
"Widget",
"::",
"class",
",",
"'MetaBoxes'",
"=>",
"MetaBox",
"::",
"class",
",",
"'Admin/Screens'",
"=>",
"Screen",
"::",
"class",
",",
"'Admin/MetaBox'",
"=>",
"EmptyMetaBox",
"::",
"class",
",",
"'Cron'",
"=>",
"CronBase",
"::",
"class",
",",
"]",
";",
"if",
"(",
"defined",
"(",
"'WP_CLI'",
")",
"&&",
"WP_CLI",
")",
"{",
"$",
"autoloaded_classes",
"[",
"'Commands'",
"]",
"=",
"Command",
"::",
"class",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
"=>",
"$",
"base_dir",
")",
"{",
"foreach",
"(",
"$",
"autoloaded_classes",
"as",
"$",
"base",
"=>",
"$",
"sub_class",
")",
"{",
"$",
"sub_base",
"=",
"$",
"base_dir",
".",
"'/'",
".",
"$",
"ns",
".",
"'/'",
".",
"$",
"base",
";",
"// Skip if directory doesn't exist",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"sub_base",
")",
")",
"{",
"continue",
";",
"}",
"// Scan directory",
"foreach",
"(",
"scandir",
"(",
"$",
"sub_base",
")",
"as",
"$",
"file",
")",
"{",
"// Parse only PHP",
"if",
"(",
"!",
"preg_match",
"(",
"'/\\.php$/u'",
",",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"// Build class name",
"$",
"class_name",
"=",
"$",
"ns",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"base",
")",
".",
"'\\\\'",
".",
"preg_replace",
"(",
"'/\\.php$/u'",
",",
"''",
",",
"basename",
"(",
"$",
"file",
")",
")",
";",
"// Check class exitence",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class_name",
")",
")",
"{",
"$",
"errors",
"->",
"add",
"(",
"404",
",",
"sprintf",
"(",
"'Class %s doesn\\'t exist.'",
",",
"$",
"class_name",
")",
")",
";",
"continue",
";",
"}",
"// Check requirements",
"if",
"(",
"$",
"this",
"->",
"is_sub_class_of",
"(",
"$",
"class_name",
",",
"$",
"sub_class",
",",
"true",
")",
")",
"{",
"// If this is singleton, call get_instance()",
"if",
"(",
"$",
"this",
"->",
"is_sub_class_of",
"(",
"$",
"class_name",
",",
"Singleton",
"::",
"class",
")",
")",
"{",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"switch",
"(",
"$",
"sub_class",
")",
"{",
"case",
"AjaxBase",
"::",
"class",
":",
"$",
"this",
"->",
"ajax_controllers",
"[",
"]",
"=",
"$",
"class_name",
";",
"break",
";",
"case",
"RestBase",
"::",
"class",
":",
"Rewrite",
"::",
"register_class",
"(",
"$",
"class_name",
")",
";",
"break",
";",
"default",
":",
"// Do nothing",
"break",
";",
"}",
"}",
"else",
"{",
"switch",
"(",
"$",
"sub_class",
")",
"{",
"case",
"Widget",
"::",
"class",
":",
"$",
"this",
"->",
"widgets",
"[",
"]",
"=",
"$",
"class_name",
";",
"break",
";",
"case",
"Command",
"::",
"class",
":",
"if",
"(",
"defined",
"(",
"'WP_CLI'",
")",
"&&",
"WP_CLI",
")",
"{",
"$",
"this",
"->",
"commands",
"[",
"]",
"=",
"$",
"class_name",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"// Show error messages",
"if",
"(",
"$",
"errors",
"->",
"get_error_messages",
"(",
")",
")",
"{",
"add_action",
"(",
"'admin_notices'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"errors",
")",
"{",
"printf",
"(",
"'<div class=\"error\"><p>%s</p></div>'",
",",
"implode",
"(",
"'<br />'",
",",
"$",
"errors",
"->",
"get_error_messages",
"(",
")",
")",
")",
";",
"}",
")",
";",
"}",
"// Register WP_CLI commands",
"if",
"(",
"defined",
"(",
"'WP_CLI'",
")",
"&&",
"WP_CLI",
")",
"{",
"$",
"this",
"->",
"register_commands",
"(",
")",
";",
"}",
"}"
] | Auto load | [
"Auto",
"load"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L123-L219 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.register_meta_box | public function register_meta_box() {
$flg = false;
foreach ( $this->namespaces as $ns => $dir ) {
$sub_base = $dir . '/' . $ns . '/MetaBoxes';
if ( is_dir( $sub_base ) ) {
// Enqueue script flag
// Load all meta boxes
foreach ( scandir( $sub_base ) as $file ) {
if ( ! preg_match( '/\.php$/u', $file ) ) {
$class_name = $ns . '\\MetaBoxes\\' . str_replace( '.php', '', $file );
if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, EditMetaBox::class ) ) {
$class_name::get_instance();
$flg = true;
}
}
}
}
}
if ( $flg ) {
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
}
} | php | public function register_meta_box() {
$flg = false;
foreach ( $this->namespaces as $ns => $dir ) {
$sub_base = $dir . '/' . $ns . '/MetaBoxes';
if ( is_dir( $sub_base ) ) {
// Enqueue script flag
// Load all meta boxes
foreach ( scandir( $sub_base ) as $file ) {
if ( ! preg_match( '/\.php$/u', $file ) ) {
$class_name = $ns . '\\MetaBoxes\\' . str_replace( '.php', '', $file );
if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, EditMetaBox::class ) ) {
$class_name::get_instance();
$flg = true;
}
}
}
}
}
if ( $flg ) {
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
}
} | [
"public",
"function",
"register_meta_box",
"(",
")",
"{",
"$",
"flg",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
"=>",
"$",
"dir",
")",
"{",
"$",
"sub_base",
"=",
"$",
"dir",
".",
"'/'",
".",
"$",
"ns",
".",
"'/MetaBoxes'",
";",
"if",
"(",
"is_dir",
"(",
"$",
"sub_base",
")",
")",
"{",
"// Enqueue script flag",
"// Load all meta boxes",
"foreach",
"(",
"scandir",
"(",
"$",
"sub_base",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/\\.php$/u'",
",",
"$",
"file",
")",
")",
"{",
"$",
"class_name",
"=",
"$",
"ns",
".",
"'\\\\MetaBoxes\\\\'",
".",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class_name",
")",
"&&",
"$",
"this",
"->",
"is_sub_class_of",
"(",
"$",
"class_name",
",",
"EditMetaBox",
"::",
"class",
")",
")",
"{",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"$",
"flg",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"flg",
")",
"{",
"add_action",
"(",
"'admin_enqueue_scripts'",
",",
"[",
"$",
"this",
",",
"'admin_enqueue_scripts'",
"]",
")",
";",
"}",
"}"
] | Register meta boxes | [
"Register",
"meta",
"boxes"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L224-L245 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.register_commands | private function register_commands() {
foreach ( $this->commands as $class_name ) {
\WP_CLI::add_command( $class_name::COMMAND_NAME, $class_name );
}
} | php | private function register_commands() {
foreach ( $this->commands as $class_name ) {
\WP_CLI::add_command( $class_name::COMMAND_NAME, $class_name );
}
} | [
"private",
"function",
"register_commands",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"class_name",
")",
"{",
"\\",
"WP_CLI",
"::",
"add_command",
"(",
"$",
"class_name",
"::",
"COMMAND_NAME",
",",
"$",
"class_name",
")",
";",
"}",
"}"
] | Register All commands | [
"Register",
"All",
"commands"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L259-L263 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.ajax_register | public function ajax_register() {
if ( AjaxBase::is_ajax() ) {
foreach ( $this->ajax_controllers as $class_name ) {
/** @var AjaxBase $instance */
$instance = $class_name::get_instance();
$instance->register();
}
}
} | php | public function ajax_register() {
if ( AjaxBase::is_ajax() ) {
foreach ( $this->ajax_controllers as $class_name ) {
/** @var AjaxBase $instance */
$instance = $class_name::get_instance();
$instance->register();
}
}
} | [
"public",
"function",
"ajax_register",
"(",
")",
"{",
"if",
"(",
"AjaxBase",
"::",
"is_ajax",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"ajax_controllers",
"as",
"$",
"class_name",
")",
"{",
"/** @var AjaxBase $instance */",
"$",
"instance",
"=",
"$",
"class_name",
"::",
"get_instance",
"(",
")",
";",
"$",
"instance",
"->",
"register",
"(",
")",
";",
"}",
"}",
"}"
] | Register ajax actions | [
"Register",
"ajax",
"actions"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L268-L276 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.scan_post_type | public function scan_post_type() {
$flg = false;
foreach ( $this->namespaces as $ns => $dir ) {
$dir = $dir . '/' . $ns . '/ThePost';
if ( is_dir( $dir ) ) {
foreach ( scandir( $dir ) as $file ) {
if ( ! preg_match( '/^\./u', $file ) ) {
$base_class = str_replace( '.php', '', $file );
$class_name = $ns . '\\ThePost\\' . $base_class;
if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, PostHelper::class ) ) {
$this->post_type_to_override[ $this->str->camel_to_hyphen( $base_class ) ] = $class_name;
$flg = true;
}
}
}
}
}
if ( $flg ) {
add_action( 'the_post', [ $this, 'the_post' ] );
}
} | php | public function scan_post_type() {
$flg = false;
foreach ( $this->namespaces as $ns => $dir ) {
$dir = $dir . '/' . $ns . '/ThePost';
if ( is_dir( $dir ) ) {
foreach ( scandir( $dir ) as $file ) {
if ( ! preg_match( '/^\./u', $file ) ) {
$base_class = str_replace( '.php', '', $file );
$class_name = $ns . '\\ThePost\\' . $base_class;
if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, PostHelper::class ) ) {
$this->post_type_to_override[ $this->str->camel_to_hyphen( $base_class ) ] = $class_name;
$flg = true;
}
}
}
}
}
if ( $flg ) {
add_action( 'the_post', [ $this, 'the_post' ] );
}
} | [
"public",
"function",
"scan_post_type",
"(",
")",
"{",
"$",
"flg",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
"=>",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"dir",
".",
"'/'",
".",
"$",
"ns",
".",
"'/ThePost'",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^\\./u'",
",",
"$",
"file",
")",
")",
"{",
"$",
"base_class",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"$",
"class_name",
"=",
"$",
"ns",
".",
"'\\\\ThePost\\\\'",
".",
"$",
"base_class",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class_name",
")",
"&&",
"$",
"this",
"->",
"is_sub_class_of",
"(",
"$",
"class_name",
",",
"PostHelper",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"post_type_to_override",
"[",
"$",
"this",
"->",
"str",
"->",
"camel_to_hyphen",
"(",
"$",
"base_class",
")",
"]",
"=",
"$",
"class_name",
";",
"$",
"flg",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"flg",
")",
"{",
"add_action",
"(",
"'the_post'",
",",
"[",
"$",
"this",
",",
"'the_post'",
"]",
")",
";",
"}",
"}"
] | Scan original post type to override | [
"Scan",
"original",
"post",
"type",
"to",
"override"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L281-L301 |
hametuha/wpametu | src/WPametu/AutoLoader.php | AutoLoader.the_post | public function the_post( &$post_obj ) {
if ( isset( $this->post_type_to_override[ $post_obj->post_type ] ) ) {
// Post type exists. Let's override
$class_name = $this->post_type_to_override[ $post_obj->post_type ];
global $post;
$post->helper = new $class_name( $post_obj );
}
} | php | public function the_post( &$post_obj ) {
if ( isset( $this->post_type_to_override[ $post_obj->post_type ] ) ) {
// Post type exists. Let's override
$class_name = $this->post_type_to_override[ $post_obj->post_type ];
global $post;
$post->helper = new $class_name( $post_obj );
}
} | [
"public",
"function",
"the_post",
"(",
"&",
"$",
"post_obj",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"post_type_to_override",
"[",
"$",
"post_obj",
"->",
"post_type",
"]",
")",
")",
"{",
"// Post type exists. Let's override",
"$",
"class_name",
"=",
"$",
"this",
"->",
"post_type_to_override",
"[",
"$",
"post_obj",
"->",
"post_type",
"]",
";",
"global",
"$",
"post",
";",
"$",
"post",
"->",
"helper",
"=",
"new",
"$",
"class_name",
"(",
"$",
"post_obj",
")",
";",
"}",
"}"
] | Assign global $post object
@param \WP_Post|\stdClass $post_obj | [
"Assign",
"global",
"$post",
"object"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L308-L315 |
navarr/verticalresponse | src/Client.php | Client.get | public function get($url, $parameters = [])
{
$query = $this->buildQuery($url, $parameters);
$url = static::LOCATION.$url.(strpos($url, '?') !== false ? '&' : '?').$query;
$headers = $this->buildHeaders();
$request = $this->requestProvider->createRequest('GET', $url, $headers);
$response = $this->client->send($request);
// Throw any errors we have before continuing
$this->errorCheckResponse($response);
return json_decode($this->streamToString($response->getBody()));
} | php | public function get($url, $parameters = [])
{
$query = $this->buildQuery($url, $parameters);
$url = static::LOCATION.$url.(strpos($url, '?') !== false ? '&' : '?').$query;
$headers = $this->buildHeaders();
$request = $this->requestProvider->createRequest('GET', $url, $headers);
$response = $this->client->send($request);
// Throw any errors we have before continuing
$this->errorCheckResponse($response);
return json_decode($this->streamToString($response->getBody()));
} | [
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"buildQuery",
"(",
"$",
"url",
",",
"$",
"parameters",
")",
";",
"$",
"url",
"=",
"static",
"::",
"LOCATION",
".",
"$",
"url",
".",
"(",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
"!==",
"false",
"?",
"'&'",
":",
"'?'",
")",
".",
"$",
"query",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"buildHeaders",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"requestProvider",
"->",
"createRequest",
"(",
"'GET'",
",",
"$",
"url",
",",
"$",
"headers",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"// Throw any errors we have before continuing",
"$",
"this",
"->",
"errorCheckResponse",
"(",
"$",
"response",
")",
";",
"return",
"json_decode",
"(",
"$",
"this",
"->",
"streamToString",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"}"
] | @param string $url
@param array $parameters
@return \stdClass
@throws Exception
@throws HttpException | [
"@param",
"string",
"$url",
"@param",
"array",
"$parameters"
] | train | https://github.com/navarr/verticalresponse/blob/d681fbf51866b59e772048e291250f0338c2c696/src/Client.php#L62-L75 |
navarr/verticalresponse | src/Client.php | Client.post | public function post($url, $parameters = [])
{
$url = static::LOCATION.$url;
$headers = $this->buildHeaders();
$request = $this->requestProvider->createRequest('POST', $url, $headers, json_encode($parameters));
$response = $this->client->send($request);
$this->errorCheckResponse($response);
return json_decode($this->streamToString($response->getBody()));
} | php | public function post($url, $parameters = [])
{
$url = static::LOCATION.$url;
$headers = $this->buildHeaders();
$request = $this->requestProvider->createRequest('POST', $url, $headers, json_encode($parameters));
$response = $this->client->send($request);
$this->errorCheckResponse($response);
return json_decode($this->streamToString($response->getBody()));
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"static",
"::",
"LOCATION",
".",
"$",
"url",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"buildHeaders",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"requestProvider",
"->",
"createRequest",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"headers",
",",
"json_encode",
"(",
"$",
"parameters",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"errorCheckResponse",
"(",
"$",
"response",
")",
";",
"return",
"json_decode",
"(",
"$",
"this",
"->",
"streamToString",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"}"
] | @param string $url
@param array $parameters
@return \stdClass
@throws Exception
@throws HttpException | [
"@param",
"string",
"$url",
"@param",
"array",
"$parameters"
] | train | https://github.com/navarr/verticalresponse/blob/d681fbf51866b59e772048e291250f0338c2c696/src/Client.php#L85-L96 |
navarr/verticalresponse | src/Client.php | Client.errorCheckResponse | protected function errorCheckResponse(ResponseInterface $response)
{
$body = $response->getBody();
if ($response->getStatusCode() >= 400) {
throw new HttpException($response);
}
$responseObject = @json_decode($this->streamToString($body));
if (!isset($responseObject)) {
throw new Exception('JSON returned is not valid', $response);
}
if (isset($responseObject->error)) {
throw new Exception($responseObject->error, $response);
}
} | php | protected function errorCheckResponse(ResponseInterface $response)
{
$body = $response->getBody();
if ($response->getStatusCode() >= 400) {
throw new HttpException($response);
}
$responseObject = @json_decode($this->streamToString($body));
if (!isset($responseObject)) {
throw new Exception('JSON returned is not valid', $response);
}
if (isset($responseObject->error)) {
throw new Exception($responseObject->error, $response);
}
} | [
"protected",
"function",
"errorCheckResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"body",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
">=",
"400",
")",
"{",
"throw",
"new",
"HttpException",
"(",
"$",
"response",
")",
";",
"}",
"$",
"responseObject",
"=",
"@",
"json_decode",
"(",
"$",
"this",
"->",
"streamToString",
"(",
"$",
"body",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"responseObject",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'JSON returned is not valid'",
",",
"$",
"response",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"responseObject",
"->",
"error",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"responseObject",
"->",
"error",
",",
"$",
"response",
")",
";",
"}",
"}"
] | @param ResponseInterface $response
@return void
@throws Exception
@throws HttpException | [
"@param",
"ResponseInterface",
"$response"
] | train | https://github.com/navarr/verticalresponse/blob/d681fbf51866b59e772048e291250f0338c2c696/src/Client.php#L127-L143 |
InactiveProjects/limoncello-illuminate | app/Api/PostsApi.php | PostsApi.indexComments | public function indexComments($postId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index post comments started.', [Post::FIELD_ID => $postId]);
$result = $this->indexRelationship($postId, Post::REL_COMMENTS, $parameters);
$this->getLogger()->debug('Index post comments completed.');
return $result;
} | php | public function indexComments($postId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index post comments started.', [Post::FIELD_ID => $postId]);
$result = $this->indexRelationship($postId, Post::REL_COMMENTS, $parameters);
$this->getLogger()->debug('Index post comments completed.');
return $result;
} | [
"public",
"function",
"indexComments",
"(",
"$",
"postId",
",",
"EncodingParametersInterface",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index post comments started.'",
",",
"[",
"Post",
"::",
"FIELD_ID",
"=>",
"$",
"postId",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"indexRelationship",
"(",
"$",
"postId",
",",
"Post",
"::",
"REL_COMMENTS",
",",
"$",
"parameters",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index post comments completed.'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param int|string $postId
@param EncodingParametersInterface $parameters
@return PagedDataInterface | [
"@param",
"int|string",
"$postId",
"@param",
"EncodingParametersInterface",
"$parameters"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/PostsApi.php#L80-L89 |
gruzilla/hydra | src/Hydra/Hydra.php | Hydra.load | public function load($serviceName = null)
{
if (null === $serviceName) {
$this->serviceProvider->loadAllServices();
} else {
$this->serviceProvider->loadService($serviceName);
}
// allow chaining
return $this;
} | php | public function load($serviceName = null)
{
if (null === $serviceName) {
$this->serviceProvider->loadAllServices();
} else {
$this->serviceProvider->loadService($serviceName);
}
// allow chaining
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"serviceName",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"serviceName",
")",
"{",
"$",
"this",
"->",
"serviceProvider",
"->",
"loadAllServices",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"serviceProvider",
"->",
"loadService",
"(",
"$",
"serviceName",
")",
";",
"}",
"// allow chaining",
"return",
"$",
"this",
";",
"}"
] | load all (leave argument empty) services configured or load a specific
service
@param string $serviceName which service to load
@return self | [
"load",
"all",
"(",
"leave",
"argument",
"empty",
")",
"services",
"configured",
"or",
"load",
"a",
"specific",
"service"
] | train | https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Hydra.php#L47-L57 |
gruzilla/hydra | src/Hydra/Hydra.php | Hydra.run | public function run()
{
foreach ($this->jobs as $job) {
$this->worker->run($job);
}
while ($this->worker->isRunning()) {
// waiting for worker to finish
}
// allow chaining
return $this;
} | php | public function run()
{
foreach ($this->jobs as $job) {
$this->worker->run($job);
}
while ($this->worker->isRunning()) {
// waiting for worker to finish
}
// allow chaining
return $this;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as",
"$",
"job",
")",
"{",
"$",
"this",
"->",
"worker",
"->",
"run",
"(",
"$",
"job",
")",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"worker",
"->",
"isRunning",
"(",
")",
")",
"{",
"// waiting for worker to finish",
"}",
"// allow chaining",
"return",
"$",
"this",
";",
"}"
] | run all jobs using the worker
@return self | [
"run",
"all",
"jobs",
"using",
"the",
"worker"
] | train | https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Hydra.php#L90-L102 |
php-lug/lug | src/Component/Behat/Extension/Api/Matcher/MatcherFactory.php | MatcherFactory.buildMatchers | protected function buildMatchers()
{
$matcher = new ArrayMatcher($this->buildScalarMatchers(), $this->buildParser());
return new ChainMatcher([
new JsonMatcher($matcher),
new XmlMatcher($matcher),
]);
} | php | protected function buildMatchers()
{
$matcher = new ArrayMatcher($this->buildScalarMatchers(), $this->buildParser());
return new ChainMatcher([
new JsonMatcher($matcher),
new XmlMatcher($matcher),
]);
} | [
"protected",
"function",
"buildMatchers",
"(",
")",
"{",
"$",
"matcher",
"=",
"new",
"ArrayMatcher",
"(",
"$",
"this",
"->",
"buildScalarMatchers",
"(",
")",
",",
"$",
"this",
"->",
"buildParser",
"(",
")",
")",
";",
"return",
"new",
"ChainMatcher",
"(",
"[",
"new",
"JsonMatcher",
"(",
"$",
"matcher",
")",
",",
"new",
"XmlMatcher",
"(",
"$",
"matcher",
")",
",",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Behat/Extension/Api/Matcher/MatcherFactory.php#L28-L36 |
tyokinuhata/html-builder | lib/Insert.php | Insert.insertElementsToBuffer | protected function insertElementsToBuffer($element, ...$options)
{
$option = '';
for ($i = 0; $i < count($options); $i++)
{
if (substr($options[$i], 0, 1) === '@')
{
$option .= ' ' . $options[$i];
}
else
{
$option .= ' ' . $options[$i] . '="' . $options[++$i] . '"';
}
}
array_splice($this->buffer, $this->pointer++, 0, '<' . $element . $option . '>');
array_splice($this->buffer, $this->pointer, 0, '</' . $element . '>');
return $this;
} | php | protected function insertElementsToBuffer($element, ...$options)
{
$option = '';
for ($i = 0; $i < count($options); $i++)
{
if (substr($options[$i], 0, 1) === '@')
{
$option .= ' ' . $options[$i];
}
else
{
$option .= ' ' . $options[$i] . '="' . $options[++$i] . '"';
}
}
array_splice($this->buffer, $this->pointer++, 0, '<' . $element . $option . '>');
array_splice($this->buffer, $this->pointer, 0, '</' . $element . '>');
return $this;
} | [
"protected",
"function",
"insertElementsToBuffer",
"(",
"$",
"element",
",",
"...",
"$",
"options",
")",
"{",
"$",
"option",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"options",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"options",
"[",
"$",
"i",
"]",
",",
"0",
",",
"1",
")",
"===",
"'@'",
")",
"{",
"$",
"option",
".=",
"' '",
".",
"$",
"options",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"option",
".=",
"' '",
".",
"$",
"options",
"[",
"$",
"i",
"]",
".",
"'=\"'",
".",
"$",
"options",
"[",
"++",
"$",
"i",
"]",
".",
"'\"'",
";",
"}",
"}",
"array_splice",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"this",
"->",
"pointer",
"++",
",",
"0",
",",
"'<'",
".",
"$",
"element",
".",
"$",
"option",
".",
"'>'",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"this",
"->",
"pointer",
",",
"0",
",",
"'</'",
".",
"$",
"element",
".",
"'>'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | バッファに閉じタグのある要素を挿入します
@param $element
@param array ...$options
@return $this | [
"バッファに閉じタグのある要素を挿入します"
] | train | https://github.com/tyokinuhata/html-builder/blob/e8deda5e275298694b35122ec0df3eeaef1f7804/lib/Insert.php#L17-L34 |
tyokinuhata/html-builder | lib/Insert.php | Insert.insertStylesToBuffer | protected function insertStylesToBuffer($element, ...$codes)
{
$codes = $codes[0];
$fmtCode = '';
foreach ($codes as $selector => $code)
{
$fmtCode .= $selector . '{';
foreach ($code as $property => $value)
{
$fmtCode .= $property . ':' . $value . ';';
}
$fmtCode .= '}';
}
array_splice($this->buffer, $this->pointer++, 0, '<' . $element . '>');
array_splice($this->buffer, $this->pointer++, 0, $fmtCode);
array_splice($this->buffer, $this->pointer++, 0, '</' . $element . '>');
return $this;
} | php | protected function insertStylesToBuffer($element, ...$codes)
{
$codes = $codes[0];
$fmtCode = '';
foreach ($codes as $selector => $code)
{
$fmtCode .= $selector . '{';
foreach ($code as $property => $value)
{
$fmtCode .= $property . ':' . $value . ';';
}
$fmtCode .= '}';
}
array_splice($this->buffer, $this->pointer++, 0, '<' . $element . '>');
array_splice($this->buffer, $this->pointer++, 0, $fmtCode);
array_splice($this->buffer, $this->pointer++, 0, '</' . $element . '>');
return $this;
} | [
"protected",
"function",
"insertStylesToBuffer",
"(",
"$",
"element",
",",
"...",
"$",
"codes",
")",
"{",
"$",
"codes",
"=",
"$",
"codes",
"[",
"0",
"]",
";",
"$",
"fmtCode",
"=",
"''",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"selector",
"=>",
"$",
"code",
")",
"{",
"$",
"fmtCode",
".=",
"$",
"selector",
".",
"'{'",
";",
"foreach",
"(",
"$",
"code",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"fmtCode",
".=",
"$",
"property",
".",
"':'",
".",
"$",
"value",
".",
"';'",
";",
"}",
"$",
"fmtCode",
".=",
"'}'",
";",
"}",
"array_splice",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"this",
"->",
"pointer",
"++",
",",
"0",
",",
"'<'",
".",
"$",
"element",
".",
"'>'",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"this",
"->",
"pointer",
"++",
",",
"0",
",",
"$",
"fmtCode",
")",
";",
"array_splice",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"this",
"->",
"pointer",
"++",
",",
"0",
",",
"'</'",
".",
"$",
"element",
".",
"'>'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | バッファにスタイルを挿入します
@param $element
@param array ...$codes
@return $this | [
"バッファにスタイルを挿入します"
] | train | https://github.com/tyokinuhata/html-builder/blob/e8deda5e275298694b35122ec0df3eeaef1f7804/lib/Insert.php#L66-L83 |
Erdiko/core | src/cache/Memcached.php | Memcached.put | public function put($key, $data)
{
$key = $this->getKeyCode($key);
$data = json_encode($data);
$this->memcacheObj->set($key, $data);
} | php | public function put($key, $data)
{
$key = $this->getKeyCode($key);
$data = json_encode($data);
$this->memcacheObj->set($key, $data);
} | [
"public",
"function",
"put",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKeyCode",
"(",
"$",
"key",
")",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"memcacheObj",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"}"
] | Put data into cache
@parm mixed $key
@parm mixed $data
@note If you put a object into cache,
the json_encode function will ignore any private property. | [
"Put",
"data",
"into",
"cache"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L77-L83 |
Erdiko/core | src/cache/Memcached.php | Memcached.get | public function get($key)
{
$key = $this->getKeyCode($key);
$value = $this->memcacheObj->get($key);
return json_decode($value);
} | php | public function get($key)
{
$key = $this->getKeyCode($key);
$value = $this->memcacheObj->get($key);
return json_decode($value);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKeyCode",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"memcacheObj",
"->",
"get",
"(",
"$",
"key",
")",
";",
"return",
"json_decode",
"(",
"$",
"value",
")",
";",
"}"
] | Get value from cache
@parm mixed $key
@return string $value
@note Any cache array will get return as object
@note If you need an array, use (array) $object | [
"Get",
"value",
"from",
"cache"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L94-L99 |
Erdiko/core | src/cache/Memcached.php | Memcached.has | public function has($key)
{
$key = $this->getKeyCode($key);
$value = $this->memcacheObj->get($key);
if (!$value) {
return false;
} else {
return true;
}
} | php | public function has($key)
{
$key = $this->getKeyCode($key);
$value = $this->memcacheObj->get($key);
if (!$value) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKeyCode",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"memcacheObj",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Check if the key exists in cache
@parm mixed $key
@return true if the key exist in cache
@return false if the key does not exist in cache | [
"Check",
"if",
"the",
"key",
"exists",
"in",
"cache"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L109-L120 |
Erdiko/core | src/cache/Memcached.php | Memcached.delete | public function delete($key)
{
$filename = $this->getKeyCode($key);
$this->memcacheObj->delete($filename);
} | php | public function delete($key)
{
$filename = $this->getKeyCode($key);
$this->memcacheObj->delete($filename);
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getKeyCode",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"memcacheObj",
"->",
"delete",
"(",
"$",
"filename",
")",
";",
"}"
] | Remove a key from cache
@parm mixed $key | [
"Remove",
"a",
"key",
"from",
"cache"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L128-L132 |
j-d/draggy | src/Draggy/Autocode/Templates/JS/Entity2.php | Entity2.getAttribute | public function getAttribute(JSAttribute $attribute)
{
$ret = '';
$ret .= ' /**' . "\n";
if (!is_null($attribute->getDescription())) {
$ret .= ' * ' . $attribute->getDescription() . "\n";
$ret .= ' *' . "\n";
}
$ret .= ' * @protected' . "\n";
$ret .= ' * @type {' . $attribute->getJSDocType() . '} ' . $attribute->getLowerName() . "\n";
$ret .= ' */' . "\n";
if ($attribute->getStatic()) {
$ret .= $attribute->getEntity()->getName() . '.prototype.' . $attribute->getName() . (!is_null($attribute->getDefaultValue()) ? ' = ' . $attribute->getDefaultValue() . ';' : ';');
return str_replace(' ', '', $ret);
}
if ($attribute->getEntity()->getProject()->getBase()) {
if (is_null($attribute->getDefaultValue())) {
$ret .= ' this.' . $attribute->getLowerName() . ' = undefined;' . "\n";
}
else {
switch($attribute->getJSType()) {
case 'string':
if ($attribute->getDefaultValue() == 'null') {
$ret .= ' this.' . $attribute->getLowerName() . ' = null;' . "\n";
} elseif ($attribute->getDefaultValue() == '\'\'') {
$ret .= ' this.' . $attribute->getLowerName() . ' = \'\';' . "\n";
}
else {
$ret .= ' this.' . $attribute->getLowerName() . ' = \'' . str_replace('\'','\\\'',$attribute->getDefaultValue()) . '\';' . "\n";
}
break;
default:
$ret .= ' this.' . $attribute->getLowerName() . ' = ' . $attribute->getDefaultValue() . ';' . "\n";
}
}
} else {
if (is_null($attribute->getDefaultValue()))
$ret .= ' private $' . $attribute->getLowerName() . ';' . "\n";
else {
switch($attribute->getJSType()) {
case 'string':
$ret .= ' private $' . $attribute->getLowerName() . ' = \'' . str_replace('\'','\\\'',$attribute->getDefaultValue()) . '\';' . "\n";
break;
default:
$ret .= ' private $' . $attribute->getLowerName() . ' = ' . $attribute->getDefaultValue() . ';' . "\n";
}
}
}
return $ret;
} | php | public function getAttribute(JSAttribute $attribute)
{
$ret = '';
$ret .= ' /**' . "\n";
if (!is_null($attribute->getDescription())) {
$ret .= ' * ' . $attribute->getDescription() . "\n";
$ret .= ' *' . "\n";
}
$ret .= ' * @protected' . "\n";
$ret .= ' * @type {' . $attribute->getJSDocType() . '} ' . $attribute->getLowerName() . "\n";
$ret .= ' */' . "\n";
if ($attribute->getStatic()) {
$ret .= $attribute->getEntity()->getName() . '.prototype.' . $attribute->getName() . (!is_null($attribute->getDefaultValue()) ? ' = ' . $attribute->getDefaultValue() . ';' : ';');
return str_replace(' ', '', $ret);
}
if ($attribute->getEntity()->getProject()->getBase()) {
if (is_null($attribute->getDefaultValue())) {
$ret .= ' this.' . $attribute->getLowerName() . ' = undefined;' . "\n";
}
else {
switch($attribute->getJSType()) {
case 'string':
if ($attribute->getDefaultValue() == 'null') {
$ret .= ' this.' . $attribute->getLowerName() . ' = null;' . "\n";
} elseif ($attribute->getDefaultValue() == '\'\'') {
$ret .= ' this.' . $attribute->getLowerName() . ' = \'\';' . "\n";
}
else {
$ret .= ' this.' . $attribute->getLowerName() . ' = \'' . str_replace('\'','\\\'',$attribute->getDefaultValue()) . '\';' . "\n";
}
break;
default:
$ret .= ' this.' . $attribute->getLowerName() . ' = ' . $attribute->getDefaultValue() . ';' . "\n";
}
}
} else {
if (is_null($attribute->getDefaultValue()))
$ret .= ' private $' . $attribute->getLowerName() . ';' . "\n";
else {
switch($attribute->getJSType()) {
case 'string':
$ret .= ' private $' . $attribute->getLowerName() . ' = \'' . str_replace('\'','\\\'',$attribute->getDefaultValue()) . '\';' . "\n";
break;
default:
$ret .= ' private $' . $attribute->getLowerName() . ' = ' . $attribute->getDefaultValue() . ';' . "\n";
}
}
}
return $ret;
} | [
"public",
"function",
"getAttribute",
"(",
"JSAttribute",
"$",
"attribute",
")",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"ret",
".=",
"' /**'",
".",
"\"\\n\"",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"attribute",
"->",
"getDescription",
"(",
")",
")",
")",
"{",
"$",
"ret",
".=",
"' * '",
".",
"$",
"attribute",
"->",
"getDescription",
"(",
")",
".",
"\"\\n\"",
";",
"$",
"ret",
".=",
"' *'",
".",
"\"\\n\"",
";",
"}",
"$",
"ret",
".=",
"' * @protected'",
".",
"\"\\n\"",
";",
"$",
"ret",
".=",
"' * @type {'",
".",
"$",
"attribute",
"->",
"getJSDocType",
"(",
")",
".",
"'} '",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"\"\\n\"",
";",
"$",
"ret",
".=",
"' */'",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"attribute",
"->",
"getStatic",
"(",
")",
")",
"{",
"$",
"ret",
".=",
"$",
"attribute",
"->",
"getEntity",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'.prototype.'",
".",
"$",
"attribute",
"->",
"getName",
"(",
")",
".",
"(",
"!",
"is_null",
"(",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
")",
"?",
"' = '",
".",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
".",
"';'",
":",
"';'",
")",
";",
"return",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"ret",
")",
";",
"}",
"if",
"(",
"$",
"attribute",
"->",
"getEntity",
"(",
")",
"->",
"getProject",
"(",
")",
"->",
"getBase",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
")",
")",
"{",
"$",
"ret",
".=",
"' this.'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = undefined;'",
".",
"\"\\n\"",
";",
"}",
"else",
"{",
"switch",
"(",
"$",
"attribute",
"->",
"getJSType",
"(",
")",
")",
"{",
"case",
"'string'",
":",
"if",
"(",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
"==",
"'null'",
")",
"{",
"$",
"ret",
".=",
"' this.'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = null;'",
".",
"\"\\n\"",
";",
"}",
"elseif",
"(",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
"==",
"'\\'\\''",
")",
"{",
"$",
"ret",
".=",
"' this.'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = \\'\\';'",
".",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"ret",
".=",
"' this.'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = \\''",
".",
"str_replace",
"(",
"'\\''",
",",
"'\\\\\\''",
",",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
")",
".",
"'\\';'",
".",
"\"\\n\"",
";",
"}",
"break",
";",
"default",
":",
"$",
"ret",
".=",
"' this.'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = '",
".",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
".",
"';'",
".",
"\"\\n\"",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"is_null",
"(",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
")",
")",
"$",
"ret",
".=",
"' private $'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"';'",
".",
"\"\\n\"",
";",
"else",
"{",
"switch",
"(",
"$",
"attribute",
"->",
"getJSType",
"(",
")",
")",
"{",
"case",
"'string'",
":",
"$",
"ret",
".=",
"' private $'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = \\''",
".",
"str_replace",
"(",
"'\\''",
",",
"'\\\\\\''",
",",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
")",
".",
"'\\';'",
".",
"\"\\n\"",
";",
"break",
";",
"default",
":",
"$",
"ret",
".=",
"' private $'",
".",
"$",
"attribute",
"->",
"getLowerName",
"(",
")",
".",
"' = '",
".",
"$",
"attribute",
"->",
"getDefaultValue",
"(",
")",
".",
"';'",
".",
"\"\\n\"",
";",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | <user-additions part="otherMethods"> | [
"<user",
"-",
"additions",
"part",
"=",
"otherMethods",
">"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/JS/Entity2.php#L44-L100 |
pbalan/directory-parser | src/pbalan/DirectoryParser/DirectoryParser.php | DirectoryParser.copyToDirectory | public function copyToDirectory($source, $destination)
{
//check to make sure the file exists
if(file_exists($source))
{
copy($source,$destination);
}
//check to make sure the file exists
if(file_exists($destination))
{
return true;
}
else
{
return false;
}
} | php | public function copyToDirectory($source, $destination)
{
//check to make sure the file exists
if(file_exists($source))
{
copy($source,$destination);
}
//check to make sure the file exists
if(file_exists($destination))
{
return true;
}
else
{
return false;
}
} | [
"public",
"function",
"copyToDirectory",
"(",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"//check to make sure the file exists",
"if",
"(",
"file_exists",
"(",
"$",
"source",
")",
")",
"{",
"copy",
"(",
"$",
"source",
",",
"$",
"destination",
")",
";",
"}",
"//check to make sure the file exists",
"if",
"(",
"file_exists",
"(",
"$",
"destination",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | /* Copy a file from source directory to destination directory
@param source: directory to copy from
@param destination: directory to copy to | [
"/",
"*",
"Copy",
"a",
"file",
"from",
"source",
"directory",
"to",
"destination",
"directory"
] | train | https://github.com/pbalan/directory-parser/blob/7b7ac0f0c7bb396e4285ed2f60330384fff00797/src/pbalan/DirectoryParser/DirectoryParser.php#L201-L217 |
DesignPond/newsletter | src/Http/Controllers/Frontend/NewsletterController.php | NewsletterController.show | public function show($id)
{
$newsletter = $this->newsletter->find($id);
return view('newsletter::Frontend.show')->with(['newsletter' => $newsletter]);
} | php | public function show($id)
{
$newsletter = $this->newsletter->find($id);
return view('newsletter::Frontend.show')->with(['newsletter' => $newsletter]);
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"newsletter",
"=",
"$",
"this",
"->",
"newsletter",
"->",
"find",
"(",
"$",
"id",
")",
";",
"return",
"view",
"(",
"'newsletter::Frontend.show'",
")",
"->",
"with",
"(",
"[",
"'newsletter'",
"=>",
"$",
"newsletter",
"]",
")",
";",
"}"
] | Display the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Display",
"the",
"specified",
"resource",
"."
] | train | https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Frontend/NewsletterController.php#L47-L52 |
DesignPond/newsletter | src/Http/Controllers/Frontend/NewsletterController.php | NewsletterController.campagne | public function campagne($id)
{
$campagne = $this->campagne->find($id);
return view('newsletter::Frontend.campagne')->with(['campagne' => $campagne]);
} | php | public function campagne($id)
{
$campagne = $this->campagne->find($id);
return view('newsletter::Frontend.campagne')->with(['campagne' => $campagne]);
} | [
"public",
"function",
"campagne",
"(",
"$",
"id",
")",
"{",
"$",
"campagne",
"=",
"$",
"this",
"->",
"campagne",
"->",
"find",
"(",
"$",
"id",
")",
";",
"return",
"view",
"(",
"'newsletter::Frontend.campagne'",
")",
"->",
"with",
"(",
"[",
"'campagne'",
"=>",
"$",
"campagne",
"]",
")",
";",
"}"
] | Show the form for editing the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"for",
"editing",
"the",
"specified",
"resource",
"."
] | train | https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Frontend/NewsletterController.php#L60-L65 |
mustardandrew/muan-laravel-acl | src/Commands/User/ClearPermissionCommand.php | ClearPermissionCommand.handle | public function handle()
{
$id = $this->argument('id');
try {
$user = $this->prepareUser($id);
} catch (Exception $e) {
$this->warn($e->getMessage());
return 1;
}
if (! method_exists($user, 'clearPermissions')) {
$this->warn("Method clearPermissions not found!");
}
$user->clearPermissions();
echo "Clear permissions. Done!", PHP_EOL;
return 0;
} | php | public function handle()
{
$id = $this->argument('id');
try {
$user = $this->prepareUser($id);
} catch (Exception $e) {
$this->warn($e->getMessage());
return 1;
}
if (! method_exists($user, 'clearPermissions')) {
$this->warn("Method clearPermissions not found!");
}
$user->clearPermissions();
echo "Clear permissions. Done!", PHP_EOL;
return 0;
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"argument",
"(",
"'id'",
")",
";",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"prepareUser",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"1",
";",
"}",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"user",
",",
"'clearPermissions'",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Method clearPermissions not found!\"",
")",
";",
"}",
"$",
"user",
"->",
"clearPermissions",
"(",
")",
";",
"echo",
"\"Clear permissions. Done!\"",
",",
"PHP_EOL",
";",
"return",
"0",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/User/ClearPermissionCommand.php#L37-L56 |
ComposePress/core | src/Traits/BaseObject.php | BaseObject.__isset | public function __isset( $name ) {
$func = "get_{$name}";
if ( method_exists( $this, $func ) ) {
return true;
}
$func = "is_{$name}";
if ( method_exists( $this, $func ) ) {
return true;
}
return isset( $GLOBALS[ $name ] );
} | php | public function __isset( $name ) {
$func = "get_{$name}";
if ( method_exists( $this, $func ) ) {
return true;
}
$func = "is_{$name}";
if ( method_exists( $this, $func ) ) {
return true;
}
return isset( $GLOBALS[ $name ] );
} | [
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"$",
"func",
"=",
"\"get_{$name}\"",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"func",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"func",
"=",
"\"is_{$name}\"",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"func",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | @param $name
@return bool | [
"@param",
"$name"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/BaseObject.php#L68-L79 |
JBZoo/Assets | src/Factory.php | Factory.create | public function create($alias, $source, $dependencies = [], $options = [])
{
$assetType = isset($options['type']) ? $options['type'] : '';
if (isset($this->_customTypes[$assetType])) {
$assetType = $this->_customTypes[$assetType];
} elseif (is_callable($source)) {
$assetType = 'Callback';
} elseif (is_string($source)) {
$ext = strtolower(FS::ext($source));
if ($ext === 'js') {
$assetType = 'JsFile';
} elseif ($ext === 'css') {
$assetType = 'CssFile';
} elseif ($ext === 'less') {
$assetType = 'LessFile';
} elseif ($ext === 'jsx') {
$assetType = 'JsxFile';
}
} elseif (is_array($source)) {
$assetType = 'Collection';
}
$className = __NAMESPACE__ . '\\Asset\\' . $assetType;
if (class_exists($className)) {
$options = is_array($options) ? new Data($options) : $options;
return new $className($this->getManager(), $alias, $source, $dependencies, $options);
}
throw new Exception('Undefined asset type: ' . print_r($source, true));
} | php | public function create($alias, $source, $dependencies = [], $options = [])
{
$assetType = isset($options['type']) ? $options['type'] : '';
if (isset($this->_customTypes[$assetType])) {
$assetType = $this->_customTypes[$assetType];
} elseif (is_callable($source)) {
$assetType = 'Callback';
} elseif (is_string($source)) {
$ext = strtolower(FS::ext($source));
if ($ext === 'js') {
$assetType = 'JsFile';
} elseif ($ext === 'css') {
$assetType = 'CssFile';
} elseif ($ext === 'less') {
$assetType = 'LessFile';
} elseif ($ext === 'jsx') {
$assetType = 'JsxFile';
}
} elseif (is_array($source)) {
$assetType = 'Collection';
}
$className = __NAMESPACE__ . '\\Asset\\' . $assetType;
if (class_exists($className)) {
$options = is_array($options) ? new Data($options) : $options;
return new $className($this->getManager(), $alias, $source, $dependencies, $options);
}
throw new Exception('Undefined asset type: ' . print_r($source, true));
} | [
"public",
"function",
"create",
"(",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"assetType",
"=",
"isset",
"(",
"$",
"options",
"[",
"'type'",
"]",
")",
"?",
"$",
"options",
"[",
"'type'",
"]",
":",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_customTypes",
"[",
"$",
"assetType",
"]",
")",
")",
"{",
"$",
"assetType",
"=",
"$",
"this",
"->",
"_customTypes",
"[",
"$",
"assetType",
"]",
";",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"source",
")",
")",
"{",
"$",
"assetType",
"=",
"'Callback'",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"$",
"ext",
"=",
"strtolower",
"(",
"FS",
"::",
"ext",
"(",
"$",
"source",
")",
")",
";",
"if",
"(",
"$",
"ext",
"===",
"'js'",
")",
"{",
"$",
"assetType",
"=",
"'JsFile'",
";",
"}",
"elseif",
"(",
"$",
"ext",
"===",
"'css'",
")",
"{",
"$",
"assetType",
"=",
"'CssFile'",
";",
"}",
"elseif",
"(",
"$",
"ext",
"===",
"'less'",
")",
"{",
"$",
"assetType",
"=",
"'LessFile'",
";",
"}",
"elseif",
"(",
"$",
"ext",
"===",
"'jsx'",
")",
"{",
"$",
"assetType",
"=",
"'JsxFile'",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"source",
")",
")",
"{",
"$",
"assetType",
"=",
"'Collection'",
";",
"}",
"$",
"className",
"=",
"__NAMESPACE__",
".",
"'\\\\Asset\\\\'",
".",
"$",
"assetType",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"options",
"=",
"is_array",
"(",
"$",
"options",
")",
"?",
"new",
"Data",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"getManager",
"(",
")",
",",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
",",
"$",
"options",
")",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'Undefined asset type: '",
".",
"print_r",
"(",
"$",
"source",
",",
"true",
")",
")",
";",
"}"
] | Create asset instance.
@param string $alias
@param mixed $source
@param string|array $dependencies
@param string|array $options
@throws Exception
@return Asset | [
"Create",
"asset",
"instance",
"."
] | train | https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Factory.php#L75-L112 |
old-town/workflow-designer-server | src/XmlWriter/XmlWriter.php | XmlWriter.processConfig | public function processConfig(array $config)
{
$writer = new NativeXmlWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(str_repeat(' ', 4));
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('data');
foreach ($config as $sectionName => $data) {
if (!is_array($data)) {
$writer->writeElement($sectionName, (string) $data);
} else {
$this->addBranch($sectionName, $data, $writer);
}
}
$writer->endElement();
$writer->endDocument();
return $writer->outputMemory();
} | php | public function processConfig(array $config)
{
$writer = new NativeXmlWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString(str_repeat(' ', 4));
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('data');
foreach ($config as $sectionName => $data) {
if (!is_array($data)) {
$writer->writeElement($sectionName, (string) $data);
} else {
$this->addBranch($sectionName, $data, $writer);
}
}
$writer->endElement();
$writer->endDocument();
return $writer->outputMemory();
} | [
"public",
"function",
"processConfig",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"writer",
"=",
"new",
"NativeXmlWriter",
"(",
")",
";",
"$",
"writer",
"->",
"openMemory",
"(",
")",
";",
"$",
"writer",
"->",
"setIndent",
"(",
"true",
")",
";",
"$",
"writer",
"->",
"setIndentString",
"(",
"str_repeat",
"(",
"' '",
",",
"4",
")",
")",
";",
"$",
"writer",
"->",
"startDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"writer",
"->",
"startElement",
"(",
"'data'",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"sectionName",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"writer",
"->",
"writeElement",
"(",
"$",
"sectionName",
",",
"(",
"string",
")",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addBranch",
"(",
"$",
"sectionName",
",",
"$",
"data",
",",
"$",
"writer",
")",
";",
"}",
"}",
"$",
"writer",
"->",
"endElement",
"(",
")",
";",
"$",
"writer",
"->",
"endDocument",
"(",
")",
";",
"return",
"$",
"writer",
"->",
"outputMemory",
"(",
")",
";",
"}"
] | processConfig(): defined by AbstractWriter.
@param array $config
@return string
@throws \Zend\Config\Exception\RuntimeException | [
"processConfig",
"()",
":",
"defined",
"by",
"AbstractWriter",
"."
] | train | https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/XmlWriter/XmlWriter.php#L25-L47 |
simbiosis-group/yii2-helper | widgets/Toastr.php | Toastr.run | public function run()
{
if ($this->useSessionFlash) {
return $this->getView()->registerJs($this->sessionFlashJs);
}
$this->getView()->registerJs($this->getJs(
$this->type,
$this->content,
$this->title
));
} | php | public function run()
{
if ($this->useSessionFlash) {
return $this->getView()->registerJs($this->sessionFlashJs);
}
$this->getView()->registerJs($this->getJs(
$this->type,
$this->content,
$this->title
));
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useSessionFlash",
")",
"{",
"return",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"$",
"this",
"->",
"sessionFlashJs",
")",
";",
"}",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"$",
"this",
"->",
"getJs",
"(",
"$",
"this",
"->",
"type",
",",
"$",
"this",
"->",
"content",
",",
"$",
"this",
"->",
"title",
")",
")",
";",
"}"
] | Renders the widget.
@return string | [
"Renders",
"the",
"widget",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/widgets/Toastr.php#L56-L68 |
GrupaZero/api | src/Gzero/Api/Transformer/RouteTranslationTransformer.php | RouteTranslationTransformer.transform | public function transform($translation)
{
$translation = $this->entityToArray(RouteTranslation::class, $translation);
return [
'id' => (int) $translation['id'],
'langCode' => $translation['lang_code'],
'url' => $translation['url'],
'isActive' => (bool) $translation['is_active'],
'createdAt' => $translation['created_at'],
'updatedAt' => $translation['updated_at'],
];
} | php | public function transform($translation)
{
$translation = $this->entityToArray(RouteTranslation::class, $translation);
return [
'id' => (int) $translation['id'],
'langCode' => $translation['lang_code'],
'url' => $translation['url'],
'isActive' => (bool) $translation['is_active'],
'createdAt' => $translation['created_at'],
'updatedAt' => $translation['updated_at'],
];
} | [
"public",
"function",
"transform",
"(",
"$",
"translation",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"RouteTranslation",
"::",
"class",
",",
"$",
"translation",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"translation",
"[",
"'id'",
"]",
",",
"'langCode'",
"=>",
"$",
"translation",
"[",
"'lang_code'",
"]",
",",
"'url'",
"=>",
"$",
"translation",
"[",
"'url'",
"]",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"translation",
"[",
"'is_active'",
"]",
",",
"'createdAt'",
"=>",
"$",
"translation",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"translation",
"[",
"'updated_at'",
"]",
",",
"]",
";",
"}"
] | Transforms route translation entity
@param RouteTranslation|array $translation RouteTranslation entity
@return array | [
"Transforms",
"route",
"translation",
"entity"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/RouteTranslationTransformer.php#L26-L37 |
gruzilla/hydra | src/Hydra/Jobs/MappedJob.php | MappedJob.createFrom | public static function createFrom(JobInterface $job, $mappedClass, RepositoryFactoryInterface $repositoryFactory = null)
{
$mappedJob = new MappedJob(
$job->getServiceName(),
$job->getRequest(),
$mappedClass
);
$mappedJob->setMethod($job->getMethod());
$mappedJob->setBody($job->getBody());
if (null !== $repositoryFactory) {
$mappedJob->setEntityRepository(
$repositoryFactory->getRepositoryForEntity($mappedClass)
);
}
return $mappedJob;
} | php | public static function createFrom(JobInterface $job, $mappedClass, RepositoryFactoryInterface $repositoryFactory = null)
{
$mappedJob = new MappedJob(
$job->getServiceName(),
$job->getRequest(),
$mappedClass
);
$mappedJob->setMethod($job->getMethod());
$mappedJob->setBody($job->getBody());
if (null !== $repositoryFactory) {
$mappedJob->setEntityRepository(
$repositoryFactory->getRepositoryForEntity($mappedClass)
);
}
return $mappedJob;
} | [
"public",
"static",
"function",
"createFrom",
"(",
"JobInterface",
"$",
"job",
",",
"$",
"mappedClass",
",",
"RepositoryFactoryInterface",
"$",
"repositoryFactory",
"=",
"null",
")",
"{",
"$",
"mappedJob",
"=",
"new",
"MappedJob",
"(",
"$",
"job",
"->",
"getServiceName",
"(",
")",
",",
"$",
"job",
"->",
"getRequest",
"(",
")",
",",
"$",
"mappedClass",
")",
";",
"$",
"mappedJob",
"->",
"setMethod",
"(",
"$",
"job",
"->",
"getMethod",
"(",
")",
")",
";",
"$",
"mappedJob",
"->",
"setBody",
"(",
"$",
"job",
"->",
"getBody",
"(",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"repositoryFactory",
")",
"{",
"$",
"mappedJob",
"->",
"setEntityRepository",
"(",
"$",
"repositoryFactory",
"->",
"getRepositoryForEntity",
"(",
"$",
"mappedClass",
")",
")",
";",
"}",
"return",
"$",
"mappedJob",
";",
"}"
] | creates a mapped job from another (basically clones it)
@param JobInterface $job the job to clone
@param string $mappedClass FQCN of the entity to map the result to
@return self | [
"creates",
"a",
"mapped",
"job",
"from",
"another",
"(",
"basically",
"clones",
"it",
")"
] | train | https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Jobs/MappedJob.php#L42-L60 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.getStatusOfTaskWithId | public function getStatusOfTaskWithId($taskId)
{
$task = $this->taskRepo->find($taskId);
if (!($task instanceof Task)) {
//the task was not found
return Task::STATUS_GONE;
}
return $task->getStatus();
} | php | public function getStatusOfTaskWithId($taskId)
{
$task = $this->taskRepo->find($taskId);
if (!($task instanceof Task)) {
//the task was not found
return Task::STATUS_GONE;
}
return $task->getStatus();
} | [
"public",
"function",
"getStatusOfTaskWithId",
"(",
"$",
"taskId",
")",
"{",
"$",
"task",
"=",
"$",
"this",
"->",
"taskRepo",
"->",
"find",
"(",
"$",
"taskId",
")",
";",
"if",
"(",
"!",
"(",
"$",
"task",
"instanceof",
"Task",
")",
")",
"{",
"//the task was not found",
"return",
"Task",
"::",
"STATUS_GONE",
";",
"}",
"return",
"$",
"task",
"->",
"getStatus",
"(",
")",
";",
"}"
] | Returns the current status of a task
@param integer $taskId
@return string | [
"Returns",
"the",
"current",
"status",
"of",
"a",
"task"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L126-L134 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.regenerateTask | public function regenerateTask($id)
{
$taskEntity = $this->taskRepo->find($id);
if (!($taskEntity instanceof Task)) {
throw new TaskQueueServiceException("No such task :" . $id, 1);
}
if ($taskEntity->getStatus() != Task::STATUS_FAILED) {
throw new TaskQueueServiceException(
"Invalid status for task. Current status: '" .
$taskEntity->getStatus() .
"' must be 'failed' to be able to restart it",
1
);
}
$data = $taskEntity->getData();
$taskEntity->setStatus(Task::STATUS_RESTARTED);
$this->entityManager->flush();
$parts = explode("::", $data, 2);
$taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json');
$taskObject->setTaskIdentifier($taskEntity->getId());
$data = get_class($taskObject) . '::' . $this->serializer->serialize($taskObject, 'json');
$this->beanstalk
->useTube($taskEntity->getTube())
->put($data);
return true;
} | php | public function regenerateTask($id)
{
$taskEntity = $this->taskRepo->find($id);
if (!($taskEntity instanceof Task)) {
throw new TaskQueueServiceException("No such task :" . $id, 1);
}
if ($taskEntity->getStatus() != Task::STATUS_FAILED) {
throw new TaskQueueServiceException(
"Invalid status for task. Current status: '" .
$taskEntity->getStatus() .
"' must be 'failed' to be able to restart it",
1
);
}
$data = $taskEntity->getData();
$taskEntity->setStatus(Task::STATUS_RESTARTED);
$this->entityManager->flush();
$parts = explode("::", $data, 2);
$taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json');
$taskObject->setTaskIdentifier($taskEntity->getId());
$data = get_class($taskObject) . '::' . $this->serializer->serialize($taskObject, 'json');
$this->beanstalk
->useTube($taskEntity->getTube())
->put($data);
return true;
} | [
"public",
"function",
"regenerateTask",
"(",
"$",
"id",
")",
"{",
"$",
"taskEntity",
"=",
"$",
"this",
"->",
"taskRepo",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"(",
"$",
"taskEntity",
"instanceof",
"Task",
")",
")",
"{",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"No such task :\"",
".",
"$",
"id",
",",
"1",
")",
";",
"}",
"if",
"(",
"$",
"taskEntity",
"->",
"getStatus",
"(",
")",
"!=",
"Task",
"::",
"STATUS_FAILED",
")",
"{",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Invalid status for task. Current status: '\"",
".",
"$",
"taskEntity",
"->",
"getStatus",
"(",
")",
".",
"\"' must be 'failed' to be able to restart it\"",
",",
"1",
")",
";",
"}",
"$",
"data",
"=",
"$",
"taskEntity",
"->",
"getData",
"(",
")",
";",
"$",
"taskEntity",
"->",
"setStatus",
"(",
"Task",
"::",
"STATUS_RESTARTED",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"\"::\"",
",",
"$",
"data",
",",
"2",
")",
";",
"$",
"taskObject",
"=",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"parts",
"[",
"0",
"]",
",",
"'json'",
")",
";",
"$",
"taskObject",
"->",
"setTaskIdentifier",
"(",
"$",
"taskEntity",
"->",
"getId",
"(",
")",
")",
";",
"$",
"data",
"=",
"get_class",
"(",
"$",
"taskObject",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"serializer",
"->",
"serialize",
"(",
"$",
"taskObject",
",",
"'json'",
")",
";",
"$",
"this",
"->",
"beanstalk",
"->",
"useTube",
"(",
"$",
"taskEntity",
"->",
"getTube",
"(",
")",
")",
"->",
"put",
"(",
"$",
"data",
")",
";",
"return",
"true",
";",
"}"
] | Regenerates a task (requeues it in the proper tube)
@param integer $id
@return boolean
@throws TaskQueueServiceException | [
"Regenerates",
"a",
"task",
"(",
"requeues",
"it",
"in",
"the",
"proper",
"tube",
")"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L169-L194 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.cleanUpTasks | public function cleanUpTasks($timePeriod)
{
$query = $this->entityManager->createQuery(
'DELETE
FROM WebdevviePheanstalkTaskQueueBundle:Task t
WHERE
t.status = :status and
t.created <= :older'
);
$query->setParameter('status', array(Task::STATUS_DONE));
$query->setParameter('older', date("Y-m-d H:i:s", time() - $timePeriod));
$query->execute();
} | php | public function cleanUpTasks($timePeriod)
{
$query = $this->entityManager->createQuery(
'DELETE
FROM WebdevviePheanstalkTaskQueueBundle:Task t
WHERE
t.status = :status and
t.created <= :older'
);
$query->setParameter('status', array(Task::STATUS_DONE));
$query->setParameter('older', date("Y-m-d H:i:s", time() - $timePeriod));
$query->execute();
} | [
"public",
"function",
"cleanUpTasks",
"(",
"$",
"timePeriod",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQuery",
"(",
"'DELETE\n FROM WebdevviePheanstalkTaskQueueBundle:Task t\n WHERE\n t.status = :status and\n t.created <= :older'",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'status'",
",",
"array",
"(",
"Task",
"::",
"STATUS_DONE",
")",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'older'",
",",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"time",
"(",
")",
"-",
"$",
"timePeriod",
")",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}"
] | Cleans up tasks that are marked as done
@param integer $timePeriod
@return void | [
"Cleans",
"up",
"tasks",
"that",
"are",
"marked",
"as",
"done"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L202-L214 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.reserveTask | public function reserveTask($tube = null)
{
if (is_null($tube)) {
$tube = $this->defaultTube;
}
$inTask = $this->beanstalk
->watch($tube)
->ignore('default')
->reserve(2);
if ($inTask === false) {
return null;
}
$data = $inTask->getData();
$parts = explode("::", $data, 2);
if (count($parts) !== 2) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube}");
}
try {
$taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json');
} catch (UnsupportedFormatException $exception) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube} ");
} catch (\ReflectionException $exception) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException(
"Invalid format in TaskQueue {$tube} class " . $parts[0] . ' is unknown'
);
}
if (!($taskObject instanceof TaskDescriptionInterface)) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid data in TaskQueue {$tube}");
}
if (!$this->databaseDisabled) {
$taskEntity = $this->taskRepo->find($taskObject->getTaskIdentifier());
} else {
//remake the task entity
$taskEntity = new Task($taskObject, '', $tube);
}
if (!($taskEntity instanceof Task)) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException(
"Unable to find taskEntity for task:" . $taskObject->getTaskIdentifier()
);
}
/**
* @var Task $taskEntity
*/
$workPackage = new WorkPackage($taskEntity, $inTask, $taskObject);
$this->updateTaskStatus($workPackage, Task::STATUS_WORKING);
return $workPackage;
} | php | public function reserveTask($tube = null)
{
if (is_null($tube)) {
$tube = $this->defaultTube;
}
$inTask = $this->beanstalk
->watch($tube)
->ignore('default')
->reserve(2);
if ($inTask === false) {
return null;
}
$data = $inTask->getData();
$parts = explode("::", $data, 2);
if (count($parts) !== 2) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube}");
}
try {
$taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json');
} catch (UnsupportedFormatException $exception) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube} ");
} catch (\ReflectionException $exception) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException(
"Invalid format in TaskQueue {$tube} class " . $parts[0] . ' is unknown'
);
}
if (!($taskObject instanceof TaskDescriptionInterface)) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException("Invalid data in TaskQueue {$tube}");
}
if (!$this->databaseDisabled) {
$taskEntity = $this->taskRepo->find($taskObject->getTaskIdentifier());
} else {
//remake the task entity
$taskEntity = new Task($taskObject, '', $tube);
}
if (!($taskEntity instanceof Task)) {
$this->beanstalk->delete($inTask);
throw new TaskQueueServiceException(
"Unable to find taskEntity for task:" . $taskObject->getTaskIdentifier()
);
}
/**
* @var Task $taskEntity
*/
$workPackage = new WorkPackage($taskEntity, $inTask, $taskObject);
$this->updateTaskStatus($workPackage, Task::STATUS_WORKING);
return $workPackage;
} | [
"public",
"function",
"reserveTask",
"(",
"$",
"tube",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"tube",
")",
")",
"{",
"$",
"tube",
"=",
"$",
"this",
"->",
"defaultTube",
";",
"}",
"$",
"inTask",
"=",
"$",
"this",
"->",
"beanstalk",
"->",
"watch",
"(",
"$",
"tube",
")",
"->",
"ignore",
"(",
"'default'",
")",
"->",
"reserve",
"(",
"2",
")",
";",
"if",
"(",
"$",
"inTask",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"data",
"=",
"$",
"inTask",
"->",
"getData",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"\"::\"",
",",
"$",
"data",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!==",
"2",
")",
"{",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"inTask",
")",
";",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Invalid format in TaskQueue {$tube}\"",
")",
";",
"}",
"try",
"{",
"$",
"taskObject",
"=",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"parts",
"[",
"0",
"]",
",",
"'json'",
")",
";",
"}",
"catch",
"(",
"UnsupportedFormatException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"inTask",
")",
";",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Invalid format in TaskQueue {$tube} \"",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"inTask",
")",
";",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Invalid format in TaskQueue {$tube} class \"",
".",
"$",
"parts",
"[",
"0",
"]",
".",
"' is unknown'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"taskObject",
"instanceof",
"TaskDescriptionInterface",
")",
")",
"{",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"inTask",
")",
";",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Invalid data in TaskQueue {$tube}\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"databaseDisabled",
")",
"{",
"$",
"taskEntity",
"=",
"$",
"this",
"->",
"taskRepo",
"->",
"find",
"(",
"$",
"taskObject",
"->",
"getTaskIdentifier",
"(",
")",
")",
";",
"}",
"else",
"{",
"//remake the task entity",
"$",
"taskEntity",
"=",
"new",
"Task",
"(",
"$",
"taskObject",
",",
"''",
",",
"$",
"tube",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"taskEntity",
"instanceof",
"Task",
")",
")",
"{",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"inTask",
")",
";",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Unable to find taskEntity for task:\"",
".",
"$",
"taskObject",
"->",
"getTaskIdentifier",
"(",
")",
")",
";",
"}",
"/**\n * @var Task $taskEntity\n */",
"$",
"workPackage",
"=",
"new",
"WorkPackage",
"(",
"$",
"taskEntity",
",",
"$",
"inTask",
",",
"$",
"taskObject",
")",
";",
"$",
"this",
"->",
"updateTaskStatus",
"(",
"$",
"workPackage",
",",
"Task",
"::",
"STATUS_WORKING",
")",
";",
"return",
"$",
"workPackage",
";",
"}"
] | Returns a task to work on.
@param string $tube (optional) the tube(queue) to reserve a task from
@throws TaskQueueServiceException
@return WorkPackage | [
"Returns",
"a",
"task",
"to",
"work",
"on",
"."
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L224-L275 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.markDone | public function markDone(WorkPackage $task, $log)
{
if ($this->logWorkerOutputOnSuccess) {
$this->updateTaskLog($task, $log);
}
$this->updateTaskStatus($task, Task::STATUS_DONE);
$this->beanstalk->delete($task->getPheanstalkJob());
} | php | public function markDone(WorkPackage $task, $log)
{
if ($this->logWorkerOutputOnSuccess) {
$this->updateTaskLog($task, $log);
}
$this->updateTaskStatus($task, Task::STATUS_DONE);
$this->beanstalk->delete($task->getPheanstalkJob());
} | [
"public",
"function",
"markDone",
"(",
"WorkPackage",
"$",
"task",
",",
"$",
"log",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logWorkerOutputOnSuccess",
")",
"{",
"$",
"this",
"->",
"updateTaskLog",
"(",
"$",
"task",
",",
"$",
"log",
")",
";",
"}",
"$",
"this",
"->",
"updateTaskStatus",
"(",
"$",
"task",
",",
"Task",
"::",
"STATUS_DONE",
")",
";",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"task",
"->",
"getPheanstalkJob",
"(",
")",
")",
";",
"}"
] | Deletes a task from the queue
@param WorkPackage $task
@param string $log
@throws TaskQueueServiceException
@return void | [
"Deletes",
"a",
"task",
"from",
"the",
"queue"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L285-L292 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.markFailed | public function markFailed(WorkPackage $task, $log)
{
if ($this->logWorkerOutputOnFailure) {
$this->updateTaskLog($task, $log);
}
$this->updateTaskStatus($task, Task::STATUS_FAILED);
$this->beanstalk->delete($task->getPheanstalkJob());
} | php | public function markFailed(WorkPackage $task, $log)
{
if ($this->logWorkerOutputOnFailure) {
$this->updateTaskLog($task, $log);
}
$this->updateTaskStatus($task, Task::STATUS_FAILED);
$this->beanstalk->delete($task->getPheanstalkJob());
} | [
"public",
"function",
"markFailed",
"(",
"WorkPackage",
"$",
"task",
",",
"$",
"log",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logWorkerOutputOnFailure",
")",
"{",
"$",
"this",
"->",
"updateTaskLog",
"(",
"$",
"task",
",",
"$",
"log",
")",
";",
"}",
"$",
"this",
"->",
"updateTaskStatus",
"(",
"$",
"task",
",",
"Task",
"::",
"STATUS_FAILED",
")",
";",
"$",
"this",
"->",
"beanstalk",
"->",
"delete",
"(",
"$",
"task",
"->",
"getPheanstalkJob",
"(",
")",
")",
";",
"}"
] | Marks a job as failed and deletes it from the beanstalk tube
@param WorkPackage $task
@param string $log
@throws TaskQueueServiceException
@return void | [
"Marks",
"a",
"job",
"as",
"failed",
"and",
"deletes",
"it",
"from",
"the",
"beanstalk",
"tube"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L302-L309 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.updateTaskLog | private function updateTaskLog(WorkPackage $task, $log)
{
if ($this->databaseDisabled) {
return;
}
$taskEntity = $task->getTaskEntity();
if ($taskEntity instanceof Task) {
$taskEntity->setLog($log);
//make sure it is stored...
$this->entityManager->flush($taskEntity);
} else {
throw new TaskQueueServiceException("Entity is not of type Task");
}
} | php | private function updateTaskLog(WorkPackage $task, $log)
{
if ($this->databaseDisabled) {
return;
}
$taskEntity = $task->getTaskEntity();
if ($taskEntity instanceof Task) {
$taskEntity->setLog($log);
//make sure it is stored...
$this->entityManager->flush($taskEntity);
} else {
throw new TaskQueueServiceException("Entity is not of type Task");
}
} | [
"private",
"function",
"updateTaskLog",
"(",
"WorkPackage",
"$",
"task",
",",
"$",
"log",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseDisabled",
")",
"{",
"return",
";",
"}",
"$",
"taskEntity",
"=",
"$",
"task",
"->",
"getTaskEntity",
"(",
")",
";",
"if",
"(",
"$",
"taskEntity",
"instanceof",
"Task",
")",
"{",
"$",
"taskEntity",
"->",
"setLog",
"(",
"$",
"log",
")",
";",
"//make sure it is stored...",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
"$",
"taskEntity",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Entity is not of type Task\"",
")",
";",
"}",
"}"
] | Writes the log to the Task entity
@param WorkPackage $task
@param string $log
@return void
@throws TaskQueueServiceException | [
"Writes",
"the",
"log",
"to",
"the",
"Task",
"entity"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L319-L332 |
webdevvie/pheanstalk-task-queue-bundle | Service/TaskQueueService.php | TaskQueueService.updateTaskStatus | private function updateTaskStatus(WorkPackage $task, $status)
{
if ($this->databaseDisabled) {
return;
}
$taskEntity = $task->getTaskEntity();
if ($taskEntity instanceof Task) {
$taskEntity->setStatus($status);
//make sure it is stored...
$this->entityManager->flush($taskEntity);
} else {
throw new TaskQueueServiceException("Entity is not of type Task");
}
} | php | private function updateTaskStatus(WorkPackage $task, $status)
{
if ($this->databaseDisabled) {
return;
}
$taskEntity = $task->getTaskEntity();
if ($taskEntity instanceof Task) {
$taskEntity->setStatus($status);
//make sure it is stored...
$this->entityManager->flush($taskEntity);
} else {
throw new TaskQueueServiceException("Entity is not of type Task");
}
} | [
"private",
"function",
"updateTaskStatus",
"(",
"WorkPackage",
"$",
"task",
",",
"$",
"status",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseDisabled",
")",
"{",
"return",
";",
"}",
"$",
"taskEntity",
"=",
"$",
"task",
"->",
"getTaskEntity",
"(",
")",
";",
"if",
"(",
"$",
"taskEntity",
"instanceof",
"Task",
")",
"{",
"$",
"taskEntity",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"//make sure it is stored...",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
"$",
"taskEntity",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TaskQueueServiceException",
"(",
"\"Entity is not of type Task\"",
")",
";",
"}",
"}"
] | Updates the task status
@param WorkPackage $task
@param string $status
@return void
@throws TaskQueueServiceException | [
"Updates",
"the",
"task",
"status"
] | train | https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L342-L355 |
thanhtaivtt/taiscript | src/Handler/Handler.php | Handler.readData | public function readData($pathFilename)
{
$pathFilename = ucfirst($pathFilename);
$pathFilename = realpath(__DIR__) . "/../Template/{$pathFilename}.template";
$file = fopen($pathFilename, 'r');
if ($data = fread($file, filesize($pathFilename))) {
return str_replace('<\?php', '<?php', $data);
} else {
throw new \ErrorException(realpath(__DIR__) . "/../Template/{$pathFilename}.template not Found");
}
} | php | public function readData($pathFilename)
{
$pathFilename = ucfirst($pathFilename);
$pathFilename = realpath(__DIR__) . "/../Template/{$pathFilename}.template";
$file = fopen($pathFilename, 'r');
if ($data = fread($file, filesize($pathFilename))) {
return str_replace('<\?php', '<?php', $data);
} else {
throw new \ErrorException(realpath(__DIR__) . "/../Template/{$pathFilename}.template not Found");
}
} | [
"public",
"function",
"readData",
"(",
"$",
"pathFilename",
")",
"{",
"$",
"pathFilename",
"=",
"ucfirst",
"(",
"$",
"pathFilename",
")",
";",
"$",
"pathFilename",
"=",
"realpath",
"(",
"__DIR__",
")",
".",
"\"/../Template/{$pathFilename}.template\"",
";",
"$",
"file",
"=",
"fopen",
"(",
"$",
"pathFilename",
",",
"'r'",
")",
";",
"if",
"(",
"$",
"data",
"=",
"fread",
"(",
"$",
"file",
",",
"filesize",
"(",
"$",
"pathFilename",
")",
")",
")",
"{",
"return",
"str_replace",
"(",
"'<\\?php'",
",",
"'<?php'",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"realpath",
"(",
"__DIR__",
")",
".",
"\"/../Template/{$pathFilename}.template not Found\"",
")",
";",
"}",
"}"
] | Read data form template folder
@param $pathFilename
@return mixed
@throws \ErrorException | [
"Read",
"data",
"form",
"template",
"folder"
] | train | https://github.com/thanhtaivtt/taiscript/blob/fbc0d2e30172dcfb9de48a457872f12c7ab5c6ca/src/Handler/Handler.php#L27-L40 |
thanhtaivtt/taiscript | src/Handler/Handler.php | Handler.make | public function make($type, $name)
{
if (!in_array(strtolower($type), $this->type)) {
echo "{$type} must is {$this->stringSuport}";
return false;
}
$data = $this->bindData($type, $name);
$file = @fopen($name . '.php', 'w+');
if ($file) {
return fwrite($file, $data);
} else {
die("permission error!\n");
}
} | php | public function make($type, $name)
{
if (!in_array(strtolower($type), $this->type)) {
echo "{$type} must is {$this->stringSuport}";
return false;
}
$data = $this->bindData($type, $name);
$file = @fopen($name . '.php', 'w+');
if ($file) {
return fwrite($file, $data);
} else {
die("permission error!\n");
}
} | [
"public",
"function",
"make",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"strtolower",
"(",
"$",
"type",
")",
",",
"$",
"this",
"->",
"type",
")",
")",
"{",
"echo",
"\"{$type} must is {$this->stringSuport}\"",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"bindData",
"(",
"$",
"type",
",",
"$",
"name",
")",
";",
"$",
"file",
"=",
"@",
"fopen",
"(",
"$",
"name",
".",
"'.php'",
",",
"'w+'",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"return",
"fwrite",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"die",
"(",
"\"permission error!\\n\"",
")",
";",
"}",
"}"
] | make file
@param $type
@param $name
@return bool|int | [
"make",
"file"
] | train | https://github.com/thanhtaivtt/taiscript/blob/fbc0d2e30172dcfb9de48a457872f12c7ab5c6ca/src/Handler/Handler.php#L104-L119 |
josh-taylor/migrations-generator | src/MigrationsGeneratorServiceProvider.php | MigrationsGeneratorServiceProvider.register | public function register()
{
// Register the Generator service provider
if ($this->app->environment() == 'local') {
$this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
}
// Register our commands
$this->app->singleton('command.josh.generate', function ($app) {
return $app['JoshTaylor\MigrationsGenerator\GenerateCommand'];
});
$this->commands('command.josh.generate');
} | php | public function register()
{
// Register the Generator service provider
if ($this->app->environment() == 'local') {
$this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
}
// Register our commands
$this->app->singleton('command.josh.generate', function ($app) {
return $app['JoshTaylor\MigrationsGenerator\GenerateCommand'];
});
$this->commands('command.josh.generate');
} | [
"public",
"function",
"register",
"(",
")",
"{",
"// Register the Generator service provider",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"environment",
"(",
")",
"==",
"'local'",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"'Laracasts\\Generators\\GeneratorsServiceProvider'",
")",
";",
"}",
"// Register our commands",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'command.josh.generate'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"[",
"'JoshTaylor\\MigrationsGenerator\\GenerateCommand'",
"]",
";",
"}",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"'command.josh.generate'",
")",
";",
"}"
] | Register any application services | [
"Register",
"any",
"application",
"services"
] | train | https://github.com/josh-taylor/migrations-generator/blob/bb6edc78773d11491881f12265a658bf058cb218/src/MigrationsGeneratorServiceProvider.php#L12-L25 |
bolt/codingstyle | src/Rules.php | Rules.getIterator | public function getIterator()
{
$rules = $this->rules;
if ($this->includePhp56) {
$rules += $this->php56Rules;
}
if ($this->includePhp70) {
$rules += $this->php70Rules;
}
if ($this->includePhp71) {
$rules += $this->php71Rules;
}
if ($this->includeRisky) {
$rules += $this->riskyRules;
if ($this->includePhp70) {
$rules += $this->php70RulesRisky;
}
if ($this->includePhp71) {
$rules += $this->php71RulesRisky;
}
}
return new \ArrayIterator($rules);
} | php | public function getIterator()
{
$rules = $this->rules;
if ($this->includePhp56) {
$rules += $this->php56Rules;
}
if ($this->includePhp70) {
$rules += $this->php70Rules;
}
if ($this->includePhp71) {
$rules += $this->php71Rules;
}
if ($this->includeRisky) {
$rules += $this->riskyRules;
if ($this->includePhp70) {
$rules += $this->php70RulesRisky;
}
if ($this->includePhp71) {
$rules += $this->php71RulesRisky;
}
}
return new \ArrayIterator($rules);
} | [
"public",
"function",
"getIterator",
"(",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"rules",
";",
"if",
"(",
"$",
"this",
"->",
"includePhp56",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"php56Rules",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"includePhp70",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"php70Rules",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"includePhp71",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"php71Rules",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"includeRisky",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"riskyRules",
";",
"if",
"(",
"$",
"this",
"->",
"includePhp70",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"php70RulesRisky",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"includePhp71",
")",
"{",
"$",
"rules",
"+=",
"$",
"this",
"->",
"php71RulesRisky",
";",
"}",
"}",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"rules",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/bolt/codingstyle/blob/df4d149430c66ce4d0ddca4d2469ca0da62a8cce/src/Rules.php#L151-L177 |
z38/pc-axis | src/Px.php | Px.variables | public function variables()
{
if (!$this->hasKeyword('STUB')) {
return $this->keyword('HEADING')->values;
} elseif (!$this->hasKeyword('HEADING')) {
return $this->keyword('STUB')->values;
} else {
return array_merge($this->keyword('STUB')->values, $this->keyword('HEADING')->values);
}
} | php | public function variables()
{
if (!$this->hasKeyword('STUB')) {
return $this->keyword('HEADING')->values;
} elseif (!$this->hasKeyword('HEADING')) {
return $this->keyword('STUB')->values;
} else {
return array_merge($this->keyword('STUB')->values, $this->keyword('HEADING')->values);
}
} | [
"public",
"function",
"variables",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasKeyword",
"(",
"'STUB'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"keyword",
"(",
"'HEADING'",
")",
"->",
"values",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"hasKeyword",
"(",
"'HEADING'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"keyword",
"(",
"'STUB'",
")",
"->",
"values",
";",
"}",
"else",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"keyword",
"(",
"'STUB'",
")",
"->",
"values",
",",
"$",
"this",
"->",
"keyword",
"(",
"'HEADING'",
")",
"->",
"values",
")",
";",
"}",
"}"
] | Returns a list of all variables.
@return array | [
"Returns",
"a",
"list",
"of",
"all",
"variables",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L71-L80 |
z38/pc-axis | src/Px.php | Px.values | public function values($variable)
{
foreach ($this->keywordList('VALUES') as $keyword) {
if ($keyword->subKeys[0] == $variable) {
return $keyword->values;
}
}
throw new RuntimeException(sprintf('Could not determine values of "%s".', $variable));
} | php | public function values($variable)
{
foreach ($this->keywordList('VALUES') as $keyword) {
if ($keyword->subKeys[0] == $variable) {
return $keyword->values;
}
}
throw new RuntimeException(sprintf('Could not determine values of "%s".', $variable));
} | [
"public",
"function",
"values",
"(",
"$",
"variable",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keywordList",
"(",
"'VALUES'",
")",
"as",
"$",
"keyword",
")",
"{",
"if",
"(",
"$",
"keyword",
"->",
"subKeys",
"[",
"0",
"]",
"==",
"$",
"variable",
")",
"{",
"return",
"$",
"keyword",
"->",
"values",
";",
"}",
"}",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Could not determine values of \"%s\".'",
",",
"$",
"variable",
")",
")",
";",
"}"
] | Returns a list of all possible values of a variable.
@param string $variable
@return array | [
"Returns",
"a",
"list",
"of",
"all",
"possible",
"values",
"of",
"a",
"variable",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L89-L97 |
z38/pc-axis | src/Px.php | Px.codes | public function codes($variable)
{
foreach ($this->keywordList('CODES') as $keyword) {
if ($keyword->subKeys[0] == $variable) {
return $keyword->values;
}
}
return null;
} | php | public function codes($variable)
{
foreach ($this->keywordList('CODES') as $keyword) {
if ($keyword->subKeys[0] == $variable) {
return $keyword->values;
}
}
return null;
} | [
"public",
"function",
"codes",
"(",
"$",
"variable",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"keywordList",
"(",
"'CODES'",
")",
"as",
"$",
"keyword",
")",
"{",
"if",
"(",
"$",
"keyword",
"->",
"subKeys",
"[",
"0",
"]",
"==",
"$",
"variable",
")",
"{",
"return",
"$",
"keyword",
"->",
"values",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns a list of all possible codes of a variable.
@param string $variable
@return array|null | [
"Returns",
"a",
"list",
"of",
"all",
"possible",
"codes",
"of",
"a",
"variable",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L106-L115 |
z38/pc-axis | src/Px.php | Px.index | public function index($indices)
{
$this->assertIndexMultipliers();
$index = 0;
for ($i = 0, $length = count($this->indexMultipliers); $i < $length; ++$i) {
$index += $indices[$i] * $this->indexMultipliers[$i];
}
return $index;
} | php | public function index($indices)
{
$this->assertIndexMultipliers();
$index = 0;
for ($i = 0, $length = count($this->indexMultipliers); $i < $length; ++$i) {
$index += $indices[$i] * $this->indexMultipliers[$i];
}
return $index;
} | [
"public",
"function",
"index",
"(",
"$",
"indices",
")",
"{",
"$",
"this",
"->",
"assertIndexMultipliers",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"length",
"=",
"count",
"(",
"$",
"this",
"->",
"indexMultipliers",
")",
";",
"$",
"i",
"<",
"$",
"length",
";",
"++",
"$",
"i",
")",
"{",
"$",
"index",
"+=",
"$",
"indices",
"[",
"$",
"i",
"]",
"*",
"$",
"this",
"->",
"indexMultipliers",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"index",
";",
"}"
] | Computes the index within the data matrix.
@param array $indices An array of all value indices
@return int | [
"Computes",
"the",
"index",
"within",
"the",
"data",
"matrix",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L124-L134 |
z38/pc-axis | src/Px.php | Px.datum | public function datum($indices)
{
$this->assertData();
$index = $this->index($indices);
if (isset($this->data[$index])) {
return $this->data[$index];
} else {
return null;
}
} | php | public function datum($indices)
{
$this->assertData();
$index = $this->index($indices);
if (isset($this->data[$index])) {
return $this->data[$index];
} else {
return null;
}
} | [
"public",
"function",
"datum",
"(",
"$",
"indices",
")",
"{",
"$",
"this",
"->",
"assertData",
"(",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"index",
"(",
"$",
"indices",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"index",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Gets a single data point.
@param array $indices An array of all value indices
@return string | [
"Gets",
"a",
"single",
"data",
"point",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L143-L153 |
z38/pc-axis | src/Px.php | Px.keywordList | public function keywordList($keyword)
{
$this->assertKeywords();
if (isset($this->keywords[$keyword])) {
return $this->keywords[$keyword];
} else {
return [];
}
} | php | public function keywordList($keyword)
{
$this->assertKeywords();
if (isset($this->keywords[$keyword])) {
return $this->keywords[$keyword];
} else {
return [];
}
} | [
"public",
"function",
"keywordList",
"(",
"$",
"keyword",
")",
"{",
"$",
"this",
"->",
"assertKeywords",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"keywords",
"[",
"$",
"keyword",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"keywords",
"[",
"$",
"keyword",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] | Returns all keywords with a given name.
@param string $keyword
@return array | [
"Returns",
"all",
"keywords",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L174-L183 |
z38/pc-axis | src/Px.php | Px.keyword | public function keyword($keyword)
{
$list = $this->keywordList($keyword);
if (empty($list)) {
throw new RuntimeException(sprintf('Keyword "%s" does not exist.', $keyword));
}
return $list[0];
} | php | public function keyword($keyword)
{
$list = $this->keywordList($keyword);
if (empty($list)) {
throw new RuntimeException(sprintf('Keyword "%s" does not exist.', $keyword));
}
return $list[0];
} | [
"public",
"function",
"keyword",
"(",
"$",
"keyword",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"keywordList",
"(",
"$",
"keyword",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Keyword \"%s\" does not exist.'",
",",
"$",
"keyword",
")",
")",
";",
"}",
"return",
"$",
"list",
"[",
"0",
"]",
";",
"}"
] | Returns the first keyword with a given name.
@param string $keyword
@return object | [
"Returns",
"the",
"first",
"keyword",
"with",
"a",
"given",
"name",
"."
] | train | https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L206-L214 |
eXistenZNL/PermCheck | src/Filesystem/AbstractFilesystem.php | AbstractFilesystem.getFiles | public function getFiles()
{
$iterator = new RecursiveDirectoryIterator(
$this->directory,
FilesystemIterator::SKIP_DOTS
);
$iterator = new RecursiveIteratorIterator($iterator);
$iterator->rewind();
return $iterator;
} | php | public function getFiles()
{
$iterator = new RecursiveDirectoryIterator(
$this->directory,
FilesystemIterator::SKIP_DOTS
);
$iterator = new RecursiveIteratorIterator($iterator);
$iterator->rewind();
return $iterator;
} | [
"public",
"function",
"getFiles",
"(",
")",
"{",
"$",
"iterator",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"directory",
",",
"FilesystemIterator",
"::",
"SKIP_DOTS",
")",
";",
"$",
"iterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"iterator",
")",
";",
"$",
"iterator",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"iterator",
";",
"}"
] | Give back a list of all files in a given directory, recursively
This returns the filename relative to the given directory.
@return Iterator | [
"Give",
"back",
"a",
"list",
"of",
"all",
"files",
"in",
"a",
"given",
"directory",
"recursively",
"This",
"returns",
"the",
"filename",
"relative",
"to",
"the",
"given",
"directory",
"."
] | train | https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/Filesystem/AbstractFilesystem.php#L51-L61 |
Erdiko/core | src/AjaxResponse.php | AjaxResponse.setStatusCode | public function setStatusCode($code = null)
{
if (!empty($code)) {
$this->_statusCode = $code;
http_response_code($this->_statusCode); // this sends the http status code
}
} | php | public function setStatusCode($code = null)
{
if (!empty($code)) {
$this->_statusCode = $code;
http_response_code($this->_statusCode); // this sends the http status code
}
} | [
"public",
"function",
"setStatusCode",
"(",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"code",
")",
")",
"{",
"$",
"this",
"->",
"_statusCode",
"=",
"$",
"code",
";",
"http_response_code",
"(",
"$",
"this",
"->",
"_statusCode",
")",
";",
"// this sends the http status code",
"}",
"}"
] | setStatusCode
Set, and send, the HTTP status code. | [
"setStatusCode"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/AjaxResponse.php#L48-L54 |
Erdiko/core | src/AjaxResponse.php | AjaxResponse.render | public function render()
{
$responseData = array(
"status" => $this->_statusCode,
"body" => $this->_content,
"errors" => $this->_errors
);
return json_encode($responseData);
} | php | public function render()
{
$responseData = array(
"status" => $this->_statusCode,
"body" => $this->_content,
"errors" => $this->_errors
);
return json_encode($responseData);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"responseData",
"=",
"array",
"(",
"\"status\"",
"=>",
"$",
"this",
"->",
"_statusCode",
",",
"\"body\"",
"=>",
"$",
"this",
"->",
"_content",
",",
"\"errors\"",
"=>",
"$",
"this",
"->",
"_errors",
")",
";",
"return",
"json_encode",
"(",
"$",
"responseData",
")",
";",
"}"
] | Ajax render function
@return string | [
"Ajax",
"render",
"function"
] | train | https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/AjaxResponse.php#L72-L81 |
xiewulong/yii2-fileupload | oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php | XcacheClassLoader.findFile | public function findFile($class)
{
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class));
}
return $file;
} | php | public function findFile($class)
{
if (xcache_isset($this->prefix.$class)) {
$file = xcache_get($this->prefix.$class);
} else {
xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class));
}
return $file;
} | [
"public",
"function",
"findFile",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"xcache_isset",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
")",
")",
"{",
"$",
"file",
"=",
"xcache_get",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
")",
";",
"}",
"else",
"{",
"xcache_set",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
",",
"$",
"file",
"=",
"$",
"this",
"->",
"classFinder",
"->",
"findFile",
"(",
"$",
"class",
")",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] | Finds a file by class name while caching lookups to Xcache.
@param string $class A class name to resolve to file
@return string|null | [
"Finds",
"a",
"file",
"by",
"class",
"name",
"while",
"caching",
"lookups",
"to",
"Xcache",
"."
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php#L114-L123 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getOption | public function getOption($field, $default = null)
{
return isset($this->options[$field]) ? $this->options[$field] : $default;
} | php | public function getOption($field, $default = null)
{
return isset($this->options[$field]) ? $this->options[$field] : $default;
} | [
"public",
"function",
"getOption",
"(",
"$",
"field",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"$",
"default",
";",
"}"
] | Get option
@param $field
@param array|string|int|null $default
@return array|string|int|null | [
"Get",
"option"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L63-L66 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.addHttpHeader | public function addHttpHeader($http_header, $value)
{
$field = EnumRequestOption::HTTP_HEADERS;
$http_headers = isset($this->options[$field]) ? $this->options[$field] : [];
foreach($http_headers as $key => $header){
if (strpos($header, $http_header) === 0){
$http_headers[$key] = "$http_header: $value\r\n";
return;
}
}
$http_headers[$http_header] = $value;
$this->options[$field] = $http_headers;
} | php | public function addHttpHeader($http_header, $value)
{
$field = EnumRequestOption::HTTP_HEADERS;
$http_headers = isset($this->options[$field]) ? $this->options[$field] : [];
foreach($http_headers as $key => $header){
if (strpos($header, $http_header) === 0){
$http_headers[$key] = "$http_header: $value\r\n";
return;
}
}
$http_headers[$http_header] = $value;
$this->options[$field] = $http_headers;
} | [
"public",
"function",
"addHttpHeader",
"(",
"$",
"http_header",
",",
"$",
"value",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"HTTP_HEADERS",
";",
"$",
"http_headers",
"=",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"http_headers",
"as",
"$",
"key",
"=>",
"$",
"header",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"header",
",",
"$",
"http_header",
")",
"===",
"0",
")",
"{",
"$",
"http_headers",
"[",
"$",
"key",
"]",
"=",
"\"$http_header: $value\\r\\n\"",
";",
"return",
";",
"}",
"}",
"$",
"http_headers",
"[",
"$",
"http_header",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
"=",
"$",
"http_headers",
";",
"}"
] | Add HTTP Header
@param string $http_header
@param string $value | [
"Add",
"HTTP",
"Header"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L74-L88 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getHttpHeaders | public function getHttpHeaders()
{
$field = EnumRequestOption::HTTP_HEADERS;
$http_deaders = isset($this->options[$field]) ? $this->options[$field] : [];
$http_deaders = array_merge($this->getDefaultHttpHeaders(), $http_deaders);
return $http_deaders;
} | php | public function getHttpHeaders()
{
$field = EnumRequestOption::HTTP_HEADERS;
$http_deaders = isset($this->options[$field]) ? $this->options[$field] : [];
$http_deaders = array_merge($this->getDefaultHttpHeaders(), $http_deaders);
return $http_deaders;
} | [
"public",
"function",
"getHttpHeaders",
"(",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"HTTP_HEADERS",
";",
"$",
"http_deaders",
"=",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"[",
"]",
";",
"$",
"http_deaders",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getDefaultHttpHeaders",
"(",
")",
",",
"$",
"http_deaders",
")",
";",
"return",
"$",
"http_deaders",
";",
"}"
] | Get HTTP headers
@return array | [
"Get",
"HTTP",
"headers"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L95-L103 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getExtraOptions | public function getExtraOptions()
{
$field = EnumRequestOption::EXTRA_OPTIONS;
return isset($this->options[$field]) ? $this->options[$field] : [];
} | php | public function getExtraOptions()
{
$field = EnumRequestOption::EXTRA_OPTIONS;
return isset($this->options[$field]) ? $this->options[$field] : [];
} | [
"public",
"function",
"getExtraOptions",
"(",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"EXTRA_OPTIONS",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"[",
"]",
";",
"}"
] | Get extra options
@return array | [
"Get",
"extra",
"options"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L110-L114 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getVerbose | public function getVerbose()
{
$field = EnumRequestOption::VERBOSE;
return isset($this->options[$field]) ? $this->options[$field] : false;
} | php | public function getVerbose()
{
$field = EnumRequestOption::VERBOSE;
return isset($this->options[$field]) ? $this->options[$field] : false;
} | [
"public",
"function",
"getVerbose",
"(",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"VERBOSE",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"false",
";",
"}"
] | Get verbose options
@return bool | [
"Get",
"verbose",
"options"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L121-L125 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getTotalTimeoutMs | public function getTotalTimeoutMs()
{
$field = EnumRequestOption::TOTAL_TIMEOUT_MS;
return isset($this->options[$field]) ? $this->options[$field] : 0;
} | php | public function getTotalTimeoutMs()
{
$field = EnumRequestOption::TOTAL_TIMEOUT_MS;
return isset($this->options[$field]) ? $this->options[$field] : 0;
} | [
"public",
"function",
"getTotalTimeoutMs",
"(",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"TOTAL_TIMEOUT_MS",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"0",
";",
"}"
] | Get total timeout(milli second)
@return bool | [
"Get",
"total",
"timeout",
"(",
"milli",
"second",
")"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L132-L136 |
stk2k/net-driver | src/Http/HttpRequest.php | HttpRequest.getConnectTimeoutMs | public function getConnectTimeoutMs()
{
$field = EnumRequestOption::CONNECT_TIMEOUT_MS;
return isset($this->options[$field]) ? $this->options[$field] : 0;
} | php | public function getConnectTimeoutMs()
{
$field = EnumRequestOption::CONNECT_TIMEOUT_MS;
return isset($this->options[$field]) ? $this->options[$field] : 0;
} | [
"public",
"function",
"getConnectTimeoutMs",
"(",
")",
"{",
"$",
"field",
"=",
"EnumRequestOption",
"::",
"CONNECT_TIMEOUT_MS",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"field",
"]",
":",
"0",
";",
"}"
] | Get connect timeout(milli second)
@return bool | [
"Get",
"connect",
"timeout",
"(",
"milli",
"second",
")"
] | train | https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L143-L147 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.transform | public function transform($content)
{
$content = $this->entityToArray(Content::class, $content);
return [
'id' => $this->setNullableValue($content['id']),
'parentId' => $this->setNullableValue($content['parent_id']),
'type' => $content['type'],
'theme' => $content['theme'],
'weight' => (int) $content['weight'],
'rating' => (int) $content['rating'],
'visits' => (int) $content['visits'],
'isActive' => (bool) $content['is_active'],
'isOnHome' => (bool) $content['is_on_home'],
'isCommentAllowed' => (bool) $content['is_comment_allowed'],
'isPromoted' => (bool) $content['is_promoted'],
'isSticky' => (bool) $content['is_sticky'],
'path' => $this->buildPath($content['path']),
'publishedAt' => $content['published_at'],
'createdAt' => $content['created_at'],
'updatedAt' => $content['updated_at']
];
} | php | public function transform($content)
{
$content = $this->entityToArray(Content::class, $content);
return [
'id' => $this->setNullableValue($content['id']),
'parentId' => $this->setNullableValue($content['parent_id']),
'type' => $content['type'],
'theme' => $content['theme'],
'weight' => (int) $content['weight'],
'rating' => (int) $content['rating'],
'visits' => (int) $content['visits'],
'isActive' => (bool) $content['is_active'],
'isOnHome' => (bool) $content['is_on_home'],
'isCommentAllowed' => (bool) $content['is_comment_allowed'],
'isPromoted' => (bool) $content['is_promoted'],
'isSticky' => (bool) $content['is_sticky'],
'path' => $this->buildPath($content['path']),
'publishedAt' => $content['published_at'],
'createdAt' => $content['created_at'],
'updatedAt' => $content['updated_at']
];
} | [
"public",
"function",
"transform",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"Content",
"::",
"class",
",",
"$",
"content",
")",
";",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"setNullableValue",
"(",
"$",
"content",
"[",
"'id'",
"]",
")",
",",
"'parentId'",
"=>",
"$",
"this",
"->",
"setNullableValue",
"(",
"$",
"content",
"[",
"'parent_id'",
"]",
")",
",",
"'type'",
"=>",
"$",
"content",
"[",
"'type'",
"]",
",",
"'theme'",
"=>",
"$",
"content",
"[",
"'theme'",
"]",
",",
"'weight'",
"=>",
"(",
"int",
")",
"$",
"content",
"[",
"'weight'",
"]",
",",
"'rating'",
"=>",
"(",
"int",
")",
"$",
"content",
"[",
"'rating'",
"]",
",",
"'visits'",
"=>",
"(",
"int",
")",
"$",
"content",
"[",
"'visits'",
"]",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"content",
"[",
"'is_active'",
"]",
",",
"'isOnHome'",
"=>",
"(",
"bool",
")",
"$",
"content",
"[",
"'is_on_home'",
"]",
",",
"'isCommentAllowed'",
"=>",
"(",
"bool",
")",
"$",
"content",
"[",
"'is_comment_allowed'",
"]",
",",
"'isPromoted'",
"=>",
"(",
"bool",
")",
"$",
"content",
"[",
"'is_promoted'",
"]",
",",
"'isSticky'",
"=>",
"(",
"bool",
")",
"$",
"content",
"[",
"'is_sticky'",
"]",
",",
"'path'",
"=>",
"$",
"this",
"->",
"buildPath",
"(",
"$",
"content",
"[",
"'path'",
"]",
")",
",",
"'publishedAt'",
"=>",
"$",
"content",
"[",
"'published_at'",
"]",
",",
"'createdAt'",
"=>",
"$",
"content",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"content",
"[",
"'updated_at'",
"]",
"]",
";",
"}"
] | Transforms content entity
@param Content|array $content Content entity
@return array | [
"Transforms",
"content",
"entity"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L46-L67 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.includeChildren | public function includeChildren(Content $content)
{
if ($content->isChildrenLoaded()) {
return $this->collection($content->children, new ContentTransformer()); // We don't want LAZY LOADING !
}
return null;
} | php | public function includeChildren(Content $content)
{
if ($content->isChildrenLoaded()) {
return $this->collection($content->children, new ContentTransformer()); // We don't want LAZY LOADING !
}
return null;
} | [
"public",
"function",
"includeChildren",
"(",
"Content",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"->",
"isChildrenLoaded",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"collection",
"(",
"$",
"content",
"->",
"children",
",",
"new",
"ContentTransformer",
"(",
")",
")",
";",
"// We don't want LAZY LOADING !",
"}",
"return",
"null",
";",
"}"
] | Include Children
@param Content $content Translation
@return \League\Fractal\ItemResource|null | [
"Include",
"Children"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L76-L82 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.includeTranslations | public function includeTranslations(Content $content)
{
$translations = $content->translations;
return $this->collection($translations, new ContentTranslationTransformer());
} | php | public function includeTranslations(Content $content)
{
$translations = $content->translations;
return $this->collection($translations, new ContentTranslationTransformer());
} | [
"public",
"function",
"includeTranslations",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"translations",
"=",
"$",
"content",
"->",
"translations",
";",
"return",
"$",
"this",
"->",
"collection",
"(",
"$",
"translations",
",",
"new",
"ContentTranslationTransformer",
"(",
")",
")",
";",
"}"
] | Include Translations
@param Content $content Translation
@return \League\Fractal\ItemResource | [
"Include",
"Translations"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L91-L95 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.includeRoute | public function includeRoute(Content $content)
{
$route = $content->route;
return (!empty($route)) ? $this->item($route, new RouteTransformer()) : null;
} | php | public function includeRoute(Content $content)
{
$route = $content->route;
return (!empty($route)) ? $this->item($route, new RouteTransformer()) : null;
} | [
"public",
"function",
"includeRoute",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"route",
"=",
"$",
"content",
"->",
"route",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"route",
")",
")",
"?",
"$",
"this",
"->",
"item",
"(",
"$",
"route",
",",
"new",
"RouteTransformer",
"(",
")",
")",
":",
"null",
";",
"}"
] | Include Route
@param Content $content Route
@return \League\Fractal\ItemResource | [
"Include",
"Route"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L104-L108 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.includeAuthor | public function includeAuthor(Content $content)
{
$author = $content->author;
return (!empty($author)) ? $this->item($author, new UserTransformer()) : null;
} | php | public function includeAuthor(Content $content)
{
$author = $content->author;
return (!empty($author)) ? $this->item($author, new UserTransformer()) : null;
} | [
"public",
"function",
"includeAuthor",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"author",
"=",
"$",
"content",
"->",
"author",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"author",
")",
")",
"?",
"$",
"this",
"->",
"item",
"(",
"$",
"author",
",",
"new",
"UserTransformer",
"(",
")",
")",
":",
"null",
";",
"}"
] | Include Author
@param Content $content User
@return \League\Fractal\ItemResource | [
"Include",
"Author"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L117-L121 |
GrupaZero/api | src/Gzero/Api/Transformer/ContentTransformer.php | ContentTransformer.includeThumb | public function includeThumb(Content $content)
{
$thumb = $content->thumb;
return (!empty($thumb)) ? $this->item($thumb, new FileTransformer()) : null;
} | php | public function includeThumb(Content $content)
{
$thumb = $content->thumb;
return (!empty($thumb)) ? $this->item($thumb, new FileTransformer()) : null;
} | [
"public",
"function",
"includeThumb",
"(",
"Content",
"$",
"content",
")",
"{",
"$",
"thumb",
"=",
"$",
"content",
"->",
"thumb",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"thumb",
")",
")",
"?",
"$",
"this",
"->",
"item",
"(",
"$",
"thumb",
",",
"new",
"FileTransformer",
"(",
")",
")",
":",
"null",
";",
"}"
] | Include Thumb
@param Content $content File
@return \League\Fractal\ItemResource | [
"Include",
"Thumb"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L130-L134 |
oroinc/OroLayoutComponent | Loader/Generator/AbstractLayoutUpdateGenerator.php | AbstractLayoutUpdateGenerator.generate | public function generate($className, GeneratorData $data, VisitorCollection $visitorCollection = null)
{
$this->visitorCollection = $visitorCollection ?: new VisitorCollection();
$this->prepare($data, $this->visitorCollection);
$this->validate($data);
$class = PhpClass::create($className);
$visitContext = new VisitContext($class);
if ($data->getFilename()) {
$writer = $visitContext->createWriter();
$writer
->writeln('/**')
->writeln(' * Filename: '.$data->getFilename())
->writeln(' */');
$class->setDocblock($writer->getContent());
}
$class->addInterfaceName('Oro\Component\Layout\LayoutUpdateInterface');
$method = PhpMethod::create(LayoutUpdateGeneratorInterface::UPDATE_METHOD_NAME);
$manipulatorParameter = PhpParameter::create(LayoutUpdateGeneratorInterface::PARAM_LAYOUT_MANIPULATOR);
$manipulatorParameter->setType('Oro\Component\Layout\LayoutManipulatorInterface');
$method->addParameter($manipulatorParameter);
$layoutItemParameter = PhpParameter::create(LayoutUpdateGeneratorInterface::PARAM_LAYOUT_ITEM);
$layoutItemParameter->setType('Oro\Component\Layout\LayoutItemInterface');
$method->addParameter($layoutItemParameter);
/** @var VisitorInterface $condition */
foreach ($this->visitorCollection as $condition) {
$condition->startVisit($visitContext);
}
$writer = $visitContext->getUpdateMethodWriter();
$writer->writeLn(trim($this->doGenerateBody($data)));
/** @var VisitorInterface $condition */
foreach ($this->visitorCollection as $condition) {
$condition->endVisit($visitContext);
}
$method->setBody($writer->getContent());
$class->setMethod($method);
$strategy = new DefaultGeneratorStrategy();
return "<?php\n\n".$strategy->generate($class);
} | php | public function generate($className, GeneratorData $data, VisitorCollection $visitorCollection = null)
{
$this->visitorCollection = $visitorCollection ?: new VisitorCollection();
$this->prepare($data, $this->visitorCollection);
$this->validate($data);
$class = PhpClass::create($className);
$visitContext = new VisitContext($class);
if ($data->getFilename()) {
$writer = $visitContext->createWriter();
$writer
->writeln('/**')
->writeln(' * Filename: '.$data->getFilename())
->writeln(' */');
$class->setDocblock($writer->getContent());
}
$class->addInterfaceName('Oro\Component\Layout\LayoutUpdateInterface');
$method = PhpMethod::create(LayoutUpdateGeneratorInterface::UPDATE_METHOD_NAME);
$manipulatorParameter = PhpParameter::create(LayoutUpdateGeneratorInterface::PARAM_LAYOUT_MANIPULATOR);
$manipulatorParameter->setType('Oro\Component\Layout\LayoutManipulatorInterface');
$method->addParameter($manipulatorParameter);
$layoutItemParameter = PhpParameter::create(LayoutUpdateGeneratorInterface::PARAM_LAYOUT_ITEM);
$layoutItemParameter->setType('Oro\Component\Layout\LayoutItemInterface');
$method->addParameter($layoutItemParameter);
/** @var VisitorInterface $condition */
foreach ($this->visitorCollection as $condition) {
$condition->startVisit($visitContext);
}
$writer = $visitContext->getUpdateMethodWriter();
$writer->writeLn(trim($this->doGenerateBody($data)));
/** @var VisitorInterface $condition */
foreach ($this->visitorCollection as $condition) {
$condition->endVisit($visitContext);
}
$method->setBody($writer->getContent());
$class->setMethod($method);
$strategy = new DefaultGeneratorStrategy();
return "<?php\n\n".$strategy->generate($class);
} | [
"public",
"function",
"generate",
"(",
"$",
"className",
",",
"GeneratorData",
"$",
"data",
",",
"VisitorCollection",
"$",
"visitorCollection",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"visitorCollection",
"=",
"$",
"visitorCollection",
"?",
":",
"new",
"VisitorCollection",
"(",
")",
";",
"$",
"this",
"->",
"prepare",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"visitorCollection",
")",
";",
"$",
"this",
"->",
"validate",
"(",
"$",
"data",
")",
";",
"$",
"class",
"=",
"PhpClass",
"::",
"create",
"(",
"$",
"className",
")",
";",
"$",
"visitContext",
"=",
"new",
"VisitContext",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"data",
"->",
"getFilename",
"(",
")",
")",
"{",
"$",
"writer",
"=",
"$",
"visitContext",
"->",
"createWriter",
"(",
")",
";",
"$",
"writer",
"->",
"writeln",
"(",
"'/**'",
")",
"->",
"writeln",
"(",
"' * Filename: '",
".",
"$",
"data",
"->",
"getFilename",
"(",
")",
")",
"->",
"writeln",
"(",
"' */'",
")",
";",
"$",
"class",
"->",
"setDocblock",
"(",
"$",
"writer",
"->",
"getContent",
"(",
")",
")",
";",
"}",
"$",
"class",
"->",
"addInterfaceName",
"(",
"'Oro\\Component\\Layout\\LayoutUpdateInterface'",
")",
";",
"$",
"method",
"=",
"PhpMethod",
"::",
"create",
"(",
"LayoutUpdateGeneratorInterface",
"::",
"UPDATE_METHOD_NAME",
")",
";",
"$",
"manipulatorParameter",
"=",
"PhpParameter",
"::",
"create",
"(",
"LayoutUpdateGeneratorInterface",
"::",
"PARAM_LAYOUT_MANIPULATOR",
")",
";",
"$",
"manipulatorParameter",
"->",
"setType",
"(",
"'Oro\\Component\\Layout\\LayoutManipulatorInterface'",
")",
";",
"$",
"method",
"->",
"addParameter",
"(",
"$",
"manipulatorParameter",
")",
";",
"$",
"layoutItemParameter",
"=",
"PhpParameter",
"::",
"create",
"(",
"LayoutUpdateGeneratorInterface",
"::",
"PARAM_LAYOUT_ITEM",
")",
";",
"$",
"layoutItemParameter",
"->",
"setType",
"(",
"'Oro\\Component\\Layout\\LayoutItemInterface'",
")",
";",
"$",
"method",
"->",
"addParameter",
"(",
"$",
"layoutItemParameter",
")",
";",
"/** @var VisitorInterface $condition */",
"foreach",
"(",
"$",
"this",
"->",
"visitorCollection",
"as",
"$",
"condition",
")",
"{",
"$",
"condition",
"->",
"startVisit",
"(",
"$",
"visitContext",
")",
";",
"}",
"$",
"writer",
"=",
"$",
"visitContext",
"->",
"getUpdateMethodWriter",
"(",
")",
";",
"$",
"writer",
"->",
"writeLn",
"(",
"trim",
"(",
"$",
"this",
"->",
"doGenerateBody",
"(",
"$",
"data",
")",
")",
")",
";",
"/** @var VisitorInterface $condition */",
"foreach",
"(",
"$",
"this",
"->",
"visitorCollection",
"as",
"$",
"condition",
")",
"{",
"$",
"condition",
"->",
"endVisit",
"(",
"$",
"visitContext",
")",
";",
"}",
"$",
"method",
"->",
"setBody",
"(",
"$",
"writer",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"class",
"->",
"setMethod",
"(",
"$",
"method",
")",
";",
"$",
"strategy",
"=",
"new",
"DefaultGeneratorStrategy",
"(",
")",
";",
"return",
"\"<?php\\n\\n\"",
".",
"$",
"strategy",
"->",
"generate",
"(",
"$",
"class",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Generator/AbstractLayoutUpdateGenerator.php#L20-L71 |
jadb/php-groovehq | src/Client.php | Client.init | protected function init(
GuzzleHttpClient $httpClient,
GuzzleHttpDescription $httpDescription,
array $options = []
) {
return new GuzzleClient($httpClient, $httpDescription, $options);
} | php | protected function init(
GuzzleHttpClient $httpClient,
GuzzleHttpDescription $httpDescription,
array $options = []
) {
return new GuzzleClient($httpClient, $httpDescription, $options);
} | [
"protected",
"function",
"init",
"(",
"GuzzleHttpClient",
"$",
"httpClient",
",",
"GuzzleHttpDescription",
"$",
"httpDescription",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"new",
"GuzzleClient",
"(",
"$",
"httpClient",
",",
"$",
"httpDescription",
",",
"$",
"options",
")",
";",
"}"
] | /* For testing purposes | [
"/",
"*",
"For",
"testing",
"purposes"
] | train | https://github.com/jadb/php-groovehq/blob/d0eb5d0baaf6f8e3dd4d3e9e160cd7e3794a0d38/src/Client.php#L57-L63 |
fapi-cz/http-client | src/Fapi/HttpClient/Utils/Json.php | Json.encode | public static function encode($value, $options = 0): string
{
$flags = \PHP_VERSION_ID >= 50400
? (\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | ($options & self::PRETTY
? \JSON_PRETTY_PRINT
: 0))
: 0;
if (\PHP_VERSION_ID < 50500) {
$json = Callback::invokeSafe('json_encode', [$value, $flags], static function ($message) { // needed to receive 'recursion detected' error
throw new JsonException($message);
});
} else {
$json = \json_encode($value, $flags);
}
$error = \json_last_error();
if ($error) {
$message = static::$messages[$error] ?? (\PHP_VERSION_ID >= 50500 ? \json_last_error_msg() : 'Unknown error');
throw new JsonException($message, $error);
}
$json = \str_replace(["\xe2\x80\xa8", "\xe2\x80\xa9"], ['\u2028', '\u2029'], $json);
return $json;
} | php | public static function encode($value, $options = 0): string
{
$flags = \PHP_VERSION_ID >= 50400
? (\JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES | ($options & self::PRETTY
? \JSON_PRETTY_PRINT
: 0))
: 0;
if (\PHP_VERSION_ID < 50500) {
$json = Callback::invokeSafe('json_encode', [$value, $flags], static function ($message) { // needed to receive 'recursion detected' error
throw new JsonException($message);
});
} else {
$json = \json_encode($value, $flags);
}
$error = \json_last_error();
if ($error) {
$message = static::$messages[$error] ?? (\PHP_VERSION_ID >= 50500 ? \json_last_error_msg() : 'Unknown error');
throw new JsonException($message, $error);
}
$json = \str_replace(["\xe2\x80\xa8", "\xe2\x80\xa9"], ['\u2028', '\u2029'], $json);
return $json;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"value",
",",
"$",
"options",
"=",
"0",
")",
":",
"string",
"{",
"$",
"flags",
"=",
"\\",
"PHP_VERSION_ID",
">=",
"50400",
"?",
"(",
"\\",
"JSON_UNESCAPED_UNICODE",
"|",
"\\",
"JSON_UNESCAPED_SLASHES",
"|",
"(",
"$",
"options",
"&",
"self",
"::",
"PRETTY",
"?",
"\\",
"JSON_PRETTY_PRINT",
":",
"0",
")",
")",
":",
"0",
";",
"if",
"(",
"\\",
"PHP_VERSION_ID",
"<",
"50500",
")",
"{",
"$",
"json",
"=",
"Callback",
"::",
"invokeSafe",
"(",
"'json_encode'",
",",
"[",
"$",
"value",
",",
"$",
"flags",
"]",
",",
"static",
"function",
"(",
"$",
"message",
")",
"{",
"// needed to receive 'recursion detected' error",
"throw",
"new",
"JsonException",
"(",
"$",
"message",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"json",
"=",
"\\",
"json_encode",
"(",
"$",
"value",
",",
"$",
"flags",
")",
";",
"}",
"$",
"error",
"=",
"\\",
"json_last_error",
"(",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"$",
"message",
"=",
"static",
"::",
"$",
"messages",
"[",
"$",
"error",
"]",
"??",
"(",
"\\",
"PHP_VERSION_ID",
">=",
"50500",
"?",
"\\",
"json_last_error_msg",
"(",
")",
":",
"'Unknown error'",
")",
";",
"throw",
"new",
"JsonException",
"(",
"$",
"message",
",",
"$",
"error",
")",
";",
"}",
"$",
"json",
"=",
"\\",
"str_replace",
"(",
"[",
"\"\\xe2\\x80\\xa8\"",
",",
"\"\\xe2\\x80\\xa9\"",
"]",
",",
"[",
"'\\u2028'",
",",
"'\\u2029'",
"]",
",",
"$",
"json",
")",
";",
"return",
"$",
"json",
";",
"}"
] | Returns the JSON representation of a value.
@param mixed $value
@param int $options
@return string
@throws JsonException
@throws \Throwable | [
"Returns",
"the",
"JSON",
"representation",
"of",
"a",
"value",
"."
] | train | https://github.com/fapi-cz/http-client/blob/5aeed581c5c115fb4d2f72b46e2ce27f91a1c999/src/Fapi/HttpClient/Utils/Json.php#L37-L65 |
fapi-cz/http-client | src/Fapi/HttpClient/Utils/Json.php | Json.decode | public static function decode(string $json, int $options = 0)
{
if (!\preg_match('##u', $json)) {
throw new JsonException('Invalid UTF-8 sequence', 5); // workaround for PHP < 5.3.3 & PECL JSON-C
}
$forceArray = (bool) ($options & self::FORCE_ARRAY);
if (!$forceArray && \preg_match('#(?<=[^\\\\]")\\\\u0000(?:[^"\\\\]|\\\\.)*+"\s*+:#', $json)) { // workaround for json_decode fatal error when object key starts with \u0000
throw new JsonException(static::$messages[\JSON_ERROR_CTRL_CHAR]);
}
$args = [$json, $forceArray, 512];
if (\PHP_VERSION_ID >= 50400 && !(\defined('JSON_C_VERSION') && \PHP_INT_SIZE > 4)) { // not implemented in PECL JSON-C 1.3.2 for 64bit systems
$args[] = \JSON_BIGINT_AS_STRING;
}
$value = \json_decode(...$args);
if ($value === null && $json !== '' && \strcasecmp($json, 'null')) { // '' is not clearing json_last_error
$error = \json_last_error();
throw new JsonException(static::$messages[$error] ?? 'Unknown error', $error);
}
return $value;
} | php | public static function decode(string $json, int $options = 0)
{
if (!\preg_match('##u', $json)) {
throw new JsonException('Invalid UTF-8 sequence', 5); // workaround for PHP < 5.3.3 & PECL JSON-C
}
$forceArray = (bool) ($options & self::FORCE_ARRAY);
if (!$forceArray && \preg_match('#(?<=[^\\\\]")\\\\u0000(?:[^"\\\\]|\\\\.)*+"\s*+:#', $json)) { // workaround for json_decode fatal error when object key starts with \u0000
throw new JsonException(static::$messages[\JSON_ERROR_CTRL_CHAR]);
}
$args = [$json, $forceArray, 512];
if (\PHP_VERSION_ID >= 50400 && !(\defined('JSON_C_VERSION') && \PHP_INT_SIZE > 4)) { // not implemented in PECL JSON-C 1.3.2 for 64bit systems
$args[] = \JSON_BIGINT_AS_STRING;
}
$value = \json_decode(...$args);
if ($value === null && $json !== '' && \strcasecmp($json, 'null')) { // '' is not clearing json_last_error
$error = \json_last_error();
throw new JsonException(static::$messages[$error] ?? 'Unknown error', $error);
}
return $value;
} | [
"public",
"static",
"function",
"decode",
"(",
"string",
"$",
"json",
",",
"int",
"$",
"options",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"\\",
"preg_match",
"(",
"'##u'",
",",
"$",
"json",
")",
")",
"{",
"throw",
"new",
"JsonException",
"(",
"'Invalid UTF-8 sequence'",
",",
"5",
")",
";",
"// workaround for PHP < 5.3.3 & PECL JSON-C",
"}",
"$",
"forceArray",
"=",
"(",
"bool",
")",
"(",
"$",
"options",
"&",
"self",
"::",
"FORCE_ARRAY",
")",
";",
"if",
"(",
"!",
"$",
"forceArray",
"&&",
"\\",
"preg_match",
"(",
"'#(?<=[^\\\\\\\\]\")\\\\\\\\u0000(?:[^\"\\\\\\\\]|\\\\\\\\.)*+\"\\s*+:#'",
",",
"$",
"json",
")",
")",
"{",
"// workaround for json_decode fatal error when object key starts with \\u0000",
"throw",
"new",
"JsonException",
"(",
"static",
"::",
"$",
"messages",
"[",
"\\",
"JSON_ERROR_CTRL_CHAR",
"]",
")",
";",
"}",
"$",
"args",
"=",
"[",
"$",
"json",
",",
"$",
"forceArray",
",",
"512",
"]",
";",
"if",
"(",
"\\",
"PHP_VERSION_ID",
">=",
"50400",
"&&",
"!",
"(",
"\\",
"defined",
"(",
"'JSON_C_VERSION'",
")",
"&&",
"\\",
"PHP_INT_SIZE",
">",
"4",
")",
")",
"{",
"// not implemented in PECL JSON-C 1.3.2 for 64bit systems",
"$",
"args",
"[",
"]",
"=",
"\\",
"JSON_BIGINT_AS_STRING",
";",
"}",
"$",
"value",
"=",
"\\",
"json_decode",
"(",
"...",
"$",
"args",
")",
";",
"if",
"(",
"$",
"value",
"===",
"null",
"&&",
"$",
"json",
"!==",
"''",
"&&",
"\\",
"strcasecmp",
"(",
"$",
"json",
",",
"'null'",
")",
")",
"{",
"// '' is not clearing json_last_error",
"$",
"error",
"=",
"\\",
"json_last_error",
"(",
")",
";",
"throw",
"new",
"JsonException",
"(",
"static",
"::",
"$",
"messages",
"[",
"$",
"error",
"]",
"??",
"'Unknown error'",
",",
"$",
"error",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Decodes a JSON string.
@param string $json
@param int $options
@return mixed
@throws JsonException | [
"Decodes",
"a",
"JSON",
"string",
"."
] | train | https://github.com/fapi-cz/http-client/blob/5aeed581c5c115fb4d2f72b46e2ce27f91a1c999/src/Fapi/HttpClient/Utils/Json.php#L75-L103 |
nonzod/yii2-foundation | ButtonGroup.php | ButtonGroup.renderButtons | protected function renderButtons() {
$buttons = [];
foreach ($this->buttons as $button) {
if (is_array($button)) {
$label = ArrayHelper::getValue($button, 'label');
$url = ArrayHelper::getValue($button, 'url');
$options = ArrayHelper::getValue($button, 'options');
$button = Button::widget([
'label' => $label,
'url' => $url,
'options' => $options,
'encodeLabel' => $this->encodeLabels
]);
$buttons[] = Html::tag('li', $button);
} else {
$buttons[] = Html::tag('li', $button);
}
}
return implode("\n", $buttons);
} | php | protected function renderButtons() {
$buttons = [];
foreach ($this->buttons as $button) {
if (is_array($button)) {
$label = ArrayHelper::getValue($button, 'label');
$url = ArrayHelper::getValue($button, 'url');
$options = ArrayHelper::getValue($button, 'options');
$button = Button::widget([
'label' => $label,
'url' => $url,
'options' => $options,
'encodeLabel' => $this->encodeLabels
]);
$buttons[] = Html::tag('li', $button);
} else {
$buttons[] = Html::tag('li', $button);
}
}
return implode("\n", $buttons);
} | [
"protected",
"function",
"renderButtons",
"(",
")",
"{",
"$",
"buttons",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"buttons",
"as",
"$",
"button",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"button",
")",
")",
"{",
"$",
"label",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"button",
",",
"'label'",
")",
";",
"$",
"url",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"button",
",",
"'url'",
")",
";",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"button",
",",
"'options'",
")",
";",
"$",
"button",
"=",
"Button",
"::",
"widget",
"(",
"[",
"'label'",
"=>",
"$",
"label",
",",
"'url'",
"=>",
"$",
"url",
",",
"'options'",
"=>",
"$",
"options",
",",
"'encodeLabel'",
"=>",
"$",
"this",
"->",
"encodeLabels",
"]",
")",
";",
"$",
"buttons",
"[",
"]",
"=",
"Html",
"::",
"tag",
"(",
"'li'",
",",
"$",
"button",
")",
";",
"}",
"else",
"{",
"$",
"buttons",
"[",
"]",
"=",
"Html",
"::",
"tag",
"(",
"'li'",
",",
"$",
"button",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"buttons",
")",
";",
"}"
] | Generates the buttons that compound the group as specified on [[buttons]].
@return string the rendering result. | [
"Generates",
"the",
"buttons",
"that",
"compound",
"the",
"group",
"as",
"specified",
"on",
"[[",
"buttons",
"]]",
"."
] | train | https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/ButtonGroup.php#L57-L77 |
GrupaZero/api | src/Gzero/Api/Transformer/FileTransformer.php | FileTransformer.transform | public function transform($file)
{
$thumb = null;
if ($file->type === 'image') {
$width = config('gzero.image.thumb.width');
$height = config('gzero.image.thumb.height');
$thumb = croppaUrl($file->getFullPath(), $width, $height);
}
$file = $this->entityToArray(File::class, $file);
return [
'id' => (int) $file['id'],
'type' => $file['type'],
'name' => $file['name'],
'extension' => $file['extension'],
'size' => (int) $file['size'],
'mimeType' => $file['mime_type'],
'info' => $file['info'],
'thumb' => $thumb,
'weight' => $this->setPivotNullableValue($file, 'weight'),
'isActive' => (bool) $file['is_active'],
'createdBy' => (int) $file['created_by'],
'createdAt' => $file['created_at'],
'updatedAt' => $file['updated_at']
];
} | php | public function transform($file)
{
$thumb = null;
if ($file->type === 'image') {
$width = config('gzero.image.thumb.width');
$height = config('gzero.image.thumb.height');
$thumb = croppaUrl($file->getFullPath(), $width, $height);
}
$file = $this->entityToArray(File::class, $file);
return [
'id' => (int) $file['id'],
'type' => $file['type'],
'name' => $file['name'],
'extension' => $file['extension'],
'size' => (int) $file['size'],
'mimeType' => $file['mime_type'],
'info' => $file['info'],
'thumb' => $thumb,
'weight' => $this->setPivotNullableValue($file, 'weight'),
'isActive' => (bool) $file['is_active'],
'createdBy' => (int) $file['created_by'],
'createdAt' => $file['created_at'],
'updatedAt' => $file['updated_at']
];
} | [
"public",
"function",
"transform",
"(",
"$",
"file",
")",
"{",
"$",
"thumb",
"=",
"null",
";",
"if",
"(",
"$",
"file",
"->",
"type",
"===",
"'image'",
")",
"{",
"$",
"width",
"=",
"config",
"(",
"'gzero.image.thumb.width'",
")",
";",
"$",
"height",
"=",
"config",
"(",
"'gzero.image.thumb.height'",
")",
";",
"$",
"thumb",
"=",
"croppaUrl",
"(",
"$",
"file",
"->",
"getFullPath",
"(",
")",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"}",
"$",
"file",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"File",
"::",
"class",
",",
"$",
"file",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"file",
"[",
"'id'",
"]",
",",
"'type'",
"=>",
"$",
"file",
"[",
"'type'",
"]",
",",
"'name'",
"=>",
"$",
"file",
"[",
"'name'",
"]",
",",
"'extension'",
"=>",
"$",
"file",
"[",
"'extension'",
"]",
",",
"'size'",
"=>",
"(",
"int",
")",
"$",
"file",
"[",
"'size'",
"]",
",",
"'mimeType'",
"=>",
"$",
"file",
"[",
"'mime_type'",
"]",
",",
"'info'",
"=>",
"$",
"file",
"[",
"'info'",
"]",
",",
"'thumb'",
"=>",
"$",
"thumb",
",",
"'weight'",
"=>",
"$",
"this",
"->",
"setPivotNullableValue",
"(",
"$",
"file",
",",
"'weight'",
")",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"file",
"[",
"'is_active'",
"]",
",",
"'createdBy'",
"=>",
"(",
"int",
")",
"$",
"file",
"[",
"'created_by'",
"]",
",",
"'createdAt'",
"=>",
"$",
"file",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"file",
"[",
"'updated_at'",
"]",
"]",
";",
"}"
] | Transforms file entity
@param File|array $file file entity
@return array | [
"Transforms",
"file",
"entity"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/FileTransformer.php#L35-L61 |
GrupaZero/api | src/Gzero/Api/Transformer/FileTransformer.php | FileTransformer.setPivotNullableValue | private function setPivotNullableValue($file, $key)
{
if (array_key_exists('pivot', $file)) {
return $this->setNullableValue($file['pivot'][$key]);
}
return null;
} | php | private function setPivotNullableValue($file, $key)
{
if (array_key_exists('pivot', $file)) {
return $this->setNullableValue($file['pivot'][$key]);
}
return null;
} | [
"private",
"function",
"setPivotNullableValue",
"(",
"$",
"file",
",",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'pivot'",
",",
"$",
"file",
")",
")",
"{",
"return",
"$",
"this",
"->",
"setNullableValue",
"(",
"$",
"file",
"[",
"'pivot'",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns pivot integer value or null
@param array $file file to check for pivot
@param string $key to evaluate
@return int|null | [
"Returns",
"pivot",
"integer",
"value",
"or",
"null"
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/FileTransformer.php#L96-L103 |
Visithor/visithor | src/Visithor/Executor/Executor.php | Executor.execute | public function execute(
UrlChain $urlChain,
RendererInterface $renderer,
OutputInterface $output
) {
$result = 0;
foreach ($urlChain->getUrls() as $url) {
$result = $result | $this->executeUrl(
$this->client,
$url,
$renderer,
$output
);
}
return $result;
} | php | public function execute(
UrlChain $urlChain,
RendererInterface $renderer,
OutputInterface $output
) {
$result = 0;
foreach ($urlChain->getUrls() as $url) {
$result = $result | $this->executeUrl(
$this->client,
$url,
$renderer,
$output
);
}
return $result;
} | [
"public",
"function",
"execute",
"(",
"UrlChain",
"$",
"urlChain",
",",
"RendererInterface",
"$",
"renderer",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"result",
"=",
"0",
";",
"foreach",
"(",
"$",
"urlChain",
"->",
"getUrls",
"(",
")",
"as",
"$",
"url",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"|",
"$",
"this",
"->",
"executeUrl",
"(",
"$",
"this",
"->",
"client",
",",
"$",
"url",
",",
"$",
"renderer",
",",
"$",
"output",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Renders the output of the result of executing some urls given a client
instance
If all urls are executed as expected, then the result of the operation
will be 0. Otherwise, the result will be 1.
@param UrlChain $urlChain Url chain
@param RendererInterface $renderer Renderer
@param OutputInterface $output Output
@return int Result of the execution | [
"Renders",
"the",
"output",
"of",
"the",
"result",
"of",
"executing",
"some",
"urls",
"given",
"a",
"client",
"instance"
] | train | https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Executor/Executor.php#L71-L88 |
Visithor/visithor | src/Visithor/Executor/Executor.php | Executor.executeUrl | protected function executeUrl(
ClientInterface $client,
Url $url,
RendererInterface $renderer,
OutputInterface $output
) {
$resultHTTPCode = $client->getResponseHTTPCode($url);
$resultExecution = in_array(
$resultHTTPCode,
$url->getAcceptableHttpCodes()
)
? 0
: 1;
$renderer->render(
$output,
$url,
$resultHTTPCode,
(0 === $resultExecution)
);
return $resultExecution;
} | php | protected function executeUrl(
ClientInterface $client,
Url $url,
RendererInterface $renderer,
OutputInterface $output
) {
$resultHTTPCode = $client->getResponseHTTPCode($url);
$resultExecution = in_array(
$resultHTTPCode,
$url->getAcceptableHttpCodes()
)
? 0
: 1;
$renderer->render(
$output,
$url,
$resultHTTPCode,
(0 === $resultExecution)
);
return $resultExecution;
} | [
"protected",
"function",
"executeUrl",
"(",
"ClientInterface",
"$",
"client",
",",
"Url",
"$",
"url",
",",
"RendererInterface",
"$",
"renderer",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"resultHTTPCode",
"=",
"$",
"client",
"->",
"getResponseHTTPCode",
"(",
"$",
"url",
")",
";",
"$",
"resultExecution",
"=",
"in_array",
"(",
"$",
"resultHTTPCode",
",",
"$",
"url",
"->",
"getAcceptableHttpCodes",
"(",
")",
")",
"?",
"0",
":",
"1",
";",
"$",
"renderer",
"->",
"render",
"(",
"$",
"output",
",",
"$",
"url",
",",
"$",
"resultHTTPCode",
",",
"(",
"0",
"===",
"$",
"resultExecution",
")",
")",
";",
"return",
"$",
"resultExecution",
";",
"}"
] | Executes an URL and render the result given a renderer.
If the url is executed as expected, then the result of the operation will
be 0. Otherwise, the result will be 1.
@param ClientInterface $client Client
@param Url $url Url
@param RendererInterface $renderer Renderer
@param OutputInterface $output Output
@return boolean Result of the execution | [
"Executes",
"an",
"URL",
"and",
"render",
"the",
"result",
"given",
"a",
"renderer",
"."
] | train | https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Executor/Executor.php#L115-L137 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.createStream | public function createStream($serverconfig = null)
{
if ($serverconfig == null) {
$serverconfig = $this->default_streamserver_config;
}
$stream = new $this->stream_class;
$stream->setRtmpServer($this->streamserver_config[$serverconfig]['rtmp_url']);
$stream->setRtmpApp($this->streamserver_config[$serverconfig]['app']);
return $stream;
} | php | public function createStream($serverconfig = null)
{
if ($serverconfig == null) {
$serverconfig = $this->default_streamserver_config;
}
$stream = new $this->stream_class;
$stream->setRtmpServer($this->streamserver_config[$serverconfig]['rtmp_url']);
$stream->setRtmpApp($this->streamserver_config[$serverconfig]['app']);
return $stream;
} | [
"public",
"function",
"createStream",
"(",
"$",
"serverconfig",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"serverconfig",
"==",
"null",
")",
"{",
"$",
"serverconfig",
"=",
"$",
"this",
"->",
"default_streamserver_config",
";",
"}",
"$",
"stream",
"=",
"new",
"$",
"this",
"->",
"stream_class",
";",
"$",
"stream",
"->",
"setRtmpServer",
"(",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"serverconfig",
"]",
"[",
"'rtmp_url'",
"]",
")",
";",
"$",
"stream",
"->",
"setRtmpApp",
"(",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"serverconfig",
"]",
"[",
"'app'",
"]",
")",
";",
"return",
"$",
"stream",
";",
"}"
] | returns a new stream object preset with default streamserver config | [
"returns",
"a",
"new",
"stream",
"object",
"preset",
"with",
"default",
"streamserver",
"config"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L36-L45 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.startRecording | public function startRecording($stream)
{
$parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
$rtmp_app = end($parts);
$success = $this->record(
$this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
$rtmp_app,
$stream->getUniqID()
);
if ($success) {
$stream->setTechnicalStatus(Stream::STATE_RECORDING);
$this->em->persist($stream);
$this->em->flush();
$event = new StartRecordingStreamEvent($stream);
$this->dispatcher->dispatch(
OktolabMediaEvent::STREAM_START_RECORDING,
$event
);
return true;
}
return false;
} | php | public function startRecording($stream)
{
$parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
$rtmp_app = end($parts);
$success = $this->record(
$this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
$rtmp_app,
$stream->getUniqID()
);
if ($success) {
$stream->setTechnicalStatus(Stream::STATE_RECORDING);
$this->em->persist($stream);
$this->em->flush();
$event = new StartRecordingStreamEvent($stream);
$this->dispatcher->dispatch(
OktolabMediaEvent::STREAM_START_RECORDING,
$event
);
return true;
}
return false;
} | [
"public",
"function",
"startRecording",
"(",
"$",
"stream",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"stream",
"->",
"getRtmpServer",
"(",
")",
"]",
"[",
"'rtmp_url'",
"]",
")",
";",
"$",
"rtmp_app",
"=",
"end",
"(",
"$",
"parts",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"record",
"(",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"stream",
"->",
"getRtmpServer",
"(",
")",
"]",
"[",
"'rtmp_control'",
"]",
",",
"$",
"rtmp_app",
",",
"$",
"stream",
"->",
"getUniqID",
"(",
")",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"stream",
"->",
"setTechnicalStatus",
"(",
"Stream",
"::",
"STATE_RECORDING",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"stream",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"event",
"=",
"new",
"StartRecordingStreamEvent",
"(",
"$",
"stream",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"OktolabMediaEvent",
"::",
"STREAM_START_RECORDING",
",",
"$",
"event",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | start recording a stream. | [
"start",
"recording",
"a",
"stream",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L78-L100 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.endRecording | public function endRecording($stream)
{
$parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
$rtmp_app = end($parts);
$success = $this->record(
$this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
$rtmp_app,
$stream->getUniqID(),
false
);
if ($success) {
$stream->setTechnicalStatus(Stream::STATE_ENDED);
$this->em->persist($stream);
$this->em->flush();
// $event = new EndRecordingStreamEvent($stream);
// $this->dispatcher->dispatch(
// OktolabMediaEvent::STREAM_END_RECORDING,
// $event
// );
return true;
}
return false;
} | php | public function endRecording($stream)
{
$parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']);
$rtmp_app = end($parts);
$success = $this->record(
$this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'],
$rtmp_app,
$stream->getUniqID(),
false
);
if ($success) {
$stream->setTechnicalStatus(Stream::STATE_ENDED);
$this->em->persist($stream);
$this->em->flush();
// $event = new EndRecordingStreamEvent($stream);
// $this->dispatcher->dispatch(
// OktolabMediaEvent::STREAM_END_RECORDING,
// $event
// );
return true;
}
return false;
} | [
"public",
"function",
"endRecording",
"(",
"$",
"stream",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"stream",
"->",
"getRtmpServer",
"(",
")",
"]",
"[",
"'rtmp_url'",
"]",
")",
";",
"$",
"rtmp_app",
"=",
"end",
"(",
"$",
"parts",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"record",
"(",
"$",
"this",
"->",
"streamserver_config",
"[",
"$",
"stream",
"->",
"getRtmpServer",
"(",
")",
"]",
"[",
"'rtmp_control'",
"]",
",",
"$",
"rtmp_app",
",",
"$",
"stream",
"->",
"getUniqID",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"stream",
"->",
"setTechnicalStatus",
"(",
"Stream",
"::",
"STATE_ENDED",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"stream",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"// $event = new EndRecordingStreamEvent($stream);",
"// $this->dispatcher->dispatch(",
"// OktolabMediaEvent::STREAM_END_RECORDING,",
"// $event",
"// );",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | end recording a stream | [
"end",
"recording",
"a",
"stream"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L105-L128 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.addPublishToAdress | public function addPublishToAdress($stream, $rtmp_adress, $clientid, $new_name, $type = 'publisher', $srv = null)
{
return $this->redirect(
$stream->getRtmpApp(),
$stream->getUniqID(),
$rtmp_adress,
$clientid,
$new_name,
$type,
$srv
);
} | php | public function addPublishToAdress($stream, $rtmp_adress, $clientid, $new_name, $type = 'publisher', $srv = null)
{
return $this->redirect(
$stream->getRtmpApp(),
$stream->getUniqID(),
$rtmp_adress,
$clientid,
$new_name,
$type,
$srv
);
} | [
"public",
"function",
"addPublishToAdress",
"(",
"$",
"stream",
",",
"$",
"rtmp_adress",
",",
"$",
"clientid",
",",
"$",
"new_name",
",",
"$",
"type",
"=",
"'publisher'",
",",
"$",
"srv",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"stream",
"->",
"getRtmpApp",
"(",
")",
",",
"$",
"stream",
"->",
"getUniqID",
"(",
")",
",",
"$",
"rtmp_adress",
",",
"$",
"clientid",
",",
"$",
"new_name",
",",
"$",
"type",
",",
"$",
"srv",
")",
";",
"}"
] | adds a push to another rtmp server. can be used to send a stream to facebook, youtube, etc.
@var stream the stream you want to push
@var rtmp_adress the adress you want to push to
@var cientid the streamkey of the destination
@var new_name the app of the rtmp server you want to push to
@var srv optional nginx server to use | [
"adds",
"a",
"push",
"to",
"another",
"rtmp",
"server",
".",
"can",
"be",
"used",
"to",
"send",
"a",
"stream",
"to",
"facebook",
"youtube",
"etc",
"."
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L154-L165 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.record | public function record($control_url, $app, $name, $start = true, $srv = null, $rec = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
if ($srv) {
$query['srv'] = $srv;
}
if ($rec) {
$query['rec'] = $rec;
}
$url = null;
$client = new Client();
try {
$response = $client->request(
'GET',
$start ? $control_url .'/record/start' : $control_url .'/record/stop',
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | php | public function record($control_url, $app, $name, $start = true, $srv = null, $rec = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
if ($srv) {
$query['srv'] = $srv;
}
if ($rec) {
$query['rec'] = $rec;
}
$url = null;
$client = new Client();
try {
$response = $client->request(
'GET',
$start ? $control_url .'/record/start' : $control_url .'/record/stop',
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"record",
"(",
"$",
"control_url",
",",
"$",
"app",
",",
"$",
"name",
",",
"$",
"start",
"=",
"true",
",",
"$",
"srv",
"=",
"null",
",",
"$",
"rec",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"[",
"]",
";",
"$",
"query",
"[",
"'app'",
"]",
"=",
"$",
"app",
";",
"$",
"query",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"srv",
")",
"{",
"$",
"query",
"[",
"'srv'",
"]",
"=",
"$",
"srv",
";",
"}",
"if",
"(",
"$",
"rec",
")",
"{",
"$",
"query",
"[",
"'rec'",
"]",
"=",
"$",
"rec",
";",
"}",
"$",
"url",
"=",
"null",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"start",
"?",
"$",
"control_url",
".",
"'/record/start'",
":",
"$",
"control_url",
".",
"'/record/stop'",
",",
"[",
"'query'",
"=>",
"$",
"query",
"]",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | sends request to start/stop recording of a stream
@var app required rtmp application name (see rtmp server config)
@var name required rtmp stream name (see Entity Stream uniqID)
@var start true if you want to start recording, false if you want to stop it
@var srv optional server{} blocknumber in nginx rtmp config, uses first one by default
@var rec optional recorder name to use in nginx rtmp config. defaults to root (unnamed) recorder
@return true if command was accepted, false if something went wrong | [
"sends",
"request",
"to",
"start",
"/",
"stop",
"recording",
"of",
"a",
"stream"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L188-L217 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.drop | public function drop($control_url, $app, $name, $type = 'publisher', $addr = null, $clientid = null, $srv = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
if ($addr) {
$query['addr'] = $addr;
}
if ($clientid) {
$query['clientid'] = $clientid;
}
if ($srv) {
$query['srv'] = $srv;
}
$client = new Client();
try {
$response = $client->request(
'GET',
$url .'/control/drop/'.$type,
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | php | public function drop($control_url, $app, $name, $type = 'publisher', $addr = null, $clientid = null, $srv = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
if ($addr) {
$query['addr'] = $addr;
}
if ($clientid) {
$query['clientid'] = $clientid;
}
if ($srv) {
$query['srv'] = $srv;
}
$client = new Client();
try {
$response = $client->request(
'GET',
$url .'/control/drop/'.$type,
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"drop",
"(",
"$",
"control_url",
",",
"$",
"app",
",",
"$",
"name",
",",
"$",
"type",
"=",
"'publisher'",
",",
"$",
"addr",
"=",
"null",
",",
"$",
"clientid",
"=",
"null",
",",
"$",
"srv",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"[",
"]",
";",
"$",
"query",
"[",
"'app'",
"]",
"=",
"$",
"app",
";",
"$",
"query",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"addr",
")",
"{",
"$",
"query",
"[",
"'addr'",
"]",
"=",
"$",
"addr",
";",
"}",
"if",
"(",
"$",
"clientid",
")",
"{",
"$",
"query",
"[",
"'clientid'",
"]",
"=",
"$",
"clientid",
";",
"}",
"if",
"(",
"$",
"srv",
")",
"{",
"$",
"query",
"[",
"'srv'",
"]",
"=",
"$",
"srv",
";",
"}",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
".",
"'/control/drop/'",
".",
"$",
"type",
",",
"[",
"'query'",
"=>",
"$",
"query",
"]",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | send a drop command to the rtmp server
@var app the app name
@var name the streamkey
@var type the type for your drop command publisher|subscriber|client
@var addr the optional client adress
@var clientId the optional nginx client id
@var srv optional server{} block number within rtmp{} block. default the first is used (nginx rtmp) | [
"send",
"a",
"drop",
"command",
"to",
"the",
"rtmp",
"server"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L228-L261 |
OKTOTV/OktolabMediaBundle | Model/StreamService.php | StreamService.redirect | public function redirect($control_url, $app, $name, $new_adress, $new_clientid, $new_name, $type = 'publisher', $srv = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
$query['addr'] = $new_adress;
$query['clientid'] = $new_clientid;
$query['newname'] = $new_name;
if ($srv) {
$query['srv'] = $srv;
}
$client = new Client();
try {
$response = $client->request(
'GET',
$url .'/control/redirect/'.$type,
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | php | public function redirect($control_url, $app, $name, $new_adress, $new_clientid, $new_name, $type = 'publisher', $srv = null)
{
$query = [];
$query['app'] = $app;
$query['name'] = $name;
$query['addr'] = $new_adress;
$query['clientid'] = $new_clientid;
$query['newname'] = $new_name;
if ($srv) {
$query['srv'] = $srv;
}
$client = new Client();
try {
$response = $client->request(
'GET',
$url .'/control/redirect/'.$type,
[
'query' => $query
]
);
} catch (RequestException $e) {
return false;
}
catch (Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"redirect",
"(",
"$",
"control_url",
",",
"$",
"app",
",",
"$",
"name",
",",
"$",
"new_adress",
",",
"$",
"new_clientid",
",",
"$",
"new_name",
",",
"$",
"type",
"=",
"'publisher'",
",",
"$",
"srv",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"[",
"]",
";",
"$",
"query",
"[",
"'app'",
"]",
"=",
"$",
"app",
";",
"$",
"query",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"query",
"[",
"'addr'",
"]",
"=",
"$",
"new_adress",
";",
"$",
"query",
"[",
"'clientid'",
"]",
"=",
"$",
"new_clientid",
";",
"$",
"query",
"[",
"'newname'",
"]",
"=",
"$",
"new_name",
";",
"if",
"(",
"$",
"srv",
")",
"{",
"$",
"query",
"[",
"'srv'",
"]",
"=",
"$",
"srv",
";",
"}",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
".",
"'/control/redirect/'",
".",
"$",
"type",
",",
"[",
"'query'",
"=>",
"$",
"query",
"]",
")",
";",
"}",
"catch",
"(",
"RequestException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | sends a redirect command to the rtmp server
@var app the rtmp app name
@var name the streamkey
@var new_adress the optional client adress
@var clientId the optional nginx client id
@var new_name new stream name to redirect to (streamkey)
@var new_clientid optional nginx client id | [
"sends",
"a",
"redirect",
"command",
"to",
"the",
"rtmp",
"server"
] | train | https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L272-L302 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.