id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
208,700 | octobercms/october | modules/backend/classes/Controller.php | Controller.execAjaxHandlers | protected function execAjaxHandlers()
{
if ($handler = $this->getAjaxHandler()) {
try {
/*
* Validate the handler name
*/
if (!preg_match('/^(?:\w+\:{2})?on[A-Z]{1}[\w+]*$/', $handler)) {
throw new SystemExcept... | php | protected function execAjaxHandlers()
{
if ($handler = $this->getAjaxHandler()) {
try {
/*
* Validate the handler name
*/
if (!preg_match('/^(?:\w+\:{2})?on[A-Z]{1}[\w+]*$/', $handler)) {
throw new SystemExcept... | [
"protected",
"function",
"execAjaxHandlers",
"(",
")",
"{",
"if",
"(",
"$",
"handler",
"=",
"$",
"this",
"->",
"getAjaxHandler",
"(",
")",
")",
"{",
"try",
"{",
"/*\n * Validate the handler name\n */",
"if",
"(",
"!",
"preg_match",
... | This method is used internally.
Invokes a controller event handler and loads the supplied partials. | [
"This",
"method",
"is",
"used",
"internally",
".",
"Invokes",
"a",
"controller",
"event",
"handler",
"and",
"loads",
"the",
"supplied",
"partials",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L395-L496 |
208,701 | octobercms/october | modules/backend/classes/Controller.php | Controller.runAjaxHandler | protected function runAjaxHandler($handler)
{
/**
* @event backend.ajax.beforeRunHandler
* Provides an opportunity to modify an AJAX request
*
* The parameter provided is `$handler` (the requested AJAX handler to be run)
*
* Example usage (forwards AJAX ... | php | protected function runAjaxHandler($handler)
{
/**
* @event backend.ajax.beforeRunHandler
* Provides an opportunity to modify an AJAX request
*
* The parameter provided is `$handler` (the requested AJAX handler to be run)
*
* Example usage (forwards AJAX ... | [
"protected",
"function",
"runAjaxHandler",
"(",
"$",
"handler",
")",
"{",
"/**\n * @event backend.ajax.beforeRunHandler\n * Provides an opportunity to modify an AJAX request\n *\n * The parameter provided is `$handler` (the requested AJAX handler to be run)\n ... | Tries to find and run an AJAX handler in the page action.
The method stops as soon as the handler is found.
@return boolean Returns true if the handler was found. Returns false otherwise. | [
"Tries",
"to",
"find",
"and",
"run",
"an",
"AJAX",
"handler",
"in",
"the",
"page",
"action",
".",
"The",
"method",
"stops",
"as",
"soon",
"as",
"the",
"handler",
"is",
"found",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L503-L603 |
208,702 | octobercms/october | modules/backend/classes/Controller.php | Controller.runAjaxHandlerForWidget | protected function runAjaxHandlerForWidget($widget, $handler)
{
$this->addViewPath($widget->getViewPaths());
$result = call_user_func_array([$widget, $handler], $this->params);
$this->vars = $widget->vars + $this->vars;
return $result;
} | php | protected function runAjaxHandlerForWidget($widget, $handler)
{
$this->addViewPath($widget->getViewPaths());
$result = call_user_func_array([$widget, $handler], $this->params);
$this->vars = $widget->vars + $this->vars;
return $result;
} | [
"protected",
"function",
"runAjaxHandlerForWidget",
"(",
"$",
"widget",
",",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"addViewPath",
"(",
"$",
"widget",
"->",
"getViewPaths",
"(",
")",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$"... | Specific code for executing an AJAX handler for a widget.
This will append the widget view paths to the controller and merge the vars.
@return mixed | [
"Specific",
"code",
"for",
"executing",
"an",
"AJAX",
"handler",
"for",
"a",
"widget",
".",
"This",
"will",
"append",
"the",
"widget",
"view",
"paths",
"to",
"the",
"controller",
"and",
"merge",
"the",
"vars",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L610-L619 |
208,703 | octobercms/october | modules/backend/classes/Controller.php | Controller.getId | public function getId($suffix = null)
{
$id = class_basename(get_called_class()) . '-' . $this->action;
if ($suffix !== null) {
$id .= '-' . $suffix;
}
return $id;
} | php | public function getId($suffix = null)
{
$id = class_basename(get_called_class()) . '-' . $this->action;
if ($suffix !== null) {
$id .= '-' . $suffix;
}
return $id;
} | [
"public",
"function",
"getId",
"(",
"$",
"suffix",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"class_basename",
"(",
"get_called_class",
"(",
")",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"action",
";",
"if",
"(",
"$",
"suffix",
"!==",
"null",
")",
"{"... | Returns a unique ID for the controller and route. Useful in creating HTML markup. | [
"Returns",
"a",
"unique",
"ID",
"for",
"the",
"controller",
"and",
"route",
".",
"Useful",
"in",
"creating",
"HTML",
"markup",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L632-L640 |
208,704 | octobercms/october | modules/backend/classes/Controller.php | Controller.onHideBackendHint | public function onHideBackendHint()
{
if (!$name = post('name')) {
throw new ApplicationException('Missing a hint name.');
}
$preferences = UserPreference::forUser();
$hiddenHints = $preferences->get('backend::hints.hidden', []);
$hiddenHints[$name] = 1;
... | php | public function onHideBackendHint()
{
if (!$name = post('name')) {
throw new ApplicationException('Missing a hint name.');
}
$preferences = UserPreference::forUser();
$hiddenHints = $preferences->get('backend::hints.hidden', []);
$hiddenHints[$name] = 1;
... | [
"public",
"function",
"onHideBackendHint",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"name",
"=",
"post",
"(",
"'name'",
")",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"'Missing a hint name.'",
")",
";",
"}",
"$",
"preferences",
"=",
"UserPreference",... | Ajax handler to hide a backend hint, once hidden the partial
will no longer display for the user.
@return void | [
"Ajax",
"handler",
"to",
"hide",
"a",
"backend",
"hint",
"once",
"hidden",
"the",
"partial",
"will",
"no",
"longer",
"display",
"for",
"the",
"user",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L689-L700 |
208,705 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.runDump | public function runDump(Twig_Environment $env, $context)
{
if (!$env->isDebug()) {
return;
}
$result = '';
$count = func_num_args();
if ($count == 2) {
$this->variablePrefix = true;
$vars = [];
foreach ($context as $key => $v... | php | public function runDump(Twig_Environment $env, $context)
{
if (!$env->isDebug()) {
return;
}
$result = '';
$count = func_num_args();
if ($count == 2) {
$this->variablePrefix = true;
$vars = [];
foreach ($context as $key => $v... | [
"public",
"function",
"runDump",
"(",
"Twig_Environment",
"$",
"env",
",",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"env",
"->",
"isDebug",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"result",
"=",
"''",
";",
"$",
"count",
"=",
"func_num_ar... | Processes the dump variables, if none is supplied, all the twig
template variables are used
@param Twig_Environment $env
@param array $context
@return string | [
"Processes",
"the",
"dump",
"variables",
"if",
"none",
"is",
"supplied",
"all",
"the",
"twig",
"template",
"variables",
"are",
"used"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L86-L134 |
208,706 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.makeTableHeader | protected function makeTableHeader($caption)
{
if (is_array($caption)) {
list($caption, $subcaption) = $caption;
}
$output = [];
$output[] = '<tr>';
$output[] = '<th colspan="3" colspan="100" style="'.$this->getHeaderCss().'">';
$output[] = $caption;
... | php | protected function makeTableHeader($caption)
{
if (is_array($caption)) {
list($caption, $subcaption) = $caption;
}
$output = [];
$output[] = '<tr>';
$output[] = '<th colspan="3" colspan="100" style="'.$this->getHeaderCss().'">';
$output[] = $caption;
... | [
"protected",
"function",
"makeTableHeader",
"(",
"$",
"caption",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"caption",
")",
")",
"{",
"list",
"(",
"$",
"caption",
",",
"$",
"subcaption",
")",
"=",
"$",
"caption",
";",
"}",
"$",
"output",
"=",
"[",
... | Builds the HTML used for the table header.
@param mixed $caption Caption [and subcaption] of the dump
@return string | [
"Builds",
"the",
"HTML",
"used",
"for",
"the",
"table",
"header",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L182-L200 |
208,707 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.makeTableRow | protected function makeTableRow($key, $variable)
{
$this->zebra = $this->zebra ? 0 : 1;
$css = $this->getDataCss($variable);
$output = [];
$output[] = '<tr>';
$output[] = '<td style="'.$css.';cursor:pointer" onclick="'.$this->evalToggleDumpOnClick().'">'.$this->evalKeyLabel($... | php | protected function makeTableRow($key, $variable)
{
$this->zebra = $this->zebra ? 0 : 1;
$css = $this->getDataCss($variable);
$output = [];
$output[] = '<tr>';
$output[] = '<td style="'.$css.';cursor:pointer" onclick="'.$this->evalToggleDumpOnClick().'">'.$this->evalKeyLabel($... | [
"protected",
"function",
"makeTableRow",
"(",
"$",
"key",
",",
"$",
"variable",
")",
"{",
"$",
"this",
"->",
"zebra",
"=",
"$",
"this",
"->",
"zebra",
"?",
"0",
":",
"1",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"getDataCss",
"(",
"$",
"variable",
... | Builds the HTML used for each table row.
@param mixed $key
@param mixed $variable
@return string | [
"Builds",
"the",
"HTML",
"used",
"for",
"each",
"table",
"row",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L208-L222 |
208,708 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalVarDump | protected function evalVarDump($variable)
{
$dumper = new HtmlDumper;
$cloner = new VarCloner;
$output = '<div style="display:none">';
$output .= $dumper->dump($cloner->cloneVar($variable), true);
$output .= '</div>';
return $output;
} | php | protected function evalVarDump($variable)
{
$dumper = new HtmlDumper;
$cloner = new VarCloner;
$output = '<div style="display:none">';
$output .= $dumper->dump($cloner->cloneVar($variable), true);
$output .= '</div>';
return $output;
} | [
"protected",
"function",
"evalVarDump",
"(",
"$",
"variable",
")",
"{",
"$",
"dumper",
"=",
"new",
"HtmlDumper",
";",
"$",
"cloner",
"=",
"new",
"VarCloner",
";",
"$",
"output",
"=",
"'<div style=\"display:none\">'",
";",
"$",
"output",
".=",
"$",
"dumper",
... | Dumps a variable using HTML Dumper, wrapped in a hidden DIV element.
@param mixed $variable
@return string | [
"Dumps",
"a",
"variable",
"using",
"HTML",
"Dumper",
"wrapped",
"in",
"a",
"hidden",
"DIV",
"element",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L240-L250 |
208,709 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalKeyLabel | protected function evalKeyLabel($key)
{
if ($this->variablePrefix === true) {
$output = '{{ <span>%s</span> }}';
}
elseif (is_array($this->variablePrefix)) {
$prefix = implode('.', $this->variablePrefix);
$output = '{{ <span>'.$prefix.'.%s</span> }}';
... | php | protected function evalKeyLabel($key)
{
if ($this->variablePrefix === true) {
$output = '{{ <span>%s</span> }}';
}
elseif (is_array($this->variablePrefix)) {
$prefix = implode('.', $this->variablePrefix);
$output = '{{ <span>'.$prefix.'.%s</span> }}';
... | [
"protected",
"function",
"evalKeyLabel",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"variablePrefix",
"===",
"true",
")",
"{",
"$",
"output",
"=",
"'{{ <span>%s</span> }}'",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"this",
"->",
"vari... | Returns a variable name as HTML friendly.
@param string $key
@return string | [
"Returns",
"a",
"variable",
"name",
"as",
"HTML",
"friendly",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L257-L274 |
208,710 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalObjLabel | protected function evalObjLabel($variable)
{
$class = get_class($variable);
$label = class_basename($variable);
if ($variable instanceof ComponentBase) {
$label = '<strong>Component</strong>';
}
elseif ($variable instanceof Collection) {
$label = 'Col... | php | protected function evalObjLabel($variable)
{
$class = get_class($variable);
$label = class_basename($variable);
if ($variable instanceof ComponentBase) {
$label = '<strong>Component</strong>';
}
elseif ($variable instanceof Collection) {
$label = 'Col... | [
"protected",
"function",
"evalObjLabel",
"(",
"$",
"variable",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"variable",
")",
";",
"$",
"label",
"=",
"class_basename",
"(",
"$",
"variable",
")",
";",
"if",
"(",
"$",
"variable",
"instanceof",
"Compo... | Evaluate an object type for label
@param object $variable
@return string | [
"Evaluate",
"an",
"object",
"type",
"for",
"label"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L316-L335 |
208,711 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalMethodDesc | protected function evalMethodDesc($variable)
{
$parts = explode('|', $variable);
if (count($parts) < 2) {
return null;
}
$method = $parts[1];
return $this->commentMap[$method] ?? null;
} | php | protected function evalMethodDesc($variable)
{
$parts = explode('|', $variable);
if (count($parts) < 2) {
return null;
}
$method = $parts[1];
return $this->commentMap[$method] ?? null;
} | [
"protected",
"function",
"evalMethodDesc",
"(",
"$",
"variable",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'|'",
",",
"$",
"variable",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
")",
"{",
"return",
"null",
";",
"}",
"$",
... | Evaluate an method type for description
@param object $variable
@return string | [
"Evaluate",
"an",
"method",
"type",
"for",
"description"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L370-L379 |
208,712 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalArrDesc | protected function evalArrDesc($variable)
{
$output = [];
foreach ($variable as $key => $value) {
$output[] = '<abbr title="'.e(gettype($value)).'">'.$key.'</abbr>';
}
return implode(', ', $output);
} | php | protected function evalArrDesc($variable)
{
$output = [];
foreach ($variable as $key => $value) {
$output[] = '<abbr title="'.e(gettype($value)).'">'.$key.'</abbr>';
}
return implode(', ', $output);
} | [
"protected",
"function",
"evalArrDesc",
"(",
"$",
"variable",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"variable",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"'<abbr title=\"'",
".",
"e",
... | Evaluate an array type for description
@param array $variable
@return string | [
"Evaluate",
"an",
"array",
"type",
"for",
"description"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L386-L394 |
208,713 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalObjDesc | protected function evalObjDesc($variable)
{
$output = [];
if ($variable instanceof ComponentBase) {
$details = $variable->componentDetails();
$output[] = '<abbr title="'.array_get($details, 'description').'">';
$output[] = array_get($details, 'name');
... | php | protected function evalObjDesc($variable)
{
$output = [];
if ($variable instanceof ComponentBase) {
$details = $variable->componentDetails();
$output[] = '<abbr title="'.array_get($details, 'description').'">';
$output[] = array_get($details, 'name');
... | [
"protected",
"function",
"evalObjDesc",
"(",
"$",
"variable",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"variable",
"instanceof",
"ComponentBase",
")",
"{",
"$",
"details",
"=",
"$",
"variable",
"->",
"componentDetails",
"(",
")",
";",... | Evaluate an object type for description
@param array $variable
@return string | [
"Evaluate",
"an",
"object",
"type",
"for",
"description"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L401-L412 |
208,714 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.objectToArray | protected function objectToArray($object)
{
$class = get_class($object);
$info = new \ReflectionClass($object);
$this->commentMap[$class] = [];
$methods = [];
foreach ($info->getMethods() as $method) {
if (!$method->isPublic()) {
continue; // Onl... | php | protected function objectToArray($object)
{
$class = get_class($object);
$info = new \ReflectionClass($object);
$this->commentMap[$class] = [];
$methods = [];
foreach ($info->getMethods() as $method) {
if (!$method->isPublic()) {
continue; // Onl... | [
"protected",
"function",
"objectToArray",
"(",
"$",
"object",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"info",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"commentMap",
"[",
... | Returns a map of an object as an array, containing methods and properties.
@param mixed $object
@return array | [
"Returns",
"a",
"map",
"of",
"an",
"object",
"as",
"an",
"array",
"containing",
"methods",
"and",
"properties",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L453-L503 |
208,715 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalDocBlock | protected function evalDocBlock($reflectionObj)
{
$comment = $reflectionObj->getDocComment();
$comment = substr($comment, 3, -2);
$parts = explode('@', $comment);
$comment = array_shift($parts);
$comment = trim(trim($comment), '*');
$comment = implode(' ', array_map(... | php | protected function evalDocBlock($reflectionObj)
{
$comment = $reflectionObj->getDocComment();
$comment = substr($comment, 3, -2);
$parts = explode('@', $comment);
$comment = array_shift($parts);
$comment = trim(trim($comment), '*');
$comment = implode(' ', array_map(... | [
"protected",
"function",
"evalDocBlock",
"(",
"$",
"reflectionObj",
")",
"{",
"$",
"comment",
"=",
"$",
"reflectionObj",
"->",
"getDocComment",
"(",
")",
";",
"$",
"comment",
"=",
"substr",
"(",
"$",
"comment",
",",
"3",
",",
"-",
"2",
")",
";",
"$",
... | Extracts the comment from a DocBlock
@param ReflectionClass $reflectionObj
@return string | [
"Extracts",
"the",
"comment",
"from",
"a",
"DocBlock"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L510-L521 |
208,716 | octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.getDataCss | protected function getDataCss($variable)
{
$css = [
'padding' => '7px',
'background-color' => $this->zebra ? '#D8D9DB' : '#FFF',
'color' => '#405261',
];
$type = gettype($variable);
if ($type == 'NULL') {
... | php | protected function getDataCss($variable)
{
$css = [
'padding' => '7px',
'background-color' => $this->zebra ? '#D8D9DB' : '#FFF',
'color' => '#405261',
];
$type = gettype($variable);
if ($type == 'NULL') {
... | [
"protected",
"function",
"getDataCss",
"(",
"$",
"variable",
")",
"{",
"$",
"css",
"=",
"[",
"'padding'",
"=>",
"'7px'",
",",
"'background-color'",
"=>",
"$",
"this",
"->",
"zebra",
"?",
"'#D8D9DB'",
":",
"'#FFF'",
",",
"'color'",
"=>",
"'#405261'",
",",
... | Get the CSS string for the output data
@param mixed $variable
@return string | [
"Get",
"the",
"CSS",
"string",
"for",
"the",
"output",
"data"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L532-L546 |
208,717 | octobercms/october | modules/cms/classes/MediaViewHelper.php | MediaViewHelper.processHtml | public function processHtml($html)
{
if (!is_string($html)) {
return $html;
}
$mediaTags = $this->extractMediaTags($html);
foreach ($mediaTags as $tagInfo) {
$pattern = preg_quote($tagInfo['declaration']);
$generatedMarkup = $this->generateMediaTa... | php | public function processHtml($html)
{
if (!is_string($html)) {
return $html;
}
$mediaTags = $this->extractMediaTags($html);
foreach ($mediaTags as $tagInfo) {
$pattern = preg_quote($tagInfo['declaration']);
$generatedMarkup = $this->generateMediaTa... | [
"public",
"function",
"processHtml",
"(",
"$",
"html",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"html",
")",
")",
"{",
"return",
"$",
"html",
";",
"}",
"$",
"mediaTags",
"=",
"$",
"this",
"->",
"extractMediaTags",
"(",
"$",
"html",
")",
";"... | Replaces audio and video tags inserted by the Media Manager with players markup.
@param string $html Specifies the HTML string to process.
@return string Returns the processed HTML string. | [
"Replaces",
"audio",
"and",
"video",
"tags",
"inserted",
"by",
"the",
"Media",
"Manager",
"with",
"players",
"markup",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/MediaViewHelper.php#L22-L36 |
208,718 | octobercms/october | modules/system/twig/Loader.php | Loader.findTemplate | protected function findTemplate($name)
{
$finder = App::make('view')->getFinder();
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
if (File::isFile($name)) {
return $this->cache[$name] = $name;
}
$view = $name;
if (Fi... | php | protected function findTemplate($name)
{
$finder = App::make('view')->getFinder();
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
if (File::isFile($name)) {
return $this->cache[$name] = $name;
}
$view = $name;
if (Fi... | [
"protected",
"function",
"findTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"finder",
"=",
"App",
"::",
"make",
"(",
"'view'",
")",
"->",
"getFinder",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"name",
"]",
")",
"... | Gets the path of a view file
@param string $name
@return string | [
"Gets",
"the",
"path",
"of",
"a",
"view",
"file"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/twig/Loader.php#L32-L51 |
208,719 | octobercms/october | modules/backend/controllers/Auth.php | Auth.signin | public function signin()
{
$this->bodyClass = 'signin';
try {
if (post('postback')) {
return $this->signin_onSubmit();
}
$this->bodyClass .= ' preload';
}
catch (Exception $ex) {
Flash::error($ex->getMessage());
... | php | public function signin()
{
$this->bodyClass = 'signin';
try {
if (post('postback')) {
return $this->signin_onSubmit();
}
$this->bodyClass .= ' preload';
}
catch (Exception $ex) {
Flash::error($ex->getMessage());
... | [
"public",
"function",
"signin",
"(",
")",
"{",
"$",
"this",
"->",
"bodyClass",
"=",
"'signin'",
";",
"try",
"{",
"if",
"(",
"post",
"(",
"'postback'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"signin_onSubmit",
"(",
")",
";",
"}",
"$",
"this",
"... | Displays the log in page. | [
"Displays",
"the",
"log",
"in",
"page",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Auth.php#L49-L63 |
208,720 | octobercms/october | modules/backend/controllers/Auth.php | Auth.restore | public function restore()
{
try {
if (post('postback')) {
return $this->restore_onSubmit();
}
}
catch (Exception $ex) {
Flash::error($ex->getMessage());
}
} | php | public function restore()
{
try {
if (post('postback')) {
return $this->restore_onSubmit();
}
}
catch (Exception $ex) {
Flash::error($ex->getMessage());
}
} | [
"public",
"function",
"restore",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"post",
"(",
"'postback'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"restore_onSubmit",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"Flash",
"::"... | Request a password reset verification code. | [
"Request",
"a",
"password",
"reset",
"verification",
"code",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Auth.php#L114-L124 |
208,721 | octobercms/october | modules/backend/controllers/Auth.php | Auth.reset | public function reset($userId = null, $code = null)
{
try {
if (post('postback')) {
return $this->reset_onSubmit();
}
if (!$userId || !$code) {
throw new ApplicationException(trans('backend::lang.account.reset_error'));
}
... | php | public function reset($userId = null, $code = null)
{
try {
if (post('postback')) {
return $this->reset_onSubmit();
}
if (!$userId || !$code) {
throw new ApplicationException(trans('backend::lang.account.reset_error'));
}
... | [
"public",
"function",
"reset",
"(",
"$",
"userId",
"=",
"null",
",",
"$",
"code",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"post",
"(",
"'postback'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"reset_onSubmit",
"(",
")",
";",
"}",
"if",
"("... | Reset backend user password using verification code. | [
"Reset",
"backend",
"user",
"password",
"using",
"verification",
"code",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Auth.php#L164-L181 |
208,722 | octobercms/october | modules/backend/formwidgets/ColorPicker.php | ColorPicker.getAvailableColors | protected function getAvailableColors()
{
$availableColors = $this->availableColors;
if (is_array($availableColors)) {
return $availableColors;
}
elseif (is_string($availableColors) && !empty($availableColors)) {
if ($this->model->methodExists($availableColors... | php | protected function getAvailableColors()
{
$availableColors = $this->availableColors;
if (is_array($availableColors)) {
return $availableColors;
}
elseif (is_string($availableColors) && !empty($availableColors)) {
if ($this->model->methodExists($availableColors... | [
"protected",
"function",
"getAvailableColors",
"(",
")",
"{",
"$",
"availableColors",
"=",
"$",
"this",
"->",
"availableColors",
";",
"if",
"(",
"is_array",
"(",
"$",
"availableColors",
")",
")",
"{",
"return",
"$",
"availableColors",
";",
"}",
"elseif",
"("... | Gets the appropriate list of colors.
@return array | [
"Gets",
"the",
"appropriate",
"list",
"of",
"colors",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/ColorPicker.php#L94-L115 |
208,723 | octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.boot | public function boot()
{
// Fix UTF8MB4 support for MariaDB < 10.2 and MySQL < 5.7
if (Config::get('database.connections.mysql.charset') === 'utf8mb4') {
Schema::defaultStringLength(191);
}
Paginator::defaultSimpleView('system::pagination.simple-default');
/*
... | php | public function boot()
{
// Fix UTF8MB4 support for MariaDB < 10.2 and MySQL < 5.7
if (Config::get('database.connections.mysql.charset') === 'utf8mb4') {
Schema::defaultStringLength(191);
}
Paginator::defaultSimpleView('system::pagination.simple-default');
/*
... | [
"public",
"function",
"boot",
"(",
")",
"{",
"// Fix UTF8MB4 support for MariaDB < 10.2 and MySQL < 5.7",
"if",
"(",
"Config",
"::",
"get",
"(",
"'database.connections.mysql.charset'",
")",
"===",
"'utf8mb4'",
")",
"{",
"Schema",
"::",
"defaultStringLength",
"(",
"191",... | Bootstrap the module events.
@return void | [
"Bootstrap",
"the",
"module",
"events",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L84-L99 |
208,724 | octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerConsole | protected function registerConsole()
{
/*
* Allow plugins to use the scheduler
*/
Event::listen('console.schedule', function ($schedule) {
$plugins = PluginManager::instance()->getPlugins();
foreach ($plugins as $plugin) {
if (method_exists($... | php | protected function registerConsole()
{
/*
* Allow plugins to use the scheduler
*/
Event::listen('console.schedule', function ($schedule) {
$plugins = PluginManager::instance()->getPlugins();
foreach ($plugins as $plugin) {
if (method_exists($... | [
"protected",
"function",
"registerConsole",
"(",
")",
"{",
"/*\n * Allow plugins to use the scheduler\n */",
"Event",
"::",
"listen",
"(",
"'console.schedule'",
",",
"function",
"(",
"$",
"schedule",
")",
"{",
"$",
"plugins",
"=",
"PluginManager",
"::",
... | Register command line specifics | [
"Register",
"command",
"line",
"specifics"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L206-L247 |
208,725 | octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerMailer | protected function registerMailer()
{
/*
* Register system layouts
*/
MailManager::instance()->registerCallback(function ($manager) {
$manager->registerMailLayouts([
'default' => 'system::mail.layout-default',
'system' => 'system::mail.la... | php | protected function registerMailer()
{
/*
* Register system layouts
*/
MailManager::instance()->registerCallback(function ($manager) {
$manager->registerMailLayouts([
'default' => 'system::mail.layout-default',
'system' => 'system::mail.la... | [
"protected",
"function",
"registerMailer",
"(",
")",
"{",
"/*\n * Register system layouts\n */",
"MailManager",
"::",
"instance",
"(",
")",
"->",
"registerCallback",
"(",
"function",
"(",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"registerMailLay... | Register mail templating and settings override. | [
"Register",
"mail",
"templating",
"and",
"settings",
"override",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L297-L336 |
208,726 | octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerValidator | protected function registerValidator()
{
$this->app->resolving('validator', function($validator) {
/*
* Allowed file extensions, as opposed to mime types.
* - extensions: png,jpg,txt
*/
$validator->extend('extensions', function ($attribute, $val... | php | protected function registerValidator()
{
$this->app->resolving('validator', function($validator) {
/*
* Allowed file extensions, as opposed to mime types.
* - extensions: png,jpg,txt
*/
$validator->extend('extensions', function ($attribute, $val... | [
"protected",
"function",
"registerValidator",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"resolving",
"(",
"'validator'",
",",
"function",
"(",
"$",
"validator",
")",
"{",
"/*\n * Allowed file extensions, as opposed to mime types.\n * - extension... | Extends the validator with custom rules | [
"Extends",
"the",
"validator",
"with",
"custom",
"rules"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L528-L544 |
208,727 | octobercms/october | modules/system/models/File.php | File.getPublicPath | public function getPublicPath()
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
}
return Url::asset($uploadsPath) . '... | php | public function getPublicPath()
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
}
return Url::asset($uploadsPath) . '... | [
"public",
"function",
"getPublicPath",
"(",
")",
"{",
"$",
"uploadsPath",
"=",
"Config",
"::",
"get",
"(",
"'cms.storage.uploads.path'",
",",
"'/storage/app/uploads'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"uploadsPath"... | Define the public address for the storage path. | [
"Define",
"the",
"public",
"address",
"for",
"the",
"storage",
"path",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/models/File.php#L68-L80 |
208,728 | octobercms/october | modules/system/models/File.php | File.copyLocalToStorage | protected function copyLocalToStorage($localPath, $storagePath)
{
$disk = Storage::disk(Config::get('cms.storage.uploads.disk'));
return $disk->put($storagePath, FileHelper::get($localPath), $this->isPublic() ? 'public' : null);
} | php | protected function copyLocalToStorage($localPath, $storagePath)
{
$disk = Storage::disk(Config::get('cms.storage.uploads.disk'));
return $disk->put($storagePath, FileHelper::get($localPath), $this->isPublic() ? 'public' : null);
} | [
"protected",
"function",
"copyLocalToStorage",
"(",
"$",
"localPath",
",",
"$",
"storagePath",
")",
"{",
"$",
"disk",
"=",
"Storage",
"::",
"disk",
"(",
"Config",
"::",
"get",
"(",
"'cms.storage.uploads.disk'",
")",
")",
";",
"return",
"$",
"disk",
"->",
"... | Copy the local file to Storage
@return bool True on success, false on failure. | [
"Copy",
"the",
"local",
"file",
"to",
"Storage"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/models/File.php#L109-L113 |
208,729 | octobercms/october | modules/system/console/OctoberUtil.php | OctoberUtil.utilGitPull | protected function utilGitPull()
{
foreach (File::directories(plugins_path()) as $authorDir) {
foreach (File::directories($authorDir) as $pluginDir) {
if (!File::isDirectory($pluginDir.'/.git')) continue;
$exec = 'cd ' . $pluginDir . ' && ';
$exec ... | php | protected function utilGitPull()
{
foreach (File::directories(plugins_path()) as $authorDir) {
foreach (File::directories($authorDir) as $pluginDir) {
if (!File::isDirectory($pluginDir.'/.git')) continue;
$exec = 'cd ' . $pluginDir . ' && ';
$exec ... | [
"protected",
"function",
"utilGitPull",
"(",
")",
"{",
"foreach",
"(",
"File",
"::",
"directories",
"(",
"plugins_path",
"(",
")",
")",
"as",
"$",
"authorDir",
")",
"{",
"foreach",
"(",
"File",
"::",
"directories",
"(",
"$",
"authorDir",
")",
"as",
"$",
... | This command requires the git binary to be installed. | [
"This",
"command",
"requires",
"the",
"git",
"binary",
"to",
"be",
"installed",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/OctoberUtil.php#L313-L332 |
208,730 | octobercms/october | modules/system/traits/ConfigMaker.php | ConfigMaker.makeConfig | public function makeConfig($configFile = [], $requiredConfig = [])
{
if (!$configFile) {
$configFile = [];
}
/*
* Config already made
*/
if (is_object($configFile)) {
$config = $configFile;
}
/*
* Embedded config
... | php | public function makeConfig($configFile = [], $requiredConfig = [])
{
if (!$configFile) {
$configFile = [];
}
/*
* Config already made
*/
if (is_object($configFile)) {
$config = $configFile;
}
/*
* Embedded config
... | [
"public",
"function",
"makeConfig",
"(",
"$",
"configFile",
"=",
"[",
"]",
",",
"$",
"requiredConfig",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"configFile",
")",
"{",
"$",
"configFile",
"=",
"[",
"]",
";",
"}",
"/*\n * Config already made\n... | Reads the contents of the supplied file and applies it to this object.
@param array $configFile
@param array $requiredConfig
@return array|stdClass | [
"Reads",
"the",
"contents",
"of",
"the",
"supplied",
"file",
"and",
"applies",
"it",
"to",
"this",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ConfigMaker.php#L32-L100 |
208,731 | octobercms/october | modules/system/traits/ConfigMaker.php | ConfigMaker.makeConfigFromArray | public function makeConfigFromArray($configArray = [])
{
$object = new stdClass;
if (!is_array($configArray)) {
return $object;
}
foreach ($configArray as $name => $value) {
$_name = camel_case($name);
$object->{$name} = $object->{$_name} = $valu... | php | public function makeConfigFromArray($configArray = [])
{
$object = new stdClass;
if (!is_array($configArray)) {
return $object;
}
foreach ($configArray as $name => $value) {
$_name = camel_case($name);
$object->{$name} = $object->{$_name} = $valu... | [
"public",
"function",
"makeConfigFromArray",
"(",
"$",
"configArray",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"new",
"stdClass",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"configArray",
")",
")",
"{",
"return",
"$",
"object",
";",
"}",
"foreach",... | Makes a config object from an array, making the first level keys properties a new object.
Property values are converted to camelCase and are not set if one already exists.
@param array $configArray Config array.
@return stdClass The config object | [
"Makes",
"a",
"config",
"object",
"from",
"an",
"array",
"making",
"the",
"first",
"level",
"keys",
"properties",
"a",
"new",
"object",
".",
"Property",
"values",
"are",
"converted",
"to",
"camelCase",
"and",
"are",
"not",
"set",
"if",
"one",
"already",
"e... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ConfigMaker.php#L108-L122 |
208,732 | octobercms/october | modules/system/traits/ConfigMaker.php | ConfigMaker.getConfigPath | public function getConfigPath($fileName, $configPath = null)
{
if (!isset($this->configPath)) {
$this->configPath = $this->guessConfigPath();
}
if (!$configPath) {
$configPath = $this->configPath;
}
$fileName = File::symbolizePath($fileName);
... | php | public function getConfigPath($fileName, $configPath = null)
{
if (!isset($this->configPath)) {
$this->configPath = $this->guessConfigPath();
}
if (!$configPath) {
$configPath = $this->configPath;
}
$fileName = File::symbolizePath($fileName);
... | [
"public",
"function",
"getConfigPath",
"(",
"$",
"fileName",
",",
"$",
"configPath",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"configPath",
")",
")",
"{",
"$",
"this",
"->",
"configPath",
"=",
"$",
"this",
"->",
"guessC... | Locates a file based on it's definition. If the file starts with
the ~ symbol it will be returned in context of the application base path,
otherwise it will be returned in context of the config path.
@param string $fileName File to load.
@param mixed $configPath Explicitly define a config path.
@return string Full path... | [
"Locates",
"a",
"file",
"based",
"on",
"it",
"s",
"definition",
".",
"If",
"the",
"file",
"starts",
"with",
"the",
"~",
"symbol",
"it",
"will",
"be",
"returned",
"in",
"context",
"of",
"the",
"application",
"base",
"path",
"otherwise",
"it",
"will",
"be"... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ConfigMaker.php#L132-L162 |
208,733 | octobercms/october | modules/system/traits/ConfigMaker.php | ConfigMaker.mergeConfig | public function mergeConfig($configA, $configB)
{
$configA = $this->makeConfig($configA);
$configB = $this->makeConfig($configB);
return (object) array_merge((array) $configA, (array) $configB);
} | php | public function mergeConfig($configA, $configB)
{
$configA = $this->makeConfig($configA);
$configB = $this->makeConfig($configB);
return (object) array_merge((array) $configA, (array) $configB);
} | [
"public",
"function",
"mergeConfig",
"(",
"$",
"configA",
",",
"$",
"configB",
")",
"{",
"$",
"configA",
"=",
"$",
"this",
"->",
"makeConfig",
"(",
"$",
"configA",
")",
";",
"$",
"configB",
"=",
"$",
"this",
"->",
"makeConfig",
"(",
"$",
"configB",
"... | Merges two configuration sources, either prepared or not, and returns
them as a single configuration object.
@param mixed $configA
@param mixed $configB
@return stdClass The config object | [
"Merges",
"two",
"configuration",
"sources",
"either",
"prepared",
"or",
"not",
"and",
"returns",
"them",
"as",
"a",
"single",
"configuration",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ConfigMaker.php#L195-L202 |
208,734 | octobercms/october | modules/cms/classes/Router.php | Router.findByFile | public function findByFile($fileName, $parameters = [])
{
if (!strlen(File::extension($fileName))) {
$fileName .= '.htm';
}
$router = $this->getRouterObject();
return $router->url($fileName, $parameters);
} | php | public function findByFile($fileName, $parameters = [])
{
if (!strlen(File::extension($fileName))) {
$fileName .= '.htm';
}
$router = $this->getRouterObject();
return $router->url($fileName, $parameters);
} | [
"public",
"function",
"findByFile",
"(",
"$",
"fileName",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"File",
"::",
"extension",
"(",
"$",
"fileName",
")",
")",
")",
"{",
"$",
"fileName",
".=",
"'.htm'",
";",
"}"... | Finds a URL by it's page. Returns the URL route for linking to the page and uses the supplied
parameters in it's address.
@param string $fileName Page file name.
@param array $parameters Route parameters to consider in the URL.
@return string A built URL matching the page route. | [
"Finds",
"a",
"URL",
"by",
"it",
"s",
"page",
".",
"Returns",
"the",
"URL",
"route",
"for",
"linking",
"to",
"the",
"page",
"and",
"uses",
"the",
"supplied",
"parameters",
"in",
"it",
"s",
"address",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Router.php#L170-L178 |
208,735 | octobercms/october | modules/cms/classes/Router.php | Router.getRouterObject | protected function getRouterObject()
{
if ($this->routerObj !== null) {
return $this->routerObj;
}
/*
* Load up each route rule
*/
$router = new RainRouter();
foreach ($this->getUrlMap() as $pageInfo) {
$router->route($pageInfo['file... | php | protected function getRouterObject()
{
if ($this->routerObj !== null) {
return $this->routerObj;
}
/*
* Load up each route rule
*/
$router = new RainRouter();
foreach ($this->getUrlMap() as $pageInfo) {
$router->route($pageInfo['file... | [
"protected",
"function",
"getRouterObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"routerObj",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"routerObj",
";",
"}",
"/*\n * Load up each route rule\n */",
"$",
"router",
"=",
"new",
... | Autoloads the URL map only allowing a single execution.
@return array Returns the URL map. | [
"Autoloads",
"the",
"URL",
"map",
"only",
"allowing",
"a",
"single",
"execution",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Router.php#L184-L204 |
208,736 | octobercms/october | modules/cms/classes/Router.php | Router.getCachedUrlFileName | protected function getCachedUrlFileName($url, &$urlList)
{
$key = $this->getUrlListCacheKey();
$urlList = Cache::get($key, false);
if ($urlList
&& ($urlList = @unserialize(@base64_decode($urlList)))
&& is_array($urlList)
&& array_key_exists($url, $urlList... | php | protected function getCachedUrlFileName($url, &$urlList)
{
$key = $this->getUrlListCacheKey();
$urlList = Cache::get($key, false);
if ($urlList
&& ($urlList = @unserialize(@base64_decode($urlList)))
&& is_array($urlList)
&& array_key_exists($url, $urlList... | [
"protected",
"function",
"getCachedUrlFileName",
"(",
"$",
"url",
",",
"&",
"$",
"urlList",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getUrlListCacheKey",
"(",
")",
";",
"$",
"urlList",
"=",
"Cache",
"::",
"get",
"(",
"$",
"key",
",",
"false",
"... | Tries to load a page file name corresponding to a specified URL from the cache.
@param string $url Specifies the requested URL.
@param array &$urlList The URL list loaded from the cache
@return mixed Returns the page file name if the URL exists in the cache. Otherwise returns null. | [
"Tries",
"to",
"load",
"a",
"page",
"file",
"name",
"corresponding",
"to",
"a",
"specified",
"URL",
"from",
"the",
"cache",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Router.php#L339-L353 |
208,737 | octobercms/october | modules/backend/traits/SessionMaker.php | SessionMaker.makeSessionId | protected function makeSessionId()
{
$controller = property_exists($this, 'controller') && $this->controller
? $this->controller
: $this;
$uniqueId = method_exists($this, 'getId') ? $this->getId() : $controller->getId();
// Removes Class name and "Controllers" direc... | php | protected function makeSessionId()
{
$controller = property_exists($this, 'controller') && $this->controller
? $this->controller
: $this;
$uniqueId = method_exists($this, 'getId') ? $this->getId() : $controller->getId();
// Removes Class name and "Controllers" direc... | [
"protected",
"function",
"makeSessionId",
"(",
")",
"{",
"$",
"controller",
"=",
"property_exists",
"(",
"$",
"this",
",",
"'controller'",
")",
"&&",
"$",
"this",
"->",
"controller",
"?",
"$",
"this",
"->",
"controller",
":",
"$",
"this",
";",
"$",
"uniq... | Returns a unique session identifier for this widget and controller action.
@return string | [
"Returns",
"a",
"unique",
"session",
"identifier",
"for",
"this",
"widget",
"and",
"controller",
"action",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/traits/SessionMaker.php#L64-L77 |
208,738 | octobercms/october | modules/backend/classes/WidgetManager.php | WidgetManager.listFormWidgets | public function listFormWidgets()
{
if ($this->formWidgets === null) {
$this->formWidgets = [];
/*
* Load module widgets
*/
foreach ($this->formWidgetCallbacks as $callback) {
$callback($this);
}
/*
... | php | public function listFormWidgets()
{
if ($this->formWidgets === null) {
$this->formWidgets = [];
/*
* Load module widgets
*/
foreach ($this->formWidgetCallbacks as $callback) {
$callback($this);
}
/*
... | [
"public",
"function",
"listFormWidgets",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formWidgets",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"formWidgets",
"=",
"[",
"]",
";",
"/*\n * Load module widgets\n */",
"foreach",
"(",
"$",
... | Returns a list of registered form widgets.
@return array Array keys are class names. | [
"Returns",
"a",
"list",
"of",
"registered",
"form",
"widgets",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/WidgetManager.php#L63-L92 |
208,739 | octobercms/october | modules/backend/classes/WidgetManager.php | WidgetManager.registerFormWidget | public function registerFormWidget($className, $widgetInfo = null)
{
if (!is_array($widgetInfo)) {
$widgetInfo = ['code' => $widgetInfo];
}
$widgetCode = $widgetInfo['code'] ?? null;
if (!$widgetCode) {
$widgetCode = Str::getClassId($className);
}
... | php | public function registerFormWidget($className, $widgetInfo = null)
{
if (!is_array($widgetInfo)) {
$widgetInfo = ['code' => $widgetInfo];
}
$widgetCode = $widgetInfo['code'] ?? null;
if (!$widgetCode) {
$widgetCode = Str::getClassId($className);
}
... | [
"public",
"function",
"registerFormWidget",
"(",
"$",
"className",
",",
"$",
"widgetInfo",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"widgetInfo",
")",
")",
"{",
"$",
"widgetInfo",
"=",
"[",
"'code'",
"=>",
"$",
"widgetInfo",
"]",
";... | Registers a single form widget.
@param string $className Widget class name.
@param array $widgetInfo Registration information, can contain a `code` key.
@return void | [
"Registers",
"a",
"single",
"form",
"widget",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/WidgetManager.php#L100-L114 |
208,740 | octobercms/october | modules/backend/classes/WidgetManager.php | WidgetManager.resolveFormWidget | public function resolveFormWidget($name)
{
if ($this->formWidgets === null) {
$this->listFormWidgets();
}
$hints = $this->formWidgetHints;
if (isset($hints[$name])) {
return $hints[$name];
}
$_name = Str::normalizeClassName($name);
i... | php | public function resolveFormWidget($name)
{
if ($this->formWidgets === null) {
$this->listFormWidgets();
}
$hints = $this->formWidgetHints;
if (isset($hints[$name])) {
return $hints[$name];
}
$_name = Str::normalizeClassName($name);
i... | [
"public",
"function",
"resolveFormWidget",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formWidgets",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"listFormWidgets",
"(",
")",
";",
"}",
"$",
"hints",
"=",
"$",
"this",
"->",
"formWidgetHint... | Returns a class name from a form widget code
Normalizes a class name or converts an code to its class name.
@param string $name Class name or form widget code.
@return string The class name resolved, or the original name. | [
"Returns",
"a",
"class",
"name",
"from",
"a",
"form",
"widget",
"code",
"Normalizes",
"a",
"class",
"name",
"or",
"converts",
"an",
"code",
"to",
"its",
"class",
"name",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/WidgetManager.php#L136-L154 |
208,741 | octobercms/october | modules/backend/classes/WidgetManager.php | WidgetManager.listReportWidgets | public function listReportWidgets()
{
if ($this->reportWidgets === null) {
$this->reportWidgets = [];
/*
* Load module widgets
*/
foreach ($this->reportWidgetCallbacks as $callback) {
$callback($this);
}
... | php | public function listReportWidgets()
{
if ($this->reportWidgets === null) {
$this->reportWidgets = [];
/*
* Load module widgets
*/
foreach ($this->reportWidgetCallbacks as $callback) {
$callback($this);
}
... | [
"public",
"function",
"listReportWidgets",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reportWidgets",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"reportWidgets",
"=",
"[",
"]",
";",
"/*\n * Load module widgets\n */",
"foreach",
"(",
"... | Returns a list of registered report widgets.
@return array Array keys are class names. | [
"Returns",
"a",
"list",
"of",
"registered",
"report",
"widgets",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/WidgetManager.php#L164-L210 |
208,742 | spatie/laravel-permission | src/PermissionServiceProvider.php | PermissionServiceProvider.getMigrationFileName | protected function getMigrationFileName(Filesystem $filesystem): string
{
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $files... | php | protected function getMigrationFileName(Filesystem $filesystem): string
{
$timestamp = date('Y_m_d_His');
return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR)
->flatMap(function ($path) use ($filesystem) {
return $files... | [
"protected",
"function",
"getMigrationFileName",
"(",
"Filesystem",
"$",
"filesystem",
")",
":",
"string",
"{",
"$",
"timestamp",
"=",
"date",
"(",
"'Y_m_d_His'",
")",
";",
"return",
"Collection",
"::",
"make",
"(",
"$",
"this",
"->",
"app",
"->",
"databaseP... | Returns existing migration file if found, else uses the current timestamp.
@param Filesystem $filesystem
@return string | [
"Returns",
"existing",
"migration",
"file",
"if",
"found",
"else",
"uses",
"the",
"current",
"timestamp",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/PermissionServiceProvider.php#L157-L166 |
208,743 | spatie/laravel-permission | src/PermissionRegistrar.php | PermissionRegistrar.getPermissions | public function getPermissions(array $params = []): Collection
{
if ($this->permissions === null) {
$this->permissions = $this->cache->remember(self::$cacheKey, self::$cacheExpirationTime, function () {
return $this->getPermissionClass()
->with('roles')
... | php | public function getPermissions(array $params = []): Collection
{
if ($this->permissions === null) {
$this->permissions = $this->cache->remember(self::$cacheKey, self::$cacheExpirationTime, function () {
return $this->getPermissionClass()
->with('roles')
... | [
"public",
"function",
"getPermissions",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"Collection",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"permissions",
"=",
"$",
"this",
"->",
"cache",
... | Get the permissions based on the passed params.
@param array $params
@return \Illuminate\Support\Collection | [
"Get",
"the",
"permissions",
"based",
"on",
"the",
"passed",
"params",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/PermissionRegistrar.php#L128-L145 |
208,744 | spatie/laravel-permission | src/Traits/HasRoles.php | HasRoles.removeRole | public function removeRole($role)
{
$this->roles()->detach($this->getStoredRole($role));
$this->load('roles');
return $this;
} | php | public function removeRole($role)
{
$this->roles()->detach($this->getStoredRole($role));
$this->load('roles');
return $this;
} | [
"public",
"function",
"removeRole",
"(",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
"detach",
"(",
"$",
"this",
"->",
"getStoredRole",
"(",
"$",
"role",
")",
")",
";",
"$",
"this",
"->",
"load",
"(",
"'roles'",
")",
";",
"... | Revoke the given role from the model.
@param string|\Spatie\Permission\Contracts\Role $role | [
"Revoke",
"the",
"given",
"role",
"from",
"the",
"model",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasRoles.php#L147-L154 |
208,745 | spatie/laravel-permission | src/Traits/HasPermissions.php | HasPermissions.scopePermission | public function scopePermission(Builder $query, $permissions): Builder
{
$permissions = $this->convertToPermissionModels($permissions);
$rolesWithPermissions = array_unique(array_reduce($permissions, function ($result, $permission) {
return array_merge($result, $permission->roles->all()... | php | public function scopePermission(Builder $query, $permissions): Builder
{
$permissions = $this->convertToPermissionModels($permissions);
$rolesWithPermissions = array_unique(array_reduce($permissions, function ($result, $permission) {
return array_merge($result, $permission->roles->all()... | [
"public",
"function",
"scopePermission",
"(",
"Builder",
"$",
"query",
",",
"$",
"permissions",
")",
":",
"Builder",
"{",
"$",
"permissions",
"=",
"$",
"this",
"->",
"convertToPermissionModels",
"(",
"$",
"permissions",
")",
";",
"$",
"rolesWithPermissions",
"... | Scope the model query to certain permissions only.
@param \Illuminate\Database\Eloquent\Builder $query
@param string|array|\Spatie\Permission\Contracts\Permission|\Illuminate\Support\Collection $permissions
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"the",
"model",
"query",
"to",
"certain",
"permissions",
"only",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasPermissions.php#L60-L86 |
208,746 | spatie/laravel-permission | src/Traits/HasPermissions.php | HasPermissions.hasAnyPermission | public function hasAnyPermission(...$permissions): bool
{
if (is_array($permissions[0])) {
$permissions = $permissions[0];
}
foreach ($permissions as $permission) {
if ($this->checkPermissionTo($permission)) {
return true;
}
}
... | php | public function hasAnyPermission(...$permissions): bool
{
if (is_array($permissions[0])) {
$permissions = $permissions[0];
}
foreach ($permissions as $permission) {
if ($this->checkPermissionTo($permission)) {
return true;
}
}
... | [
"public",
"function",
"hasAnyPermission",
"(",
"...",
"$",
"permissions",
")",
":",
"bool",
"{",
"if",
"(",
"is_array",
"(",
"$",
"permissions",
"[",
"0",
"]",
")",
")",
"{",
"$",
"permissions",
"=",
"$",
"permissions",
"[",
"0",
"]",
";",
"}",
"fore... | Determine if the model has any of the given permissions.
@param array ...$permissions
@return bool
@throws \Exception | [
"Determine",
"if",
"the",
"model",
"has",
"any",
"of",
"the",
"given",
"permissions",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasPermissions.php#L178-L191 |
208,747 | spatie/laravel-permission | src/Traits/HasPermissions.php | HasPermissions.getPermissionsViaRoles | public function getPermissionsViaRoles(): Collection
{
return $this->load('roles', 'roles.permissions')
->roles->flatMap(function ($role) {
return $role->permissions;
})->sort()->values();
} | php | public function getPermissionsViaRoles(): Collection
{
return $this->load('roles', 'roles.permissions')
->roles->flatMap(function ($role) {
return $role->permissions;
})->sort()->values();
} | [
"public",
"function",
"getPermissionsViaRoles",
"(",
")",
":",
"Collection",
"{",
"return",
"$",
"this",
"->",
"load",
"(",
"'roles'",
",",
"'roles.permissions'",
")",
"->",
"roles",
"->",
"flatMap",
"(",
"function",
"(",
"$",
"role",
")",
"{",
"return",
"... | Return all the permissions the model has via roles. | [
"Return",
"all",
"the",
"permissions",
"the",
"model",
"has",
"via",
"roles",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasPermissions.php#L263-L269 |
208,748 | spatie/laravel-permission | src/Traits/HasPermissions.php | HasPermissions.getAllPermissions | public function getAllPermissions(): Collection
{
$permissions = $this->permissions;
if ($this->roles) {
$permissions = $permissions->merge($this->getPermissionsViaRoles());
}
return $permissions->sort()->values();
} | php | public function getAllPermissions(): Collection
{
$permissions = $this->permissions;
if ($this->roles) {
$permissions = $permissions->merge($this->getPermissionsViaRoles());
}
return $permissions->sort()->values();
} | [
"public",
"function",
"getAllPermissions",
"(",
")",
":",
"Collection",
"{",
"$",
"permissions",
"=",
"$",
"this",
"->",
"permissions",
";",
"if",
"(",
"$",
"this",
"->",
"roles",
")",
"{",
"$",
"permissions",
"=",
"$",
"permissions",
"->",
"merge",
"(",... | Return all the permissions the model has, both directly and via roles.
@throws \Exception | [
"Return",
"all",
"the",
"permissions",
"the",
"model",
"has",
"both",
"directly",
"and",
"via",
"roles",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasPermissions.php#L276-L285 |
208,749 | slimphp/Slim | Slim/DefaultServicesProvider.php | DefaultServicesProvider.register | public function register($container)
{
if (!isset($container['environment'])) {
/**
* This service MUST return a shared instance of \Slim\Http\Environment.
*
* @return Environment
*/
$container['environment'] = function () {
... | php | public function register($container)
{
if (!isset($container['environment'])) {
/**
* This service MUST return a shared instance of \Slim\Http\Environment.
*
* @return Environment
*/
$container['environment'] = function () {
... | [
"public",
"function",
"register",
"(",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'environment'",
"]",
")",
")",
"{",
"/**\n * This service MUST return a shared instance of \\Slim\\Http\\Environment.\n *\n ... | Register Slim's default services.
@param Container $container A DI container implementing ArrayAccess and container-interop. | [
"Register",
"Slim",
"s",
"default",
"services",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/DefaultServicesProvider.php#L32-L193 |
208,750 | slimphp/Slim | Slim/Router.php | Router.setCacheFile | public function setCacheFile($cacheFile)
{
if (!is_string($cacheFile) && $cacheFile !== false) {
throw new InvalidArgumentException('Router cache file must be a string or false');
}
if ($cacheFile && file_exists($cacheFile) && !is_readable($cacheFile)) {
throw new Ru... | php | public function setCacheFile($cacheFile)
{
if (!is_string($cacheFile) && $cacheFile !== false) {
throw new InvalidArgumentException('Router cache file must be a string or false');
}
if ($cacheFile && file_exists($cacheFile) && !is_readable($cacheFile)) {
throw new Ru... | [
"public",
"function",
"setCacheFile",
"(",
"$",
"cacheFile",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"cacheFile",
")",
"&&",
"$",
"cacheFile",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Router cache file must be a strin... | Set path to fast route cache file. If this is false then route caching is disabled.
@param string|false $cacheFile
@return static
@throws InvalidArgumentException If cacheFile is not a string or not false
@throws RuntimeException If cacheFile directory is not writable | [
"Set",
"path",
"to",
"fast",
"route",
"cache",
"file",
".",
"If",
"this",
"is",
"false",
"then",
"route",
"caching",
"is",
"disabled",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Router.php#L130-L150 |
208,751 | slimphp/Slim | Slim/Router.php | Router.urlFor | public function urlFor($name, array $data = [], array $queryParams = [])
{
$url = $this->relativePathFor($name, $data, $queryParams);
if ($this->basePath) {
$url = $this->basePath . $url;
}
return $url;
} | php | public function urlFor($name, array $data = [], array $queryParams = [])
{
$url = $this->relativePathFor($name, $data, $queryParams);
if ($this->basePath) {
$url = $this->basePath . $url;
}
return $url;
} | [
"public",
"function",
"urlFor",
"(",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"relativePathFor",
"(",
"$",
"name",
",",
"$",
"data",
",",... | Build the path for a named route including the base path
@param string $name Route name
@param array $data Named argument replacement data
@param array $queryParams Optional query string parameters
@return string
@throws RuntimeException If named route does not exist
@throws InvalidArgumentEx... | [
"Build",
"the",
"path",
"for",
"a",
"named",
"route",
"including",
"the",
"base",
"path"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Router.php#L412-L421 |
208,752 | slimphp/Slim | Slim/Router.php | Router.fullUrlFor | public function fullUrlFor(UriInterface $uri, $routeName, array $data = [], array $queryParams = [])
{
$path = $this->urlFor($routeName, $data, $queryParams);
$scheme = $uri->getScheme();
$authority = $uri->getAuthority();
$protocol = ($scheme ? $scheme . ':' : '') . ($authority ? '/... | php | public function fullUrlFor(UriInterface $uri, $routeName, array $data = [], array $queryParams = [])
{
$path = $this->urlFor($routeName, $data, $queryParams);
$scheme = $uri->getScheme();
$authority = $uri->getAuthority();
$protocol = ($scheme ? $scheme . ':' : '') . ($authority ? '/... | [
"public",
"function",
"fullUrlFor",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"routeName",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"urlFor",
"(",
"$"... | Get fully qualified URL for named route
@param UriInterface $uri
@param string $routeName
@param array $data Named argument replacement data
@param array $queryParams Optional query string parameters
@return string
@throws RuntimeException If named route does not exist
@throws InvalidArgumentException If req... | [
"Get",
"fully",
"qualified",
"URL",
"for",
"named",
"route"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Router.php#L436-L444 |
208,753 | slimphp/Slim | Slim/Http/Stream.php | Stream.attach | protected function attach($newStream)
{
if (is_resource($newStream) === false) {
throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource');
}
if ($this->isAttached() === true) {
$this->detach();
}
$this->stream = $newS... | php | protected function attach($newStream)
{
if (is_resource($newStream) === false) {
throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource');
}
if ($this->isAttached() === true) {
$this->detach();
}
$this->stream = $newS... | [
"protected",
"function",
"attach",
"(",
"$",
"newStream",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"newStream",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"' argument must be a valid PHP resource'",
")",... | Attach new resource to this object.
Note: This method is not part of the PSR-7 standard.
@param resource $newStream A PHP resource handle.
@throws InvalidArgumentException If argument is not a valid PHP resource. | [
"Attach",
"new",
"resource",
"to",
"this",
"object",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Stream.php#L142-L153 |
208,754 | slimphp/Slim | Slim/Http/Response.php | Response.isEmpty | public function isEmpty()
{
return in_array(
$this->getStatusCode(),
[StatusCode::HTTP_NO_CONTENT, StatusCode::HTTP_RESET_CONTENT, StatusCode::HTTP_NOT_MODIFIED]
);
} | php | public function isEmpty()
{
return in_array(
$this->getStatusCode(),
[StatusCode::HTTP_NO_CONTENT, StatusCode::HTTP_RESET_CONTENT, StatusCode::HTTP_NOT_MODIFIED]
);
} | [
"public",
"function",
"isEmpty",
"(",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
",",
"[",
"StatusCode",
"::",
"HTTP_NO_CONTENT",
",",
"StatusCode",
"::",
"HTTP_RESET_CONTENT",
",",
"StatusCode",
"::",
"HTTP_NOT_MODIFIED",... | Is this response empty?
Note: This method is not part of the PSR-7 standard.
@return bool | [
"Is",
"this",
"response",
"empty?"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Response.php#L373-L379 |
208,755 | slimphp/Slim | Slim/Http/Response.php | Response.isRedirect | public function isRedirect()
{
return in_array(
$this->getStatusCode(),
[
StatusCode::HTTP_MOVED_PERMANENTLY,
StatusCode::HTTP_FOUND,
StatusCode::HTTP_SEE_OTHER,
StatusCode::HTTP_TEMPORARY_REDIRECT,
Statu... | php | public function isRedirect()
{
return in_array(
$this->getStatusCode(),
[
StatusCode::HTTP_MOVED_PERMANENTLY,
StatusCode::HTTP_FOUND,
StatusCode::HTTP_SEE_OTHER,
StatusCode::HTTP_TEMPORARY_REDIRECT,
Statu... | [
"public",
"function",
"isRedirect",
"(",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
",",
"[",
"StatusCode",
"::",
"HTTP_MOVED_PERMANENTLY",
",",
"StatusCode",
"::",
"HTTP_FOUND",
",",
"StatusCode",
"::",
"HTTP_SEE_OTHER",
... | Is this response a redirect?
Note: This method is not part of the PSR-7 standard.
@return bool | [
"Is",
"this",
"response",
"a",
"redirect?"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Response.php#L425-L437 |
208,756 | slimphp/Slim | Slim/Http/Request.php | Request.getParsedBodyParam | public function getParsedBodyParam($key, $default = null)
{
$postParams = $this->getParsedBody();
$result = $default;
if (is_array($postParams) && isset($postParams[$key])) {
$result = $postParams[$key];
} elseif (is_object($postParams) && property_exists($postParams, $ke... | php | public function getParsedBodyParam($key, $default = null)
{
$postParams = $this->getParsedBody();
$result = $default;
if (is_array($postParams) && isset($postParams[$key])) {
$result = $postParams[$key];
} elseif (is_object($postParams) && property_exists($postParams, $ke... | [
"public",
"function",
"getParsedBodyParam",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"postParams",
"=",
"$",
"this",
"->",
"getParsedBody",
"(",
")",
";",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"is_array",
"(",
"... | Fetch parameter value from request body.
Note: This method is not part of the PSR-7 standard.
@param string $key
@param mixed $default
@return mixed | [
"Fetch",
"parameter",
"value",
"from",
"request",
"body",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Request.php#L1148-L1159 |
208,757 | slimphp/Slim | Slim/App.php | App.redirect | public function redirect($from, $to, $status = 302)
{
$handler = function ($request, ResponseInterface $response) use ($to, $status) {
return $response->withHeader('Location', (string)$to)->withStatus($status);
};
return $this->get($from, $handler);
} | php | public function redirect($from, $to, $status = 302)
{
$handler = function ($request, ResponseInterface $response) use ($to, $status) {
return $response->withHeader('Location', (string)$to)->withStatus($status);
};
return $this->get($from, $handler);
} | [
"public",
"function",
"redirect",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"status",
"=",
"302",
")",
"{",
"$",
"handler",
"=",
"function",
"(",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"use",
"(",
"$",
"to",
",",
"$",
"st... | Add a route that sends an HTTP redirect
@param string $from
@param string|UriInterface $to
@param int $status
@return RouteInterface | [
"Add",
"a",
"route",
"that",
"sends",
"an",
"HTTP",
"redirect"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L243-L250 |
208,758 | slimphp/Slim | Slim/App.php | App.isEmptyResponse | protected function isEmptyResponse(ResponseInterface $response)
{
if (method_exists($response, 'isEmpty')) {
return $response->isEmpty();
}
return in_array($response->getStatusCode(), [204, 205, 304]);
} | php | protected function isEmptyResponse(ResponseInterface $response)
{
if (method_exists($response, 'isEmpty')) {
return $response->isEmpty();
}
return in_array($response->getStatusCode(), [204, 205, 304]);
} | [
"protected",
"function",
"isEmptyResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"response",
",",
"'isEmpty'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"isEmpty",
"(",
")",
";",
"}",
"return",
"i... | Helper method, which returns true if the provided response must not output a body and false
if the response could have a body.
@see https://tools.ietf.org/html/rfc7231
@param ResponseInterface $response
@return bool | [
"Helper",
"method",
"which",
"returns",
"true",
"if",
"the",
"provided",
"response",
"must",
"not",
"output",
"a",
"body",
"and",
"false",
"if",
"the",
"response",
"could",
"have",
"a",
"body",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L648-L655 |
208,759 | slimphp/Slim | Slim/Http/Headers.php | Headers.set | public function set($key, $value)
{
if (!is_array($value)) {
$value = [$value];
}
parent::set($this->normalizeKey($key), [
'value' => $value,
'originalKey' => $key
]);
} | php | public function set($key, $value)
{
if (!is_array($value)) {
$value = [$value];
}
parent::set($this->normalizeKey($key), [
'value' => $value,
'originalKey' => $key
]);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"parent",
"::",
"set",
"(",
"$",
"this",
"->",
"norm... | Set HTTP header value
This method sets a header value. It replaces
any values that may already exist for the header name.
@param string $key The case-insensitive header name
@param array|string $value The header value | [
"Set",
"HTTP",
"header",
"value"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Headers.php#L117-L126 |
208,760 | slimphp/Slim | Slim/MiddlewareAwareTrait.php | MiddlewareAwareTrait.seedMiddlewareStack | protected function seedMiddlewareStack(callable $kernel = null)
{
if (!is_null($this->tip)) {
throw new RuntimeException('MiddlewareStack can only be seeded once.');
}
if ($kernel === null) {
$kernel = $this;
}
$this->tip = $kernel;
} | php | protected function seedMiddlewareStack(callable $kernel = null)
{
if (!is_null($this->tip)) {
throw new RuntimeException('MiddlewareStack can only be seeded once.');
}
if ($kernel === null) {
$kernel = $this;
}
$this->tip = $kernel;
} | [
"protected",
"function",
"seedMiddlewareStack",
"(",
"callable",
"$",
"kernel",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"tip",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'MiddlewareStack can only be seeded once.'",... | Seed middleware stack with first callable
@param callable $kernel The last item to run as middleware
@throws RuntimeException if the stack is seeded more than once | [
"Seed",
"middleware",
"stack",
"with",
"first",
"callable"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/MiddlewareAwareTrait.php#L90-L99 |
208,761 | slimphp/Slim | Slim/Handlers/Error.php | Error.renderHtmlExceptionOrError | protected function renderHtmlExceptionOrError($exception)
{
if (!$exception instanceof Exception && !$exception instanceof \Error) {
throw new RuntimeException("Unexpected type. Expected Exception or Error.");
}
$html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($... | php | protected function renderHtmlExceptionOrError($exception)
{
if (!$exception instanceof Exception && !$exception instanceof \Error) {
throw new RuntimeException("Unexpected type. Expected Exception or Error.");
}
$html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($... | [
"protected",
"function",
"renderHtmlExceptionOrError",
"(",
"$",
"exception",
")",
"{",
"if",
"(",
"!",
"$",
"exception",
"instanceof",
"Exception",
"&&",
"!",
"$",
"exception",
"instanceof",
"\\",
"Error",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\... | Render exception or error as HTML.
@param Exception|\Error $exception
@return string
@throws RuntimeException | [
"Render",
"exception",
"or",
"error",
"as",
"HTML",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Handlers/Error.php#L120-L150 |
208,762 | opencart/opencart | upload/admin/controller/extension/payment/pp_express.php | ControllerExtensionPaymentPPExpress.void | public function void() {
$json = array();
$this->load->language('extension/payment/pp_express_order');
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = 0;
}
$this->load->model('extension/payment/pp_express');
$paypal_info = $this->mo... | php | public function void() {
$json = array();
$this->load->language('extension/payment/pp_express_order');
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = 0;
}
$this->load->model('extension/payment/pp_express');
$paypal_info = $this->mo... | [
"public",
"function",
"void",
"(",
")",
"{",
"$",
"json",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"load",
"->",
"language",
"(",
"'extension/payment/pp_express_order'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request",
"->",
"get... | used to void an authorised payment | [
"used",
"to",
"void",
"an",
"authorised",
"payment"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/admin/controller/extension/payment/pp_express.php#L770-L826 |
208,763 | opencart/opencart | upload/admin/controller/event/language.php | ControllerEventLanguage.after | public function after(&$route, &$args, &$output) {
$data = $this->language->get('backup');
if (is_array($data)) {
foreach ($data as $key => $value) {
$this->language->set($key, $value);
}
}
} | php | public function after(&$route, &$args, &$output) {
$data = $this->language->get('backup');
if (is_array($data)) {
foreach ($data as $key => $value) {
$this->language->set($key, $value);
}
}
} | [
"public",
"function",
"after",
"(",
"&",
"$",
"route",
",",
"&",
"$",
"args",
",",
"&",
"$",
"output",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"language",
"->",
"get",
"(",
"'backup'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
"... | 2. After controller load restore old language data | [
"2",
".",
"After",
"controller",
"load",
"restore",
"old",
"language",
"data"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/admin/controller/event/language.php#L17-L25 |
208,764 | fullcalendar/fullcalendar | demos/php/utils.php | Event.toArray | public function toArray() {
// Start with the misc properties (don't worry, PHP won't affect the original array)
$array = $this->properties;
$array['title'] = $this->title;
// Figure out the date format. This essentially encodes allDay into the date string.
if ($this->allDay) {
$format = 'Y... | php | public function toArray() {
// Start with the misc properties (don't worry, PHP won't affect the original array)
$array = $this->properties;
$array['title'] = $this->title;
// Figure out the date format. This essentially encodes allDay into the date string.
if ($this->allDay) {
$format = 'Y... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"// Start with the misc properties (don't worry, PHP won't affect the original array)",
"$",
"array",
"=",
"$",
"this",
"->",
"properties",
";",
"$",
"array",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"title",
";",
... | Converts this Event object back to a plain data array, to be used for generating JSON | [
"Converts",
"this",
"Event",
"object",
"back",
"to",
"a",
"plain",
"data",
"array",
"to",
"be",
"used",
"for",
"generating",
"JSON"
] | f827f233581338ceb9723eabb7f895731498fd5b | https://github.com/fullcalendar/fullcalendar/blob/f827f233581338ceb9723eabb7f895731498fd5b/demos/php/utils.php#L79-L101 |
208,765 | php-ai/php-ml | src/Classification/Ensemble/RandomForest.php | RandomForest.getFeatureImportances | public function getFeatureImportances(): array
{
// Traverse each tree and sum importance of the columns
$sum = [];
foreach ($this->classifiers as $tree) {
/** @var DecisionTree $tree */
$importances = $tree->getFeatureImportances();
foreach ($importances... | php | public function getFeatureImportances(): array
{
// Traverse each tree and sum importance of the columns
$sum = [];
foreach ($this->classifiers as $tree) {
/** @var DecisionTree $tree */
$importances = $tree->getFeatureImportances();
foreach ($importances... | [
"public",
"function",
"getFeatureImportances",
"(",
")",
":",
"array",
"{",
"// Traverse each tree and sum importance of the columns",
"$",
"sum",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"classifiers",
"as",
"$",
"tree",
")",
"{",
"/** @var Decision... | This will return an array including an importance value for
each column in the given dataset. Importance values for a column
is the average importance of that column in all trees in the forest | [
"This",
"will",
"return",
"an",
"array",
"including",
"an",
"importance",
"value",
"for",
"each",
"column",
"in",
"the",
"given",
"dataset",
".",
"Importance",
"values",
"for",
"a",
"column",
"is",
"the",
"average",
"importance",
"of",
"that",
"column",
"in"... | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/RandomForest.php#L86-L111 |
208,766 | php-ai/php-ml | src/Math/Matrix.php | Matrix.getIdentity | private function getIdentity(): self
{
$array = array_fill(0, $this->rows, array_fill(0, $this->columns, 0));
for ($i = 0; $i < $this->rows; ++$i) {
$array[$i][$i] = 1;
}
return new self($array, false);
} | php | private function getIdentity(): self
{
$array = array_fill(0, $this->rows, array_fill(0, $this->columns, 0));
for ($i = 0; $i < $this->rows; ++$i) {
$array[$i][$i] = 1;
}
return new self($array, false);
} | [
"private",
"function",
"getIdentity",
"(",
")",
":",
"self",
"{",
"$",
"array",
"=",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"rows",
",",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"columns",
",",
"0",
")",
")",
";",
"for",
"(",
"$",... | Returns diagonal identity matrix of the same size of this matrix | [
"Returns",
"diagonal",
"identity",
"matrix",
"of",
"the",
"same",
"size",
"of",
"this",
"matrix"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Math/Matrix.php#L318-L326 |
208,767 | php-ai/php-ml | src/Regression/LeastSquares.php | LeastSquares.getSamplesMatrix | private function getSamplesMatrix(): Matrix
{
$samples = [];
foreach ($this->samples as $sample) {
array_unshift($sample, 1);
$samples[] = $sample;
}
return new Matrix($samples);
} | php | private function getSamplesMatrix(): Matrix
{
$samples = [];
foreach ($this->samples as $sample) {
array_unshift($sample, 1);
$samples[] = $sample;
}
return new Matrix($samples);
} | [
"private",
"function",
"getSamplesMatrix",
"(",
")",
":",
"Matrix",
"{",
"$",
"samples",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"samples",
"as",
"$",
"sample",
")",
"{",
"array_unshift",
"(",
"$",
"sample",
",",
"1",
")",
";",
"$",
... | Add one dimension for intercept calculation. | [
"Add",
"one",
"dimension",
"for",
"intercept",
"calculation",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Regression/LeastSquares.php#L83-L92 |
208,768 | php-ai/php-ml | src/Classification/Linear/Perceptron.php | Perceptron.output | protected function output(array $sample)
{
$sum = 0;
foreach ($this->weights as $index => $w) {
if ($index == 0) {
$sum += $w;
} else {
$sum += $w * $sample[$index - 1];
}
}
return $sum;
} | php | protected function output(array $sample)
{
$sum = 0;
foreach ($this->weights as $index => $w) {
if ($index == 0) {
$sum += $w;
} else {
$sum += $w * $sample[$index - 1];
}
}
return $sum;
} | [
"protected",
"function",
"output",
"(",
"array",
"$",
"sample",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"weights",
"as",
"$",
"index",
"=>",
"$",
"w",
")",
"{",
"if",
"(",
"$",
"index",
"==",
"0",
")",
"{",
"$",
... | Calculates net output of the network as a float value for the given input
@return int|float | [
"Calculates",
"net",
"output",
"of",
"the",
"network",
"as",
"a",
"float",
"value",
"for",
"the",
"given",
"input"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/Perceptron.php#L210-L222 |
208,769 | php-ai/php-ml | src/DimensionReduction/KernelPCA.php | KernelPCA.getKernel | protected function getKernel(): Closure
{
switch ($this->kernel) {
case self::KERNEL_LINEAR:
// k(x,y) = xT.y
return function ($x, $y) {
return Matrix::dot($x, $y)[0];
};
case self::KERNEL_RBF:
// k(x... | php | protected function getKernel(): Closure
{
switch ($this->kernel) {
case self::KERNEL_LINEAR:
// k(x,y) = xT.y
return function ($x, $y) {
return Matrix::dot($x, $y)[0];
};
case self::KERNEL_RBF:
// k(x... | [
"protected",
"function",
"getKernel",
"(",
")",
":",
"Closure",
"{",
"switch",
"(",
"$",
"this",
"->",
"kernel",
")",
"{",
"case",
"self",
"::",
"KERNEL_LINEAR",
":",
"// k(x,y) = xT.y",
"return",
"function",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"re... | Returns the callable kernel function
@throws \Exception | [
"Returns",
"the",
"callable",
"kernel",
"function"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/KernelPCA.php#L170-L206 |
208,770 | php-ai/php-ml | src/Helper/Optimizer/ConjugateGradient.php | ConjugateGradient.getNewDirection | protected function getNewDirection(array $theta, float $beta, array $d): array
{
$grad = $this->gradient($theta);
return MP::add(MP::muls($grad, -1), MP::muls($d, $beta));
} | php | protected function getNewDirection(array $theta, float $beta, array $d): array
{
$grad = $this->gradient($theta);
return MP::add(MP::muls($grad, -1), MP::muls($d, $beta));
} | [
"protected",
"function",
"getNewDirection",
"(",
"array",
"$",
"theta",
",",
"float",
"$",
"beta",
",",
"array",
"$",
"d",
")",
":",
"array",
"{",
"$",
"grad",
"=",
"$",
"this",
"->",
"gradient",
"(",
"$",
"theta",
")",
";",
"return",
"MP",
"::",
"... | Calculates the new conjugate direction
d(k+1) =–∇f(x(k+1)) + β(k).d(k) | [
"Calculates",
"the",
"new",
"conjugate",
"direction"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/Optimizer/ConjugateGradient.php#L197-L202 |
208,771 | php-ai/php-ml | src/Classification/DecisionTree.php | DecisionTree.setColumnNames | public function setColumnNames(array $names)
{
if ($this->featureCount !== 0 && count($names) !== $this->featureCount) {
throw new InvalidArgumentException(sprintf('Length of the given array should be equal to feature count %s', $this->featureCount));
}
$this->columnNames = $nam... | php | public function setColumnNames(array $names)
{
if ($this->featureCount !== 0 && count($names) !== $this->featureCount) {
throw new InvalidArgumentException(sprintf('Length of the given array should be equal to feature count %s', $this->featureCount));
}
$this->columnNames = $nam... | [
"public",
"function",
"setColumnNames",
"(",
"array",
"$",
"names",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"featureCount",
"!==",
"0",
"&&",
"count",
"(",
"$",
"names",
")",
"!==",
"$",
"this",
"->",
"featureCount",
")",
"{",
"throw",
"new",
"InvalidA... | A string array to represent columns. Useful when HTML output or
column importances are desired to be inspected.
@return $this
@throws InvalidArgumentException | [
"A",
"string",
"array",
"to",
"represent",
"columns",
".",
"Useful",
"when",
"HTML",
"output",
"or",
"column",
"importances",
"are",
"desired",
"to",
"be",
"inspected",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/DecisionTree.php#L180-L189 |
208,772 | php-ai/php-ml | src/Classification/DecisionTree.php | DecisionTree.getSplitNodesByColumn | protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
{
if ($node->isTerminal) {
return [];
}
$nodes = [];
if ($node->columnIndex === $column) {
$nodes[] = $node;
}
$lNodes = [];
$rNodes = [];
if... | php | protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
{
if ($node->isTerminal) {
return [];
}
$nodes = [];
if ($node->columnIndex === $column) {
$nodes[] = $node;
}
$lNodes = [];
$rNodes = [];
if... | [
"protected",
"function",
"getSplitNodesByColumn",
"(",
"int",
"$",
"column",
",",
"DecisionTreeLeaf",
"$",
"node",
")",
":",
"array",
"{",
"if",
"(",
"$",
"node",
"->",
"isTerminal",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"nodes",
"=",
"[",
"]",
... | Collects and returns an array of internal nodes that use the given
column as a split criterion | [
"Collects",
"and",
"returns",
"an",
"array",
"of",
"internal",
"nodes",
"that",
"use",
"the",
"given",
"column",
"as",
"a",
"split",
"criterion"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/DecisionTree.php#L440-L462 |
208,773 | php-ai/php-ml | src/Math/Statistic/ANOVA.php | ANOVA.oneWayF | public static function oneWayF(array $samples): array
{
$classes = count($samples);
if ($classes < 2) {
throw new InvalidArgumentException('The array must have at least 2 elements');
}
$samplesPerClass = array_map(function (array $class): int {
return count($... | php | public static function oneWayF(array $samples): array
{
$classes = count($samples);
if ($classes < 2) {
throw new InvalidArgumentException('The array must have at least 2 elements');
}
$samplesPerClass = array_map(function (array $class): int {
return count($... | [
"public",
"static",
"function",
"oneWayF",
"(",
"array",
"$",
"samples",
")",
":",
"array",
"{",
"$",
"classes",
"=",
"count",
"(",
"$",
"samples",
")",
";",
"if",
"(",
"$",
"classes",
"<",
"2",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"("... | The one-way ANOVA tests the null hypothesis that 2 or more groups have
the same population mean. The test is applied to samples from two or
more groups, possibly with differing sizes.
@param array[] $samples - each row is class samples
@return float[] | [
"The",
"one",
"-",
"way",
"ANOVA",
"tests",
"the",
"null",
"hypothesis",
"that",
"2",
"or",
"more",
"groups",
"have",
"the",
"same",
"population",
"mean",
".",
"The",
"test",
"is",
"applied",
"to",
"samples",
"from",
"two",
"or",
"more",
"groups",
"possi... | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Math/Statistic/ANOVA.php#L24-L57 |
208,774 | php-ai/php-ml | src/Classification/NaiveBayes.php | NaiveBayes.calculateStatistics | private function calculateStatistics(string $label, array $samples): void
{
$this->std[$label] = array_fill(0, $this->featureCount, 0);
$this->mean[$label] = array_fill(0, $this->featureCount, 0);
$this->dataType[$label] = array_fill(0, $this->featureCount, self::CONTINUOS);
$this->d... | php | private function calculateStatistics(string $label, array $samples): void
{
$this->std[$label] = array_fill(0, $this->featureCount, 0);
$this->mean[$label] = array_fill(0, $this->featureCount, 0);
$this->dataType[$label] = array_fill(0, $this->featureCount, self::CONTINUOS);
$this->d... | [
"private",
"function",
"calculateStatistics",
"(",
"string",
"$",
"label",
",",
"array",
"$",
"samples",
")",
":",
"void",
"{",
"$",
"this",
"->",
"std",
"[",
"$",
"label",
"]",
"=",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"featureCount",
",",
... | Calculates vital statistics for each label & feature. Stores these
values in private array in order to avoid repeated calculation | [
"Calculates",
"vital",
"statistics",
"for",
"each",
"label",
"&",
"feature",
".",
"Stores",
"these",
"values",
"in",
"private",
"array",
"in",
"order",
"to",
"avoid",
"repeated",
"calculation"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/NaiveBayes.php#L108-L134 |
208,775 | php-ai/php-ml | src/Classification/NaiveBayes.php | NaiveBayes.getSamplesByLabel | private function getSamplesByLabel(string $label): array
{
$samples = [];
for ($i = 0; $i < $this->sampleCount; ++$i) {
if ($this->targets[$i] == $label) {
$samples[] = $this->samples[$i];
}
}
return $samples;
} | php | private function getSamplesByLabel(string $label): array
{
$samples = [];
for ($i = 0; $i < $this->sampleCount; ++$i) {
if ($this->targets[$i] == $label) {
$samples[] = $this->samples[$i];
}
}
return $samples;
} | [
"private",
"function",
"getSamplesByLabel",
"(",
"string",
"$",
"label",
")",
":",
"array",
"{",
"$",
"samples",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"sampleCount",
";",
"++",
"$",
"i",
")",
... | Return samples belonging to specific label | [
"Return",
"samples",
"belonging",
"to",
"specific",
"label"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/NaiveBayes.php#L173-L183 |
208,776 | php-ai/php-ml | src/Classification/Linear/LogisticRegression.php | LogisticRegression.runTraining | protected function runTraining(array $samples, array $targets): void
{
$callback = $this->getCostFunction();
switch ($this->trainingType) {
case self::BATCH_TRAINING:
$this->runGradientDescent($samples, $targets, $callback, true);
return;
ca... | php | protected function runTraining(array $samples, array $targets): void
{
$callback = $this->getCostFunction();
switch ($this->trainingType) {
case self::BATCH_TRAINING:
$this->runGradientDescent($samples, $targets, $callback, true);
return;
ca... | [
"protected",
"function",
"runTraining",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
")",
":",
"void",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"getCostFunction",
"(",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"trainingType",
")",
... | Adapts the weights with respect to given samples and targets
by use of selected solver
@throws \Exception | [
"Adapts",
"the",
"weights",
"with",
"respect",
"to",
"given",
"samples",
"and",
"targets",
"by",
"use",
"of",
"selected",
"solver"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/LogisticRegression.php#L127-L151 |
208,777 | php-ai/php-ml | src/Classification/Linear/LogisticRegression.php | LogisticRegression.runConjugateGradient | protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void
{
if ($this->optimizer === null) {
$this->optimizer = (new ConjugateGradient($this->featureCount))
->setMaxIterations($this->maxIterations);
}
$this->weights = $t... | php | protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void
{
if ($this->optimizer === null) {
$this->optimizer = (new ConjugateGradient($this->featureCount))
->setMaxIterations($this->maxIterations);
}
$this->weights = $t... | [
"protected",
"function",
"runConjugateGradient",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
",",
"Closure",
"$",
"gradientFunc",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"optimizer",
"===",
"null",
")",
"{",
"$",
"this",
"->"... | Executes Conjugate Gradient method to optimize the weights of the LogReg model | [
"Executes",
"Conjugate",
"Gradient",
"method",
"to",
"optimize",
"the",
"weights",
"of",
"the",
"LogReg",
"model"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/LogisticRegression.php#L156-L165 |
208,778 | php-ai/php-ml | src/Classification/Ensemble/AdaBoost.php | AdaBoost.getBestClassifier | protected function getBestClassifier(): Classifier
{
$ref = new ReflectionClass($this->baseClassifier);
/** @var Classifier $classifier */
$classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);
if ($classifier ins... | php | protected function getBestClassifier(): Classifier
{
$ref = new ReflectionClass($this->baseClassifier);
/** @var Classifier $classifier */
$classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);
if ($classifier ins... | [
"protected",
"function",
"getBestClassifier",
"(",
")",
":",
"Classifier",
"{",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"baseClassifier",
")",
";",
"/** @var Classifier $classifier */",
"$",
"classifier",
"=",
"count",
"(",
"$",
"this"... | Returns the classifier with the lowest error rate with the
consideration of current sample weights | [
"Returns",
"the",
"classifier",
"with",
"the",
"lowest",
"error",
"rate",
"with",
"the",
"consideration",
"of",
"current",
"sample",
"weights"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/AdaBoost.php#L159-L174 |
208,779 | php-ai/php-ml | src/Classification/Ensemble/AdaBoost.php | AdaBoost.resample | protected function resample(): array
{
$weights = $this->weights;
$std = StandardDeviation::population($weights);
$mean = Mean::arithmetic($weights);
$min = min($weights);
$minZ = (int) round(($min - $mean) / $std);
$samples = [];
$targets = [];
forea... | php | protected function resample(): array
{
$weights = $this->weights;
$std = StandardDeviation::population($weights);
$mean = Mean::arithmetic($weights);
$min = min($weights);
$minZ = (int) round(($min - $mean) / $std);
$samples = [];
$targets = [];
forea... | [
"protected",
"function",
"resample",
"(",
")",
":",
"array",
"{",
"$",
"weights",
"=",
"$",
"this",
"->",
"weights",
";",
"$",
"std",
"=",
"StandardDeviation",
"::",
"population",
"(",
"$",
"weights",
")",
";",
"$",
"mean",
"=",
"Mean",
"::",
"arithmet... | Resamples the dataset in accordance with the weights and
returns the new dataset | [
"Resamples",
"the",
"dataset",
"in",
"accordance",
"with",
"the",
"weights",
"and",
"returns",
"the",
"new",
"dataset"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/AdaBoost.php#L180-L203 |
208,780 | php-ai/php-ml | src/Math/Statistic/Covariance.php | Covariance.covarianceMatrix | public static function covarianceMatrix(array $data, ?array $means = null): array
{
$n = count($data[0]);
if ($means === null) {
$means = [];
for ($i = 0; $i < $n; ++$i) {
$means[] = Mean::arithmetic(array_column($data, $i));
}
}
... | php | public static function covarianceMatrix(array $data, ?array $means = null): array
{
$n = count($data[0]);
if ($means === null) {
$means = [];
for ($i = 0; $i < $n; ++$i) {
$means[] = Mean::arithmetic(array_column($data, $i));
}
}
... | [
"public",
"static",
"function",
"covarianceMatrix",
"(",
"array",
"$",
"data",
",",
"?",
"array",
"$",
"means",
"=",
"null",
")",
":",
"array",
"{",
"$",
"n",
"=",
"count",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"means",
"==="... | Returns the covariance matrix of n-dimensional data
@param array|null $means | [
"Returns",
"the",
"covariance",
"matrix",
"of",
"n",
"-",
"dimensional",
"data"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Math/Statistic/Covariance.php#L117-L147 |
208,781 | php-ai/php-ml | src/Association/Apriori.php | Apriori.getRules | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | php | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | [
"public",
"function",
"getRules",
"(",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"large",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"large",
"=",
"$",
"this",
"->",
"apriori",
"(",
")",
";",
"}",
"if",
"(",
"count"... | Get all association rules which are generated for every k-length frequent item set.
@return mixed[][] | [
"Get",
"all",
"association",
"rules",
"which",
"are",
"generated",
"for",
"every",
"k",
"-",
"length",
"frequent",
"item",
"set",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L65-L80 |
208,782 | php-ai/php-ml | src/Association/Apriori.php | Apriori.generateRules | private function generateRules(array $frequent): void
{
foreach ($this->antecedents($frequent) as $antecedent) {
$confidence = $this->confidence($frequent, $antecedent);
if ($this->confidence <= $confidence) {
$consequent = array_values(array_diff($frequent, $antecede... | php | private function generateRules(array $frequent): void
{
foreach ($this->antecedents($frequent) as $antecedent) {
$confidence = $this->confidence($frequent, $antecedent);
if ($this->confidence <= $confidence) {
$consequent = array_values(array_diff($frequent, $antecede... | [
"private",
"function",
"generateRules",
"(",
"array",
"$",
"frequent",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"antecedents",
"(",
"$",
"frequent",
")",
"as",
"$",
"antecedent",
")",
"{",
"$",
"confidence",
"=",
"$",
"this",
"->",
"co... | Generate confident rules for frequent item set.
@param mixed[] $frequent | [
"Generate",
"confident",
"rules",
"for",
"frequent",
"item",
"set",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L133-L147 |
208,783 | php-ai/php-ml | src/Association/Apriori.php | Apriori.items | private function items(): array
{
$items = [];
foreach ($this->samples as $sample) {
foreach ($sample as $item) {
if (!in_array($item, $items, true)) {
$items[] = $item;
}
}
}
return array_map(function ($en... | php | private function items(): array
{
$items = [];
foreach ($this->samples as $sample) {
foreach ($sample as $item) {
if (!in_array($item, $items, true)) {
$items[] = $item;
}
}
}
return array_map(function ($en... | [
"private",
"function",
"items",
"(",
")",
":",
"array",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"samples",
"as",
"$",
"sample",
")",
"{",
"foreach",
"(",
"$",
"sample",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"... | Calculates frequent k = 1 item sets.
@return mixed[][] | [
"Calculates",
"frequent",
"k",
"=",
"1",
"item",
"sets",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L190-L205 |
208,784 | php-ai/php-ml | src/Association/Apriori.php | Apriori.frequent | private function frequent(array $samples): array
{
return array_values(array_filter($samples, function ($entry) {
return $this->support($entry) >= $this->support;
}));
} | php | private function frequent(array $samples): array
{
return array_values(array_filter($samples, function ($entry) {
return $this->support($entry) >= $this->support;
}));
} | [
"private",
"function",
"frequent",
"(",
"array",
"$",
"samples",
")",
":",
"array",
"{",
"return",
"array_values",
"(",
"array_filter",
"(",
"$",
"samples",
",",
"function",
"(",
"$",
"entry",
")",
"{",
"return",
"$",
"this",
"->",
"support",
"(",
"$",
... | Returns frequent item sets only.
@param mixed[][] $samples
@return mixed[][] | [
"Returns",
"frequent",
"item",
"sets",
"only",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L214-L219 |
208,785 | php-ai/php-ml | src/Association/Apriori.php | Apriori.contains | private function contains(array $system, array $set): bool
{
return (bool) array_filter($system, function ($entry) use ($set) {
return $this->equals($entry, $set);
});
} | php | private function contains(array $system, array $set): bool
{
return (bool) array_filter($system, function ($entry) use ($set) {
return $this->equals($entry, $set);
});
} | [
"private",
"function",
"contains",
"(",
"array",
"$",
"system",
",",
"array",
"$",
"set",
")",
":",
"bool",
"{",
"return",
"(",
"bool",
")",
"array_filter",
"(",
"$",
"system",
",",
"function",
"(",
"$",
"entry",
")",
"use",
"(",
"$",
"set",
")",
"... | Returns true if set is an element of system.
@see \Phpml\Association\Apriori::equals()
@param mixed[][] $system
@param mixed[] $set | [
"Returns",
"true",
"if",
"set",
"is",
"an",
"element",
"of",
"system",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L304-L309 |
208,786 | php-ai/php-ml | src/Association/Apriori.php | Apriori.equals | private function equals(array $set1, array $set2): bool
{
return array_diff($set1, $set2) == array_diff($set2, $set1);
} | php | private function equals(array $set1, array $set2): bool
{
return array_diff($set1, $set2) == array_diff($set2, $set1);
} | [
"private",
"function",
"equals",
"(",
"array",
"$",
"set1",
",",
"array",
"$",
"set2",
")",
":",
"bool",
"{",
"return",
"array_diff",
"(",
"$",
"set1",
",",
"$",
"set2",
")",
"==",
"array_diff",
"(",
"$",
"set2",
",",
"$",
"set1",
")",
";",
"}"
] | Returns true if string representation of items does not differ.
@param mixed[] $set1
@param mixed[] $set2 | [
"Returns",
"true",
"if",
"string",
"representation",
"of",
"items",
"does",
"not",
"differ",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L328-L331 |
208,787 | php-ai/php-ml | src/DimensionReduction/LDA.php | LDA.fit | public function fit(array $data, array $classes): array
{
$this->labels = $this->getLabels($classes);
$this->means = $this->calculateMeans($data, $classes);
$sW = $this->calculateClassVar($data, $classes);
$sB = $this->calculateClassCov();
$S = $sW->inverse()->multiply($sB)... | php | public function fit(array $data, array $classes): array
{
$this->labels = $this->getLabels($classes);
$this->means = $this->calculateMeans($data, $classes);
$sW = $this->calculateClassVar($data, $classes);
$sB = $this->calculateClassCov();
$S = $sW->inverse()->multiply($sB)... | [
"public",
"function",
"fit",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"classes",
")",
":",
"array",
"{",
"$",
"this",
"->",
"labels",
"=",
"$",
"this",
"->",
"getLabels",
"(",
"$",
"classes",
")",
";",
"$",
"this",
"->",
"means",
"=",
"$",
"... | Trains the algorithm to transform the given data to a lower dimensional space. | [
"Trains",
"the",
"algorithm",
"to",
"transform",
"the",
"given",
"data",
"to",
"a",
"lower",
"dimensional",
"space",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/LDA.php#L78-L92 |
208,788 | php-ai/php-ml | src/Classification/Linear/DecisionStump.php | DecisionStump.getBestNumericalSplit | protected function getBestNumericalSplit(array $samples, array $targets, int $col): array
{
$values = array_column($samples, $col);
// Trying all possible points may be accomplished in two general ways:
// 1- Try all values in the $samples array ($values)
// 2- Artificially split the... | php | protected function getBestNumericalSplit(array $samples, array $targets, int $col): array
{
$values = array_column($samples, $col);
// Trying all possible points may be accomplished in two general ways:
// 1- Try all values in the $samples array ($values)
// 2- Artificially split the... | [
"protected",
"function",
"getBestNumericalSplit",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
",",
"int",
"$",
"col",
")",
":",
"array",
"{",
"$",
"values",
"=",
"array_column",
"(",
"$",
"samples",
",",
"$",
"col",
")",
";",
"// Trying a... | Determines best split point for the given column | [
"Determines",
"best",
"split",
"point",
"for",
"the",
"given",
"column"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/DecisionStump.php#L169-L214 |
208,789 | php-ai/php-ml | src/Classification/Linear/DecisionStump.php | DecisionStump.calculateErrorRate | protected function calculateErrorRate(array $targets, float $threshold, string $operator, array $values): array
{
$wrong = 0.0;
$prob = [];
$leftLabel = $this->binaryLabels[0];
$rightLabel = $this->binaryLabels[1];
foreach ($values as $index => $value) {
if (Comp... | php | protected function calculateErrorRate(array $targets, float $threshold, string $operator, array $values): array
{
$wrong = 0.0;
$prob = [];
$leftLabel = $this->binaryLabels[0];
$rightLabel = $this->binaryLabels[1];
foreach ($values as $index => $value) {
if (Comp... | [
"protected",
"function",
"calculateErrorRate",
"(",
"array",
"$",
"targets",
",",
"float",
"$",
"threshold",
",",
"string",
"$",
"operator",
",",
"array",
"$",
"values",
")",
":",
"array",
"{",
"$",
"wrong",
"=",
"0.0",
";",
"$",
"prob",
"=",
"[",
"]",... | Calculates the ratio of wrong predictions based on the new threshold
value given as the parameter | [
"Calculates",
"the",
"ratio",
"of",
"wrong",
"predictions",
"based",
"on",
"the",
"new",
"threshold",
"value",
"given",
"as",
"the",
"parameter"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/DecisionStump.php#L246-L284 |
208,790 | php-ai/php-ml | src/Classification/Linear/DecisionStump.php | DecisionStump.predictProbability | protected function predictProbability(array $sample, $label): float
{
$predicted = $this->predictSampleBinary($sample);
if ((string) $predicted == (string) $label) {
return $this->prob[$label];
}
return 0.0;
} | php | protected function predictProbability(array $sample, $label): float
{
$predicted = $this->predictSampleBinary($sample);
if ((string) $predicted == (string) $label) {
return $this->prob[$label];
}
return 0.0;
} | [
"protected",
"function",
"predictProbability",
"(",
"array",
"$",
"sample",
",",
"$",
"label",
")",
":",
"float",
"{",
"$",
"predicted",
"=",
"$",
"this",
"->",
"predictSampleBinary",
"(",
"$",
"sample",
")",
";",
"if",
"(",
"(",
"string",
")",
"$",
"p... | Returns the probability of the sample of belonging to the given label
Probability of a sample is calculated as the proportion of the label
within the labels of the training samples in the decision node
@param mixed $label | [
"Returns",
"the",
"probability",
"of",
"the",
"sample",
"of",
"belonging",
"to",
"the",
"given",
"label"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/DecisionStump.php#L294-L302 |
208,791 | php-ai/php-ml | src/Helper/OneVsRest.php | OneVsRest.train | public function train(array $samples, array $targets): void
{
// Clears previous stuff.
$this->reset();
$this->trainByLabel($samples, $targets);
} | php | public function train(array $samples, array $targets): void
{
// Clears previous stuff.
$this->reset();
$this->trainByLabel($samples, $targets);
} | [
"public",
"function",
"train",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
")",
":",
"void",
"{",
"// Clears previous stuff.",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"$",
"this",
"->",
"trainByLabel",
"(",
"$",
"samples",
",",
"$",
... | Train a binary classifier in the OvR style | [
"Train",
"a",
"binary",
"classifier",
"in",
"the",
"OvR",
"style"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/OneVsRest.php#L31-L37 |
208,792 | php-ai/php-ml | src/Helper/OneVsRest.php | OneVsRest.reset | public function reset(): void
{
$this->classifiers = [];
$this->allLabels = [];
$this->costValues = [];
$this->resetBinary();
} | php | public function reset(): void
{
$this->classifiers = [];
$this->allLabels = [];
$this->costValues = [];
$this->resetBinary();
} | [
"public",
"function",
"reset",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"classifiers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"allLabels",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"costValues",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"resetBin... | Resets the classifier and the vars internally used by OneVsRest to create multiple classifiers. | [
"Resets",
"the",
"classifier",
"and",
"the",
"vars",
"internally",
"used",
"by",
"OneVsRest",
"to",
"create",
"multiple",
"classifiers",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/OneVsRest.php#L42-L49 |
208,793 | php-ai/php-ml | src/Helper/Optimizer/GD.php | GD.gradient | protected function gradient(array $theta): array
{
$costs = [];
$gradient = [];
$totalPenalty = 0;
if ($this->gradientCb === null) {
throw new InvalidOperationException('Gradient callback is not defined');
}
foreach ($this->samples as $index => $sample) ... | php | protected function gradient(array $theta): array
{
$costs = [];
$gradient = [];
$totalPenalty = 0;
if ($this->gradientCb === null) {
throw new InvalidOperationException('Gradient callback is not defined');
}
foreach ($this->samples as $index => $sample) ... | [
"protected",
"function",
"gradient",
"(",
"array",
"$",
"theta",
")",
":",
"array",
"{",
"$",
"costs",
"=",
"[",
"]",
";",
"$",
"gradient",
"=",
"[",
"]",
";",
"$",
"totalPenalty",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"gradientCb",
"===",
... | Calculates gradient, cost function and penalty term for each sample
then returns them as an array of values | [
"Calculates",
"gradient",
"cost",
"function",
"and",
"penalty",
"term",
"for",
"each",
"sample",
"then",
"returns",
"them",
"as",
"an",
"array",
"of",
"values"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/Optimizer/GD.php#L57-L81 |
208,794 | php-ai/php-ml | src/DimensionReduction/EigenTransformerBase.php | EigenTransformerBase.reduce | protected function reduce(array $data): array
{
$m1 = new Matrix($data);
$m2 = new Matrix($this->eigVectors);
return $m1->multiply($m2->transpose())->toArray();
} | php | protected function reduce(array $data): array
{
$m1 = new Matrix($data);
$m2 = new Matrix($this->eigVectors);
return $m1->multiply($m2->transpose())->toArray();
} | [
"protected",
"function",
"reduce",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"m1",
"=",
"new",
"Matrix",
"(",
"$",
"data",
")",
";",
"$",
"m2",
"=",
"new",
"Matrix",
"(",
"$",
"this",
"->",
"eigVectors",
")",
";",
"return",
"$",
"m1... | Returns the reduced data | [
"Returns",
"the",
"reduced",
"data"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/EigenTransformerBase.php#L87-L93 |
208,795 | php-ai/php-ml | src/Classification/Linear/Adaline.php | Adaline.runTraining | protected function runTraining(array $samples, array $targets): void
{
// The cost function is the sum of squares
$callback = function ($weights, $sample, $target) {
$this->weights = $weights;
$output = $this->output($sample);
$gradient = $output - $target;
... | php | protected function runTraining(array $samples, array $targets): void
{
// The cost function is the sum of squares
$callback = function ($weights, $sample, $target) {
$this->weights = $weights;
$output = $this->output($sample);
$gradient = $output - $target;
... | [
"protected",
"function",
"runTraining",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
")",
":",
"void",
"{",
"// The cost function is the sum of squares",
"$",
"callback",
"=",
"function",
"(",
"$",
"weights",
",",
"$",
"sample",
",",
"$",
"targe... | Adapts the weights with respect to given samples and targets
by use of gradient descent learning rule | [
"Adapts",
"the",
"weights",
"with",
"respect",
"to",
"given",
"samples",
"and",
"targets",
"by",
"use",
"of",
"gradient",
"descent",
"learning",
"rule"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/Adaline.php#L58-L74 |
208,796 | hhxsv5/laravel-s | src/Swoole/Task/Task.php | Task.deliver | public static function deliver(Task $task, $bySendMessage = false)
{
$task->bySendMessage = $bySendMessage;
$deliver = function () use ($task, $bySendMessage) {
/**
* @var \swoole_http_server $swoole
*/
$swoole = app('swoole');
if ($bySen... | php | public static function deliver(Task $task, $bySendMessage = false)
{
$task->bySendMessage = $bySendMessage;
$deliver = function () use ($task, $bySendMessage) {
/**
* @var \swoole_http_server $swoole
*/
$swoole = app('swoole');
if ($bySen... | [
"public",
"static",
"function",
"deliver",
"(",
"Task",
"$",
"task",
",",
"$",
"bySendMessage",
"=",
"false",
")",
"{",
"$",
"task",
"->",
"bySendMessage",
"=",
"$",
"bySendMessage",
";",
"$",
"deliver",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"tas... | Deliver a task
@param Task $task The task object
@param bool $bySendMessage If set to true, the task will be delivered via the pipe message, and this task does not support the finish callback. Default false.
@return bool | [
"Deliver",
"a",
"task"
] | 247b86c9d5aee0f347f1b37fe89d739f806057bd | https://github.com/hhxsv5/laravel-s/blob/247b86c9d5aee0f347f1b37fe89d739f806057bd/src/Swoole/Task/Task.php#L54-L89 |
208,797 | matomo-org/matomo | plugins/Actions/Archiver.php | Archiver.aggregateDayReport | public function aggregateDayReport()
{
$rankingQueryLimit = ArchivingHelper::getRankingQueryLimit();
ArchivingHelper::reloadConfig();
$this->initActionsTables();
$this->archiveDayPageActions($rankingQueryLimit);
$this->archiveDaySiteSearchActions($rankingQueryLimit);
... | php | public function aggregateDayReport()
{
$rankingQueryLimit = ArchivingHelper::getRankingQueryLimit();
ArchivingHelper::reloadConfig();
$this->initActionsTables();
$this->archiveDayPageActions($rankingQueryLimit);
$this->archiveDaySiteSearchActions($rankingQueryLimit);
... | [
"public",
"function",
"aggregateDayReport",
"(",
")",
"{",
"$",
"rankingQueryLimit",
"=",
"ArchivingHelper",
"::",
"getRankingQueryLimit",
"(",
")",
";",
"ArchivingHelper",
"::",
"reloadConfig",
"(",
")",
";",
"$",
"this",
"->",
"initActionsTables",
"(",
")",
";... | Archives Actions reports for a Day
@return bool | [
"Archives",
"Actions",
"reports",
"for",
"a",
"Day"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/Archiver.php#L55-L71 |
208,798 | matomo-org/matomo | plugins/Actions/Archiver.php | Archiver.initActionsTables | private function initActionsTables()
{
$this->actionsTablesByType = array();
foreach (Metrics::$actionTypes as $type) {
$dataTable = new DataTable();
if ($type === Action::TYPE_SITE_SEARCH) {
$maxRows = ArchivingHelper::$maximumRowsInDataTableSiteSearch;
... | php | private function initActionsTables()
{
$this->actionsTablesByType = array();
foreach (Metrics::$actionTypes as $type) {
$dataTable = new DataTable();
if ($type === Action::TYPE_SITE_SEARCH) {
$maxRows = ArchivingHelper::$maximumRowsInDataTableSiteSearch;
... | [
"private",
"function",
"initActionsTables",
"(",
")",
"{",
"$",
"this",
"->",
"actionsTablesByType",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Metrics",
"::",
"$",
"actionTypes",
"as",
"$",
"type",
")",
"{",
"$",
"dataTable",
"=",
"new",
"DataTable",
... | Initializes the DataTables created by the archiveDay function. | [
"Initializes",
"the",
"DataTables",
"created",
"by",
"the",
"archiveDay",
"function",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/Archiver.php#L130-L151 |
208,799 | matomo-org/matomo | plugins/Actions/Archiver.php | Archiver.archiveDayEntryActions | protected function archiveDayEntryActions($rankingQueryLimit)
{
$rankingQuery = false;
if ($rankingQueryLimit > 0) {
$rankingQuery = new RankingQuery($rankingQueryLimit);
$rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW);
$rankingQuery->addLabelColumn('i... | php | protected function archiveDayEntryActions($rankingQueryLimit)
{
$rankingQuery = false;
if ($rankingQueryLimit > 0) {
$rankingQuery = new RankingQuery($rankingQueryLimit);
$rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW);
$rankingQuery->addLabelColumn('i... | [
"protected",
"function",
"archiveDayEntryActions",
"(",
"$",
"rankingQueryLimit",
")",
"{",
"$",
"rankingQuery",
"=",
"false",
";",
"if",
"(",
"$",
"rankingQueryLimit",
">",
"0",
")",
"{",
"$",
"rankingQuery",
"=",
"new",
"RankingQuery",
"(",
"$",
"rankingQuer... | Entry actions for Page URLs and Page names | [
"Entry",
"actions",
"for",
"Page",
"URLs",
"and",
"Page",
"names"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/Archiver.php#L279-L323 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.