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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
10,800 | iMoneza/imoneza-php-api | src/iMoneza/Connection.php | Connection.handleRequestError | protected function handleRequestError($result)
{
/**
* Curl error
*/
if ($result === false) {
throw new Exception\TransferError($this->request->getErrorString(), $this->request->getErrorCode());
}
switch ($this->request->getResponseHTTPCode()) {
case 401:
$this->error($result, ['CODE'=>401]);
throw new Exception\AuthenticationFailure($result, 401);
break;
case 403:
$this->error($result, ['CODE'=>403]);
throw new Exception\AccessDenied($result, 403);
break;
case 404:
//sometimes it's a json string, sometimes it's not... so there's that.
if (stripos($result, '{') === 0) {
$error = json_decode($result);
$errorMessage = $error->Message;
}
else {
$errorMessage = $result;
}
$this->error($errorMessage, ['CODE'=>404]);
throw new Exception\NotFound($errorMessage, 404);
break;
}
} | php | protected function handleRequestError($result)
{
/**
* Curl error
*/
if ($result === false) {
throw new Exception\TransferError($this->request->getErrorString(), $this->request->getErrorCode());
}
switch ($this->request->getResponseHTTPCode()) {
case 401:
$this->error($result, ['CODE'=>401]);
throw new Exception\AuthenticationFailure($result, 401);
break;
case 403:
$this->error($result, ['CODE'=>403]);
throw new Exception\AccessDenied($result, 403);
break;
case 404:
//sometimes it's a json string, sometimes it's not... so there's that.
if (stripos($result, '{') === 0) {
$error = json_decode($result);
$errorMessage = $error->Message;
}
else {
$errorMessage = $result;
}
$this->error($errorMessage, ['CODE'=>404]);
throw new Exception\NotFound($errorMessage, 404);
break;
}
} | [
"protected",
"function",
"handleRequestError",
"(",
"$",
"result",
")",
"{",
"/**\n * Curl error\n */",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"TransferError",
"(",
"$",
"this",
"->",
"request",
"->",
"getErrorString",
"(",
")",
",",
"$",
"this",
"->",
"request",
"->",
"getErrorCode",
"(",
")",
")",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"request",
"->",
"getResponseHTTPCode",
"(",
")",
")",
"{",
"case",
"401",
":",
"$",
"this",
"->",
"error",
"(",
"$",
"result",
",",
"[",
"'CODE'",
"=>",
"401",
"]",
")",
";",
"throw",
"new",
"Exception",
"\\",
"AuthenticationFailure",
"(",
"$",
"result",
",",
"401",
")",
";",
"break",
";",
"case",
"403",
":",
"$",
"this",
"->",
"error",
"(",
"$",
"result",
",",
"[",
"'CODE'",
"=>",
"403",
"]",
")",
";",
"throw",
"new",
"Exception",
"\\",
"AccessDenied",
"(",
"$",
"result",
",",
"403",
")",
";",
"break",
";",
"case",
"404",
":",
"//sometimes it's a json string, sometimes it's not... so there's that.",
"if",
"(",
"stripos",
"(",
"$",
"result",
",",
"'{'",
")",
"===",
"0",
")",
"{",
"$",
"error",
"=",
"json_decode",
"(",
"$",
"result",
")",
";",
"$",
"errorMessage",
"=",
"$",
"error",
"->",
"Message",
";",
"}",
"else",
"{",
"$",
"errorMessage",
"=",
"$",
"result",
";",
"}",
"$",
"this",
"->",
"error",
"(",
"$",
"errorMessage",
",",
"[",
"'CODE'",
"=>",
"404",
"]",
")",
";",
"throw",
"new",
"Exception",
"\\",
"NotFound",
"(",
"$",
"errorMessage",
",",
"404",
")",
";",
"break",
";",
"}",
"}"
] | Handles a potential request error by throwing a useful exception
@param $result string|false
@throws Exception\AccessDenied
@throws Exception\AuthenticationFailure
@throws Exception\NotFound
@throws Exception\TransferError | [
"Handles",
"a",
"potential",
"request",
"error",
"by",
"throwing",
"a",
"useful",
"exception"
] | 8347702c88c3cf754d21631a304a2c2d3abac98e | https://github.com/iMoneza/imoneza-php-api/blob/8347702c88c3cf754d21631a304a2c2d3abac98e/src/iMoneza/Connection.php#L185-L216 |
10,801 | osflab/view | Helper/Bootstrap/Addon/Popover.php | Popover.setPopover | public function setPopover(string $title, string $txt, $placement = null, $html = null, $container = null, $delay = null)
{
$this->popover = ['title' => $title, 'data-content' => $txt];
$this->popoverOptions['title'] = $title;
$placement !== null && Checkers::checkPlacement($placement);
$placement !== null && $this->popoverOptions['data-placement'] = $placement;
$html !== null && $this->popoverOptions['data-html'] = (int) (bool) $html;
$container !== null && $this->popoverOptions['data-container'] = (string) $container;
$delay !== null && $this->popoverOptions['data-delay'] = (int) $delay;
return $this;
} | php | public function setPopover(string $title, string $txt, $placement = null, $html = null, $container = null, $delay = null)
{
$this->popover = ['title' => $title, 'data-content' => $txt];
$this->popoverOptions['title'] = $title;
$placement !== null && Checkers::checkPlacement($placement);
$placement !== null && $this->popoverOptions['data-placement'] = $placement;
$html !== null && $this->popoverOptions['data-html'] = (int) (bool) $html;
$container !== null && $this->popoverOptions['data-container'] = (string) $container;
$delay !== null && $this->popoverOptions['data-delay'] = (int) $delay;
return $this;
} | [
"public",
"function",
"setPopover",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"txt",
",",
"$",
"placement",
"=",
"null",
",",
"$",
"html",
"=",
"null",
",",
"$",
"container",
"=",
"null",
",",
"$",
"delay",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"popover",
"=",
"[",
"'title'",
"=>",
"$",
"title",
",",
"'data-content'",
"=>",
"$",
"txt",
"]",
";",
"$",
"this",
"->",
"popoverOptions",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"$",
"placement",
"!==",
"null",
"&&",
"Checkers",
"::",
"checkPlacement",
"(",
"$",
"placement",
")",
";",
"$",
"placement",
"!==",
"null",
"&&",
"$",
"this",
"->",
"popoverOptions",
"[",
"'data-placement'",
"]",
"=",
"$",
"placement",
";",
"$",
"html",
"!==",
"null",
"&&",
"$",
"this",
"->",
"popoverOptions",
"[",
"'data-html'",
"]",
"=",
"(",
"int",
")",
"(",
"bool",
")",
"$",
"html",
";",
"$",
"container",
"!==",
"null",
"&&",
"$",
"this",
"->",
"popoverOptions",
"[",
"'data-container'",
"]",
"=",
"(",
"string",
")",
"$",
"container",
";",
"$",
"delay",
"!==",
"null",
"&&",
"$",
"this",
"->",
"popoverOptions",
"[",
"'data-delay'",
"]",
"=",
"(",
"int",
")",
"$",
"delay",
";",
"return",
"$",
"this",
";",
"}"
] | Help bubble with title
@param string $title
@param string $txt
@param string $placement top, bottom, left, right
@param bool $html to put HTML instead of text
@param string $container 'body' or name of the tag to attache to the popover
@param int $delay délai de l'animation (ms)
@return $this | [
"Help",
"bubble",
"with",
"title"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Addon/Popover.php#L39-L49 |
10,802 | osflab/view | Helper/Bootstrap/Addon/Popover.php | Popover.getPopoverAttributes | public function getPopoverAttributes():array
{
if ($this->popover !== null) {
Component::getJquery()->enablePopovers();
$attrs = $this->popoverOptions;
$attrs['data-toggle'] = 'popover';
$attrs['title'] = $this->popover['title'];
$attrs['data-content'] = $this->popover['data-content'];
return $attrs;
}
return [];
} | php | public function getPopoverAttributes():array
{
if ($this->popover !== null) {
Component::getJquery()->enablePopovers();
$attrs = $this->popoverOptions;
$attrs['data-toggle'] = 'popover';
$attrs['title'] = $this->popover['title'];
$attrs['data-content'] = $this->popover['data-content'];
return $attrs;
}
return [];
} | [
"public",
"function",
"getPopoverAttributes",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"popover",
"!==",
"null",
")",
"{",
"Component",
"::",
"getJquery",
"(",
")",
"->",
"enablePopovers",
"(",
")",
";",
"$",
"attrs",
"=",
"$",
"this",
"->",
"popoverOptions",
";",
"$",
"attrs",
"[",
"'data-toggle'",
"]",
"=",
"'popover'",
";",
"$",
"attrs",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"popover",
"[",
"'title'",
"]",
";",
"$",
"attrs",
"[",
"'data-content'",
"]",
"=",
"$",
"this",
"->",
"popover",
"[",
"'data-content'",
"]",
";",
"return",
"$",
"attrs",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Get attributes and active popovers for jquery
@return array | [
"Get",
"attributes",
"and",
"active",
"popovers",
"for",
"jquery"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Addon/Popover.php#L55-L66 |
10,803 | mschop/NoTeePHP | src/NodeFactory.php | NodeFactory.flatten | protected static function flatten(array $arguments) : array
{
$result = [];
foreach($arguments as $argument) {
if(is_array($argument)) {
$result = array_merge($result, $argument);
} elseif($argument !== null) {
$result[] = $argument;
}
}
return $result;
} | php | protected static function flatten(array $arguments) : array
{
$result = [];
foreach($arguments as $argument) {
if(is_array($argument)) {
$result = array_merge($result, $argument);
} elseif($argument !== null) {
$result[] = $argument;
}
}
return $result;
} | [
"protected",
"static",
"function",
"flatten",
"(",
"array",
"$",
"arguments",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"argument",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"argument",
")",
";",
"}",
"elseif",
"(",
"$",
"argument",
"!==",
"null",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"argument",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | An api consumer can pass arrays coming from function calls as children to the method "create". Elements in this
array are direct children of the node created with the method "create". Those must therefore be flattened.
@param array $arguments
@return array | [
"An",
"api",
"consumer",
"can",
"pass",
"arrays",
"coming",
"from",
"function",
"calls",
"as",
"children",
"to",
"the",
"method",
"create",
".",
"Elements",
"in",
"this",
"array",
"are",
"direct",
"children",
"of",
"the",
"node",
"created",
"with",
"the",
"method",
"create",
".",
"Those",
"must",
"therefore",
"be",
"flattened",
"."
] | 08186a0ff40df82cb0de9be8fb08f48f3e4e80b5 | https://github.com/mschop/NoTeePHP/blob/08186a0ff40df82cb0de9be8fb08f48f3e4e80b5/src/NodeFactory.php#L137-L148 |
10,804 | Stratadox/HydrationMapper | src/Mapper.php | Mapper.add | private function add(
string $property,
?InstructsHowToMap $instruction
): array {
return $this->properties + [$property => $instruction ?: Is::string()];
} | php | private function add(
string $property,
?InstructsHowToMap $instruction
): array {
return $this->properties + [$property => $instruction ?: Is::string()];
} | [
"private",
"function",
"add",
"(",
"string",
"$",
"property",
",",
"?",
"InstructsHowToMap",
"$",
"instruction",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"properties",
"+",
"[",
"$",
"property",
"=>",
"$",
"instruction",
"?",
":",
"Is",
"::",
"string",
"(",
")",
"]",
";",
"}"
] | Adds a property to the mapper.
@param string $property The name of the property.
@param InstructsHowToMap|null $instruction The instruction to follow.
@return InstructsHowToMap[] The map of properties to
mapping instructions. | [
"Adds",
"a",
"property",
"to",
"the",
"mapper",
"."
] | d9bf1f10b7626312e0a2466a2ef255ec972acb41 | https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Mapper.php#L109-L114 |
10,805 | nullivex/lib-datamodel | LSS/DataModel.php | DataModel._camelName | public static function _camelName($name,$prefix=null){
$name = str_replace('_',' ',$name);
$name = ucwords($name);
$name = str_replace(' ','',$name);
if(!is_null($prefix))
$name = lcfirst($name);
return $prefix.$name;
} | php | public static function _camelName($name,$prefix=null){
$name = str_replace('_',' ',$name);
$name = ucwords($name);
$name = str_replace(' ','',$name);
if(!is_null($prefix))
$name = lcfirst($name);
return $prefix.$name;
} | [
"public",
"static",
"function",
"_camelName",
"(",
"$",
"name",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"ucwords",
"(",
"$",
"name",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"prefix",
")",
")",
"$",
"name",
"=",
"lcfirst",
"(",
"$",
"name",
")",
";",
"return",
"$",
"prefix",
".",
"$",
"name",
";",
"}"
] | converts real_name into camelName | [
"converts",
"real_name",
"into",
"camelName"
] | da3ed52657371ed84dc255a2d4115e7a8b4280b8 | https://github.com/nullivex/lib-datamodel/blob/da3ed52657371ed84dc255a2d4115e7a8b4280b8/LSS/DataModel.php#L88-L95 |
10,806 | nullivex/lib-datamodel | LSS/DataModel.php | DataModel._realName | public static function _realName($name,$prefix=null){
$name = preg_replace('/^'.$prefix.'/','',$name);
$name = preg_replace('/([A-Z]{1})/','_$1',$name);
$name = strtolower($name);
$name = trim($name,'_');
return $name;
} | php | public static function _realName($name,$prefix=null){
$name = preg_replace('/^'.$prefix.'/','',$name);
$name = preg_replace('/([A-Z]{1})/','_$1',$name);
$name = strtolower($name);
$name = trim($name,'_');
return $name;
} | [
"public",
"static",
"function",
"_realName",
"(",
"$",
"name",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"preg_replace",
"(",
"'/^'",
".",
"$",
"prefix",
".",
"'/'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"preg_replace",
"(",
"'/([A-Z]{1})/'",
",",
"'_$1'",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
",",
"'_'",
")",
";",
"return",
"$",
"name",
";",
"}"
] | this converts camel case into real_case | [
"this",
"converts",
"camel",
"case",
"into",
"real_case"
] | da3ed52657371ed84dc255a2d4115e7a8b4280b8 | https://github.com/nullivex/lib-datamodel/blob/da3ed52657371ed84dc255a2d4115e7a8b4280b8/LSS/DataModel.php#L98-L104 |
10,807 | neemzy/patchwork-core | src/Model/Entity.php | Entity.getAsserts | public function getAsserts()
{
$metadata = $this->app['validator.mapping.class_metadata_factory']->getMetadataFor(get_class($this));
return array_map(
function ($member) {
return $member[0]->constraints;
},
$metadata->members
);
} | php | public function getAsserts()
{
$metadata = $this->app['validator.mapping.class_metadata_factory']->getMetadataFor(get_class($this));
return array_map(
function ($member) {
return $member[0]->constraints;
},
$metadata->members
);
} | [
"public",
"function",
"getAsserts",
"(",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"app",
"[",
"'validator.mapping.class_metadata_factory'",
"]",
"->",
"getMetadataFor",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"member",
")",
"{",
"return",
"$",
"member",
"[",
"0",
"]",
"->",
"constraints",
";",
"}",
",",
"$",
"metadata",
"->",
"members",
")",
";",
"}"
] | Model validation metadata getter
@return array | [
"Model",
"validation",
"metadata",
"getter"
] | 81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee | https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/Entity.php#L28-L38 |
10,808 | neemzy/patchwork-core | src/Model/Entity.php | Entity.dispatch | public function dispatch($method, $parameters = [])
{
$base = ucfirst($method);
$traits = $this->getRecursiveTraits();
foreach ($traits as $trait) {
$trait = explode('\\', $trait);
$trait = str_replace('model', '', strtolower(array_pop($trait)));
$method = $trait.$base;
if (method_exists($this, $method)) {
call_user_func_array([$this, $method], $parameters);
}
}
} | php | public function dispatch($method, $parameters = [])
{
$base = ucfirst($method);
$traits = $this->getRecursiveTraits();
foreach ($traits as $trait) {
$trait = explode('\\', $trait);
$trait = str_replace('model', '', strtolower(array_pop($trait)));
$method = $trait.$base;
if (method_exists($this, $method)) {
call_user_func_array([$this, $method], $parameters);
}
}
} | [
"public",
"function",
"dispatch",
"(",
"$",
"method",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"base",
"=",
"ucfirst",
"(",
"$",
"method",
")",
";",
"$",
"traits",
"=",
"$",
"this",
"->",
"getRecursiveTraits",
"(",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"$",
"trait",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"trait",
")",
";",
"$",
"trait",
"=",
"str_replace",
"(",
"'model'",
",",
"''",
",",
"strtolower",
"(",
"array_pop",
"(",
"$",
"trait",
")",
")",
")",
";",
"$",
"method",
"=",
"$",
"trait",
".",
"$",
"base",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"}",
"}"
] | Calls a given method on all the current's class used traits, based on a prefix
@param string $method Method name
@param array $parameters Method parameters
@return void | [
"Calls",
"a",
"given",
"method",
"on",
"all",
"the",
"current",
"s",
"class",
"used",
"traits",
"based",
"on",
"a",
"prefix"
] | 81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee | https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/Entity.php#L50-L65 |
10,809 | neemzy/patchwork-core | src/Model/Entity.php | Entity.getRecursiveTraits | private function getRecursiveTraits($class = null)
{
if (null == $class) {
$class = get_class($this);
}
$reflection = new \ReflectionClass($class);
$traits = array_keys($reflection->getTraits());
foreach ($traits as $trait) {
$traits = array_merge($traits, $this->getRecursiveTraits($trait));
}
if ($parent = $reflection->getParentClass()) {
$traits = array_merge($traits, $this->getRecursiveTraits($parent->getName()));
}
return $traits;
} | php | private function getRecursiveTraits($class = null)
{
if (null == $class) {
$class = get_class($this);
}
$reflection = new \ReflectionClass($class);
$traits = array_keys($reflection->getTraits());
foreach ($traits as $trait) {
$traits = array_merge($traits, $this->getRecursiveTraits($trait));
}
if ($parent = $reflection->getParentClass()) {
$traits = array_merge($traits, $this->getRecursiveTraits($parent->getName()));
}
return $traits;
} | [
"private",
"function",
"getRecursiveTraits",
"(",
"$",
"class",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"}",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"traits",
"=",
"array_keys",
"(",
"$",
"reflection",
"->",
"getTraits",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"$",
"traits",
"=",
"array_merge",
"(",
"$",
"traits",
",",
"$",
"this",
"->",
"getRecursiveTraits",
"(",
"$",
"trait",
")",
")",
";",
"}",
"if",
"(",
"$",
"parent",
"=",
"$",
"reflection",
"->",
"getParentClass",
"(",
")",
")",
"{",
"$",
"traits",
"=",
"array_merge",
"(",
"$",
"traits",
",",
"$",
"this",
"->",
"getRecursiveTraits",
"(",
"$",
"parent",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"traits",
";",
"}"
] | Gets a recursive list of traits used by a class
@param string $class Full class name
@return array | [
"Gets",
"a",
"recursive",
"list",
"of",
"traits",
"used",
"by",
"a",
"class"
] | 81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee | https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/Entity.php#L102-L120 |
10,810 | bishopb/vanilla | applications/vanilla/controllers/class.draftscontroller.php | DraftsController.Delete | public function Delete($DraftID = '', $TransientKey = '') {
$Form = Gdn::Factory('Form');
$Session = Gdn::Session();
if (
is_numeric($DraftID)
&& $DraftID > 0
&& $Session->UserID > 0
&& $Session->ValidateTransientKey($TransientKey)
) {
// Delete the draft
$Draft = $this->DraftModel->GetID($DraftID);
if ($Draft && !$this->DraftModel->Delete($DraftID))
$Form->AddError('Failed to delete discussion');
} else {
// Log an error
$Form->AddError('ErrPermission');
}
// Redirect
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$Target = GetIncomingValue('Target', '/vanilla/drafts');
Redirect($Target);
}
// Return any errors
if ($Form->ErrorCount() > 0)
$this->SetJson('ErrorMessage', $Form->Errors());
// Render default view
$this->Render();
} | php | public function Delete($DraftID = '', $TransientKey = '') {
$Form = Gdn::Factory('Form');
$Session = Gdn::Session();
if (
is_numeric($DraftID)
&& $DraftID > 0
&& $Session->UserID > 0
&& $Session->ValidateTransientKey($TransientKey)
) {
// Delete the draft
$Draft = $this->DraftModel->GetID($DraftID);
if ($Draft && !$this->DraftModel->Delete($DraftID))
$Form->AddError('Failed to delete discussion');
} else {
// Log an error
$Form->AddError('ErrPermission');
}
// Redirect
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
$Target = GetIncomingValue('Target', '/vanilla/drafts');
Redirect($Target);
}
// Return any errors
if ($Form->ErrorCount() > 0)
$this->SetJson('ErrorMessage', $Form->Errors());
// Render default view
$this->Render();
} | [
"public",
"function",
"Delete",
"(",
"$",
"DraftID",
"=",
"''",
",",
"$",
"TransientKey",
"=",
"''",
")",
"{",
"$",
"Form",
"=",
"Gdn",
"::",
"Factory",
"(",
"'Form'",
")",
";",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"DraftID",
")",
"&&",
"$",
"DraftID",
">",
"0",
"&&",
"$",
"Session",
"->",
"UserID",
">",
"0",
"&&",
"$",
"Session",
"->",
"ValidateTransientKey",
"(",
"$",
"TransientKey",
")",
")",
"{",
"// Delete the draft",
"$",
"Draft",
"=",
"$",
"this",
"->",
"DraftModel",
"->",
"GetID",
"(",
"$",
"DraftID",
")",
";",
"if",
"(",
"$",
"Draft",
"&&",
"!",
"$",
"this",
"->",
"DraftModel",
"->",
"Delete",
"(",
"$",
"DraftID",
")",
")",
"$",
"Form",
"->",
"AddError",
"(",
"'Failed to delete discussion'",
")",
";",
"}",
"else",
"{",
"// Log an error",
"$",
"Form",
"->",
"AddError",
"(",
"'ErrPermission'",
")",
";",
"}",
"// Redirect",
"if",
"(",
"$",
"this",
"->",
"_DeliveryType",
"===",
"DELIVERY_TYPE_ALL",
")",
"{",
"$",
"Target",
"=",
"GetIncomingValue",
"(",
"'Target'",
",",
"'/vanilla/drafts'",
")",
";",
"Redirect",
"(",
"$",
"Target",
")",
";",
"}",
"// Return any errors ",
"if",
"(",
"$",
"Form",
"->",
"ErrorCount",
"(",
")",
">",
"0",
")",
"$",
"this",
"->",
"SetJson",
"(",
"'ErrorMessage'",
",",
"$",
"Form",
"->",
"Errors",
"(",
")",
")",
";",
"// Render default view",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Delete a single draft.
Redirects user back to Index unless DeliveryType is set.
@since 2.0.0
@access public
@param int $DraftID Unique ID of draft to be deleted.
@param string $TransientKey Single-use hash to prove intent. | [
"Delete",
"a",
"single",
"draft",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/controllers/class.draftscontroller.php#L92-L122 |
10,811 | brosland/framework | src/Brosland/UI/SecurityPresenter.php | SecurityPresenter.hasMethodAnnotation | protected function hasMethodAnnotation($method, $annotation)
{
if (!$this->getReflection()->hasMethod($method))
{
return FALSE;
}
$rm = Method::from($this->getReflection()->getName(), $method);
return $rm->hasAnnotation($annotation);
} | php | protected function hasMethodAnnotation($method, $annotation)
{
if (!$this->getReflection()->hasMethod($method))
{
return FALSE;
}
$rm = Method::from($this->getReflection()->getName(), $method);
return $rm->hasAnnotation($annotation);
} | [
"protected",
"function",
"hasMethodAnnotation",
"(",
"$",
"method",
",",
"$",
"annotation",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getReflection",
"(",
")",
"->",
"hasMethod",
"(",
"$",
"method",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"rm",
"=",
"Method",
"::",
"from",
"(",
"$",
"this",
"->",
"getReflection",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"method",
")",
";",
"return",
"$",
"rm",
"->",
"hasAnnotation",
"(",
"$",
"annotation",
")",
";",
"}"
] | Checks if given method has a given annotation
@param string $method
@param string $annotation
@return bool | [
"Checks",
"if",
"given",
"method",
"has",
"a",
"given",
"annotation"
] | 8e1c66830779dd7c3de3cb2b4beef7df82f15b0b | https://github.com/brosland/framework/blob/8e1c66830779dd7c3de3cb2b4beef7df82f15b0b/src/Brosland/UI/SecurityPresenter.php#L119-L128 |
10,812 | brosland/framework | src/Brosland/UI/SecurityPresenter.php | SecurityPresenter.getAnnotation | protected function getAnnotation($reflection, $name)
{
$res = $reflection->getAnnotations();
if (isset($res[$name]))
{
if (sizeof($res[$name]) > 1)
{
return $res[$name];
}
return end($res[$name]);
}
return NULL;
} | php | protected function getAnnotation($reflection, $name)
{
$res = $reflection->getAnnotations();
if (isset($res[$name]))
{
if (sizeof($res[$name]) > 1)
{
return $res[$name];
}
return end($res[$name]);
}
return NULL;
} | [
"protected",
"function",
"getAnnotation",
"(",
"$",
"reflection",
",",
"$",
"name",
")",
"{",
"$",
"res",
"=",
"$",
"reflection",
"->",
"getAnnotations",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"res",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"sizeof",
"(",
"$",
"res",
"[",
"$",
"name",
"]",
")",
">",
"1",
")",
"{",
"return",
"$",
"res",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"end",
"(",
"$",
"res",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"NULL",
";",
"}"
] | Get all anotations of given name
@param object $reflection
@param string $name
@return mixed|null | [
"Get",
"all",
"anotations",
"of",
"given",
"name"
] | 8e1c66830779dd7c3de3cb2b4beef7df82f15b0b | https://github.com/brosland/framework/blob/8e1c66830779dd7c3de3cb2b4beef7df82f15b0b/src/Brosland/UI/SecurityPresenter.php#L137-L152 |
10,813 | dstockto/phergie-irc-plugin-react-magic-eightball | src/Plugin.php | Plugin.handleEvent | public function handleEvent(Event $event, Queue $queue)
{
if ($event instanceof UserEvent) {
$nick = $event->getNick();
$channel = $event->getSource();
$params = $event->getParams();
$text = $params['text'];
$matched = stripos($text, '8 ball') !== false;
if ($matched) {
$msg = $nick . ', the magic 8 ball says "' . $this->getMagicEightBallAnswer() . '"';
$queue->ircPrivmsg($channel, $msg);
}
}
} | php | public function handleEvent(Event $event, Queue $queue)
{
if ($event instanceof UserEvent) {
$nick = $event->getNick();
$channel = $event->getSource();
$params = $event->getParams();
$text = $params['text'];
$matched = stripos($text, '8 ball') !== false;
if ($matched) {
$msg = $nick . ', the magic 8 ball says "' . $this->getMagicEightBallAnswer() . '"';
$queue->ircPrivmsg($channel, $msg);
}
}
} | [
"public",
"function",
"handleEvent",
"(",
"Event",
"$",
"event",
",",
"Queue",
"$",
"queue",
")",
"{",
"if",
"(",
"$",
"event",
"instanceof",
"UserEvent",
")",
"{",
"$",
"nick",
"=",
"$",
"event",
"->",
"getNick",
"(",
")",
";",
"$",
"channel",
"=",
"$",
"event",
"->",
"getSource",
"(",
")",
";",
"$",
"params",
"=",
"$",
"event",
"->",
"getParams",
"(",
")",
";",
"$",
"text",
"=",
"$",
"params",
"[",
"'text'",
"]",
";",
"$",
"matched",
"=",
"stripos",
"(",
"$",
"text",
",",
"'8 ball'",
")",
"!==",
"false",
";",
"if",
"(",
"$",
"matched",
")",
"{",
"$",
"msg",
"=",
"$",
"nick",
".",
"', the magic 8 ball says \"'",
".",
"$",
"this",
"->",
"getMagicEightBallAnswer",
"(",
")",
".",
"'\"'",
";",
"$",
"queue",
"->",
"ircPrivmsg",
"(",
"$",
"channel",
",",
"$",
"msg",
")",
";",
"}",
"}",
"}"
] | Responds with a magic eight ball phrase when asked questions
@param \Phergie\Irc\Event\EventInterface $event
@param \Phergie\Irc\Bot\React\EventQueueInterface $queue | [
"Responds",
"with",
"a",
"magic",
"eight",
"ball",
"phrase",
"when",
"asked",
"questions"
] | 269a102982541e7a00165a0a97e3f849c5ee0205 | https://github.com/dstockto/phergie-irc-plugin-react-magic-eightball/blob/269a102982541e7a00165a0a97e3f849c5ee0205/src/Plugin.php#L57-L70 |
10,814 | extendsframework/extends-shell | src/Shell.php | Shell.getDefinition | protected function getDefinition(): DefinitionInterface
{
if ($this->definition === null) {
$this->definition = (new Definition())
->addOption(new Option('verbose', 'Be more verbose.', 'v', 'verbose', true, true))
->addOption(new Option('help', 'Show help about shell or command.', 'h', 'help'));
}
return $this->definition;
} | php | protected function getDefinition(): DefinitionInterface
{
if ($this->definition === null) {
$this->definition = (new Definition())
->addOption(new Option('verbose', 'Be more verbose.', 'v', 'verbose', true, true))
->addOption(new Option('help', 'Show help about shell or command.', 'h', 'help'));
}
return $this->definition;
} | [
"protected",
"function",
"getDefinition",
"(",
")",
":",
"DefinitionInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"definition",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"definition",
"=",
"(",
"new",
"Definition",
"(",
")",
")",
"->",
"addOption",
"(",
"new",
"Option",
"(",
"'verbose'",
",",
"'Be more verbose.'",
",",
"'v'",
",",
"'verbose'",
",",
"true",
",",
"true",
")",
")",
"->",
"addOption",
"(",
"new",
"Option",
"(",
"'help'",
",",
"'Show help about shell or command.'",
",",
"'h'",
",",
"'help'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"definition",
";",
"}"
] | Get definition for default options.
@return DefinitionInterface | [
"Get",
"definition",
"for",
"default",
"options",
"."
] | 115a38dd7e2af82d56d15407d7955da2d382521b | https://github.com/extendsframework/extends-shell/blob/115a38dd7e2af82d56d15407d7955da2d382521b/src/Shell.php#L197-L206 |
10,815 | dev-lucid/container | src/php/LockableTrait.php | LockableTrait.unlock | public function unlock(string $id) : LockableInterface
{
if (isset($this->locks[$id]) === true) {
unset($this->locks[$id]);
}
return $this;
} | php | public function unlock(string $id) : LockableInterface
{
if (isset($this->locks[$id]) === true) {
unset($this->locks[$id]);
}
return $this;
} | [
"public",
"function",
"unlock",
"(",
"string",
"$",
"id",
")",
":",
"LockableInterface",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"locks",
"[",
"$",
"id",
"]",
")",
"===",
"true",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"locks",
"[",
"$",
"id",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Unlocks an index
@param string $id The index to unlock | [
"Unlocks",
"an",
"index"
] | 546c0abfa3f30bb6705850b920692d4ab0e3872b | https://github.com/dev-lucid/container/blob/546c0abfa3f30bb6705850b920692d4ab0e3872b/src/php/LockableTrait.php#L43-L49 |
10,816 | codebobbly/dvoconnector | Classes/Domain/Repository/GenericRepository.php | GenericRepository.recursivCompleteEntity | private function recursivCompleteEntity($entity)
{
switch (true) {
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Repertoire::class):
return $this->metaRepository->findAssociationRepertoireByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Category::class):
return $this->metaRepository->findAssociationCategoryByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Performancelevel::class):
return $this->metaRepository->findAssociationPerformancelevelByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Event\Type::class):
return $this->metaRepository->findEventTypeByID($entity->getID());
break;
default:
$classSchema = $this->reflectionService->getClassSchema(get_class($entity));
foreach ($classSchema->getProperties() as $propertyName => $propertyDefinition) {
switch (true) {
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):
$objectStorage = $entity->_getProperty($propertyName);
$newObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$objectStorage->rewind();
while ($objectStorage->valid()) {
$subEntity = $objectStorage->current();
if (!is_null($subEntity)) {
$newSubEntity = $this->recursivCompleteEntity($subEntity);
if ($newSubEntity) {
$newObjectStorage->attach($newSubEntity);
} else {
$newObjectStorage->attach($subEntity);
}
}
$objectStorage->next();
}
$entity->_setProperty($propertyName, $newObjectStorage);
break;
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, true):
$subEntity = $entity->_getProperty($propertyName);
if (!is_null($subEntity)) {
$newSubEntity = $this->recursivCompleteEntity($subEntity);
$entity->_setProperty($propertyName, $newSubEntity);
}
break;
}
}
return $entity;
break;
}
} | php | private function recursivCompleteEntity($entity)
{
switch (true) {
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Repertoire::class):
return $this->metaRepository->findAssociationRepertoireByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Category::class):
return $this->metaRepository->findAssociationCategoryByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Association\Performancelevel::class):
return $this->metaRepository->findAssociationPerformancelevelByID($entity->getID());
break;
case is_a($entity, \RGU\Dvoconnector\Domain\Model\Meta\Event\Type::class):
return $this->metaRepository->findEventTypeByID($entity->getID());
break;
default:
$classSchema = $this->reflectionService->getClassSchema(get_class($entity));
foreach ($classSchema->getProperties() as $propertyName => $propertyDefinition) {
switch (true) {
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):
$objectStorage = $entity->_getProperty($propertyName);
$newObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$objectStorage->rewind();
while ($objectStorage->valid()) {
$subEntity = $objectStorage->current();
if (!is_null($subEntity)) {
$newSubEntity = $this->recursivCompleteEntity($subEntity);
if ($newSubEntity) {
$newObjectStorage->attach($newSubEntity);
} else {
$newObjectStorage->attach($subEntity);
}
}
$objectStorage->next();
}
$entity->_setProperty($propertyName, $newObjectStorage);
break;
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, true):
$subEntity = $entity->_getProperty($propertyName);
if (!is_null($subEntity)) {
$newSubEntity = $this->recursivCompleteEntity($subEntity);
$entity->_setProperty($propertyName, $newSubEntity);
}
break;
}
}
return $entity;
break;
}
} | [
"private",
"function",
"recursivCompleteEntity",
"(",
"$",
"entity",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_a",
"(",
"$",
"entity",
",",
"\\",
"RGU",
"\\",
"Dvoconnector",
"\\",
"Domain",
"\\",
"Model",
"\\",
"Meta",
"\\",
"Association",
"\\",
"Repertoire",
"::",
"class",
")",
":",
"return",
"$",
"this",
"->",
"metaRepository",
"->",
"findAssociationRepertoireByID",
"(",
"$",
"entity",
"->",
"getID",
"(",
")",
")",
";",
"break",
";",
"case",
"is_a",
"(",
"$",
"entity",
",",
"\\",
"RGU",
"\\",
"Dvoconnector",
"\\",
"Domain",
"\\",
"Model",
"\\",
"Meta",
"\\",
"Association",
"\\",
"Category",
"::",
"class",
")",
":",
"return",
"$",
"this",
"->",
"metaRepository",
"->",
"findAssociationCategoryByID",
"(",
"$",
"entity",
"->",
"getID",
"(",
")",
")",
";",
"break",
";",
"case",
"is_a",
"(",
"$",
"entity",
",",
"\\",
"RGU",
"\\",
"Dvoconnector",
"\\",
"Domain",
"\\",
"Model",
"\\",
"Meta",
"\\",
"Association",
"\\",
"Performancelevel",
"::",
"class",
")",
":",
"return",
"$",
"this",
"->",
"metaRepository",
"->",
"findAssociationPerformancelevelByID",
"(",
"$",
"entity",
"->",
"getID",
"(",
")",
")",
";",
"break",
";",
"case",
"is_a",
"(",
"$",
"entity",
",",
"\\",
"RGU",
"\\",
"Dvoconnector",
"\\",
"Domain",
"\\",
"Model",
"\\",
"Meta",
"\\",
"Event",
"\\",
"Type",
"::",
"class",
")",
":",
"return",
"$",
"this",
"->",
"metaRepository",
"->",
"findEventTypeByID",
"(",
"$",
"entity",
"->",
"getID",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"classSchema",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getClassSchema",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"foreach",
"(",
"$",
"classSchema",
"->",
"getProperties",
"(",
")",
"as",
"$",
"propertyName",
"=>",
"$",
"propertyDefinition",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_a",
"(",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"Persistence",
"\\",
"ObjectStorage",
"::",
"class",
",",
"true",
")",
":",
"$",
"objectStorage",
"=",
"$",
"entity",
"->",
"_getProperty",
"(",
"$",
"propertyName",
")",
";",
"$",
"newObjectStorage",
"=",
"new",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"Persistence",
"\\",
"ObjectStorage",
"(",
")",
";",
"$",
"objectStorage",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"objectStorage",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"subEntity",
"=",
"$",
"objectStorage",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"subEntity",
")",
")",
"{",
"$",
"newSubEntity",
"=",
"$",
"this",
"->",
"recursivCompleteEntity",
"(",
"$",
"subEntity",
")",
";",
"if",
"(",
"$",
"newSubEntity",
")",
"{",
"$",
"newObjectStorage",
"->",
"attach",
"(",
"$",
"newSubEntity",
")",
";",
"}",
"else",
"{",
"$",
"newObjectStorage",
"->",
"attach",
"(",
"$",
"subEntity",
")",
";",
"}",
"}",
"$",
"objectStorage",
"->",
"next",
"(",
")",
";",
"}",
"$",
"entity",
"->",
"_setProperty",
"(",
"$",
"propertyName",
",",
"$",
"newObjectStorage",
")",
";",
"break",
";",
"case",
"is_a",
"(",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"DomainObject",
"\\",
"AbstractEntity",
"::",
"class",
",",
"true",
")",
":",
"$",
"subEntity",
"=",
"$",
"entity",
"->",
"_getProperty",
"(",
"$",
"propertyName",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"subEntity",
")",
")",
"{",
"$",
"newSubEntity",
"=",
"$",
"this",
"->",
"recursivCompleteEntity",
"(",
"$",
"subEntity",
")",
";",
"$",
"entity",
"->",
"_setProperty",
"(",
"$",
"propertyName",
",",
"$",
"newSubEntity",
")",
";",
"}",
"break",
";",
"}",
"}",
"return",
"$",
"entity",
";",
"break",
";",
"}",
"}"
] | complete a entity
@param AbstractEntity entity
@return AbstractEntity | [
"complete",
"a",
"entity"
] | 9b63790d2fc9fd21bf415b4a5757678895b73bbc | https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Domain/Repository/GenericRepository.php#L51-L122 |
10,817 | paliari/php-date-time | src/Paliari/DateTime/TDateTime.php | TDateTime.prepareDate | protected static function prepareDate($date)
{
if (null === $date) {
return null;
}
if ($date instanceof DateTime) {
return static::timeToString($date->getTimestamp());
} elseif (is_numeric($date)) {
return static::timeToString($date);
} elseif (is_array($date)) {
return @$date['date'];
} elseif (self::hasTimestamp($date)) {
return static::timeToString($date->getTimestamp());
} elseif (is_string($date)) {
return false !== strtotime($date) ? $date : null;
}
return null;
} | php | protected static function prepareDate($date)
{
if (null === $date) {
return null;
}
if ($date instanceof DateTime) {
return static::timeToString($date->getTimestamp());
} elseif (is_numeric($date)) {
return static::timeToString($date);
} elseif (is_array($date)) {
return @$date['date'];
} elseif (self::hasTimestamp($date)) {
return static::timeToString($date->getTimestamp());
} elseif (is_string($date)) {
return false !== strtotime($date) ? $date : null;
}
return null;
} | [
"protected",
"static",
"function",
"prepareDate",
"(",
"$",
"date",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"date",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"date",
"instanceof",
"DateTime",
")",
"{",
"return",
"static",
"::",
"timeToString",
"(",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"date",
")",
")",
"{",
"return",
"static",
"::",
"timeToString",
"(",
"$",
"date",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"date",
")",
")",
"{",
"return",
"@",
"$",
"date",
"[",
"'date'",
"]",
";",
"}",
"elseif",
"(",
"self",
"::",
"hasTimestamp",
"(",
"$",
"date",
")",
")",
"{",
"return",
"static",
"::",
"timeToString",
"(",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"date",
")",
")",
"{",
"return",
"false",
"!==",
"strtotime",
"(",
"$",
"date",
")",
"?",
"$",
"date",
":",
"null",
";",
"}",
"return",
"null",
";",
"}"
] | Prepara data para validar.
@param mixed $date
@return null|string se for uma data valida retorna string no formato universal ou falso caso contrario. | [
"Prepara",
"data",
"para",
"validar",
"."
] | bc7df2867c9dd61583a21f751291abfd69a39d74 | https://github.com/paliari/php-date-time/blob/bc7df2867c9dd61583a21f751291abfd69a39d74/src/Paliari/DateTime/TDateTime.php#L485-L503 |
10,818 | interactivesolutions/honeycomb-resources | src/app/helpers/HCImageThumbs.php | HCImageThumbs.generate | public function generate(string $resourceId, string $thumbId, $quality = 100)
{
$setting = $this->getThumbSettings($thumbId);
$this->setThumbFolderName($setting);
$resource = $this->getResource($resourceId);
$file = $this->getOriginalFile($resource);
if( $file ) {
$image = $this->resizeImage($file, $setting);
// $image = $this->addWatermark($image, $setting);
$image->encode('jpg', $quality);
$image->save($this->getLocation($resource));
}
} | php | public function generate(string $resourceId, string $thumbId, $quality = 100)
{
$setting = $this->getThumbSettings($thumbId);
$this->setThumbFolderName($setting);
$resource = $this->getResource($resourceId);
$file = $this->getOriginalFile($resource);
if( $file ) {
$image = $this->resizeImage($file, $setting);
// $image = $this->addWatermark($image, $setting);
$image->encode('jpg', $quality);
$image->save($this->getLocation($resource));
}
} | [
"public",
"function",
"generate",
"(",
"string",
"$",
"resourceId",
",",
"string",
"$",
"thumbId",
",",
"$",
"quality",
"=",
"100",
")",
"{",
"$",
"setting",
"=",
"$",
"this",
"->",
"getThumbSettings",
"(",
"$",
"thumbId",
")",
";",
"$",
"this",
"->",
"setThumbFolderName",
"(",
"$",
"setting",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"getResource",
"(",
"$",
"resourceId",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"getOriginalFile",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"file",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"resizeImage",
"(",
"$",
"file",
",",
"$",
"setting",
")",
";",
"// $image = $this->addWatermark($image, $setting);",
"$",
"image",
"->",
"encode",
"(",
"'jpg'",
",",
"$",
"quality",
")",
";",
"$",
"image",
"->",
"save",
"(",
"$",
"this",
"->",
"getLocation",
"(",
"$",
"resource",
")",
")",
";",
"}",
"}"
] | Generate thumb by given params
@param string $resourceId
@param string $thumbId
@param int $quality | [
"Generate",
"thumb",
"by",
"given",
"params"
] | 79cfcce99f24ee1905d6b75ee19476d71381a520 | https://github.com/interactivesolutions/honeycomb-resources/blob/79cfcce99f24ee1905d6b75ee19476d71381a520/src/app/helpers/HCImageThumbs.php#L29-L45 |
10,819 | interactivesolutions/honeycomb-resources | src/app/helpers/HCImageThumbs.php | HCImageThumbs.getOriginalFile | protected function getOriginalFile($resource)
{
$file = null;
$path = storage_path('app/' . $resource->path);
if( ! File::exists($path) ) {
HCLog::error('R-THUMB-001', 'File not found at path: ' . $path);
} else if( $resource->isImage() || strpos($resource->mime_type, 'svg') !== false ) {
$file = File::get($path);
}
return $file;
} | php | protected function getOriginalFile($resource)
{
$file = null;
$path = storage_path('app/' . $resource->path);
if( ! File::exists($path) ) {
HCLog::error('R-THUMB-001', 'File not found at path: ' . $path);
} else if( $resource->isImage() || strpos($resource->mime_type, 'svg') !== false ) {
$file = File::get($path);
}
return $file;
} | [
"protected",
"function",
"getOriginalFile",
"(",
"$",
"resource",
")",
"{",
"$",
"file",
"=",
"null",
";",
"$",
"path",
"=",
"storage_path",
"(",
"'app/'",
".",
"$",
"resource",
"->",
"path",
")",
";",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"HCLog",
"::",
"error",
"(",
"'R-THUMB-001'",
",",
"'File not found at path: '",
".",
"$",
"path",
")",
";",
"}",
"else",
"if",
"(",
"$",
"resource",
"->",
"isImage",
"(",
")",
"||",
"strpos",
"(",
"$",
"resource",
"->",
"mime_type",
",",
"'svg'",
")",
"!==",
"false",
")",
"{",
"$",
"file",
"=",
"File",
"::",
"get",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] | Get original file instance
@param $resource
@return mixed | [
"Get",
"original",
"file",
"instance"
] | 79cfcce99f24ee1905d6b75ee19476d71381a520 | https://github.com/interactivesolutions/honeycomb-resources/blob/79cfcce99f24ee1905d6b75ee19476d71381a520/src/app/helpers/HCImageThumbs.php#L75-L87 |
10,820 | interactivesolutions/honeycomb-resources | src/app/helpers/HCImageThumbs.php | HCImageThumbs.resizeImage | protected function resizeImage($file, $setting)
{
$image = ImageManagerStatic::make($file);
if( $setting->fit === "1" ) {
$image->fit($setting->width, $setting->height, function ($constraint) use ($setting) {
$constraint->upsize();
});
} else {
$image->resize($setting->width, $setting->height, function ($constraint) use ($setting) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
return $image;
} | php | protected function resizeImage($file, $setting)
{
$image = ImageManagerStatic::make($file);
if( $setting->fit === "1" ) {
$image->fit($setting->width, $setting->height, function ($constraint) use ($setting) {
$constraint->upsize();
});
} else {
$image->resize($setting->width, $setting->height, function ($constraint) use ($setting) {
$constraint->aspectRatio();
$constraint->upsize();
});
}
return $image;
} | [
"protected",
"function",
"resizeImage",
"(",
"$",
"file",
",",
"$",
"setting",
")",
"{",
"$",
"image",
"=",
"ImageManagerStatic",
"::",
"make",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"setting",
"->",
"fit",
"===",
"\"1\"",
")",
"{",
"$",
"image",
"->",
"fit",
"(",
"$",
"setting",
"->",
"width",
",",
"$",
"setting",
"->",
"height",
",",
"function",
"(",
"$",
"constraint",
")",
"use",
"(",
"$",
"setting",
")",
"{",
"$",
"constraint",
"->",
"upsize",
"(",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"image",
"->",
"resize",
"(",
"$",
"setting",
"->",
"width",
",",
"$",
"setting",
"->",
"height",
",",
"function",
"(",
"$",
"constraint",
")",
"use",
"(",
"$",
"setting",
")",
"{",
"$",
"constraint",
"->",
"aspectRatio",
"(",
")",
";",
"$",
"constraint",
"->",
"upsize",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"image",
";",
"}"
] | Resize image by given settings
@param $file
@param $setting
@return mixed | [
"Resize",
"image",
"by",
"given",
"settings"
] | 79cfcce99f24ee1905d6b75ee19476d71381a520 | https://github.com/interactivesolutions/honeycomb-resources/blob/79cfcce99f24ee1905d6b75ee19476d71381a520/src/app/helpers/HCImageThumbs.php#L96-L112 |
10,821 | interactivesolutions/honeycomb-resources | src/app/helpers/HCImageThumbs.php | HCImageThumbs.setThumbFolderName | protected function setThumbFolderName($setting)
{
$name = getThumbName($setting);
$this->thumbsFolder = storage_path('app/public/thumbs/' . $name . DIRECTORY_SEPARATOR);
$this->createThumbsFolder($this->thumbsFolder);
} | php | protected function setThumbFolderName($setting)
{
$name = getThumbName($setting);
$this->thumbsFolder = storage_path('app/public/thumbs/' . $name . DIRECTORY_SEPARATOR);
$this->createThumbsFolder($this->thumbsFolder);
} | [
"protected",
"function",
"setThumbFolderName",
"(",
"$",
"setting",
")",
"{",
"$",
"name",
"=",
"getThumbName",
"(",
"$",
"setting",
")",
";",
"$",
"this",
"->",
"thumbsFolder",
"=",
"storage_path",
"(",
"'app/public/thumbs/'",
".",
"$",
"name",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"this",
"->",
"createThumbsFolder",
"(",
"$",
"this",
"->",
"thumbsFolder",
")",
";",
"}"
] | Get thumb folder name
@param $setting
@return string | [
"Get",
"thumb",
"folder",
"name"
] | 79cfcce99f24ee1905d6b75ee19476d71381a520 | https://github.com/interactivesolutions/honeycomb-resources/blob/79cfcce99f24ee1905d6b75ee19476d71381a520/src/app/helpers/HCImageThumbs.php#L227-L234 |
10,822 | phergie/phergie-irc-plugin-react-eventfilter | src/NotFilter.php | NotFilter.filter | public function filter(EventInterface $event)
{
$result = $this->filter->filter($event);
if ($result === null) {
return null;
}
return !$result;
} | php | public function filter(EventInterface $event)
{
$result = $this->filter->filter($event);
if ($result === null) {
return null;
}
return !$result;
} | [
"public",
"function",
"filter",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"filter",
"->",
"filter",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"!",
"$",
"result",
";",
"}"
] | Filters events that do not pass the contained filter.
@param \Phergie\Irc\Event\EventInterface $event
@return boolean|null TRUE if the contained filter fails, FALSE if it passes,
or NULL if it returns NULL. | [
"Filters",
"events",
"that",
"do",
"not",
"pass",
"the",
"contained",
"filter",
"."
] | 8fdde571a23ab1379d62a48e9de4570845c0e9dd | https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/NotFilter.php#L47-L54 |
10,823 | cidinho/Repository | src/EntityManager.php | EntityManager.get_instance | public static function get_instance() {
if (self::$_entityManager === null) {
self::initConfig();
//setando as configurações definidas anteriormente
$config = Setup::createAnnotationMetadataConfiguration(self::$settings['entidades'], self::$settings['isDevMod']);
$config->addCustomStringFunction('group_concat', 'Oro\ORM\Query\AST\Functions\String\GroupConcat');
$config->addCustomNumericFunction('hour', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
$config->addCustomNumericFunction('timestampdiff', 'Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff');
$config->addCustomDatetimeFunction('date', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
//criando o Entity Manager com base nas configurações de dev e banco de dados
self::$_entityManager = Em::create(self::$settings['dbParams'], $config);
}
return self::$_entityManager;
} | php | public static function get_instance() {
if (self::$_entityManager === null) {
self::initConfig();
//setando as configurações definidas anteriormente
$config = Setup::createAnnotationMetadataConfiguration(self::$settings['entidades'], self::$settings['isDevMod']);
$config->addCustomStringFunction('group_concat', 'Oro\ORM\Query\AST\Functions\String\GroupConcat');
$config->addCustomNumericFunction('hour', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
$config->addCustomNumericFunction('timestampdiff', 'Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff');
$config->addCustomDatetimeFunction('date', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
//criando o Entity Manager com base nas configurações de dev e banco de dados
self::$_entityManager = Em::create(self::$settings['dbParams'], $config);
}
return self::$_entityManager;
} | [
"public",
"static",
"function",
"get_instance",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_entityManager",
"===",
"null",
")",
"{",
"self",
"::",
"initConfig",
"(",
")",
";",
"//setando as configurações definidas anteriormente",
"$",
"config",
"=",
"Setup",
"::",
"createAnnotationMetadataConfiguration",
"(",
"self",
"::",
"$",
"settings",
"[",
"'entidades'",
"]",
",",
"self",
"::",
"$",
"settings",
"[",
"'isDevMod'",
"]",
")",
";",
"$",
"config",
"->",
"addCustomStringFunction",
"(",
"'group_concat'",
",",
"'Oro\\ORM\\Query\\AST\\Functions\\String\\GroupConcat'",
")",
";",
"$",
"config",
"->",
"addCustomNumericFunction",
"(",
"'hour'",
",",
"'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction'",
")",
";",
"$",
"config",
"->",
"addCustomNumericFunction",
"(",
"'timestampdiff'",
",",
"'Oro\\ORM\\Query\\AST\\Functions\\Numeric\\TimestampDiff'",
")",
";",
"$",
"config",
"->",
"addCustomDatetimeFunction",
"(",
"'date'",
",",
"'Oro\\ORM\\Query\\AST\\Functions\\SimpleFunction'",
")",
";",
"//criando o Entity Manager com base nas configurações de dev e banco de dados",
"self",
"::",
"$",
"_entityManager",
"=",
"Em",
"::",
"create",
"(",
"self",
"::",
"$",
"settings",
"[",
"'dbParams'",
"]",
",",
"$",
"config",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_entityManager",
";",
"}"
] | Retorna \Doctrine\ORM\EntityManager
@return Em | [
"Retorna",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"EntityManager"
] | 7905ebc02d1821fc267b7edfb699d0b41421e37f | https://github.com/cidinho/Repository/blob/7905ebc02d1821fc267b7edfb699d0b41421e37f/src/EntityManager.php#L72-L87 |
10,824 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/image/imagick.php | Image_Imagick.create_color | protected function create_color($hex, $alpha)
{
extract($this->create_hex_color($hex));
return new \ImagickPixel('rgba('.$red.', '.$green.', '.$blue.', '.round($alpha / 100, 2).')');
} | php | protected function create_color($hex, $alpha)
{
extract($this->create_hex_color($hex));
return new \ImagickPixel('rgba('.$red.', '.$green.', '.$blue.', '.round($alpha / 100, 2).')');
} | [
"protected",
"function",
"create_color",
"(",
"$",
"hex",
",",
"$",
"alpha",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"create_hex_color",
"(",
"$",
"hex",
")",
")",
";",
"return",
"new",
"\\",
"ImagickPixel",
"(",
"'rgba('",
".",
"$",
"red",
".",
"', '",
".",
"$",
"green",
".",
"', '",
".",
"$",
"blue",
".",
"', '",
".",
"round",
"(",
"$",
"alpha",
"/",
"100",
",",
"2",
")",
".",
"')'",
")",
";",
"}"
] | Creates a new color usable by Imagick.
@param string $hex The hex code of the color
@param integer $alpha The alpha of the color, 0 (trans) to 100 (opaque)
@return string rgba representation of the hex and alpha values. | [
"Creates",
"a",
"new",
"color",
"usable",
"by",
"Imagick",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/image/imagick.php#L281-L285 |
10,825 | vox-tecnologia/functions | src/Functions/ExtendedOperations/EasterEggFunctions.php | EasterEggFunctions.getLeflersLaw | public function getLeflersLaw($number = null): string
{
return in_array($number, array_keys($this->theLaws))
? $this->theLaws[$number]
: $this->theLaws[array_rand($this->theLaws, 1)];
} | php | public function getLeflersLaw($number = null): string
{
return in_array($number, array_keys($this->theLaws))
? $this->theLaws[$number]
: $this->theLaws[array_rand($this->theLaws, 1)];
} | [
"public",
"function",
"getLeflersLaw",
"(",
"$",
"number",
"=",
"null",
")",
":",
"string",
"{",
"return",
"in_array",
"(",
"$",
"number",
",",
"array_keys",
"(",
"$",
"this",
"->",
"theLaws",
")",
")",
"?",
"$",
"this",
"->",
"theLaws",
"[",
"$",
"number",
"]",
":",
"$",
"this",
"->",
"theLaws",
"[",
"array_rand",
"(",
"$",
"this",
"->",
"theLaws",
",",
"1",
")",
"]",
";",
"}"
] | Lefler's Laws.
Ensign Robin Lefler was a 24th century Starfleet officer who was stationed on board the USS Enterprise-D in 2368 and
became close with Wesley Crusher. Her parents were plasma specialists and moved around very often, so Lefler could
neither call a place 'home' nor develop friendships, claiming her first friend had been a tricorder. (TNG: "The Game")
Lefler served as mission specialist for a mission exploring the Phoenix Cluster. She had a brief romance with Wesley,
and she and Wesley foiled a plot by the Ktarians to take over the Enterprise (and subsequently, Starfleet), using an
addictive game to get control over the crew. (TNG: "The Game")
Robin created a set of 102 "Laws" to live by. "Every time I learn something essential," she explained, "I make up a law
about it, so I never forget." Below are the only laws to be found by Ensign Robin Lefler from an Internet search.
@param int $number The specific Lefler Law to return
@return string The random law will be returned if out-of-range, non-existent, or none provided
@api | [
"Lefler",
"s",
"Laws",
"."
] | 1da249ac87f9d7c46d1c714d65443cda9face807 | https://github.com/vox-tecnologia/functions/blob/1da249ac87f9d7c46d1c714d65443cda9face807/src/Functions/ExtendedOperations/EasterEggFunctions.php#L87-L92 |
10,826 | vpg/titon.common | src/Titon/Common/Traits/Instanceable.php | Instanceable.getInstance | public static function getInstance($key = 'default', array $params = []) {
$class = get_called_class();
if (isset(static::$_instances[$class][$key])) {
return static::$_instances[$class][$key];
}
$reflection = new ReflectionClass($class);
$object = $reflection->newInstanceArgs($params);
static::$_instances[$class][$key] = $object;
return $object;
} | php | public static function getInstance($key = 'default', array $params = []) {
$class = get_called_class();
if (isset(static::$_instances[$class][$key])) {
return static::$_instances[$class][$key];
}
$reflection = new ReflectionClass($class);
$object = $reflection->newInstanceArgs($params);
static::$_instances[$class][$key] = $object;
return $object;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"key",
"=",
"'default'",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"_instances",
"[",
"$",
"class",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"class",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"object",
"=",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"params",
")",
";",
"static",
"::",
"$",
"_instances",
"[",
"$",
"class",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"object",
";",
"return",
"$",
"object",
";",
"}"
] | Return an object instance else instantiate a new one.
@param string $key
@param array $params
@return $this | [
"Return",
"an",
"object",
"instance",
"else",
"instantiate",
"a",
"new",
"one",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Traits/Instanceable.php#L55-L68 |
10,827 | yinheark/yincart2-framework | base/base/Widget.php | Widget.renderJs | public function renderJs()
{
$jsLines = "\n";
if ($this->getView()->assetBundles) {
foreach ($this->getView()->assetBundles as $assetBundle) {
if (!$assetBundle->sourcePath) {
foreach ($assetBundle->js as $jsFile) {
$jsLines .= "\n" . Html::jsFile($jsFile, $assetBundle->jsOptions);
}
}
}
}
if ($this->getView()->jsFiles) {
foreach ($this->getView()->jsFiles as $jsFiles) {
$jsLines .= implode("\n", $jsFiles);
}
}
if ($this->getView()->js) {
foreach ($this->getView()->js as $js) {
$jsLines .= implode("\n", $js);
}
}
return $jsLines;
} | php | public function renderJs()
{
$jsLines = "\n";
if ($this->getView()->assetBundles) {
foreach ($this->getView()->assetBundles as $assetBundle) {
if (!$assetBundle->sourcePath) {
foreach ($assetBundle->js as $jsFile) {
$jsLines .= "\n" . Html::jsFile($jsFile, $assetBundle->jsOptions);
}
}
}
}
if ($this->getView()->jsFiles) {
foreach ($this->getView()->jsFiles as $jsFiles) {
$jsLines .= implode("\n", $jsFiles);
}
}
if ($this->getView()->js) {
foreach ($this->getView()->js as $js) {
$jsLines .= implode("\n", $js);
}
}
return $jsLines;
} | [
"public",
"function",
"renderJs",
"(",
")",
"{",
"$",
"jsLines",
"=",
"\"\\n\"",
";",
"if",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"assetBundles",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"assetBundles",
"as",
"$",
"assetBundle",
")",
"{",
"if",
"(",
"!",
"$",
"assetBundle",
"->",
"sourcePath",
")",
"{",
"foreach",
"(",
"$",
"assetBundle",
"->",
"js",
"as",
"$",
"jsFile",
")",
"{",
"$",
"jsLines",
".=",
"\"\\n\"",
".",
"Html",
"::",
"jsFile",
"(",
"$",
"jsFile",
",",
"$",
"assetBundle",
"->",
"jsOptions",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"jsFiles",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"jsFiles",
"as",
"$",
"jsFiles",
")",
"{",
"$",
"jsLines",
".=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"jsFiles",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"js",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"js",
"as",
"$",
"js",
")",
"{",
"$",
"jsLines",
".=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"js",
")",
";",
"}",
"}",
"return",
"$",
"jsLines",
";",
"}"
] | render js in page
@return string | [
"render",
"js",
"in",
"page"
] | c37421924abeba63337c685bfa31ece9997ac27d | https://github.com/yinheark/yincart2-framework/blob/c37421924abeba63337c685bfa31ece9997ac27d/base/base/Widget.php#L55-L78 |
10,828 | nuffleapp/nuffle-php | src/Nuffle.php | Calculator.calculate | public function calculate() {
// reset the rolls array
$this->rolls = array();
// throw rolls and replace 'xdy' dice notation with results
$this->equation = preg_replace_callback("/(?P<count>\d+)d(?P<sides>\d+)/i", "self::_expand_equation", $this->input);
// calculate result
$this->result = @eval("return $this->equation;");
return $this;
} | php | public function calculate() {
// reset the rolls array
$this->rolls = array();
// throw rolls and replace 'xdy' dice notation with results
$this->equation = preg_replace_callback("/(?P<count>\d+)d(?P<sides>\d+)/i", "self::_expand_equation", $this->input);
// calculate result
$this->result = @eval("return $this->equation;");
return $this;
} | [
"public",
"function",
"calculate",
"(",
")",
"{",
"// reset the rolls array",
"$",
"this",
"->",
"rolls",
"=",
"array",
"(",
")",
";",
"// throw rolls and replace 'xdy' dice notation with results",
"$",
"this",
"->",
"equation",
"=",
"preg_replace_callback",
"(",
"\"/(?P<count>\\d+)d(?P<sides>\\d+)/i\"",
",",
"\"self::_expand_equation\"",
",",
"$",
"this",
"->",
"input",
")",
";",
"// calculate result",
"$",
"this",
"->",
"result",
"=",
"@",
"eval",
"(",
"\"return $this->equation;\"",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Calculate the results based on the user input
@return object | [
"Calculate",
"the",
"results",
"based",
"on",
"the",
"user",
"input"
] | 4c9cfd1a0f09592ea161b9c72486631613067722 | https://github.com/nuffleapp/nuffle-php/blob/4c9cfd1a0f09592ea161b9c72486631613067722/src/Nuffle.php#L67-L78 |
10,829 | nuffleapp/nuffle-php | src/Nuffle.php | Calculator._validate | private function _validate($input) {
// has to be something we can calculate
if ( !is_string($input) && !is_numeric($input) ) {
throw new \Exception("Input must be an equation or a number.");
}
// no empty inputs
if ( trim($input) === '' ) {
throw new \Exception("Input can't be blank.");
}
// validate the input format
if ( !preg_match("/^[\(\s]*(([1-9][0-9]*d[1-9][0-9]*)|\d+)[\s\)]*(\s*([\-\+\*\/])[\s\(]*(([1-9][0-9]*d[1-9][0-9]*)|\d+)\)*)*$/i", $input) ) {
throw new \Exception("Invalid equation.");
}
// make sure the parens are balanced
if ( !$this->_is_balanced($input) ) {
throw new \Exception("Unbalanced parens.");
}
$this->input = $input;
} | php | private function _validate($input) {
// has to be something we can calculate
if ( !is_string($input) && !is_numeric($input) ) {
throw new \Exception("Input must be an equation or a number.");
}
// no empty inputs
if ( trim($input) === '' ) {
throw new \Exception("Input can't be blank.");
}
// validate the input format
if ( !preg_match("/^[\(\s]*(([1-9][0-9]*d[1-9][0-9]*)|\d+)[\s\)]*(\s*([\-\+\*\/])[\s\(]*(([1-9][0-9]*d[1-9][0-9]*)|\d+)\)*)*$/i", $input) ) {
throw new \Exception("Invalid equation.");
}
// make sure the parens are balanced
if ( !$this->_is_balanced($input) ) {
throw new \Exception("Unbalanced parens.");
}
$this->input = $input;
} | [
"private",
"function",
"_validate",
"(",
"$",
"input",
")",
"{",
"// has to be something we can calculate",
"if",
"(",
"!",
"is_string",
"(",
"$",
"input",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Input must be an equation or a number.\"",
")",
";",
"}",
"// no empty inputs",
"if",
"(",
"trim",
"(",
"$",
"input",
")",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Input can't be blank.\"",
")",
";",
"}",
"// validate the input format",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^[\\(\\s]*(([1-9][0-9]*d[1-9][0-9]*)|\\d+)[\\s\\)]*(\\s*([\\-\\+\\*\\/])[\\s\\(]*(([1-9][0-9]*d[1-9][0-9]*)|\\d+)\\)*)*$/i\"",
",",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid equation.\"",
")",
";",
"}",
"// make sure the parens are balanced",
"if",
"(",
"!",
"$",
"this",
"->",
"_is_balanced",
"(",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Unbalanced parens.\"",
")",
";",
"}",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"}"
] | Validate user input
@param string $input User input
@return void | [
"Validate",
"user",
"input"
] | 4c9cfd1a0f09592ea161b9c72486631613067722 | https://github.com/nuffleapp/nuffle-php/blob/4c9cfd1a0f09592ea161b9c72486631613067722/src/Nuffle.php#L86-L108 |
10,830 | nuffleapp/nuffle-php | src/Nuffle.php | Calculator._is_balanced | private function _is_balanced($input) {
$balance = 0;
foreach ( str_split($input) as $char ) {
if ( $char == '(' ) {
$balance++;
} else if ( $char == ')' ) {
$balance--;
}
// found a close paren without a matching open paren,
// no need to continue further
if ( $balance < 0 ) {
break;
}
}
return $balance === 0;
} | php | private function _is_balanced($input) {
$balance = 0;
foreach ( str_split($input) as $char ) {
if ( $char == '(' ) {
$balance++;
} else if ( $char == ')' ) {
$balance--;
}
// found a close paren without a matching open paren,
// no need to continue further
if ( $balance < 0 ) {
break;
}
}
return $balance === 0;
} | [
"private",
"function",
"_is_balanced",
"(",
"$",
"input",
")",
"{",
"$",
"balance",
"=",
"0",
";",
"foreach",
"(",
"str_split",
"(",
"$",
"input",
")",
"as",
"$",
"char",
")",
"{",
"if",
"(",
"$",
"char",
"==",
"'('",
")",
"{",
"$",
"balance",
"++",
";",
"}",
"else",
"if",
"(",
"$",
"char",
"==",
"')'",
")",
"{",
"$",
"balance",
"--",
";",
"}",
"// found a close paren without a matching open paren,",
"// no need to continue further",
"if",
"(",
"$",
"balance",
"<",
"0",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"balance",
"===",
"0",
";",
"}"
] | Check if equation has balanced parens
@param string $input User input
@return boolean Whether or not the parens are balanced | [
"Check",
"if",
"equation",
"has",
"balanced",
"parens"
] | 4c9cfd1a0f09592ea161b9c72486631613067722 | https://github.com/nuffleapp/nuffle-php/blob/4c9cfd1a0f09592ea161b9c72486631613067722/src/Nuffle.php#L116-L134 |
10,831 | nuffleapp/nuffle-php | src/Nuffle.php | Calculator._expand_equation | private function _expand_equation($matches) {
$rolls = array();
for ( $i = 0; $i < $matches['count']; $i++ ) {
$rolls[] = mt_rand(1, $matches['sides']);
}
// save individual roll results
$this->rolls[] = array(
'notation' => $matches[0],
'rolls' => $rolls
);
return "(" . implode(" + ", $rolls) . ")";
} | php | private function _expand_equation($matches) {
$rolls = array();
for ( $i = 0; $i < $matches['count']; $i++ ) {
$rolls[] = mt_rand(1, $matches['sides']);
}
// save individual roll results
$this->rolls[] = array(
'notation' => $matches[0],
'rolls' => $rolls
);
return "(" . implode(" + ", $rolls) . ")";
} | [
"private",
"function",
"_expand_equation",
"(",
"$",
"matches",
")",
"{",
"$",
"rolls",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"matches",
"[",
"'count'",
"]",
";",
"$",
"i",
"++",
")",
"{",
"$",
"rolls",
"[",
"]",
"=",
"mt_rand",
"(",
"1",
",",
"$",
"matches",
"[",
"'sides'",
"]",
")",
";",
"}",
"// save individual roll results",
"$",
"this",
"->",
"rolls",
"[",
"]",
"=",
"array",
"(",
"'notation'",
"=>",
"$",
"matches",
"[",
"0",
"]",
",",
"'rolls'",
"=>",
"$",
"rolls",
")",
";",
"return",
"\"(\"",
".",
"implode",
"(",
"\" + \"",
",",
"$",
"rolls",
")",
".",
"\")\"",
";",
"}"
] | Roll dice and expand the input into a matching equation
@param string $matches Regex match
@return string Replaced match | [
"Roll",
"dice",
"and",
"expand",
"the",
"input",
"into",
"a",
"matching",
"equation"
] | 4c9cfd1a0f09592ea161b9c72486631613067722 | https://github.com/nuffleapp/nuffle-php/blob/4c9cfd1a0f09592ea161b9c72486631613067722/src/Nuffle.php#L142-L156 |
10,832 | ehough/shortstop | src/main/php/ehough/shortstop/impl/exec/command/CurlCommand.php | ehough_shortstop_impl_exec_command_CurlCommand.tearDown | protected function tearDown()
{
if ($this->_logger->isHandling(ehough_epilog_Logger::DEBUG)) {
$this->_logger->debug('Closing cURL');
}
if (isset($this->_handle)) {
curl_close($this->_handle);
unset($this->_handle);
}
} | php | protected function tearDown()
{
if ($this->_logger->isHandling(ehough_epilog_Logger::DEBUG)) {
$this->_logger->debug('Closing cURL');
}
if (isset($this->_handle)) {
curl_close($this->_handle);
unset($this->_handle);
}
} | [
"protected",
"function",
"tearDown",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_logger",
"->",
"isHandling",
"(",
"ehough_epilog_Logger",
"::",
"DEBUG",
")",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"debug",
"(",
"'Closing cURL'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_handle",
")",
")",
"{",
"curl_close",
"(",
"$",
"this",
"->",
"_handle",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_handle",
")",
";",
"}",
"}"
] | Perform optional tear down after handling a request.
@return void | [
"Perform",
"optional",
"tear",
"down",
"after",
"handling",
"a",
"request",
"."
] | 4cef21457741347546c70e8e5c0cef6d3162b257 | https://github.com/ehough/shortstop/blob/4cef21457741347546c70e8e5c0cef6d3162b257/src/main/php/ehough/shortstop/impl/exec/command/CurlCommand.php#L165-L177 |
10,833 | tarsana/filesystem | src/Collection.php | Collection.add | public function add($item)
{
if (is_array($item)) {
foreach ($item as $element) {
$this->add($element);
}
} else if (! $this->contains($item->path())) {
$this->items[$item->path()] = [
'instance' => $item,
'listener_index' => $item->addPathListener([$this, 'updatePath'])
];
}
return $this;
} | php | public function add($item)
{
if (is_array($item)) {
foreach ($item as $element) {
$this->add($element);
}
} else if (! $this->contains($item->path())) {
$this->items[$item->path()] = [
'instance' => $item,
'listener_index' => $item->addPathListener([$this, 'updatePath'])
];
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"element",
")",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"item",
"->",
"path",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"item",
"->",
"path",
"(",
")",
"]",
"=",
"[",
"'instance'",
"=>",
"$",
"item",
",",
"'listener_index'",
"=>",
"$",
"item",
"->",
"addPathListener",
"(",
"[",
"$",
"this",
",",
"'updatePath'",
"]",
")",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds new items to the collection. If an
item already exists It will be ignored.
@param Tarsana\Filesystem\Interfaces\AbstractFile|array $item
@return self | [
"Adds",
"new",
"items",
"to",
"the",
"collection",
".",
"If",
"an",
"item",
"already",
"exists",
"It",
"will",
"be",
"ignored",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Collection.php#L38-L51 |
10,834 | tarsana/filesystem | src/Collection.php | Collection.updatePath | public function updatePath($oldPath, $newPath)
{
if ($this->contains($oldPath)) {
$this->items[$newPath] = $this->items[$oldPath];
unset($this->items[$oldPath]);
}
} | php | public function updatePath($oldPath, $newPath)
{
if ($this->contains($oldPath)) {
$this->items[$newPath] = $this->items[$oldPath];
unset($this->items[$oldPath]);
}
} | [
"public",
"function",
"updatePath",
"(",
"$",
"oldPath",
",",
"$",
"newPath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"oldPath",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"newPath",
"]",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"oldPath",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"oldPath",
"]",
")",
";",
"}",
"}"
] | This is called when the path of an item is changed, It updates
the paths array by replacing the old path with the new one.
@param string $oldPath
@param string $newPath
@return void | [
"This",
"is",
"called",
"when",
"the",
"path",
"of",
"an",
"item",
"is",
"changed",
"It",
"updates",
"the",
"paths",
"array",
"by",
"replacing",
"the",
"old",
"path",
"with",
"the",
"new",
"one",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Collection.php#L61-L67 |
10,835 | tarsana/filesystem | src/Collection.php | Collection.files | public function files()
{
$filesList = array_filter($this->items, function($item) {
return ($item['instance'] instanceof FileInterface);
});
$filesList = array_map(function($item) {
return $item['instance'];
}, $filesList);
return new Collection($filesList);
} | php | public function files()
{
$filesList = array_filter($this->items, function($item) {
return ($item['instance'] instanceof FileInterface);
});
$filesList = array_map(function($item) {
return $item['instance'];
}, $filesList);
return new Collection($filesList);
} | [
"public",
"function",
"files",
"(",
")",
"{",
"$",
"filesList",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"(",
"$",
"item",
"[",
"'instance'",
"]",
"instanceof",
"FileInterface",
")",
";",
"}",
")",
";",
"$",
"filesList",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"[",
"'instance'",
"]",
";",
"}",
",",
"$",
"filesList",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"filesList",
")",
";",
"}"
] | Returns a new collection containing only files.
@return self | [
"Returns",
"a",
"new",
"collection",
"containing",
"only",
"files",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Collection.php#L96-L107 |
10,836 | tarsana/filesystem | src/Collection.php | Collection.dirs | public function dirs()
{
$filesList = array_filter($this->items, function($item) {
return ($item['instance'] instanceof DirectoryInterface);
});
$filesList = array_map(function($item) {
return $item['instance'];
}, $filesList);
return new Collection($filesList);
} | php | public function dirs()
{
$filesList = array_filter($this->items, function($item) {
return ($item['instance'] instanceof DirectoryInterface);
});
$filesList = array_map(function($item) {
return $item['instance'];
}, $filesList);
return new Collection($filesList);
} | [
"public",
"function",
"dirs",
"(",
")",
"{",
"$",
"filesList",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"(",
"$",
"item",
"[",
"'instance'",
"]",
"instanceof",
"DirectoryInterface",
")",
";",
"}",
")",
";",
"$",
"filesList",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"[",
"'instance'",
"]",
";",
"}",
",",
"$",
"filesList",
")",
";",
"return",
"new",
"Collection",
"(",
"$",
"filesList",
")",
";",
"}"
] | Returns a new collection containing only directories.
@return self | [
"Returns",
"a",
"new",
"collection",
"containing",
"only",
"directories",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Collection.php#L114-L125 |
10,837 | tarsana/filesystem | src/Collection.php | Collection.remove | public function remove($path)
{
if ($this->contains($path)) {
$item = $this->items[$path];
$item['instance']->removePathListener($item['listener_index']);
unset($this->items[$path]);
}
return $this;
} | php | public function remove($path)
{
if ($this->contains($path)) {
$item = $this->items[$path];
$item['instance']->removePathListener($item['listener_index']);
unset($this->items[$path]);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"path",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"path",
"]",
";",
"$",
"item",
"[",
"'instance'",
"]",
"->",
"removePathListener",
"(",
"$",
"item",
"[",
"'listener_index'",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"path",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes a file or directory from the collection.
@param string $path
@return self | [
"Removes",
"a",
"file",
"or",
"directory",
"from",
"the",
"collection",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Collection.php#L207-L215 |
10,838 | vinala/kernel | src/Setup/Documentations/Database.php | Database.set | public static function set($driver, $host, $database, $user, $password, $prefixing, $prefix)
{
$default = self::dbRow('default', "'default' => '$driver', ");
//
switch ($driver) {
case 'mysql':
$connections = self::mysqlConnections($host, $database, $user, $password);
break;
}
//
$connections = self::dbRow('connections', $connections);
$table = self::dbRow('table', "'migration' => 'vinala_migrations',");
$prefixing = self::dbRow('prefixing', "'prefixing' => $prefixing ,");
$prefixe = self::dbRow('prefixe', "'prefixe' => '".$prefix."_',");
//
return "<?php\n\nreturn [\n\t".$default.$connections.$table.$prefixing.$prefixe."\n];";
} | php | public static function set($driver, $host, $database, $user, $password, $prefixing, $prefix)
{
$default = self::dbRow('default', "'default' => '$driver', ");
//
switch ($driver) {
case 'mysql':
$connections = self::mysqlConnections($host, $database, $user, $password);
break;
}
//
$connections = self::dbRow('connections', $connections);
$table = self::dbRow('table', "'migration' => 'vinala_migrations',");
$prefixing = self::dbRow('prefixing', "'prefixing' => $prefixing ,");
$prefixe = self::dbRow('prefixe', "'prefixe' => '".$prefix."_',");
//
return "<?php\n\nreturn [\n\t".$default.$connections.$table.$prefixing.$prefixe."\n];";
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"driver",
",",
"$",
"host",
",",
"$",
"database",
",",
"$",
"user",
",",
"$",
"password",
",",
"$",
"prefixing",
",",
"$",
"prefix",
")",
"{",
"$",
"default",
"=",
"self",
"::",
"dbRow",
"(",
"'default'",
",",
"\"'default' => '$driver', \"",
")",
";",
"//",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'mysql'",
":",
"$",
"connections",
"=",
"self",
"::",
"mysqlConnections",
"(",
"$",
"host",
",",
"$",
"database",
",",
"$",
"user",
",",
"$",
"password",
")",
";",
"break",
";",
"}",
"//",
"$",
"connections",
"=",
"self",
"::",
"dbRow",
"(",
"'connections'",
",",
"$",
"connections",
")",
";",
"$",
"table",
"=",
"self",
"::",
"dbRow",
"(",
"'table'",
",",
"\"'migration' => 'vinala_migrations',\"",
")",
";",
"$",
"prefixing",
"=",
"self",
"::",
"dbRow",
"(",
"'prefixing'",
",",
"\"'prefixing' => $prefixing ,\"",
")",
";",
"$",
"prefixe",
"=",
"self",
"::",
"dbRow",
"(",
"'prefixe'",
",",
"\"'prefixe' => '\"",
".",
"$",
"prefix",
".",
"\"_',\"",
")",
";",
"//",
"return",
"\"<?php\\n\\nreturn [\\n\\t\"",
".",
"$",
"default",
".",
"$",
"connections",
".",
"$",
"table",
".",
"$",
"prefixing",
".",
"$",
"prefixe",
".",
"\"\\n];\"",
";",
"}"
] | set database config file.
@param string $host
@param string $database
@param string $usre
@param string $password
@return null | [
"set",
"database",
"config",
"file",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Setup/Documentations/Database.php#L71-L88 |
10,839 | flowcode/enlace | src/flowcode/enlace/http/HttpRequest.php | HttpRequest.getParameter | public function getParameter($parameter) {
$value = NULL;
if ($parameter != NULL) {
if (isset($this->params[$parameter])) {
$value = $this->params[$parameter];
}
}
if (is_null($value)) {
if (isset($_POST[$parameter])) {
$value = $_POST[$parameter];
}
}
if (is_null($value)) {
if (isset($_GET[$parameter])) {
$value = $_GET[$parameter];
}
}
if (is_string($value)) {
$value = urldecode($value);
}
return $value;
} | php | public function getParameter($parameter) {
$value = NULL;
if ($parameter != NULL) {
if (isset($this->params[$parameter])) {
$value = $this->params[$parameter];
}
}
if (is_null($value)) {
if (isset($_POST[$parameter])) {
$value = $_POST[$parameter];
}
}
if (is_null($value)) {
if (isset($_GET[$parameter])) {
$value = $_GET[$parameter];
}
}
if (is_string($value)) {
$value = urldecode($value);
}
return $value;
} | [
"public",
"function",
"getParameter",
"(",
"$",
"parameter",
")",
"{",
"$",
"value",
"=",
"NULL",
";",
"if",
"(",
"$",
"parameter",
"!=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"parameter",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"params",
"[",
"$",
"parameter",
"]",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"$",
"parameter",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"_POST",
"[",
"$",
"parameter",
"]",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"$",
"parameter",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"_GET",
"[",
"$",
"parameter",
"]",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"urldecode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Retorna el valor del parametro.
Si no existe retorna NULL.
@param String $parameter
@return String value. | [
"Retorna",
"el",
"valor",
"del",
"parametro",
".",
"Si",
"no",
"existe",
"retorna",
"NULL",
"."
] | 2dacd15cd3cf32171a19695c331487e1620eacb8 | https://github.com/flowcode/enlace/blob/2dacd15cd3cf32171a19695c331487e1620eacb8/src/flowcode/enlace/http/HttpRequest.php#L73-L94 |
10,840 | olajoscs/QueryBuilder | src/Common/Clauses/WhereElement.php | WhereElement.addValue | protected function addValue($value)
{
$name = 'where' . $this->whereContainer->getBindingCount();
$this->values[$name] = $value;
return ':' . $name;
} | php | protected function addValue($value)
{
$name = 'where' . $this->whereContainer->getBindingCount();
$this->values[$name] = $value;
return ':' . $name;
} | [
"protected",
"function",
"addValue",
"(",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'where'",
".",
"$",
"this",
"->",
"whereContainer",
"->",
"getBindingCount",
"(",
")",
";",
"$",
"this",
"->",
"values",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"':'",
".",
"$",
"name",
";",
"}"
] | Add a value to the value list
@param mixed $value
@return string The name of the parameter at binding | [
"Add",
"a",
"value",
"to",
"the",
"value",
"list"
] | 5e1568ced2c2c7f0294cf32f30a290db1e642035 | https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/Common/Clauses/WhereElement.php#L145-L151 |
10,841 | emhar/SearchDoctrineBundle | Query/Driver/ORMDriver.php | ORMDriver.loadDatabaseMapping | public function loadDatabaseMapping(ItemMetaData $itemMetaData)
{
$databaseMapping = array();
foreach($itemMetaData->getEntityIdentifiers() as $entityKey => $entityIdentifier)
{
$tableAlias = 't' . $entityKey;
$databaseMapping[$entityIdentifier] = $this->loadEntity($entityIdentifier, $tableAlias, $itemMetaData);
}
return $databaseMapping;
} | php | public function loadDatabaseMapping(ItemMetaData $itemMetaData)
{
$databaseMapping = array();
foreach($itemMetaData->getEntityIdentifiers() as $entityKey => $entityIdentifier)
{
$tableAlias = 't' . $entityKey;
$databaseMapping[$entityIdentifier] = $this->loadEntity($entityIdentifier, $tableAlias, $itemMetaData);
}
return $databaseMapping;
} | [
"public",
"function",
"loadDatabaseMapping",
"(",
"ItemMetaData",
"$",
"itemMetaData",
")",
"{",
"$",
"databaseMapping",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"itemMetaData",
"->",
"getEntityIdentifiers",
"(",
")",
"as",
"$",
"entityKey",
"=>",
"$",
"entityIdentifier",
")",
"{",
"$",
"tableAlias",
"=",
"'t'",
".",
"$",
"entityKey",
";",
"$",
"databaseMapping",
"[",
"$",
"entityIdentifier",
"]",
"=",
"$",
"this",
"->",
"loadEntity",
"(",
"$",
"entityIdentifier",
",",
"$",
"tableAlias",
",",
"$",
"itemMetaData",
")",
";",
"}",
"return",
"$",
"databaseMapping",
";",
"}"
] | Loads the database mapping for the specified item
<pre>
array(
<string|Entity identifier> => array(
'table' => <string|Table name>,
'Alias' => <string|Table alias>,
'columns' => array(
<int|hit constructor position> => array(
'expression' => <string|Attribute name>,
'type' => <string|Attribute type>,
'scoreFactor' => <int|Score factor>
)
),
'joins' => array(
array(
'table' => <string|Table name>,
'tableAlias' => <string|Table alias>,
'onClause' => <string|ON clause>
)
)
)
)
</pre>
@param ItemMetaData $itemMetaData | [
"Loads",
"the",
"database",
"mapping",
"for",
"the",
"specified",
"item"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Driver/ORMDriver.php#L60-L69 |
10,842 | emhar/SearchDoctrineBundle | Query/Driver/ORMDriver.php | ORMDriver.loadEntity | protected function loadEntity($entityIdentifier, $tableAlias, $itemMetaData)
{
//For FROM clause
$entityMetaData = $this->em->getMetadataFactory()
->getMetadataFor($itemMetaData->getEntityClass($entityIdentifier));
$table = $entityMetaData->getTableName();
//Joins and selected columns
$joins = array();
$columns = array();
foreach($itemMetaData->getOrderedRequiredHits() as $hitPos => $hitIdentifier)
{
if($hitIdentifier == ItemMetaData::TYPE)
{
$columns[$hitPos] = array(
'expression' => '\'' . $entityIdentifier . '\'',
'type' => Type::STRING,
'scoreFactor' => 0
);
}
//Score is added in query with search request
elseif($hitIdentifier != ItemMetaData::SCORE)
{
$attribute = $itemMetaData->getHitEntityAttribute($hitIdentifier, $entityIdentifier);
$columns[$hitPos] = array();
$this->loadEntityHit($columns[$hitPos], $joins, $tableAlias, $itemMetaData->getEntityClass($entityIdentifier),
$attribute);
$hitScoreFactors = $itemMetaData->getHitScoreFactors();
$columns[$hitPos]['scoreFactor'] = isset($hitScoreFactors[$hitIdentifier]) ?
$hitScoreFactors[$hitIdentifier] : 0;
}
}
return array(
'table' => $table,
'tableAlias' => $tableAlias,
'joins' => $joins,
'columns' => $columns
);
} | php | protected function loadEntity($entityIdentifier, $tableAlias, $itemMetaData)
{
//For FROM clause
$entityMetaData = $this->em->getMetadataFactory()
->getMetadataFor($itemMetaData->getEntityClass($entityIdentifier));
$table = $entityMetaData->getTableName();
//Joins and selected columns
$joins = array();
$columns = array();
foreach($itemMetaData->getOrderedRequiredHits() as $hitPos => $hitIdentifier)
{
if($hitIdentifier == ItemMetaData::TYPE)
{
$columns[$hitPos] = array(
'expression' => '\'' . $entityIdentifier . '\'',
'type' => Type::STRING,
'scoreFactor' => 0
);
}
//Score is added in query with search request
elseif($hitIdentifier != ItemMetaData::SCORE)
{
$attribute = $itemMetaData->getHitEntityAttribute($hitIdentifier, $entityIdentifier);
$columns[$hitPos] = array();
$this->loadEntityHit($columns[$hitPos], $joins, $tableAlias, $itemMetaData->getEntityClass($entityIdentifier),
$attribute);
$hitScoreFactors = $itemMetaData->getHitScoreFactors();
$columns[$hitPos]['scoreFactor'] = isset($hitScoreFactors[$hitIdentifier]) ?
$hitScoreFactors[$hitIdentifier] : 0;
}
}
return array(
'table' => $table,
'tableAlias' => $tableAlias,
'joins' => $joins,
'columns' => $columns
);
} | [
"protected",
"function",
"loadEntity",
"(",
"$",
"entityIdentifier",
",",
"$",
"tableAlias",
",",
"$",
"itemMetaData",
")",
"{",
"//For FROM clause",
"$",
"entityMetaData",
"=",
"$",
"this",
"->",
"em",
"->",
"getMetadataFactory",
"(",
")",
"->",
"getMetadataFor",
"(",
"$",
"itemMetaData",
"->",
"getEntityClass",
"(",
"$",
"entityIdentifier",
")",
")",
";",
"$",
"table",
"=",
"$",
"entityMetaData",
"->",
"getTableName",
"(",
")",
";",
"//Joins and selected columns",
"$",
"joins",
"=",
"array",
"(",
")",
";",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"itemMetaData",
"->",
"getOrderedRequiredHits",
"(",
")",
"as",
"$",
"hitPos",
"=>",
"$",
"hitIdentifier",
")",
"{",
"if",
"(",
"$",
"hitIdentifier",
"==",
"ItemMetaData",
"::",
"TYPE",
")",
"{",
"$",
"columns",
"[",
"$",
"hitPos",
"]",
"=",
"array",
"(",
"'expression'",
"=>",
"'\\''",
".",
"$",
"entityIdentifier",
".",
"'\\''",
",",
"'type'",
"=>",
"Type",
"::",
"STRING",
",",
"'scoreFactor'",
"=>",
"0",
")",
";",
"}",
"//Score is added in query with search request",
"elseif",
"(",
"$",
"hitIdentifier",
"!=",
"ItemMetaData",
"::",
"SCORE",
")",
"{",
"$",
"attribute",
"=",
"$",
"itemMetaData",
"->",
"getHitEntityAttribute",
"(",
"$",
"hitIdentifier",
",",
"$",
"entityIdentifier",
")",
";",
"$",
"columns",
"[",
"$",
"hitPos",
"]",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"loadEntityHit",
"(",
"$",
"columns",
"[",
"$",
"hitPos",
"]",
",",
"$",
"joins",
",",
"$",
"tableAlias",
",",
"$",
"itemMetaData",
"->",
"getEntityClass",
"(",
"$",
"entityIdentifier",
")",
",",
"$",
"attribute",
")",
";",
"$",
"hitScoreFactors",
"=",
"$",
"itemMetaData",
"->",
"getHitScoreFactors",
"(",
")",
";",
"$",
"columns",
"[",
"$",
"hitPos",
"]",
"[",
"'scoreFactor'",
"]",
"=",
"isset",
"(",
"$",
"hitScoreFactors",
"[",
"$",
"hitIdentifier",
"]",
")",
"?",
"$",
"hitScoreFactors",
"[",
"$",
"hitIdentifier",
"]",
":",
"0",
";",
"}",
"}",
"return",
"array",
"(",
"'table'",
"=>",
"$",
"table",
",",
"'tableAlias'",
"=>",
"$",
"tableAlias",
",",
"'joins'",
"=>",
"$",
"joins",
",",
"'columns'",
"=>",
"$",
"columns",
")",
";",
"}"
] | Loads the database mapping for the specified entity
@param ItemMetaData $itemMetaData | [
"Loads",
"the",
"database",
"mapping",
"for",
"the",
"specified",
"entity"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Driver/ORMDriver.php#L76-L114 |
10,843 | sebardo/ecommerce | EcommerceBundle/Service/PaymentManager.php | PaymentManager.getProviders | public function getProviders(PaymentServiceProvider $psp=null)
{
if(!is_null($psp)){
foreach ($this->providers as $ppf) {
if($ppf->getSlug() == $psp->getSlug()){
return $ppf;
}
}
}
return $this->providers;
} | php | public function getProviders(PaymentServiceProvider $psp=null)
{
if(!is_null($psp)){
foreach ($this->providers as $ppf) {
if($ppf->getSlug() == $psp->getSlug()){
return $ppf;
}
}
}
return $this->providers;
} | [
"public",
"function",
"getProviders",
"(",
"PaymentServiceProvider",
"$",
"psp",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"psp",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"providers",
"as",
"$",
"ppf",
")",
"{",
"if",
"(",
"$",
"ppf",
"->",
"getSlug",
"(",
")",
"==",
"$",
"psp",
"->",
"getSlug",
"(",
")",
")",
"{",
"return",
"$",
"ppf",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"providers",
";",
"}"
] | Return ArrayCollection of PaymentProviderFactory
@return PersistCollection $psps | [
"Return",
"ArrayCollection",
"of",
"PaymentProviderFactory"
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Service/PaymentManager.php#L61-L71 |
10,844 | phlexible/phlexible | src/Phlexible/Bundle/UserBundle/Controller/OptionsController.php | OptionsController.savedetailsAction | public function savedetailsAction(Request $request)
{
$user = $this->getUser()
->setFirstname($request->request->get('firstname'))
->setLastname($request->request->get('lastname'))
->setEmail($request->request->get('email'));
$this->get('phlexible_user.user_manager')->updateUser($user);
return new ResultResponse(true, 'User details saved.');
} | php | public function savedetailsAction(Request $request)
{
$user = $this->getUser()
->setFirstname($request->request->get('firstname'))
->setLastname($request->request->get('lastname'))
->setEmail($request->request->get('email'));
$this->get('phlexible_user.user_manager')->updateUser($user);
return new ResultResponse(true, 'User details saved.');
} | [
"public",
"function",
"savedetailsAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"setFirstname",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'firstname'",
")",
")",
"->",
"setLastname",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'lastname'",
")",
")",
"->",
"setEmail",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'phlexible_user.user_manager'",
")",
"->",
"updateUser",
"(",
"$",
"user",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"'User details saved.'",
")",
";",
"}"
] | Save details.
@param Request $request
@return ResultResponse
@Route("/savedetails", name="users_options_savedetails") | [
"Save",
"details",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/OptionsController.php#L35-L45 |
10,845 | phlexible/phlexible | src/Phlexible/Bundle/UserBundle/Controller/OptionsController.php | OptionsController.savepasswordAction | public function savepasswordAction(Request $request)
{
$user = $this->getUser();
if ($request->request->has('password')) {
$user->setPlainPassword($request->request->get('password'));
}
$this->get('phlexible_user.user_manager')->updateUser($user);
return new ResultResponse(true, 'User password saved.');
} | php | public function savepasswordAction(Request $request)
{
$user = $this->getUser();
if ($request->request->has('password')) {
$user->setPlainPassword($request->request->get('password'));
}
$this->get('phlexible_user.user_manager')->updateUser($user);
return new ResultResponse(true, 'User password saved.');
} | [
"public",
"function",
"savepasswordAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'password'",
")",
")",
"{",
"$",
"user",
"->",
"setPlainPassword",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'password'",
")",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'phlexible_user.user_manager'",
")",
"->",
"updateUser",
"(",
"$",
"user",
")",
";",
"return",
"new",
"ResultResponse",
"(",
"true",
",",
"'User password saved.'",
")",
";",
"}"
] | Save password.
@param Request $request
@return ResultResponse
@Route("/savepassword", name="users_options_savepassword") | [
"Save",
"password",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/OptionsController.php#L55-L66 |
10,846 | stonedz/pff2-installers | src/Composer/Installer/Pff2Installer.php | Pff2Installer.postUpdateActions | protected function postUpdateActions($type, $downloadPath, PackageInterface $package){
switch ($type)
{
case 'pff2-module':
$this->moveConfiguration($downloadPath, $package);
$this->updatePff();
break;
case 'pff2-core':
$this->updatePff();
break;
}
} | php | protected function postUpdateActions($type, $downloadPath, PackageInterface $package){
switch ($type)
{
case 'pff2-module':
$this->moveConfiguration($downloadPath, $package);
$this->updatePff();
break;
case 'pff2-core':
$this->updatePff();
break;
}
} | [
"protected",
"function",
"postUpdateActions",
"(",
"$",
"type",
",",
"$",
"downloadPath",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'pff2-module'",
":",
"$",
"this",
"->",
"moveConfiguration",
"(",
"$",
"downloadPath",
",",
"$",
"package",
")",
";",
"$",
"this",
"->",
"updatePff",
"(",
")",
";",
"break",
";",
"case",
"'pff2-core'",
":",
"$",
"this",
"->",
"updatePff",
"(",
")",
";",
"break",
";",
"}",
"}"
] | Performs actions on the updated files after an installation or update
@var string $type
@var string $downloadPath | [
"Performs",
"actions",
"on",
"the",
"updated",
"files",
"after",
"an",
"installation",
"or",
"update"
] | 7dd0295f2a7fd1e97f26421db288769ea5673083 | https://github.com/stonedz/pff2-installers/blob/7dd0295f2a7fd1e97f26421db288769ea5673083/src/Composer/Installer/Pff2Installer.php#L112-L123 |
10,847 | mecum/expand | src/LibraryTrait.php | LibraryTrait.get | public static function get($name)
{
$class = get_called_class();
if (!isset(self::$instance[$class])) {
self::$instance[$class] = new static();
}
return self::$instance[$class]->getExtensions()->get($name);
} | php | public static function get($name)
{
$class = get_called_class();
if (!isset(self::$instance[$class])) {
self::$instance[$class] = new static();
}
return self::$instance[$class]->getExtensions()->get($name);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
"=",
"new",
"static",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
"->",
"getExtensions",
"(",
")",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}"
] | Get an extension
@param string $name
@return \Closure | [
"Get",
"an",
"extension"
] | 09e8462c0aec9ba888826fa93d362b3a39464258 | https://github.com/mecum/expand/blob/09e8462c0aec9ba888826fa93d362b3a39464258/src/LibraryTrait.php#L41-L50 |
10,848 | mecum/expand | src/LibraryTrait.php | LibraryTrait.getAll | public static function getAll()
{
$class = get_called_class();
if (!isset(self::$instance[$class])) {
self::$instance[$class] = new static();
}
return self::$instance[$class]->getExtensions();
} | php | public static function getAll()
{
$class = get_called_class();
if (!isset(self::$instance[$class])) {
self::$instance[$class] = new static();
}
return self::$instance[$class]->getExtensions();
} | [
"public",
"static",
"function",
"getAll",
"(",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
"=",
"new",
"static",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"class",
"]",
"->",
"getExtensions",
"(",
")",
";",
"}"
] | Get all extension
@return \Mecum\Component\Expand\ExtensionCollection | [
"Get",
"all",
"extension"
] | 09e8462c0aec9ba888826fa93d362b3a39464258 | https://github.com/mecum/expand/blob/09e8462c0aec9ba888826fa93d362b3a39464258/src/LibraryTrait.php#L57-L66 |
10,849 | CatLabInteractive/base-laravel | src/CatLab/Laravel/Database/SelectQueryTransformer.php | SelectQueryTransformer.processComparison | protected function processComparison($query, Comparison $comparison)
{
$subject = self::translateColumnName($query, $comparison);
$value = self::translateParameter($query, $comparison->getValue());
$operator = $comparison->getOperator();
switch ($operator) {
case Operator::SEARCH:
$value = '%' . $value . '%';
$operator = 'LIKE';
break;
}
$query->where($subject, $operator, $value);
} | php | protected function processComparison($query, Comparison $comparison)
{
$subject = self::translateColumnName($query, $comparison);
$value = self::translateParameter($query, $comparison->getValue());
$operator = $comparison->getOperator();
switch ($operator) {
case Operator::SEARCH:
$value = '%' . $value . '%';
$operator = 'LIKE';
break;
}
$query->where($subject, $operator, $value);
} | [
"protected",
"function",
"processComparison",
"(",
"$",
"query",
",",
"Comparison",
"$",
"comparison",
")",
"{",
"$",
"subject",
"=",
"self",
"::",
"translateColumnName",
"(",
"$",
"query",
",",
"$",
"comparison",
")",
";",
"$",
"value",
"=",
"self",
"::",
"translateParameter",
"(",
"$",
"query",
",",
"$",
"comparison",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"operator",
"=",
"$",
"comparison",
"->",
"getOperator",
"(",
")",
";",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"Operator",
"::",
"SEARCH",
":",
"$",
"value",
"=",
"'%'",
".",
"$",
"value",
".",
"'%'",
";",
"$",
"operator",
"=",
"'LIKE'",
";",
"break",
";",
"}",
"$",
"query",
"->",
"where",
"(",
"$",
"subject",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}"
] | Process a single comparison
@param $query
@param Comparison $comparison | [
"Process",
"a",
"single",
"comparison"
] | 7ea7fdbecf9db47f1f00c54446a85960a84e9b98 | https://github.com/CatLabInteractive/base-laravel/blob/7ea7fdbecf9db47f1f00c54446a85960a84e9b98/src/CatLab/Laravel/Database/SelectQueryTransformer.php#L105-L119 |
10,850 | CatLabInteractive/base-laravel | src/CatLab/Laravel/Database/SelectQueryTransformer.php | SelectQueryTransformer.getEntityTable | protected function getEntityTable($subject)
{
if (!isset($this->tableNames[$subject])) {
$this->tableNames[$subject] = $this->resolveEntityTable($subject);
}
return $this->tableNames[$subject];
} | php | protected function getEntityTable($subject)
{
if (!isset($this->tableNames[$subject])) {
$this->tableNames[$subject] = $this->resolveEntityTable($subject);
}
return $this->tableNames[$subject];
} | [
"protected",
"function",
"getEntityTable",
"(",
"$",
"subject",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tableNames",
"[",
"$",
"subject",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tableNames",
"[",
"$",
"subject",
"]",
"=",
"$",
"this",
"->",
"resolveEntityTable",
"(",
"$",
"subject",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tableNames",
"[",
"$",
"subject",
"]",
";",
"}"
] | Translate a parameter subject and translate it to the table name
@param $subject
@return string | [
"Translate",
"a",
"parameter",
"subject",
"and",
"translate",
"it",
"to",
"the",
"table",
"name"
] | 7ea7fdbecf9db47f1f00c54446a85960a84e9b98 | https://github.com/CatLabInteractive/base-laravel/blob/7ea7fdbecf9db47f1f00c54446a85960a84e9b98/src/CatLab/Laravel/Database/SelectQueryTransformer.php#L190-L197 |
10,851 | Sowapps/orpheus-hook | src/Hook/Hook.php | Hook.registerHook | public function registerHook($callback) {
if( !is_callable($callback) ) {
throw new \Exception('Callback not callable');
}
if( in_array($callback, $this->callbacks) ) {
throw new \Exception('Callback already registered');
}
$this->callbacks[] = $callback;
return $this;
} | php | public function registerHook($callback) {
if( !is_callable($callback) ) {
throw new \Exception('Callback not callable');
}
if( in_array($callback, $this->callbacks) ) {
throw new \Exception('Callback already registered');
}
$this->callbacks[] = $callback;
return $this;
} | [
"public",
"function",
"registerHook",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Callback not callable'",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"callbacks",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Callback already registered'",
")",
";",
"}",
"$",
"this",
"->",
"callbacks",
"[",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
"this",
";",
"}"
] | Register a new callback for this hook.
@param callback $callback A callback.
@throws \Exception
@return \Orpheus\Hook\Hook
@see register()
@see http://php.net/manual/en/language.pseudo-types.php#language.types.callback
Registers the $callback associating with this hook.
The callback will be called when this hook will be triggered. | [
"Register",
"a",
"new",
"callback",
"for",
"this",
"hook",
"."
] | 55d45514f1bda4a1dbf5c88f828cfde5fba25cbe | https://github.com/Sowapps/orpheus-hook/blob/55d45514f1bda4a1dbf5c88f828cfde5fba25cbe/src/Hook/Hook.php#L57-L66 |
10,852 | Sowapps/orpheus-hook | src/Hook/Hook.php | Hook.triggerHook | public function triggerHook($params=NULL) {
if( !isset($params) ) {
$params = array(
0 => null,
);
} else if( !is_array($params) ) {
$params = array(
0 => $params,
);
}
foreach($this->callbacks as $callback) {
$r = call_user_func_array($callback, $params);
if( $r !== NULL ) {
$params[0] = $r;
}
}
return isset($params[0]) ? $params[0] : null;
} | php | public function triggerHook($params=NULL) {
if( !isset($params) ) {
$params = array(
0 => null,
);
} else if( !is_array($params) ) {
$params = array(
0 => $params,
);
}
foreach($this->callbacks as $callback) {
$r = call_user_func_array($callback, $params);
if( $r !== NULL ) {
$params[0] = $r;
}
}
return isset($params[0]) ? $params[0] : null;
} | [
"public",
"function",
"triggerHook",
"(",
"$",
"params",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"0",
"=>",
"null",
",",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"0",
"=>",
"$",
"params",
",",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"as",
"$",
"callback",
")",
"{",
"$",
"r",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"r",
"!==",
"NULL",
")",
"{",
"$",
"params",
"[",
"0",
"]",
"=",
"$",
"r",
";",
"}",
"}",
"return",
"isset",
"(",
"$",
"params",
"[",
"0",
"]",
")",
"?",
"$",
"params",
"[",
"0",
"]",
":",
"null",
";",
"}"
] | Trigger this hook.
@param array $params Params sent to the callback.
@return mixed The first param as result.
@see trigger()
Trigger this hook calling all associated callbacks.
$params array is passed to the callback as its arguments.
The first parameter, $params[0], is considered as the result of the trigger.
If $params is not an array, its value is assigned to the second value of a new $params array. | [
"Trigger",
"this",
"hook",
"."
] | 55d45514f1bda4a1dbf5c88f828cfde5fba25cbe | https://github.com/Sowapps/orpheus-hook/blob/55d45514f1bda4a1dbf5c88f828cfde5fba25cbe/src/Hook/Hook.php#L80-L97 |
10,853 | Sowapps/orpheus-hook | src/Hook/Hook.php | Hook.create | public static function create($name) {
$name = static::slug($name);
static::$hooks[$name] = new static($name);
return self::$hooks[$name];
} | php | public static function create($name) {
$name = static::slug($name);
static::$hooks[$name] = new static($name);
return self::$hooks[$name];
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"slug",
"(",
"$",
"name",
")",
";",
"static",
"::",
"$",
"hooks",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
")",
";",
"return",
"self",
"::",
"$",
"hooks",
"[",
"$",
"name",
"]",
";",
"}"
] | Create new Hook
@param string $name The new hook name.
@return Hook The new hook. | [
"Create",
"new",
"Hook"
] | 55d45514f1bda4a1dbf5c88f828cfde5fba25cbe | https://github.com/Sowapps/orpheus-hook/blob/55d45514f1bda4a1dbf5c88f828cfde5fba25cbe/src/Hook/Hook.php#L117-L121 |
10,854 | Sowapps/orpheus-hook | src/Hook/Hook.php | Hook.trigger | public static function trigger($name, $silent=false) {
$name = static::slug($name);
$firstParam = null;
if( !is_bool($silent) ) {
$firstParam = $silent;
$silent = false;// Default
}
if( empty(static::$hooks[$name]) ) {
if( $silent ) { return; }
throw new \Exception('No hook with this name');
}
$params = null;
if( func_num_args() > 2 ) {
$params = func_get_args();
unset($params[0], $params[1]);
if( isset($firstParam) ) {
$params[0] = $firstParam;
}
$params = array_values($params);
}
return static::$hooks[$name]->triggerHook($params);
} | php | public static function trigger($name, $silent=false) {
$name = static::slug($name);
$firstParam = null;
if( !is_bool($silent) ) {
$firstParam = $silent;
$silent = false;// Default
}
if( empty(static::$hooks[$name]) ) {
if( $silent ) { return; }
throw new \Exception('No hook with this name');
}
$params = null;
if( func_num_args() > 2 ) {
$params = func_get_args();
unset($params[0], $params[1]);
if( isset($firstParam) ) {
$params[0] = $firstParam;
}
$params = array_values($params);
}
return static::$hooks[$name]->triggerHook($params);
} | [
"public",
"static",
"function",
"trigger",
"(",
"$",
"name",
",",
"$",
"silent",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"slug",
"(",
"$",
"name",
")",
";",
"$",
"firstParam",
"=",
"null",
";",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"silent",
")",
")",
"{",
"$",
"firstParam",
"=",
"$",
"silent",
";",
"$",
"silent",
"=",
"false",
";",
"// Default",
"}",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"hooks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"silent",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'No hook with this name'",
")",
";",
"}",
"$",
"params",
"=",
"null",
";",
"if",
"(",
"func_num_args",
"(",
")",
">",
"2",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"unset",
"(",
"$",
"params",
"[",
"0",
"]",
",",
"$",
"params",
"[",
"1",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"firstParam",
")",
")",
"{",
"$",
"params",
"[",
"0",
"]",
"=",
"$",
"firstParam",
";",
"}",
"$",
"params",
"=",
"array_values",
"(",
"$",
"params",
")",
";",
"}",
"return",
"static",
"::",
"$",
"hooks",
"[",
"$",
"name",
"]",
"->",
"triggerHook",
"(",
"$",
"params",
")",
";",
"}"
] | Trigger a hook by name
@param string $name The hook name.
@param boolean $silent Make it silent, no exception thrown. Default value is false.
@return The triggerHook() result, usually the first parameter.
Trigger the hook named $name.
e.g trigger('MyHook', true, $parameter1); trigger('MyHook', $parameter1, $parameter2);
We advise to always provide $silent parameters if you pass additional parameters to the callback | [
"Trigger",
"a",
"hook",
"by",
"name"
] | 55d45514f1bda4a1dbf5c88f828cfde5fba25cbe | https://github.com/Sowapps/orpheus-hook/blob/55d45514f1bda4a1dbf5c88f828cfde5fba25cbe/src/Hook/Hook.php#L152-L173 |
10,855 | fond-of/active-campaign | src/Service/MailingList.php | MailingList.getByIds | public function getByIds(array $ids)
{
if (empty($ids)) {
return null;
}
$parameters = array(
'api_action' => 'list_list',
'ids' => implode(',', $ids)
);
$response = $this->request($parameters);
if ($response === null || $response->getStatusCode() !== 200) {
return null;
}
$json = $response->getBody()->getContents();
return $this->serializer->deserialize(
$this->removeResultInformation($json),
'array<integer, ' . \FondOfPHP\ActiveCampaign\DataTransferObject\MailingList::class . '>',
'json'
);
} | php | public function getByIds(array $ids)
{
if (empty($ids)) {
return null;
}
$parameters = array(
'api_action' => 'list_list',
'ids' => implode(',', $ids)
);
$response = $this->request($parameters);
if ($response === null || $response->getStatusCode() !== 200) {
return null;
}
$json = $response->getBody()->getContents();
return $this->serializer->deserialize(
$this->removeResultInformation($json),
'array<integer, ' . \FondOfPHP\ActiveCampaign\DataTransferObject\MailingList::class . '>',
'json'
);
} | [
"public",
"function",
"getByIds",
"(",
"array",
"$",
"ids",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"parameters",
"=",
"array",
"(",
"'api_action'",
"=>",
"'list_list'",
",",
"'ids'",
"=>",
"implode",
"(",
"','",
",",
"$",
"ids",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"$",
"response",
"===",
"null",
"||",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"return",
"null",
";",
"}",
"$",
"json",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"this",
"->",
"removeResultInformation",
"(",
"$",
"json",
")",
",",
"'array<integer, '",
".",
"\\",
"FondOfPHP",
"\\",
"ActiveCampaign",
"\\",
"DataTransferObject",
"\\",
"MailingList",
"::",
"class",
".",
"'>'",
",",
"'json'",
")",
";",
"}"
] | Get multiple mailing lists by ids
@param array $ids
@return null|\FondOfPHP\ActiveCampaign\DataTransferObject\MailingList | [
"Get",
"multiple",
"mailing",
"lists",
"by",
"ids"
] | 389e6c3ca4e39f2f94f92a9673fe3207a9d15807 | https://github.com/fond-of/active-campaign/blob/389e6c3ca4e39f2f94f92a9673fe3207a9d15807/src/Service/MailingList.php#L15-L39 |
10,856 | cityware/city-snmp | src/MIBS/Asterisk/Channels.php | Channels.details | public function details( $useIndex = false )
{
$details = [];
foreach( $this->names() as $index => $name )
{
if( $useIndex )
$idx = $index;
else
$idx = $name;
$details[ $idx ]['name'] = $name;
$details[ $idx ]['index'] = $index;
$details[ $idx ]['description'] = $this->descriptions()[$index];
$details[ $idx ]['hasDeviceState'] = $this->deviceStates()[$index];
$details[ $idx ]['hasProgressIndications'] = $this->progressIndications()[$index];
$details[ $idx ]['canTransfer'] = $this->transfers()[$index];
$details[ $idx ]['activeCalls'] = $this->activeCalls()[$index];
}
return $details;
} | php | public function details( $useIndex = false )
{
$details = [];
foreach( $this->names() as $index => $name )
{
if( $useIndex )
$idx = $index;
else
$idx = $name;
$details[ $idx ]['name'] = $name;
$details[ $idx ]['index'] = $index;
$details[ $idx ]['description'] = $this->descriptions()[$index];
$details[ $idx ]['hasDeviceState'] = $this->deviceStates()[$index];
$details[ $idx ]['hasProgressIndications'] = $this->progressIndications()[$index];
$details[ $idx ]['canTransfer'] = $this->transfers()[$index];
$details[ $idx ]['activeCalls'] = $this->activeCalls()[$index];
}
return $details;
} | [
"public",
"function",
"details",
"(",
"$",
"useIndex",
"=",
"false",
")",
"{",
"$",
"details",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"names",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"useIndex",
")",
"$",
"idx",
"=",
"$",
"index",
";",
"else",
"$",
"idx",
"=",
"$",
"name",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'index'",
"]",
"=",
"$",
"index",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'description'",
"]",
"=",
"$",
"this",
"->",
"descriptions",
"(",
")",
"[",
"$",
"index",
"]",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'hasDeviceState'",
"]",
"=",
"$",
"this",
"->",
"deviceStates",
"(",
")",
"[",
"$",
"index",
"]",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'hasProgressIndications'",
"]",
"=",
"$",
"this",
"->",
"progressIndications",
"(",
")",
"[",
"$",
"index",
"]",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'canTransfer'",
"]",
"=",
"$",
"this",
"->",
"transfers",
"(",
")",
"[",
"$",
"index",
"]",
";",
"$",
"details",
"[",
"$",
"idx",
"]",
"[",
"'activeCalls'",
"]",
"=",
"$",
"this",
"->",
"activeCalls",
"(",
")",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"$",
"details",
";",
"}"
] | Utility function to gather channel details together in an associative array.
Returns an array of support channel types. For example:
Array
(
....
[SIP] => Array
(
[name] => SIP
[index] => 5
[description] => Session Initiation Protocol (SIP)
[hasDeviceState] => 1
[hasProgressIndications] => 1
[canTransfer] => 1
[activeCalls] => 0
)
....
)
If you chose to index by SNMP table entries, the above element would be indexed with `5` rather than `SIP`.
@param bool $useIndex If true, the array is indexed using the SNMP table index rather than the unique channel type name
@return array Channel details as an associative array | [
"Utility",
"function",
"to",
"gather",
"channel",
"details",
"together",
"in",
"an",
"associative",
"array",
"."
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Asterisk/Channels.php#L204-L225 |
10,857 | n0m4dz/laracasa | Zend/Gdata/YouTube/UserProfileEntry.php | Zend_Gdata_YouTube_UserProfileEntry.setAboutMe | public function setAboutMe($aboutMe = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setAboutMe ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_aboutMe = $aboutMe;
return $this;
}
} | php | public function setAboutMe($aboutMe = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setAboutMe ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_aboutMe = $aboutMe;
return $this;
}
} | [
"public",
"function",
"setAboutMe",
"(",
"$",
"aboutMe",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"null",
")",
"||",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"1",
")",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"'The setAboutMe '",
".",
"' method is only supported as of version 2 of the YouTube '",
".",
"'API.'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_aboutMe",
"=",
"$",
"aboutMe",
";",
"return",
"$",
"this",
";",
"}",
"}"
] | Sets the content of the 'about me' field.
@param Zend_Gdata_YouTube_Extension_AboutMe $aboutMe The 'about me'
information.
@throws Zend_Gdata_App_VersionException
@return Zend_Gdata_YouTube_UserProfileEntry Provides a fluent interface | [
"Sets",
"the",
"content",
"of",
"the",
"about",
"me",
"field",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/UserProfileEntry.php#L498-L510 |
10,858 | n0m4dz/laracasa | Zend/Gdata/YouTube/UserProfileEntry.php | Zend_Gdata_YouTube_UserProfileEntry.setFirstName | public function setFirstName($firstName = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setFirstName ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_firstName = $firstName;
return $this;
}
} | php | public function setFirstName($firstName = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setFirstName ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_firstName = $firstName;
return $this;
}
} | [
"public",
"function",
"setFirstName",
"(",
"$",
"firstName",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"null",
")",
"||",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"1",
")",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"'The setFirstName '",
".",
"' method is only supported as of version 2 of the YouTube '",
".",
"'API.'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_firstName",
"=",
"$",
"firstName",
";",
"return",
"$",
"this",
";",
"}",
"}"
] | Sets the content of the 'first name' field.
@param Zend_Gdata_YouTube_Extension_FirstName $firstName The first name
@throws Zend_Gdata_App_VersionException
@return Zend_Gdata_YouTube_UserProfileEntry Provides a fluent interface | [
"Sets",
"the",
"content",
"of",
"the",
"first",
"name",
"field",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/UserProfileEntry.php#L538-L550 |
10,859 | n0m4dz/laracasa | Zend/Gdata/YouTube/UserProfileEntry.php | Zend_Gdata_YouTube_UserProfileEntry.setLastName | public function setLastName($lastName = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setLastName ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_lastName = $lastName;
return $this;
}
} | php | public function setLastName($lastName = null)
{
if (($this->getMajorProtocolVersion() == null) ||
($this->getMajorProtocolVersion() == 1)) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException('The setLastName ' .
' method is only supported as of version 2 of the YouTube ' .
'API.');
} else {
$this->_lastName = $lastName;
return $this;
}
} | [
"public",
"function",
"setLastName",
"(",
"$",
"lastName",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"null",
")",
"||",
"(",
"$",
"this",
"->",
"getMajorProtocolVersion",
"(",
")",
"==",
"1",
")",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"'The setLastName '",
".",
"' method is only supported as of version 2 of the YouTube '",
".",
"'API.'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_lastName",
"=",
"$",
"lastName",
";",
"return",
"$",
"this",
";",
"}",
"}"
] | Sets the content of the 'last name' field.
@param Zend_Gdata_YouTube_Extension_LastName $lastName The last name
@throws Zend_Gdata_App_VersionException
@return Zend_Gdata_YouTube_UserProfileEntry Provides a fluent interface | [
"Sets",
"the",
"content",
"of",
"the",
"last",
"name",
"field",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/UserProfileEntry.php#L578-L590 |
10,860 | undefined-exception-coders/UECMediaBundle | Services/MediaService.php | MediaService.create | public function create($context)
{
$providerManager = $this->providerService->getProviderManager($context);
$media = $this->mediaManager->createMedia($context);
$mediaProvider = $providerManager->getMediaProviderManager()->createMediaProvider();
$mediaProvider->setMedia($media);
return $mediaProvider;
} | php | public function create($context)
{
$providerManager = $this->providerService->getProviderManager($context);
$media = $this->mediaManager->createMedia($context);
$mediaProvider = $providerManager->getMediaProviderManager()->createMediaProvider();
$mediaProvider->setMedia($media);
return $mediaProvider;
} | [
"public",
"function",
"create",
"(",
"$",
"context",
")",
"{",
"$",
"providerManager",
"=",
"$",
"this",
"->",
"providerService",
"->",
"getProviderManager",
"(",
"$",
"context",
")",
";",
"$",
"media",
"=",
"$",
"this",
"->",
"mediaManager",
"->",
"createMedia",
"(",
"$",
"context",
")",
";",
"$",
"mediaProvider",
"=",
"$",
"providerManager",
"->",
"getMediaProviderManager",
"(",
")",
"->",
"createMediaProvider",
"(",
")",
";",
"$",
"mediaProvider",
"->",
"setMedia",
"(",
"$",
"media",
")",
";",
"return",
"$",
"mediaProvider",
";",
"}"
] | Create an empty instance of the MediaProvider by the context
@param $context
@return MediaProviderInterface | [
"Create",
"an",
"empty",
"instance",
"of",
"the",
"MediaProvider",
"by",
"the",
"context"
] | 93c7bd6b3e1185ef716c26368677c08f95200f0b | https://github.com/undefined-exception-coders/UECMediaBundle/blob/93c7bd6b3e1185ef716c26368677c08f95200f0b/Services/MediaService.php#L33-L43 |
10,861 | erdemkeren/jet-sms-php | src/ShortMessageCollection.php | ShortMessageCollection.push | public function push(ShortMessage $shortMessage)
{
if ($shortMessage->hasManyReceivers()) {
throw new \LogicException(
"Expected one receiver per short message, got many."
);
}
$this->items[] = $shortMessage;
return $this;
} | php | public function push(ShortMessage $shortMessage)
{
if ($shortMessage->hasManyReceivers()) {
throw new \LogicException(
"Expected one receiver per short message, got many."
);
}
$this->items[] = $shortMessage;
return $this;
} | [
"public",
"function",
"push",
"(",
"ShortMessage",
"$",
"shortMessage",
")",
"{",
"if",
"(",
"$",
"shortMessage",
"->",
"hasManyReceivers",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Expected one receiver per short message, got many.\"",
")",
";",
"}",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"$",
"shortMessage",
";",
"return",
"$",
"this",
";",
"}"
] | Push a new short message to the given collection.
@param ShortMessage $shortMessage
@return self | [
"Push",
"a",
"new",
"short",
"message",
"to",
"the",
"given",
"collection",
"."
] | 5b103a980bd2a8dce003964a17e2568736dfcf4e | https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/ShortMessageCollection.php#L24-L35 |
10,862 | erdemkeren/jet-sms-php | src/ShortMessageCollection.php | ShortMessageCollection.toXml | public function toXml()
{
$messages = '';
/** @var ShortMessage $shortMessage */
foreach ($this->items as $shortMessage) {
$messages .= $shortMessage->toMultipleMessagesXml();
}
return $messages;
} | php | public function toXml()
{
$messages = '';
/** @var ShortMessage $shortMessage */
foreach ($this->items as $shortMessage) {
$messages .= $shortMessage->toMultipleMessagesXml();
}
return $messages;
} | [
"public",
"function",
"toXml",
"(",
")",
"{",
"$",
"messages",
"=",
"''",
";",
"/** @var ShortMessage $shortMessage */",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"shortMessage",
")",
"{",
"$",
"messages",
".=",
"$",
"shortMessage",
"->",
"toMultipleMessagesXml",
"(",
")",
";",
"}",
"return",
"$",
"messages",
";",
"}"
] | Get the xml representation of the items.
@return string | [
"Get",
"the",
"xml",
"representation",
"of",
"the",
"items",
"."
] | 5b103a980bd2a8dce003964a17e2568736dfcf4e | https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/ShortMessageCollection.php#L42-L51 |
10,863 | erdemkeren/jet-sms-php | src/ShortMessageCollection.php | ShortMessageCollection.toArray | public function toArray()
{
$messages = [];
$receivers = [];
/** @var ShortMessage $shortMessage */
foreach ($this->items as $shortMessage) {
$messages[] = $shortMessage->body();
$receivers[] = $shortMessage->receiversString();
}
return [
'Msisdns' => implode('|', $receivers),
'Messages' => implode('|', $messages),
];
} | php | public function toArray()
{
$messages = [];
$receivers = [];
/** @var ShortMessage $shortMessage */
foreach ($this->items as $shortMessage) {
$messages[] = $shortMessage->body();
$receivers[] = $shortMessage->receiversString();
}
return [
'Msisdns' => implode('|', $receivers),
'Messages' => implode('|', $messages),
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"$",
"receivers",
"=",
"[",
"]",
";",
"/** @var ShortMessage $shortMessage */",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"shortMessage",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"shortMessage",
"->",
"body",
"(",
")",
";",
"$",
"receivers",
"[",
"]",
"=",
"$",
"shortMessage",
"->",
"receiversString",
"(",
")",
";",
"}",
"return",
"[",
"'Msisdns'",
"=>",
"implode",
"(",
"'|'",
",",
"$",
"receivers",
")",
",",
"'Messages'",
"=>",
"implode",
"(",
"'|'",
",",
"$",
"messages",
")",
",",
"]",
";",
"}"
] | Get the array presentation of the items.
@return array | [
"Get",
"the",
"array",
"presentation",
"of",
"the",
"items",
"."
] | 5b103a980bd2a8dce003964a17e2568736dfcf4e | https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/ShortMessageCollection.php#L58-L73 |
10,864 | urmaul/rich-types | src/collections/Variables.php | Variables.indexBy | public function indexBy($callback)
{
$keys = array_map($callback, $this->value);
$value = array_combine($keys, $this->value);
return $this->setValue($value);
} | php | public function indexBy($callback)
{
$keys = array_map($callback, $this->value);
$value = array_combine($keys, $this->value);
return $this->setValue($value);
} | [
"public",
"function",
"indexBy",
"(",
"$",
"callback",
")",
"{",
"$",
"keys",
"=",
"array_map",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"value",
")",
";",
"$",
"value",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"this",
"->",
"value",
")",
";",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}"
] | Maps values to keys using callback
@param callable $callback
@return static | [
"Maps",
"values",
"to",
"keys",
"using",
"callback"
] | 895d8d6f25197652d4502cf69d9ff96cf9f2c4bc | https://github.com/urmaul/rich-types/blob/895d8d6f25197652d4502cf69d9ff96cf9f2c4bc/src/collections/Variables.php#L54-L59 |
10,865 | urmaul/rich-types | src/collections/Variables.php | Variables.mapKeys | public function mapKeys(array $replaces, $strict = true)
{
$mapped = [];
foreach ($this->value as $key => $value) {
if (isset($replaces[$key])) {
$newKey = $replaces[$key];
} elseif ($strict) {
throw new UnexpectedKeyException('Key "' . $key . '" not found in map.');
} else {
$newKey = $key;
}
$mapped[$newKey] = $value;
}
$this->value = $mapped;
return $this;
} | php | public function mapKeys(array $replaces, $strict = true)
{
$mapped = [];
foreach ($this->value as $key => $value) {
if (isset($replaces[$key])) {
$newKey = $replaces[$key];
} elseif ($strict) {
throw new UnexpectedKeyException('Key "' . $key . '" not found in map.');
} else {
$newKey = $key;
}
$mapped[$newKey] = $value;
}
$this->value = $mapped;
return $this;
} | [
"public",
"function",
"mapKeys",
"(",
"array",
"$",
"replaces",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"$",
"mapped",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"value",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"replaces",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"newKey",
"=",
"$",
"replaces",
"[",
"$",
"key",
"]",
";",
"}",
"elseif",
"(",
"$",
"strict",
")",
"{",
"throw",
"new",
"UnexpectedKeyException",
"(",
"'Key \"'",
".",
"$",
"key",
".",
"'\" not found in map.'",
")",
";",
"}",
"else",
"{",
"$",
"newKey",
"=",
"$",
"key",
";",
"}",
"$",
"mapped",
"[",
"$",
"newKey",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"$",
"mapped",
";",
"return",
"$",
"this",
";",
"}"
] | Replaces collection keys using map array.
@param array $replaces old keys to new keys map.
@param boolean $strict whether to throw exception when key is not in the map.
@return $this
@throws UnexpectedKeyException if strict and key is not in the map. | [
"Replaces",
"collection",
"keys",
"using",
"map",
"array",
"."
] | 895d8d6f25197652d4502cf69d9ff96cf9f2c4bc | https://github.com/urmaul/rich-types/blob/895d8d6f25197652d4502cf69d9ff96cf9f2c4bc/src/collections/Variables.php#L68-L86 |
10,866 | urmaul/rich-types | src/collections/Variables.php | Variables.filter | public function filter($callback = null)
{
if ($callback !== null)
$value = array_filter($this->value, $callback);
else
$value = array_filter($this->value);
return $this->setValue($value);
} | php | public function filter($callback = null)
{
if ($callback !== null)
$value = array_filter($this->value, $callback);
else
$value = array_filter($this->value);
return $this->setValue($value);
} | [
"public",
"function",
"filter",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"callback",
"!==",
"null",
")",
"$",
"value",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"callback",
")",
";",
"else",
"$",
"value",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"value",
")",
";",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}"
] | Performs `array_filter` to each item in collection.
@param callable $callback
@see array_filter()
@return $this | [
"Performs",
"array_filter",
"to",
"each",
"item",
"in",
"collection",
"."
] | 895d8d6f25197652d4502cf69d9ff96cf9f2c4bc | https://github.com/urmaul/rich-types/blob/895d8d6f25197652d4502cf69d9ff96cf9f2c4bc/src/collections/Variables.php#L94-L102 |
10,867 | urmaul/rich-types | src/collections/Variables.php | Variables.find | public function find($callback)
{
foreach ($this->value as $value) {
if (call_user_func($callback, $value)) {
return $value;
}
}
return null;
} | php | public function find($callback)
{
foreach ($this->value as $value) {
if (call_user_func($callback, $value)) {
return $value;
}
}
return null;
} | [
"public",
"function",
"find",
"(",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"value",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Finds an item by callback function.
Returns it's value.
@param callable $callback
@return mixed first item found or null if nothing match | [
"Finds",
"an",
"item",
"by",
"callback",
"function",
".",
"Returns",
"it",
"s",
"value",
"."
] | 895d8d6f25197652d4502cf69d9ff96cf9f2c4bc | https://github.com/urmaul/rich-types/blob/895d8d6f25197652d4502cf69d9ff96cf9f2c4bc/src/collections/Variables.php#L144-L153 |
10,868 | SergioMadness/framework | framework/web/Request.php | Request.get | public function get($paramName = null, $default = null)
{
$result = $default;
$params = $this->getRequestParams();
if ($paramName === null) {
$result = $params;
} elseif (isset($params[$paramName])) {
$result = $params[$paramName];
}
return $result;
} | php | public function get($paramName = null, $default = null)
{
$result = $default;
$params = $this->getRequestParams();
if ($paramName === null) {
$result = $params;
} elseif (isset($params[$paramName])) {
$result = $params[$paramName];
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"paramName",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"default",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"getRequestParams",
"(",
")",
";",
"if",
"(",
"$",
"paramName",
"===",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"params",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"params",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"params",
"[",
"$",
"paramName",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get param value by name
@param string $paramName
@param mixed $default
@return mized | [
"Get",
"param",
"value",
"by",
"name"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L74-L87 |
10,869 | SergioMadness/framework | framework/web/Request.php | Request.getCookie | public function getCookie($name, $default = null)
{
$result = $default;
if (isset($_COOKIE[$name])) {
$result = $_COOKIE[$name];
}
return $result;
} | php | public function getCookie($name, $default = null)
{
$result = $default;
if (isset($_COOKIE[$name])) {
$result = $_COOKIE[$name];
}
return $result;
} | [
"public",
"function",
"getCookie",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get cookie's value by name
@param string $name
@param string $default
@return string | [
"Get",
"cookie",
"s",
"value",
"by",
"name"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L116-L125 |
10,870 | SergioMadness/framework | framework/web/Request.php | Request.getFile | public function getFile($fileName)
{
$result = false;
if (isset($_FILES[$fileName])) {
$result = $_FILES[$fileName];
}
return $result;
} | php | public function getFile($fileName)
{
$result = false;
if (isset($_FILES[$fileName])) {
$result = $_FILES[$fileName];
}
return $result;
} | [
"public",
"function",
"getFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"_FILES",
"[",
"$",
"fileName",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"_FILES",
"[",
"$",
"fileName",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get file by name
@param string $fileName
@return array|false | [
"Get",
"file",
"by",
"name"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L133-L142 |
10,871 | SergioMadness/framework | framework/web/Request.php | Request.getSegment | public function getSegment($index, $default = null)
{
return $index > 0 && count($this->urlParts) - 1 <= $index ? $this->urlParts[$index]
: $default;
} | php | public function getSegment($index, $default = null)
{
return $index > 0 && count($this->urlParts) - 1 <= $index ? $this->urlParts[$index]
: $default;
} | [
"public",
"function",
"getSegment",
"(",
"$",
"index",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"$",
"index",
">",
"0",
"&&",
"count",
"(",
"$",
"this",
"->",
"urlParts",
")",
"-",
"1",
"<=",
"$",
"index",
"?",
"$",
"this",
"->",
"urlParts",
"[",
"$",
"index",
"]",
":",
"$",
"default",
";",
"}"
] | Get URL segment
@param int $index
@param string $default
@return string | [
"Get",
"URL",
"segment"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L151-L155 |
10,872 | SergioMadness/framework | framework/web/Request.php | Request.devideUrl | protected function devideUrl()
{
$parts = explode('/', $this->getPath());
$cnt = count($parts);
for ($i = 0; $i < $cnt; $i++) {
$parts[$i] = trim($parts[$i]);
}
return $parts;
} | php | protected function devideUrl()
{
$parts = explode('/', $this->getPath());
$cnt = count($parts);
for ($i = 0; $i < $cnt; $i++) {
$parts[$i] = trim($parts[$i]);
}
return $parts;
} | [
"protected",
"function",
"devideUrl",
"(",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"cnt",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"cnt",
";",
"$",
"i",
"++",
")",
"{",
"$",
"parts",
"[",
"$",
"i",
"]",
"=",
"trim",
"(",
"$",
"parts",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"parts",
";",
"}"
] | Devide url on segments
@return array | [
"Devide",
"url",
"on",
"segments"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L162-L170 |
10,873 | SergioMadness/framework | framework/web/Request.php | Request.getHeader | public function getHeader($name)
{
$name = mb_strtolower($name);
return isset($this->headers[$name]) ? $this->headers[$name] : null;
} | php | public function getHeader($name)
{
$name = mb_strtolower($name);
return isset($this->headers[$name]) ? $this->headers[$name] : null;
} | [
"public",
"function",
"getHeader",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"mb_strtolower",
"(",
"$",
"name",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Get header by name
@param string $name
@return string | [
"Get",
"header",
"by",
"name"
] | a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e | https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/web/Request.php#L206-L210 |
10,874 | slickframework/mvc | src/Controller/FormAwareMethods.php | FormAwareMethods.getGeneralErrorMessage | protected function getGeneralErrorMessage(\Exception $caught)
{
$singleName = $this->getEntityNameSingular();
$message = "There was an error when saving {$singleName} data: %s";
return sprintf($this->translate($message), $caught->getMessage());
} | php | protected function getGeneralErrorMessage(\Exception $caught)
{
$singleName = $this->getEntityNameSingular();
$message = "There was an error when saving {$singleName} data: %s";
return sprintf($this->translate($message), $caught->getMessage());
} | [
"protected",
"function",
"getGeneralErrorMessage",
"(",
"\\",
"Exception",
"$",
"caught",
")",
"{",
"$",
"singleName",
"=",
"$",
"this",
"->",
"getEntityNameSingular",
"(",
")",
";",
"$",
"message",
"=",
"\"There was an error when saving {$singleName} data: %s\"",
";",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"translate",
"(",
"$",
"message",
")",
",",
"$",
"caught",
"->",
"getMessage",
"(",
")",
")",
";",
"}"
] | Get invalid form data message
@param \Exception $caught
@return string | [
"Get",
"invalid",
"form",
"data",
"message"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/FormAwareMethods.php#L56-L61 |
10,875 | slickframework/mvc | src/Controller/FormAwareMethods.php | FormAwareMethods.getUpdateService | public function getUpdateService()
{
if (null == $this->updateService) {
$this->setUpdateService(
new EntityUpdateService($this->getNewEntity())
);
}
return $this->updateService;
} | php | public function getUpdateService()
{
if (null == $this->updateService) {
$this->setUpdateService(
new EntityUpdateService($this->getNewEntity())
);
}
return $this->updateService;
} | [
"public",
"function",
"getUpdateService",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"updateService",
")",
"{",
"$",
"this",
"->",
"setUpdateService",
"(",
"new",
"EntityUpdateService",
"(",
"$",
"this",
"->",
"getNewEntity",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"updateService",
";",
"}"
] | Get update service
@return EntityUpdateService | [
"Get",
"update",
"service"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/FormAwareMethods.php#L75-L83 |
10,876 | gamernetwork/yolk-support | src/Validator.php | Validator.validateIP | public static function validateIP( $v ) {
// if integer then convert to string
if( $ip = filter_var($v, FILTER_VALIDATE_INT) )
$v = long2ip($ip);
return filter_var($v, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
} | php | public static function validateIP( $v ) {
// if integer then convert to string
if( $ip = filter_var($v, FILTER_VALIDATE_INT) )
$v = long2ip($ip);
return filter_var($v, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
} | [
"public",
"static",
"function",
"validateIP",
"(",
"$",
"v",
")",
"{",
"// if integer then convert to string",
"if",
"(",
"$",
"ip",
"=",
"filter_var",
"(",
"$",
"v",
",",
"FILTER_VALIDATE_INT",
")",
")",
"$",
"v",
"=",
"long2ip",
"(",
"$",
"ip",
")",
";",
"return",
"filter_var",
"(",
"$",
"v",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV4",
")",
";",
"}"
] | Validates a value as an ip4 address.
@param mixed $v
@return string | [
"Validates",
"a",
"value",
"as",
"an",
"ip4",
"address",
"."
] | 83e517b9a12c6ade712ce734574d1de64bcdd0c2 | https://github.com/gamernetwork/yolk-support/blob/83e517b9a12c6ade712ce734574d1de64bcdd0c2/src/Validator.php#L155-L160 |
10,877 | codebobbly/dvoconnector | Classes/Controller/AnnouncementController.php | AnnouncementController.detailAnnouncementAction | public function detailAnnouncementAction(string $anID)
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID],
self::VIEW_VARIABLE_ANNOUNCEMENT_ID => $anID
], __CLASS__, __FUNCTION__);
return $this->view->render();
} | php | public function detailAnnouncementAction(string $anID)
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID],
self::VIEW_VARIABLE_ANNOUNCEMENT_ID => $anID
], __CLASS__, __FUNCTION__);
return $this->view->render();
} | [
"public",
"function",
"detailAnnouncementAction",
"(",
"string",
"$",
"anID",
")",
"{",
"$",
"this",
"->",
"checkStaticTemplateIsIncluded",
"(",
")",
";",
"$",
"this",
"->",
"checkSettings",
"(",
")",
";",
"$",
"this",
"->",
"slotExtendedAssignMultiple",
"(",
"[",
"self",
"::",
"VIEW_VARIABLE_ASSOCIATION_ID",
"=>",
"$",
"this",
"->",
"settings",
"[",
"self",
"::",
"SETTINGS_ASSOCIATION_ID",
"]",
",",
"self",
"::",
"VIEW_VARIABLE_ANNOUNCEMENT_ID",
"=>",
"$",
"anID",
"]",
",",
"__CLASS__",
",",
"__FUNCTION__",
")",
";",
"return",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | detail announcement action.
@param string $anID announcement ID
@return string | [
"detail",
"announcement",
"action",
"."
] | 9b63790d2fc9fd21bf415b4a5757678895b73bbc | https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AnnouncementController.php#L52-L63 |
10,878 | helthe/Segmentio | HttpClient.php | HttpClient.sendData | public function sendData($userId)
{
$this->client->post('http://api.segment.io/v1/import', array('body' => json_encode(array(
'secret' => $this->getWriteKey(),
'batch' => $this->buildBatch($userId)
))));
} | php | public function sendData($userId)
{
$this->client->post('http://api.segment.io/v1/import', array('body' => json_encode(array(
'secret' => $this->getWriteKey(),
'batch' => $this->buildBatch($userId)
))));
} | [
"public",
"function",
"sendData",
"(",
"$",
"userId",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"'http://api.segment.io/v1/import'",
",",
"array",
"(",
"'body'",
"=>",
"json_encode",
"(",
"array",
"(",
"'secret'",
"=>",
"$",
"this",
"->",
"getWriteKey",
"(",
")",
",",
"'batch'",
"=>",
"$",
"this",
"->",
"buildBatch",
"(",
"$",
"userId",
")",
")",
")",
")",
")",
";",
"}"
] | Sends the data to Segment.io for the given user id.
@param string $userId | [
"Sends",
"the",
"data",
"to",
"Segment",
".",
"io",
"for",
"the",
"given",
"user",
"id",
"."
] | 40a97cf9780404bf0a48ad4621cc994ca66e9128 | https://github.com/helthe/Segmentio/blob/40a97cf9780404bf0a48ad4621cc994ca66e9128/HttpClient.php#L50-L56 |
10,879 | helthe/Segmentio | HttpClient.php | HttpClient.buildBatch | private function buildBatch($userId)
{
$batch = array();
while ($method = $this->getQueue()->dequeue(MethodInterface::SERVER_PLATFORM)) {
$batch[] = $this->getMethodData($method, $userId);
}
return $batch;
} | php | private function buildBatch($userId)
{
$batch = array();
while ($method = $this->getQueue()->dequeue(MethodInterface::SERVER_PLATFORM)) {
$batch[] = $this->getMethodData($method, $userId);
}
return $batch;
} | [
"private",
"function",
"buildBatch",
"(",
"$",
"userId",
")",
"{",
"$",
"batch",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"method",
"=",
"$",
"this",
"->",
"getQueue",
"(",
")",
"->",
"dequeue",
"(",
"MethodInterface",
"::",
"SERVER_PLATFORM",
")",
")",
"{",
"$",
"batch",
"[",
"]",
"=",
"$",
"this",
"->",
"getMethodData",
"(",
"$",
"method",
",",
"$",
"userId",
")",
";",
"}",
"return",
"$",
"batch",
";",
"}"
] | Builds the batch of method data for the given user id.
@param string $userId
@return array | [
"Builds",
"the",
"batch",
"of",
"method",
"data",
"for",
"the",
"given",
"user",
"id",
"."
] | 40a97cf9780404bf0a48ad4621cc994ca66e9128 | https://github.com/helthe/Segmentio/blob/40a97cf9780404bf0a48ad4621cc994ca66e9128/HttpClient.php#L65-L74 |
10,880 | helthe/Segmentio | HttpClient.php | HttpClient.getMethodData | private function getMethodData(MethodInterface $method, $userId)
{
$data = $method->getArguments();
$data['action'] = $method->getName();
$data['secret'] = $this->getWriteKey();
// Don't overwrite the userId if it it is present.
if (!isset($data['userId']) && !isset($data['from'])) {
$data['userId'] = $userId;
}
return $data;
} | php | private function getMethodData(MethodInterface $method, $userId)
{
$data = $method->getArguments();
$data['action'] = $method->getName();
$data['secret'] = $this->getWriteKey();
// Don't overwrite the userId if it it is present.
if (!isset($data['userId']) && !isset($data['from'])) {
$data['userId'] = $userId;
}
return $data;
} | [
"private",
"function",
"getMethodData",
"(",
"MethodInterface",
"$",
"method",
",",
"$",
"userId",
")",
"{",
"$",
"data",
"=",
"$",
"method",
"->",
"getArguments",
"(",
")",
";",
"$",
"data",
"[",
"'action'",
"]",
"=",
"$",
"method",
"->",
"getName",
"(",
")",
";",
"$",
"data",
"[",
"'secret'",
"]",
"=",
"$",
"this",
"->",
"getWriteKey",
"(",
")",
";",
"// Don't overwrite the userId if it it is present.",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'userId'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"data",
"[",
"'from'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'userId'",
"]",
"=",
"$",
"userId",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Get the method data for the given user id.
@param MethodInterface $method
@param string $userId
@return array | [
"Get",
"the",
"method",
"data",
"for",
"the",
"given",
"user",
"id",
"."
] | 40a97cf9780404bf0a48ad4621cc994ca66e9128 | https://github.com/helthe/Segmentio/blob/40a97cf9780404bf0a48ad4621cc994ca66e9128/HttpClient.php#L84-L96 |
10,881 | frogsystem/legacy-bridge | src/Services/GlobalData.php | GlobalData.text | public function text($type, $tag)
{
$this->deprecate('text');
if (isset($this->text[$type]))
return $this->text[$type]->get($tag);
return null;
} | php | public function text($type, $tag)
{
$this->deprecate('text');
if (isset($this->text[$type]))
return $this->text[$type]->get($tag);
return null;
} | [
"public",
"function",
"text",
"(",
"$",
"type",
",",
"$",
"tag",
")",
"{",
"$",
"this",
"->",
"deprecate",
"(",
"'text'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"text",
"[",
"$",
"type",
"]",
")",
")",
"return",
"$",
"this",
"->",
"text",
"[",
"$",
"type",
"]",
"->",
"get",
"(",
"$",
"tag",
")",
";",
"return",
"null",
";",
"}"
] | Return the text internal
@param $type
@param $tag
@return null | [
"Return",
"the",
"text",
"internal"
] | a4ea3bea701e2b737c119a5d89b7778e8745658c | https://github.com/frogsystem/legacy-bridge/blob/a4ea3bea701e2b737c119a5d89b7778e8745658c/src/Services/GlobalData.php#L69-L76 |
10,882 | tenside/core-bundle | src/Controller/AbstractController.php | AbstractController.getComposer | public function getComposer(IOInterface $inputOutput = null)
{
if (null === $inputOutput) {
$inputOutput = $this->getInputOutput();
}
RuntimeHelper::setupHome($this->getTensideHome());
return ComposerFactory::create($inputOutput);
} | php | public function getComposer(IOInterface $inputOutput = null)
{
if (null === $inputOutput) {
$inputOutput = $this->getInputOutput();
}
RuntimeHelper::setupHome($this->getTensideHome());
return ComposerFactory::create($inputOutput);
} | [
"public",
"function",
"getComposer",
"(",
"IOInterface",
"$",
"inputOutput",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"inputOutput",
")",
"{",
"$",
"inputOutput",
"=",
"$",
"this",
"->",
"getInputOutput",
"(",
")",
";",
"}",
"RuntimeHelper",
"::",
"setupHome",
"(",
"$",
"this",
"->",
"getTensideHome",
"(",
")",
")",
";",
"return",
"ComposerFactory",
"::",
"create",
"(",
"$",
"inputOutput",
")",
";",
"}"
] | Retrieve a composer instance.
@param null|IOInterface $inputOutput The input/output handler to use.
@return Composer | [
"Retrieve",
"a",
"composer",
"instance",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Controller/AbstractController.php#L79-L87 |
10,883 | interactivesolutions/honeycomb-galleries | src/app/forms/HCGalleriesForm.php | HCGalleriesForm.getNewStructure | public function getNewStructure()
{
return [
[
"type" => "singleLine",
"fieldID" => $this->prefix . "title",
"tabID" => trans("Translations"),
"label" => trans("HCGalleries::galleries.title"),
"required" => 1,
"requiredVisible" => 1,
"multiLanguage" => 1,
],
[
"type" => "richTextArea",
"fieldID" => $this->prefix . "content",
"tabID" => trans("Translations"),
"label" => trans("HCGalleries::galleries.content"),
"multiLanguage" => 1,
],
[
"type" => "singleLine",
"fieldID" => $this->prefix . "location",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.location"),
"multiLanguage" => 1,
],
[
"type" => "dateTimePicker",
"properties" => [
"format" => "YYYY-MM-DD HH:mm:ss",
],
"fieldID" => $this->prefix . "publish_at",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.publish_at"),
"requiredVisible" => 1,
], [
"type" => "dateTimePicker",
"properties" => [
"format" => "YYYY-MM-DD HH:mm:ss",
],
"fieldID" => $this->prefix . "expires_at",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.expires_at"),
],
[
"type" => "resource",
"fieldID" => $this->prefix . "images",
"tabID" => trans("Resources"),
"uploadURL" => route("admin.api.resources"),
"viewURL" => route("resource.get", ['/']),
"sortable" => 1,
],
];
} | php | public function getNewStructure()
{
return [
[
"type" => "singleLine",
"fieldID" => $this->prefix . "title",
"tabID" => trans("Translations"),
"label" => trans("HCGalleries::galleries.title"),
"required" => 1,
"requiredVisible" => 1,
"multiLanguage" => 1,
],
[
"type" => "richTextArea",
"fieldID" => $this->prefix . "content",
"tabID" => trans("Translations"),
"label" => trans("HCGalleries::galleries.content"),
"multiLanguage" => 1,
],
[
"type" => "singleLine",
"fieldID" => $this->prefix . "location",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.location"),
"multiLanguage" => 1,
],
[
"type" => "dateTimePicker",
"properties" => [
"format" => "YYYY-MM-DD HH:mm:ss",
],
"fieldID" => $this->prefix . "publish_at",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.publish_at"),
"requiredVisible" => 1,
], [
"type" => "dateTimePicker",
"properties" => [
"format" => "YYYY-MM-DD HH:mm:ss",
],
"fieldID" => $this->prefix . "expires_at",
"tabID" => trans("General"),
"label" => trans("HCGalleries::galleries.expires_at"),
],
[
"type" => "resource",
"fieldID" => $this->prefix . "images",
"tabID" => trans("Resources"),
"uploadURL" => route("admin.api.resources"),
"viewURL" => route("resource.get", ['/']),
"sortable" => 1,
],
];
} | [
"public",
"function",
"getNewStructure",
"(",
")",
"{",
"return",
"[",
"[",
"\"type\"",
"=>",
"\"singleLine\"",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"title\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"Translations\"",
")",
",",
"\"label\"",
"=>",
"trans",
"(",
"\"HCGalleries::galleries.title\"",
")",
",",
"\"required\"",
"=>",
"1",
",",
"\"requiredVisible\"",
"=>",
"1",
",",
"\"multiLanguage\"",
"=>",
"1",
",",
"]",
",",
"[",
"\"type\"",
"=>",
"\"richTextArea\"",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"content\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"Translations\"",
")",
",",
"\"label\"",
"=>",
"trans",
"(",
"\"HCGalleries::galleries.content\"",
")",
",",
"\"multiLanguage\"",
"=>",
"1",
",",
"]",
",",
"[",
"\"type\"",
"=>",
"\"singleLine\"",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"location\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"General\"",
")",
",",
"\"label\"",
"=>",
"trans",
"(",
"\"HCGalleries::galleries.location\"",
")",
",",
"\"multiLanguage\"",
"=>",
"1",
",",
"]",
",",
"[",
"\"type\"",
"=>",
"\"dateTimePicker\"",
",",
"\"properties\"",
"=>",
"[",
"\"format\"",
"=>",
"\"YYYY-MM-DD HH:mm:ss\"",
",",
"]",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"publish_at\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"General\"",
")",
",",
"\"label\"",
"=>",
"trans",
"(",
"\"HCGalleries::galleries.publish_at\"",
")",
",",
"\"requiredVisible\"",
"=>",
"1",
",",
"]",
",",
"[",
"\"type\"",
"=>",
"\"dateTimePicker\"",
",",
"\"properties\"",
"=>",
"[",
"\"format\"",
"=>",
"\"YYYY-MM-DD HH:mm:ss\"",
",",
"]",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"expires_at\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"General\"",
")",
",",
"\"label\"",
"=>",
"trans",
"(",
"\"HCGalleries::galleries.expires_at\"",
")",
",",
"]",
",",
"[",
"\"type\"",
"=>",
"\"resource\"",
",",
"\"fieldID\"",
"=>",
"$",
"this",
"->",
"prefix",
".",
"\"images\"",
",",
"\"tabID\"",
"=>",
"trans",
"(",
"\"Resources\"",
")",
",",
"\"uploadURL\"",
"=>",
"route",
"(",
"\"admin.api.resources\"",
")",
",",
"\"viewURL\"",
"=>",
"route",
"(",
"\"resource.get\"",
",",
"[",
"'/'",
"]",
")",
",",
"\"sortable\"",
"=>",
"1",
",",
"]",
",",
"]",
";",
"}"
] | New form structure
@return array | [
"New",
"form",
"structure"
] | ae625d0bf0b3dadd99e76a1ab494021ef0aa82a8 | https://github.com/interactivesolutions/honeycomb-galleries/blob/ae625d0bf0b3dadd99e76a1ab494021ef0aa82a8/src/app/forms/HCGalleriesForm.php#L65-L120 |
10,884 | roygoldman/composer-installers-discovery | src/InstallEventHandler.php | InstallEventHandler.onPostPackageEvent | public function onPostPackageEvent(PackageEvent $event) {
// Get the effected package from the Event.
$installed_package = NULL;
$operation = $event->getOperation();
if ($operation instanceof UpdateOperation) {
$installed_package = $operation->getTargetPackage();
}
else {
$installed_package = $operation->getPackage();
}
$package_extra = $installed_package->getExtra();
// If the effected package has installers, reset cached installers.
if (isset($package_extra) && isset($package_extra['installer-paths'])) {
$composer = $event->getComposer();
$composer->getInstallationManager()->removeInstaller($this->installer);
$composer->getInstallationManager()->addInstaller($this->installer);
$this->installer->clearCache();
}
} | php | public function onPostPackageEvent(PackageEvent $event) {
// Get the effected package from the Event.
$installed_package = NULL;
$operation = $event->getOperation();
if ($operation instanceof UpdateOperation) {
$installed_package = $operation->getTargetPackage();
}
else {
$installed_package = $operation->getPackage();
}
$package_extra = $installed_package->getExtra();
// If the effected package has installers, reset cached installers.
if (isset($package_extra) && isset($package_extra['installer-paths'])) {
$composer = $event->getComposer();
$composer->getInstallationManager()->removeInstaller($this->installer);
$composer->getInstallationManager()->addInstaller($this->installer);
$this->installer->clearCache();
}
} | [
"public",
"function",
"onPostPackageEvent",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"// Get the effected package from the Event.",
"$",
"installed_package",
"=",
"NULL",
";",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"if",
"(",
"$",
"operation",
"instanceof",
"UpdateOperation",
")",
"{",
"$",
"installed_package",
"=",
"$",
"operation",
"->",
"getTargetPackage",
"(",
")",
";",
"}",
"else",
"{",
"$",
"installed_package",
"=",
"$",
"operation",
"->",
"getPackage",
"(",
")",
";",
"}",
"$",
"package_extra",
"=",
"$",
"installed_package",
"->",
"getExtra",
"(",
")",
";",
"// If the effected package has installers, reset cached installers.",
"if",
"(",
"isset",
"(",
"$",
"package_extra",
")",
"&&",
"isset",
"(",
"$",
"package_extra",
"[",
"'installer-paths'",
"]",
")",
")",
"{",
"$",
"composer",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
";",
"$",
"composer",
"->",
"getInstallationManager",
"(",
")",
"->",
"removeInstaller",
"(",
"$",
"this",
"->",
"installer",
")",
";",
"$",
"composer",
"->",
"getInstallationManager",
"(",
")",
"->",
"addInstaller",
"(",
"$",
"this",
"->",
"installer",
")",
";",
"$",
"this",
"->",
"installer",
"->",
"clearCache",
"(",
")",
";",
"}",
"}"
] | Event handler for to process package events.
@param \Composer\Installer\PackageEvent $event
Composer Package event for the currently installing package. | [
"Event",
"handler",
"for",
"to",
"process",
"package",
"events",
"."
] | c5cd1acf067ae0843a511fd9af114b837f9784af | https://github.com/roygoldman/composer-installers-discovery/blob/c5cd1acf067ae0843a511fd9af114b837f9784af/src/InstallEventHandler.php#L37-L56 |
10,885 | jpcercal/resource-manager | src/ResourceManager.php | ResourceManager.create | public static function create($driver, array $args = [])
{
if (is_string($driver) && lcfirst($driver) === 'doctrine') {
return new DoctrineResourceManager(new DoctrineDriver($args));
} elseif ($driver instanceof DoctrineDriver) {
return new DoctrineResourceManager($driver);
}
throw new \InvalidArgumentException(sprintf(
'The driver "%s" can not be found.',
is_string($driver) ? lcfirst($driver) : get_class($driver)
));
} | php | public static function create($driver, array $args = [])
{
if (is_string($driver) && lcfirst($driver) === 'doctrine') {
return new DoctrineResourceManager(new DoctrineDriver($args));
} elseif ($driver instanceof DoctrineDriver) {
return new DoctrineResourceManager($driver);
}
throw new \InvalidArgumentException(sprintf(
'The driver "%s" can not be found.',
is_string($driver) ? lcfirst($driver) : get_class($driver)
));
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"driver",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"driver",
")",
"&&",
"lcfirst",
"(",
"$",
"driver",
")",
"===",
"'doctrine'",
")",
"{",
"return",
"new",
"DoctrineResourceManager",
"(",
"new",
"DoctrineDriver",
"(",
"$",
"args",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"driver",
"instanceof",
"DoctrineDriver",
")",
"{",
"return",
"new",
"DoctrineResourceManager",
"(",
"$",
"driver",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The driver \"%s\" can not be found.'",
",",
"is_string",
"(",
"$",
"driver",
")",
"?",
"lcfirst",
"(",
"$",
"driver",
")",
":",
"get_class",
"(",
"$",
"driver",
")",
")",
")",
";",
"}"
] | Create a instance of ResourceManagerInterface.
@param string|DriverInterface $driver driver name
@param array $args if the fisrt argument is a string this
argument is used to set the driver options.
@return ResourceManagerInterface
@throws \InvalidArgumentException | [
"Create",
"a",
"instance",
"of",
"ResourceManagerInterface",
"."
] | e3565eb1ce3c0f7f16188596f0a58a42a35baa64 | https://github.com/jpcercal/resource-manager/blob/e3565eb1ce3c0f7f16188596f0a58a42a35baa64/src/ResourceManager.php#L37-L49 |
10,886 | wwtg99/StructureFiles | structure_files/FileType/CommonFile.php | CommonFile.download | public function download($filename = '')
{
$filename = $this->formatFilename($filename);
if ($this->content) {
$this->printHeader();
header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
ob_clean();
echo $this->content;
} elseif ($this->path) {
$fsize = filesize($this->path);
$this->printHeader($fsize);
header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
ob_clean();
readfile($this->path);
}
} | php | public function download($filename = '')
{
$filename = $this->formatFilename($filename);
if ($this->content) {
$this->printHeader();
header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
ob_clean();
echo $this->content;
} elseif ($this->path) {
$fsize = filesize($this->path);
$this->printHeader($fsize);
header("Content-Disposition: attachment; filename=\"" . $filename . "\";" );
ob_clean();
readfile($this->path);
}
} | [
"public",
"function",
"download",
"(",
"$",
"filename",
"=",
"''",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"formatFilename",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"this",
"->",
"content",
")",
"{",
"$",
"this",
"->",
"printHeader",
"(",
")",
";",
"header",
"(",
"\"Content-Disposition: attachment; filename=\\\"\"",
".",
"$",
"filename",
".",
"\"\\\";\"",
")",
";",
"ob_clean",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"content",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"path",
")",
"{",
"$",
"fsize",
"=",
"filesize",
"(",
"$",
"this",
"->",
"path",
")",
";",
"$",
"this",
"->",
"printHeader",
"(",
"$",
"fsize",
")",
";",
"header",
"(",
"\"Content-Disposition: attachment; filename=\\\"\"",
".",
"$",
"filename",
".",
"\"\\\";\"",
")",
";",
"ob_clean",
"(",
")",
";",
"readfile",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}",
"}"
] | Download file in web browser.
@param string $filename
@return void | [
"Download",
"file",
"in",
"web",
"browser",
"."
] | 92e83116f9e7161c2d95b531ad03f4e3f1593f33 | https://github.com/wwtg99/StructureFiles/blob/92e83116f9e7161c2d95b531ad03f4e3f1593f33/structure_files/FileType/CommonFile.php#L65-L80 |
10,887 | veonik/VeonikBlogBundle | src/Controller/Admin/TagController.php | TagController.indexAction | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('VeonikBlogBundle:Tag')->findAll();
return array(
'entities' => $entities,
);
} | php | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('VeonikBlogBundle:Tag')->findAll();
return array(
'entities' => $entities,
);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entities",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'VeonikBlogBundle:Tag'",
")",
"->",
"findAll",
"(",
")",
";",
"return",
"array",
"(",
"'entities'",
"=>",
"$",
"entities",
",",
")",
";",
"}"
] | Lists all Tag entities.
@Route("s/", name="manage_tags")
@Template() | [
"Lists",
"all",
"Tag",
"entities",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/Admin/TagController.php#L33-L42 |
10,888 | veonik/VeonikBlogBundle | src/Controller/Admin/TagController.php | TagController.editAction | public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('VeonikBlogBundle:Tag')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Tag entity.');
}
$form = $this->createForm(new TagType(), $entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function editAction($id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('VeonikBlogBundle:Tag')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Tag entity.');
}
$form = $this->createForm(new TagType(), $entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'VeonikBlogBundle:Tag'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Tag entity.'",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"TagType",
"(",
")",
",",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to edit an existing Tag entity.
@Route("/{id}/edit", name="manage_tag_edit")
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"Tag",
"entity",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/Admin/TagController.php#L96-L112 |
10,889 | veonik/VeonikBlogBundle | src/Controller/Admin/TagController.php | TagController.updateAction | public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('VeonikBlogBundle:Tag')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Tag entity.');
}
$form = $this->createForm(new TagType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The tag has been updated successfully.');
return $this->redirect($this->generateUrl('manage_tags'));
}
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$entity = $em->getRepository('VeonikBlogBundle:Tag')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Tag entity.');
}
$form = $this->createForm(new TagType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$em->persist($entity);
$em->flush();
$this->getSession()->getFlashBag()->set('success', 'The tag has been updated successfully.');
return $this->redirect($this->generateUrl('manage_tags'));
}
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'VeonikBlogBundle:Tag'",
")",
"->",
"find",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Tag entity.'",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"TagType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"form",
"->",
"bind",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"set",
"(",
"'success'",
",",
"'The tag has been updated successfully.'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'manage_tags'",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Edits an existing Tag entity.
@Route("/{id}/update", name="manage_tag_update")
@Method("POST")
@Template("VeonikBlogBundle:Admin/Tag:edit.html.twig") | [
"Edits",
"an",
"existing",
"Tag",
"entity",
"."
] | 52cca6b37feadd77fa564600b4db0e8e196099dd | https://github.com/veonik/VeonikBlogBundle/blob/52cca6b37feadd77fa564600b4db0e8e196099dd/src/Controller/Admin/TagController.php#L121-L147 |
10,890 | artscorestudio/website-bundle | Twig/Extension/LayoutHelpersExtension.php | LayoutHelpersExtension.getParameter | public function getParameter(\Twig_Environment $environment, $parameterName, $configAlias = null, $debug = false)
{
$defaultConfig = $this->configManager->getRepository()->getDefaultConfiguration();
$this->config = count($defaultConfig) > 0 ? $defaultConfig[0] : null;
$parameters = array();
if ( $configAlias === null && $this->config !== null ) {
$params = $this->config->getParameters();
} elseif ( $this->config !== null ) {
$config = $this->configManager->getRepository()->findOneBy(array('alias' => $configAlias));
if ( $config === null ) {
throw new \Exception(sprintf('The configuration with name "%s" not found.', $configAlias));
}
$params = $config->getParameters();
}
if ( !isset($params) ) {
return;
}
foreach($params as $p) {
$parameters[$p->getName()] = $p->getValue();
}
if ( $debug === true && !isset($parameters[$parameterName]) ) {
throw new \Exception(sprintf('The parameter with name "%s" not found.', $parameterName));
}
return isset($parameters[$parameterName]) ? $parameters[$parameterName] : '';
} | php | public function getParameter(\Twig_Environment $environment, $parameterName, $configAlias = null, $debug = false)
{
$defaultConfig = $this->configManager->getRepository()->getDefaultConfiguration();
$this->config = count($defaultConfig) > 0 ? $defaultConfig[0] : null;
$parameters = array();
if ( $configAlias === null && $this->config !== null ) {
$params = $this->config->getParameters();
} elseif ( $this->config !== null ) {
$config = $this->configManager->getRepository()->findOneBy(array('alias' => $configAlias));
if ( $config === null ) {
throw new \Exception(sprintf('The configuration with name "%s" not found.', $configAlias));
}
$params = $config->getParameters();
}
if ( !isset($params) ) {
return;
}
foreach($params as $p) {
$parameters[$p->getName()] = $p->getValue();
}
if ( $debug === true && !isset($parameters[$parameterName]) ) {
throw new \Exception(sprintf('The parameter with name "%s" not found.', $parameterName));
}
return isset($parameters[$parameterName]) ? $parameters[$parameterName] : '';
} | [
"public",
"function",
"getParameter",
"(",
"\\",
"Twig_Environment",
"$",
"environment",
",",
"$",
"parameterName",
",",
"$",
"configAlias",
"=",
"null",
",",
"$",
"debug",
"=",
"false",
")",
"{",
"$",
"defaultConfig",
"=",
"$",
"this",
"->",
"configManager",
"->",
"getRepository",
"(",
")",
"->",
"getDefaultConfiguration",
"(",
")",
";",
"$",
"this",
"->",
"config",
"=",
"count",
"(",
"$",
"defaultConfig",
")",
">",
"0",
"?",
"$",
"defaultConfig",
"[",
"0",
"]",
":",
"null",
";",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"configAlias",
"===",
"null",
"&&",
"$",
"this",
"->",
"config",
"!==",
"null",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"config",
"->",
"getParameters",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"config",
"!==",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"configManager",
"->",
"getRepository",
"(",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'alias'",
"=>",
"$",
"configAlias",
")",
")",
";",
"if",
"(",
"$",
"config",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The configuration with name \"%s\" not found.'",
",",
"$",
"configAlias",
")",
")",
";",
"}",
"$",
"params",
"=",
"$",
"config",
"->",
"getParameters",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"params",
"as",
"$",
"p",
")",
"{",
"$",
"parameters",
"[",
"$",
"p",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"p",
"->",
"getValue",
"(",
")",
";",
"}",
"if",
"(",
"$",
"debug",
"===",
"true",
"&&",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'The parameter with name \"%s\" not found.'",
",",
"$",
"parameterName",
")",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"parameters",
"[",
"$",
"parameterName",
"]",
")",
"?",
"$",
"parameters",
"[",
"$",
"parameterName",
"]",
":",
"''",
";",
"}"
] | Return the website configuration parameter value | [
"Return",
"the",
"website",
"configuration",
"parameter",
"value"
] | 016d62d7558cd8c2fe821ae2645735149c5e6ee5 | https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Twig/Extension/LayoutHelpersExtension.php#L58-L87 |
10,891 | mlocati/composer-patcher | src/Util/PathResolver.php | PathResolver.resolve | public function resolve($path, $baseFolder)
{
if (!is_string($path)) {
return '';
}
if (stripos($path, 'file://') === 0) {
$path = substr($path, 7);
}
if ($path === '') {
return '';
}
if (preg_match('_^\w\w+://_', $path)) {
return $this->resolveRemotePath($path);
}
return $this->resolveLocalPath($path, $baseFolder);
} | php | public function resolve($path, $baseFolder)
{
if (!is_string($path)) {
return '';
}
if (stripos($path, 'file://') === 0) {
$path = substr($path, 7);
}
if ($path === '') {
return '';
}
if (preg_match('_^\w\w+://_', $path)) {
return $this->resolveRemotePath($path);
}
return $this->resolveLocalPath($path, $baseFolder);
} | [
"public",
"function",
"resolve",
"(",
"$",
"path",
",",
"$",
"baseFolder",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"stripos",
"(",
"$",
"path",
",",
"'file://'",
")",
"===",
"0",
")",
"{",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"7",
")",
";",
"}",
"if",
"(",
"$",
"path",
"===",
"''",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'_^\\w\\w+://_'",
",",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resolveRemotePath",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolveLocalPath",
"(",
"$",
"path",
",",
"$",
"baseFolder",
")",
";",
"}"
] | Resolve a local or remote path.
@param string $path The path to be resolved
@param string $baseFolder the absolute path to be used when $path is a local relative path
@throws \ComposerPatcher\Exception\PathNotFound when $path is not found
@return string Empty string if $path is not a string or if it's an empty string | [
"Resolve",
"a",
"local",
"or",
"remote",
"path",
"."
] | d8ba45c10b5cf8ac8da3591e09b6afd47fc10667 | https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Util/PathResolver.php#L65-L81 |
10,892 | wasabi-cms/core | src/View/Helper/MenuHelper.php | MenuHelper.renderNested | public function renderNested(array $items, $level = 0)
{
$out = '';
foreach ($items as $item) {
$out .= $this->_renderItem($item, $level);
}
return $out;
} | php | public function renderNested(array $items, $level = 0)
{
$out = '';
foreach ($items as $item) {
$out .= $this->_renderItem($item, $level);
}
return $out;
} | [
"public",
"function",
"renderNested",
"(",
"array",
"$",
"items",
",",
"$",
"level",
"=",
"0",
")",
"{",
"$",
"out",
"=",
"''",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"_renderItem",
"(",
"$",
"item",
",",
"$",
"level",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Render all nested items of a menu.
@param array $items The menu items to render.
@param int $level The current level of rendered menu items.
@return string The rendered items without an outer ul. | [
"Render",
"all",
"nested",
"items",
"of",
"a",
"menu",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/MenuHelper.php#L112-L119 |
10,893 | wasabi-cms/core | src/View/Helper/MenuHelper.php | MenuHelper.renderTree | public function renderTree($menuItems, $level = null)
{
$output = '';
$depth = ($level !== null) ? $level : 1;
foreach ($menuItems as $key => $menuItem) {
$classes = ['menu-item'];
$menuItemRow = $this->_View->element('../Menus/__menu-item-row', [
'menuItem' => $menuItem,
'level' => $level
]);
if (!empty($menuItem['children'])) {
$menuItemRow .= '<ul>' . $this->renderTree($menuItem['children'], $depth + 1) . '</ul>';
} else {
$classes[] = 'no-children';
}
$output .= '<li class="' . join(' ', $classes) . '" data-menu-item-id="' . $menuItem['id'] . '">' . $menuItemRow . '</li>';
}
return $output;
} | php | public function renderTree($menuItems, $level = null)
{
$output = '';
$depth = ($level !== null) ? $level : 1;
foreach ($menuItems as $key => $menuItem) {
$classes = ['menu-item'];
$menuItemRow = $this->_View->element('../Menus/__menu-item-row', [
'menuItem' => $menuItem,
'level' => $level
]);
if (!empty($menuItem['children'])) {
$menuItemRow .= '<ul>' . $this->renderTree($menuItem['children'], $depth + 1) . '</ul>';
} else {
$classes[] = 'no-children';
}
$output .= '<li class="' . join(' ', $classes) . '" data-menu-item-id="' . $menuItem['id'] . '">' . $menuItemRow . '</li>';
}
return $output;
} | [
"public",
"function",
"renderTree",
"(",
"$",
"menuItems",
",",
"$",
"level",
"=",
"null",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"depth",
"=",
"(",
"$",
"level",
"!==",
"null",
")",
"?",
"$",
"level",
":",
"1",
";",
"foreach",
"(",
"$",
"menuItems",
"as",
"$",
"key",
"=>",
"$",
"menuItem",
")",
"{",
"$",
"classes",
"=",
"[",
"'menu-item'",
"]",
";",
"$",
"menuItemRow",
"=",
"$",
"this",
"->",
"_View",
"->",
"element",
"(",
"'../Menus/__menu-item-row'",
",",
"[",
"'menuItem'",
"=>",
"$",
"menuItem",
",",
"'level'",
"=>",
"$",
"level",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"menuItem",
"[",
"'children'",
"]",
")",
")",
"{",
"$",
"menuItemRow",
".=",
"'<ul>'",
".",
"$",
"this",
"->",
"renderTree",
"(",
"$",
"menuItem",
"[",
"'children'",
"]",
",",
"$",
"depth",
"+",
"1",
")",
".",
"'</ul>'",
";",
"}",
"else",
"{",
"$",
"classes",
"[",
"]",
"=",
"'no-children'",
";",
"}",
"$",
"output",
".=",
"'<li class=\"'",
".",
"join",
"(",
"' '",
",",
"$",
"classes",
")",
".",
"'\" data-menu-item-id=\"'",
".",
"$",
"menuItem",
"[",
"'id'",
"]",
".",
"'\">'",
".",
"$",
"menuItemRow",
".",
"'</li>'",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Used to render menu items as a ul li fake table
in the backend.
@param array $menuItems The menu items to render as tree.
@param null|int $level The current level.
@return string | [
"Used",
"to",
"render",
"menu",
"items",
"as",
"a",
"ul",
"li",
"fake",
"table",
"in",
"the",
"backend",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/MenuHelper.php#L129-L151 |
10,894 | wasabi-cms/core | src/View/Helper/MenuHelper.php | MenuHelper._buildItemClasses | protected function _buildItemClasses($item)
{
$cls = [
$this->config('itemClass')
];
if ($this->_isActive($item)) {
$cls[] = $this->config('itemActiveClass');
}
if ($this->_isOpen($item)) {
$cls[] = $this->config('itemOpenClass');
}
return $cls;
} | php | protected function _buildItemClasses($item)
{
$cls = [
$this->config('itemClass')
];
if ($this->_isActive($item)) {
$cls[] = $this->config('itemActiveClass');
}
if ($this->_isOpen($item)) {
$cls[] = $this->config('itemOpenClass');
}
return $cls;
} | [
"protected",
"function",
"_buildItemClasses",
"(",
"$",
"item",
")",
"{",
"$",
"cls",
"=",
"[",
"$",
"this",
"->",
"config",
"(",
"'itemClass'",
")",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_isActive",
"(",
"$",
"item",
")",
")",
"{",
"$",
"cls",
"[",
"]",
"=",
"$",
"this",
"->",
"config",
"(",
"'itemActiveClass'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_isOpen",
"(",
"$",
"item",
")",
")",
"{",
"$",
"cls",
"[",
"]",
"=",
"$",
"this",
"->",
"config",
"(",
"'itemOpenClass'",
")",
";",
"}",
"return",
"$",
"cls",
";",
"}"
] | Build the css classes for a menu item.
@param array $item The menu item.
@return array An array of applied css classes. | [
"Build",
"the",
"css",
"classes",
"for",
"a",
"menu",
"item",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/MenuHelper.php#L159-L174 |
10,895 | wasabi-cms/core | src/View/Helper/MenuHelper.php | MenuHelper._renderLink | protected function _renderLink($item, $level)
{
$templater = $this->templater();
if ($item['icon'] ?? false) {
$attrs = [
'class' => [
$this->config('iconClass'),
$item['icon']
]
];
$icon = $this->formatTemplate('icon', [
'attrs' => $templater->formatAttributes($attrs)
]);
} else {
$icon = null;
}
if ($item['name_short'] ?? false) {
$attrs = [
'class' => $this->config('nameShortClass')
];
$shortName = $this->formatTemplate('name', [
'attrs' => $templater->formatAttributes($attrs),
'shortName' => $item['name_short']
]);
} else {
$shortName = null;
}
if ($item['name'] ?? false) {
$attrs = [
'class' => $this->config('nameClass')
];
$name = $this->formatTemplate('name', [
'attrs' => $templater->formatAttributes($attrs),
'name' => $item['name']
]);
} else {
$name = null;
}
if ($this->_hasChildren($item)) {
$attrs = [
'class' => $this->config('caretClass')
];
$caret = $this->formatTemplate('caret', [
'attrs' => $templater->formatAttributes($attrs)
]);
} else {
$caret = null;
}
$linkContent = $this->formatTemplate('linkContent', compact('icon', 'shortName', 'name', 'caret'));
$options = [
'class' => $this->_buildLinkClasses($level),
'escape' => false
];
if (isset($item['url']) && !empty($item['url'])) {
return $this->Guardian->protectedLink($linkContent, $item['url'], $options);
}
return $this->Html->link($linkContent, 'javascript:void(0)', $options);
} | php | protected function _renderLink($item, $level)
{
$templater = $this->templater();
if ($item['icon'] ?? false) {
$attrs = [
'class' => [
$this->config('iconClass'),
$item['icon']
]
];
$icon = $this->formatTemplate('icon', [
'attrs' => $templater->formatAttributes($attrs)
]);
} else {
$icon = null;
}
if ($item['name_short'] ?? false) {
$attrs = [
'class' => $this->config('nameShortClass')
];
$shortName = $this->formatTemplate('name', [
'attrs' => $templater->formatAttributes($attrs),
'shortName' => $item['name_short']
]);
} else {
$shortName = null;
}
if ($item['name'] ?? false) {
$attrs = [
'class' => $this->config('nameClass')
];
$name = $this->formatTemplate('name', [
'attrs' => $templater->formatAttributes($attrs),
'name' => $item['name']
]);
} else {
$name = null;
}
if ($this->_hasChildren($item)) {
$attrs = [
'class' => $this->config('caretClass')
];
$caret = $this->formatTemplate('caret', [
'attrs' => $templater->formatAttributes($attrs)
]);
} else {
$caret = null;
}
$linkContent = $this->formatTemplate('linkContent', compact('icon', 'shortName', 'name', 'caret'));
$options = [
'class' => $this->_buildLinkClasses($level),
'escape' => false
];
if (isset($item['url']) && !empty($item['url'])) {
return $this->Guardian->protectedLink($linkContent, $item['url'], $options);
}
return $this->Html->link($linkContent, 'javascript:void(0)', $options);
} | [
"protected",
"function",
"_renderLink",
"(",
"$",
"item",
",",
"$",
"level",
")",
"{",
"$",
"templater",
"=",
"$",
"this",
"->",
"templater",
"(",
")",
";",
"if",
"(",
"$",
"item",
"[",
"'icon'",
"]",
"??",
"false",
")",
"{",
"$",
"attrs",
"=",
"[",
"'class'",
"=>",
"[",
"$",
"this",
"->",
"config",
"(",
"'iconClass'",
")",
",",
"$",
"item",
"[",
"'icon'",
"]",
"]",
"]",
";",
"$",
"icon",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'icon'",
",",
"[",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"attrs",
")",
"]",
")",
";",
"}",
"else",
"{",
"$",
"icon",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"item",
"[",
"'name_short'",
"]",
"??",
"false",
")",
"{",
"$",
"attrs",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"config",
"(",
"'nameShortClass'",
")",
"]",
";",
"$",
"shortName",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'name'",
",",
"[",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"attrs",
")",
",",
"'shortName'",
"=>",
"$",
"item",
"[",
"'name_short'",
"]",
"]",
")",
";",
"}",
"else",
"{",
"$",
"shortName",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"item",
"[",
"'name'",
"]",
"??",
"false",
")",
"{",
"$",
"attrs",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"config",
"(",
"'nameClass'",
")",
"]",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'name'",
",",
"[",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"attrs",
")",
",",
"'name'",
"=>",
"$",
"item",
"[",
"'name'",
"]",
"]",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_hasChildren",
"(",
"$",
"item",
")",
")",
"{",
"$",
"attrs",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"config",
"(",
"'caretClass'",
")",
"]",
";",
"$",
"caret",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'caret'",
",",
"[",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"attrs",
")",
"]",
")",
";",
"}",
"else",
"{",
"$",
"caret",
"=",
"null",
";",
"}",
"$",
"linkContent",
"=",
"$",
"this",
"->",
"formatTemplate",
"(",
"'linkContent'",
",",
"compact",
"(",
"'icon'",
",",
"'shortName'",
",",
"'name'",
",",
"'caret'",
")",
")",
";",
"$",
"options",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"_buildLinkClasses",
"(",
"$",
"level",
")",
",",
"'escape'",
"=>",
"false",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'url'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"item",
"[",
"'url'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"Guardian",
"->",
"protectedLink",
"(",
"$",
"linkContent",
",",
"$",
"item",
"[",
"'url'",
"]",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"this",
"->",
"Html",
"->",
"link",
"(",
"$",
"linkContent",
",",
"'javascript:void(0)'",
",",
"$",
"options",
")",
";",
"}"
] | Render the link of the menu item.
@param array $item The menu item.
@param int $level The current nesting level.
@return string | [
"Render",
"the",
"link",
"of",
"the",
"menu",
"item",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/MenuHelper.php#L270-L335 |
10,896 | wasabi-cms/core | src/View/Helper/MenuHelper.php | MenuHelper._renderChildren | protected function _renderChildren($item, $level)
{
if (!$this->_hasChildren($item)) {
return '';
}
$subnavItems = $this->renderNested($item['children'], $level);
if ($subnavItems === '') {
return '';
}
$templater = $this->templater();
$htmlAttributes = [
'class' => $this->_buildSubnavClasses($item, $level)
];
return $this->formatTemplate('subnav', [
'attrs' => $templater->formatAttributes($htmlAttributes),
'items' => $subnavItems
]);
} | php | protected function _renderChildren($item, $level)
{
if (!$this->_hasChildren($item)) {
return '';
}
$subnavItems = $this->renderNested($item['children'], $level);
if ($subnavItems === '') {
return '';
}
$templater = $this->templater();
$htmlAttributes = [
'class' => $this->_buildSubnavClasses($item, $level)
];
return $this->formatTemplate('subnav', [
'attrs' => $templater->formatAttributes($htmlAttributes),
'items' => $subnavItems
]);
} | [
"protected",
"function",
"_renderChildren",
"(",
"$",
"item",
",",
"$",
"level",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_hasChildren",
"(",
"$",
"item",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"subnavItems",
"=",
"$",
"this",
"->",
"renderNested",
"(",
"$",
"item",
"[",
"'children'",
"]",
",",
"$",
"level",
")",
";",
"if",
"(",
"$",
"subnavItems",
"===",
"''",
")",
"{",
"return",
"''",
";",
"}",
"$",
"templater",
"=",
"$",
"this",
"->",
"templater",
"(",
")",
";",
"$",
"htmlAttributes",
"=",
"[",
"'class'",
"=>",
"$",
"this",
"->",
"_buildSubnavClasses",
"(",
"$",
"item",
",",
"$",
"level",
")",
"]",
";",
"return",
"$",
"this",
"->",
"formatTemplate",
"(",
"'subnav'",
",",
"[",
"'attrs'",
"=>",
"$",
"templater",
"->",
"formatAttributes",
"(",
"$",
"htmlAttributes",
")",
",",
"'items'",
"=>",
"$",
"subnavItems",
"]",
")",
";",
"}"
] | Render the subnavigation of the menu item.
@param array $item The menu item.
@param int $level The current
@return string | [
"Render",
"the",
"subnavigation",
"of",
"the",
"menu",
"item",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/MenuHelper.php#L344-L365 |
10,897 | mlocati/composer-patcher | src/Plugin.php | Plugin.getPatchCollection | protected function getPatchCollection()
{
if ($this->patchCollection === null) {
$patchCollector = $this->getPatchCollector();
$packages = $this->getLocalRepositoryPackages(true);
$this->patchCollection = $patchCollector->collectPatches($this->composer->getPackage(), $packages);
}
return $this->patchCollection;
} | php | protected function getPatchCollection()
{
if ($this->patchCollection === null) {
$patchCollector = $this->getPatchCollector();
$packages = $this->getLocalRepositoryPackages(true);
$this->patchCollection = $patchCollector->collectPatches($this->composer->getPackage(), $packages);
}
return $this->patchCollection;
} | [
"protected",
"function",
"getPatchCollection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"patchCollection",
"===",
"null",
")",
"{",
"$",
"patchCollector",
"=",
"$",
"this",
"->",
"getPatchCollector",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"this",
"->",
"getLocalRepositoryPackages",
"(",
"true",
")",
";",
"$",
"this",
"->",
"patchCollection",
"=",
"$",
"patchCollector",
"->",
"collectPatches",
"(",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
",",
"$",
"packages",
")",
";",
"}",
"return",
"$",
"this",
"->",
"patchCollection",
";",
"}"
] | The list of patches to be applied.
@return \ComposerPatcher\PatchCollection | [
"The",
"list",
"of",
"patches",
"to",
"be",
"applied",
"."
] | d8ba45c10b5cf8ac8da3591e09b6afd47fc10667 | https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L238-L247 |
10,898 | mlocati/composer-patcher | src/Plugin.php | Plugin.getPatcher | protected function getPatcher()
{
if ($this->patcher === null) {
$this->patcher = new Patcher($this->io, $this->composer->getInstallationManager(), $this->composer->getEventDispatcher(), new ProcessExecutor($this->io), $this->getVolatileDirectory());
}
return $this->patcher;
} | php | protected function getPatcher()
{
if ($this->patcher === null) {
$this->patcher = new Patcher($this->io, $this->composer->getInstallationManager(), $this->composer->getEventDispatcher(), new ProcessExecutor($this->io), $this->getVolatileDirectory());
}
return $this->patcher;
} | [
"protected",
"function",
"getPatcher",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"patcher",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"patcher",
"=",
"new",
"Patcher",
"(",
"$",
"this",
"->",
"io",
",",
"$",
"this",
"->",
"composer",
"->",
"getInstallationManager",
"(",
")",
",",
"$",
"this",
"->",
"composer",
"->",
"getEventDispatcher",
"(",
")",
",",
"new",
"ProcessExecutor",
"(",
"$",
"this",
"->",
"io",
")",
",",
"$",
"this",
"->",
"getVolatileDirectory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"patcher",
";",
"}"
] | Get the Patcher instance.
@return \ComposerPatcher\Patcher | [
"Get",
"the",
"Patcher",
"instance",
"."
] | d8ba45c10b5cf8ac8da3591e09b6afd47fc10667 | https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L262-L269 |
10,899 | mlocati/composer-patcher | src/Plugin.php | Plugin.mustInstallPatchesForPackage | protected function mustInstallPatchesForPackage(PackageInterface $package)
{
$result = false;
$patches = $this->getPatchCollection()->getPatchesFor($package);
if ($patches->isEmpty()) {
if ($this->io->isVerbose()) {
$this->io->write('<info>No patches found for '.$package->getName().'.</info>');
}
} else {
$result = true;
}
return $result;
} | php | protected function mustInstallPatchesForPackage(PackageInterface $package)
{
$result = false;
$patches = $this->getPatchCollection()->getPatchesFor($package);
if ($patches->isEmpty()) {
if ($this->io->isVerbose()) {
$this->io->write('<info>No patches found for '.$package->getName().'.</info>');
}
} else {
$result = true;
}
return $result;
} | [
"protected",
"function",
"mustInstallPatchesForPackage",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"patches",
"=",
"$",
"this",
"->",
"getPatchCollection",
"(",
")",
"->",
"getPatchesFor",
"(",
"$",
"package",
")",
";",
"if",
"(",
"$",
"patches",
"->",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isVerbose",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"'<info>No patches found for '",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"'.</info>'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Should we apply patches to the package?
@param \Composer\Package\PackageInterface $package the package to be patched
@return bool | [
"Should",
"we",
"apply",
"patches",
"to",
"the",
"package?"
] | d8ba45c10b5cf8ac8da3591e09b6afd47fc10667 | https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L311-L324 |
Subsets and Splits