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
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,000 | diatem-net/jin-filesystem | src/FileSystem/PublicSecuredFile.php | PublicSecuredFile.encodeValue | protected static function encodeValue($valueToEncode)
{
return openssl_encrypt($valueToEncode, self::$encodeMethod, self::$privateKey, false, self::$initializationVector);
} | php | protected static function encodeValue($valueToEncode)
{
return openssl_encrypt($valueToEncode, self::$encodeMethod, self::$privateKey, false, self::$initializationVector);
} | [
"protected",
"static",
"function",
"encodeValue",
"(",
"$",
"valueToEncode",
")",
"{",
"return",
"openssl_encrypt",
"(",
"$",
"valueToEncode",
",",
"self",
"::",
"$",
"encodeMethod",
",",
"self",
"::",
"$",
"privateKey",
",",
"false",
",",
"self",
"::",
"$",
"initializationVector",
")",
";",
"}"
] | Encode une valeur
@param string $valueToEncode Chaîne à encoder
@return string | [
"Encode",
"une",
"valeur"
] | 0a97844284ca48cb47e28ef2834f20b8a42ef798 | https://github.com/diatem-net/jin-filesystem/blob/0a97844284ca48cb47e28ef2834f20b8a42ef798/src/FileSystem/PublicSecuredFile.php#L310-L313 |
2,001 | lezhnev74/dummy-config-loader | src/Config.php | Config.get | public function get(string $key, $default = null)
{
// 1. split keys
$keys = explode(".", $key);
// 2. locate file
$config_file = $this->context_directory . DIRECTORY_SEPARATOR . array_shift($keys) . ".php";
// 3. load file contents
if (!isset($this->config_content[$config_file])) {
if (!is_file($config_file)) {
throw new \Exception("Config file was not found: " . $config_file);
}
$config_content = require($config_file);
} else {
$config_content = $this->config_content[$config_file];
}
// 4. locate desired key
try {
return $this->getNestedVar($config_content, $keys);
} catch (\Exception $e) {
return $default; // fallback if unable to locate desired key
}
} | php | public function get(string $key, $default = null)
{
// 1. split keys
$keys = explode(".", $key);
// 2. locate file
$config_file = $this->context_directory . DIRECTORY_SEPARATOR . array_shift($keys) . ".php";
// 3. load file contents
if (!isset($this->config_content[$config_file])) {
if (!is_file($config_file)) {
throw new \Exception("Config file was not found: " . $config_file);
}
$config_content = require($config_file);
} else {
$config_content = $this->config_content[$config_file];
}
// 4. locate desired key
try {
return $this->getNestedVar($config_content, $keys);
} catch (\Exception $e) {
return $default; // fallback if unable to locate desired key
}
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// 1. split keys",
"$",
"keys",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"key",
")",
";",
"// 2. locate file",
"$",
"config_file",
"=",
"$",
"this",
"->",
"context_directory",
".",
"DIRECTORY_SEPARATOR",
".",
"array_shift",
"(",
"$",
"keys",
")",
".",
"\".php\"",
";",
"// 3. load file contents",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config_content",
"[",
"$",
"config_file",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"config_file",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Config file was not found: \"",
".",
"$",
"config_file",
")",
";",
"}",
"$",
"config_content",
"=",
"require",
"(",
"$",
"config_file",
")",
";",
"}",
"else",
"{",
"$",
"config_content",
"=",
"$",
"this",
"->",
"config_content",
"[",
"$",
"config_file",
"]",
";",
"}",
"// 4. locate desired key",
"try",
"{",
"return",
"$",
"this",
"->",
"getNestedVar",
"(",
"$",
"config_content",
",",
"$",
"keys",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"default",
";",
"// fallback if unable to locate desired key",
"}",
"}"
] | get config value or fallback gracefully
@param string $key
@param null $default
@throws \Exception
@return mixed|null | [
"get",
"config",
"value",
"or",
"fallback",
"gracefully"
] | 989b295243ee271d3dca6e11081d10a5f227bb93 | https://github.com/lezhnev74/dummy-config-loader/blob/989b295243ee271d3dca6e11081d10a5f227bb93/src/Config.php#L44-L69 |
2,002 | OWeb/OWeb-Framework | OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php | Form.validateElements | public function validateElements(){
$this->_isValid = true;
$values = $this->getParams();
$this->recValidateElements($this->_elements, $values);
} | php | public function validateElements(){
$this->_isValid = true;
$values = $this->getParams();
$this->recValidateElements($this->_elements, $values);
} | [
"public",
"function",
"validateElements",
"(",
")",
"{",
"$",
"this",
"->",
"_isValid",
"=",
"true",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"getParams",
"(",
")",
";",
"$",
"this",
"->",
"recValidateElements",
"(",
"$",
"this",
"->",
"_elements",
",",
"$",
"values",
")",
";",
"}"
] | Will run a check on all elements to check if their values are correct.
Will also parse the values of the elements to whom parser validators are applied. | [
"Will",
"run",
"a",
"check",
"on",
"all",
"elements",
"to",
"check",
"if",
"their",
"values",
"are",
"correct",
".",
"Will",
"also",
"parse",
"the",
"values",
"of",
"the",
"elements",
"to",
"whom",
"parser",
"validators",
"are",
"applied",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php#L71-L76 |
2,003 | OWeb/OWeb-Framework | OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php | Form.addDisplayElement | public function addDisplayElement(\OWeb\types\Controller $element){
$this->_displayElements[] = $element;
if($element instanceof \Controller\OWeb\Helpers\Form\Elements\AbstractElement){
$this->_elements[] = $element;
}
//$element->init();
} | php | public function addDisplayElement(\OWeb\types\Controller $element){
$this->_displayElements[] = $element;
if($element instanceof \Controller\OWeb\Helpers\Form\Elements\AbstractElement){
$this->_elements[] = $element;
}
//$element->init();
} | [
"public",
"function",
"addDisplayElement",
"(",
"\\",
"OWeb",
"\\",
"types",
"\\",
"Controller",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"_displayElements",
"[",
"]",
"=",
"$",
"element",
";",
"if",
"(",
"$",
"element",
"instanceof",
"\\",
"Controller",
"\\",
"OWeb",
"\\",
"Helpers",
"\\",
"Form",
"\\",
"Elements",
"\\",
"AbstractElement",
")",
"{",
"$",
"this",
"->",
"_elements",
"[",
"]",
"=",
"$",
"element",
";",
"}",
"//$element->init();",
"}"
] | Add a display element to the Form. If this element is also a Form Element
then it will automatically be added to the list of form elements.
@param \OWeb\types\Controller $element The element to add | [
"Add",
"a",
"display",
"element",
"to",
"the",
"Form",
".",
"If",
"this",
"element",
"is",
"also",
"a",
"Form",
"Element",
"then",
"it",
"will",
"automatically",
"be",
"added",
"to",
"the",
"list",
"of",
"form",
"elements",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php#L113-L119 |
2,004 | OWeb/OWeb-Framework | OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php | Form.addElement | public function addElement(\Controller\OWeb\Helpers\Form\Elements\AbstractElement $element){
$this->_elements[] = $element;
//$element->init();
} | php | public function addElement(\Controller\OWeb\Helpers\Form\Elements\AbstractElement $element){
$this->_elements[] = $element;
//$element->init();
} | [
"public",
"function",
"addElement",
"(",
"\\",
"Controller",
"\\",
"OWeb",
"\\",
"Helpers",
"\\",
"Form",
"\\",
"Elements",
"\\",
"AbstractElement",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"_elements",
"[",
"]",
"=",
"$",
"element",
";",
"//$element->init();",
"}"
] | Adds an Form Element to the Form without adding it to the Display List.
@param \Controller\OWeb\Helpers\Form\Elements\AbstractElement $element | [
"Adds",
"an",
"Form",
"Element",
"to",
"the",
"Form",
"without",
"adding",
"it",
"to",
"the",
"Display",
"List",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php#L126-L129 |
2,005 | OWeb/OWeb-Framework | OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php | Form.setAction | public function setAction($actionName){
$this->_action = new Elements\Hidden();
$this->_action->setName('action');
$this->_action->setVal($actionName);
$this->_action->init();
} | php | public function setAction($actionName){
$this->_action = new Elements\Hidden();
$this->_action->setName('action');
$this->_action->setVal($actionName);
$this->_action->init();
} | [
"public",
"function",
"setAction",
"(",
"$",
"actionName",
")",
"{",
"$",
"this",
"->",
"_action",
"=",
"new",
"Elements",
"\\",
"Hidden",
"(",
")",
";",
"$",
"this",
"->",
"_action",
"->",
"setName",
"(",
"'action'",
")",
";",
"$",
"this",
"->",
"_action",
"->",
"setVal",
"(",
"$",
"actionName",
")",
";",
"$",
"this",
"->",
"_action",
"->",
"init",
"(",
")",
";",
"}"
] | Set the action of the form.
It will generate a hidden element with name action and the desired action name
@param type $actionName | [
"Set",
"the",
"action",
"of",
"the",
"form",
".",
"It",
"will",
"generate",
"a",
"hidden",
"element",
"with",
"name",
"action",
"and",
"the",
"desired",
"action",
"name"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/controllers/OWeb/Helpers/Form/Form.php#L163-L168 |
2,006 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.setFormat | public function setFormat(string $format)
{
// Control rendering by requested output format
$no_render_format = [
'json',
'xml',
'css',
'js',
'file'
];
if (in_array($format, $no_render_format)) {
$this->render = false;
}
$this->format = $format;
} | php | public function setFormat(string $format)
{
// Control rendering by requested output format
$no_render_format = [
'json',
'xml',
'css',
'js',
'file'
];
if (in_array($format, $no_render_format)) {
$this->render = false;
}
$this->format = $format;
} | [
"public",
"function",
"setFormat",
"(",
"string",
"$",
"format",
")",
"{",
"// Control rendering by requested output format",
"$",
"no_render_format",
"=",
"[",
"'json'",
",",
"'xml'",
",",
"'css'",
",",
"'js'",
",",
"'file'",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"format",
",",
"$",
"no_render_format",
")",
")",
"{",
"$",
"this",
"->",
"render",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"format",
"=",
"$",
"format",
";",
"}"
] | Sets the output format
@param string $format | [
"Sets",
"the",
"output",
"format"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L111-L127 |
2,007 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.ajax | public function ajax($selector = '#content')
{
$this->ajax = $this->di->get('core.ajax');
$cmd = new DomCommand($selector, 'html', '--empty--');
// Prepare a fresh ajax command object
$this->ajax_cmd = $cmd;
// Get content from Controller::run()
$content = $this->run();
if ($content !== false) {
$this->ajax_cmd->setArgs($content);
$this->ajax_cmd->setId(get_called_class() . '::' . $this->action);
if (empty($this->ajax_cmd->getSelector()) && !empty($selector)) {
$this->ajax_cmd->setSelector($selector);
}
$this->ajax->addCommand($this->ajax_cmd);
}
} | php | public function ajax($selector = '#content')
{
$this->ajax = $this->di->get('core.ajax');
$cmd = new DomCommand($selector, 'html', '--empty--');
// Prepare a fresh ajax command object
$this->ajax_cmd = $cmd;
// Get content from Controller::run()
$content = $this->run();
if ($content !== false) {
$this->ajax_cmd->setArgs($content);
$this->ajax_cmd->setId(get_called_class() . '::' . $this->action);
if (empty($this->ajax_cmd->getSelector()) && !empty($selector)) {
$this->ajax_cmd->setSelector($selector);
}
$this->ajax->addCommand($this->ajax_cmd);
}
} | [
"public",
"function",
"ajax",
"(",
"$",
"selector",
"=",
"'#content'",
")",
"{",
"$",
"this",
"->",
"ajax",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.ajax'",
")",
";",
"$",
"cmd",
"=",
"new",
"DomCommand",
"(",
"$",
"selector",
",",
"'html'",
",",
"'--empty--'",
")",
";",
"// Prepare a fresh ajax command object",
"$",
"this",
"->",
"ajax_cmd",
"=",
"$",
"cmd",
";",
"// Get content from Controller::run()",
"$",
"content",
"=",
"$",
"this",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"content",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"ajax_cmd",
"->",
"setArgs",
"(",
"$",
"content",
")",
";",
"$",
"this",
"->",
"ajax_cmd",
"->",
"setId",
"(",
"get_called_class",
"(",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"action",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"ajax_cmd",
"->",
"getSelector",
"(",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"selector",
")",
")",
"{",
"$",
"this",
"->",
"ajax_cmd",
"->",
"setSelector",
"(",
"$",
"selector",
")",
";",
"}",
"$",
"this",
"->",
"ajax",
"->",
"addCommand",
"(",
"$",
"this",
"->",
"ajax_cmd",
")",
";",
"}",
"}"
] | Ajax method to send the result of an action as ajax html command
This works similiar to the run() method and even uses it. The difference is that the renderesult is wrapped by an
ajax command object. This ajax command can be controlled by setting the wanted parameters via $this->ajax->...
@param string $selector
Optional jQuery selector to html() the result.
Can be overridden by setAjaxTarget() method.
Default: '#content' | [
"Ajax",
"method",
"to",
"send",
"the",
"result",
"of",
"an",
"action",
"as",
"ajax",
"html",
"command"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L282-L305 |
2,008 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.redirect | protected function redirect(string $target, array $params = [], bool $clear_post = true)
{
if (empty($params)) {
$params = $this->params;
}
$this->redirect = [
$target,
$params,
$clear_post
];
return $this;
} | php | protected function redirect(string $target, array $params = [], bool $clear_post = true)
{
if (empty($params)) {
$params = $this->params;
}
$this->redirect = [
$target,
$params,
$clear_post
];
return $this;
} | [
"protected",
"function",
"redirect",
"(",
"string",
"$",
"target",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"bool",
"$",
"clear_post",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
";",
"}",
"$",
"this",
"->",
"redirect",
"=",
"[",
"$",
"target",
",",
"$",
"params",
",",
"$",
"clear_post",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Redirects from one action to another
@param string|array $target
Name of redirectaction to call within this controller or an array aof app, controller and action name
which will be called as redirect.
@param array $params
Optional key => value array of params to pass into redirect action (Default: empty array)
@param bool $clear_post
Optional flag to control emptying posted data (Default: true) | [
"Redirects",
"from",
"one",
"action",
"to",
"another"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L318-L331 |
2,009 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.checkControllerAccess | protected function checkControllerAccess($force = false): bool
{
// Is there an global access method in the app main class to call?
if (method_exists($this->app, 'Access') && $this->app->Access() === false) {
return false;
}
// No ACL
if (empty($this->access)) {
return true;
}
$perm = [];
// Global access for all actions?
if (array_key_exists('*', $this->access)) {
if (!is_array($this->access['*'])) {
$this->access['*'] = (array) $this->access['*'];
}
$perm += $this->access['*'];
}
else {
// ACL exists but action not in it? This means to grant access.
if (!array_key_exists($this->action, $this->access)) {
return true;
}
}
// Actions access set?
if (isset($this->access[$this->action])) {
if (!is_array($this->access[$this->action])) {
$this->access[$this->action] = (array) $this->access[$this->action];
}
$perm += $this->access[$this->action];
}
// Check the permissions against the current user
if ($perm) {
return $this->checkAccess($perm);
}
return false;
} | php | protected function checkControllerAccess($force = false): bool
{
// Is there an global access method in the app main class to call?
if (method_exists($this->app, 'Access') && $this->app->Access() === false) {
return false;
}
// No ACL
if (empty($this->access)) {
return true;
}
$perm = [];
// Global access for all actions?
if (array_key_exists('*', $this->access)) {
if (!is_array($this->access['*'])) {
$this->access['*'] = (array) $this->access['*'];
}
$perm += $this->access['*'];
}
else {
// ACL exists but action not in it? This means to grant access.
if (!array_key_exists($this->action, $this->access)) {
return true;
}
}
// Actions access set?
if (isset($this->access[$this->action])) {
if (!is_array($this->access[$this->action])) {
$this->access[$this->action] = (array) $this->access[$this->action];
}
$perm += $this->access[$this->action];
}
// Check the permissions against the current user
if ($perm) {
return $this->checkAccess($perm);
}
return false;
} | [
"protected",
"function",
"checkControllerAccess",
"(",
"$",
"force",
"=",
"false",
")",
":",
"bool",
"{",
"// Is there an global access method in the app main class to call?",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"app",
",",
"'Access'",
")",
"&&",
"$",
"this",
"->",
"app",
"->",
"Access",
"(",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// No ACL",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"access",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"perm",
"=",
"[",
"]",
";",
"// Global access for all actions?",
"if",
"(",
"array_key_exists",
"(",
"'*'",
",",
"$",
"this",
"->",
"access",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"access",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"access",
"[",
"'*'",
"]",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"access",
"[",
"'*'",
"]",
";",
"}",
"$",
"perm",
"+=",
"$",
"this",
"->",
"access",
"[",
"'*'",
"]",
";",
"}",
"else",
"{",
"// ACL exists but action not in it? This means to grant access.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"action",
",",
"$",
"this",
"->",
"access",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// Actions access set?",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"access",
"[",
"$",
"this",
"->",
"action",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"access",
"[",
"$",
"this",
"->",
"action",
"]",
")",
")",
"{",
"$",
"this",
"->",
"access",
"[",
"$",
"this",
"->",
"action",
"]",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"access",
"[",
"$",
"this",
"->",
"action",
"]",
";",
"}",
"$",
"perm",
"+=",
"$",
"this",
"->",
"access",
"[",
"$",
"this",
"->",
"action",
"]",
";",
"}",
"// Check the permissions against the current user",
"if",
"(",
"$",
"perm",
")",
"{",
"return",
"$",
"this",
"->",
"checkAccess",
"(",
"$",
"perm",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Checks the controller access of the user
This accesscheck works on serveral levels.
Level 0 - App: Tries to check access on possible app wide access function.
Level 1 - Controller: Tries to check access by looking for access setting in the controller itself.
@param bool $force
Set this to true if you want to force a brutal stop
@return boolean | [
"Checks",
"the",
"controller",
"access",
"of",
"the",
"user"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L366-L411 |
2,010 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.getFormDesigner | protected function getFormDesigner($id = '')
{
/* @var $fd \Core\Html\FormDesigner\FormDesigner */
$fd = new FormDesigner($this->app->getName(true));
// Generate form id when id is not provided
if (!$id) {
$pieces = [];
$string = new CamelCase($this->app->getName());
$pieces[] = $string->uncamelize();
$string->setString($this->name);
$pieces[] = $string->uncamelize();
// get calling method name
$dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
if (isset($dbt[1]['function'])) {
$string->setString($dbt[1]['function']);
$pieces[] = $string->uncamelize();
}
$id = implode('-', $pieces);
}
if ($id) {
$fd->setId($id);
}
// Create forms eaction url
if (isset($this->route)) {
$fd->html->setAction($this->app->url($this->route, $this->params));
}
// Set session token
$fd->setToken($this->di->get('core.security.form.token.name'), $this->di->get('core.security.form.token'));
return $fd;
} | php | protected function getFormDesigner($id = '')
{
/* @var $fd \Core\Html\FormDesigner\FormDesigner */
$fd = new FormDesigner($this->app->getName(true));
// Generate form id when id is not provided
if (!$id) {
$pieces = [];
$string = new CamelCase($this->app->getName());
$pieces[] = $string->uncamelize();
$string->setString($this->name);
$pieces[] = $string->uncamelize();
// get calling method name
$dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
if (isset($dbt[1]['function'])) {
$string->setString($dbt[1]['function']);
$pieces[] = $string->uncamelize();
}
$id = implode('-', $pieces);
}
if ($id) {
$fd->setId($id);
}
// Create forms eaction url
if (isset($this->route)) {
$fd->html->setAction($this->app->url($this->route, $this->params));
}
// Set session token
$fd->setToken($this->di->get('core.security.form.token.name'), $this->di->get('core.security.form.token'));
return $fd;
} | [
"protected",
"function",
"getFormDesigner",
"(",
"$",
"id",
"=",
"''",
")",
"{",
"/* @var $fd \\Core\\Html\\FormDesigner\\FormDesigner */",
"$",
"fd",
"=",
"new",
"FormDesigner",
"(",
"$",
"this",
"->",
"app",
"->",
"getName",
"(",
"true",
")",
")",
";",
"// Generate form id when id is not provided",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"pieces",
"=",
"[",
"]",
";",
"$",
"string",
"=",
"new",
"CamelCase",
"(",
"$",
"this",
"->",
"app",
"->",
"getName",
"(",
")",
")",
";",
"$",
"pieces",
"[",
"]",
"=",
"$",
"string",
"->",
"uncamelize",
"(",
")",
";",
"$",
"string",
"->",
"setString",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"pieces",
"[",
"]",
"=",
"$",
"string",
"->",
"uncamelize",
"(",
")",
";",
"// get calling method name",
"$",
"dbt",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
",",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"dbt",
"[",
"1",
"]",
"[",
"'function'",
"]",
")",
")",
"{",
"$",
"string",
"->",
"setString",
"(",
"$",
"dbt",
"[",
"1",
"]",
"[",
"'function'",
"]",
")",
";",
"$",
"pieces",
"[",
"]",
"=",
"$",
"string",
"->",
"uncamelize",
"(",
")",
";",
"}",
"$",
"id",
"=",
"implode",
"(",
"'-'",
",",
"$",
"pieces",
")",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"fd",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"}",
"// Create forms eaction url",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"route",
")",
")",
"{",
"$",
"fd",
"->",
"html",
"->",
"setAction",
"(",
"$",
"this",
"->",
"app",
"->",
"url",
"(",
"$",
"this",
"->",
"route",
",",
"$",
"this",
"->",
"params",
")",
")",
";",
"}",
"// Set session token",
"$",
"fd",
"->",
"setToken",
"(",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.security.form.token.name'",
")",
",",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"'core.security.form.token'",
")",
")",
";",
"return",
"$",
"fd",
";",
"}"
] | Shorthand method for a FormDesigner instance with auto attached model
@return FormDesigner | [
"Shorthand",
"method",
"for",
"a",
"FormDesigner",
"instance",
"with",
"auto",
"attached",
"model"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L470-L510 |
2,011 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.setAjaxTarget | protected function setAjaxTarget($target)
{
if (!empty($this->ajax_cmd)) {
$this->ajax_cmd->setSelector($target);
}
return $this;
} | php | protected function setAjaxTarget($target)
{
if (!empty($this->ajax_cmd)) {
$this->ajax_cmd->setSelector($target);
}
return $this;
} | [
"protected",
"function",
"setAjaxTarget",
"(",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"ajax_cmd",
")",
")",
"{",
"$",
"this",
"->",
"ajax_cmd",
"->",
"setSelector",
"(",
"$",
"target",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the selector name to where the result is ajaxed.
@param string $target
@return \Core\Framework\Amvc\Controller | [
"Sets",
"the",
"selector",
"name",
"to",
"where",
"the",
"result",
"is",
"ajaxed",
"."
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L519-L526 |
2,012 | tekkla/core-framework | Core/Framework/Amvc/Controller/Controller.php | Controller.redirectExit | protected function redirectExit($location = '', $permanent = false)
{
// No view rendering!
$this->render = false;
if (empty($location)) {
$location = BASEURL;
}
if (preg_match('~^(ftp|http)[s]?://~', $location) == 0 && substr($location, 0, 6) != 'about:') {
$location = BASEURL . $location;
}
$_SESSION['Core']['redirect'] = [
'location' => $location,
'permanent' => $permanent
];
} | php | protected function redirectExit($location = '', $permanent = false)
{
// No view rendering!
$this->render = false;
if (empty($location)) {
$location = BASEURL;
}
if (preg_match('~^(ftp|http)[s]?://~', $location) == 0 && substr($location, 0, 6) != 'about:') {
$location = BASEURL . $location;
}
$_SESSION['Core']['redirect'] = [
'location' => $location,
'permanent' => $permanent
];
} | [
"protected",
"function",
"redirectExit",
"(",
"$",
"location",
"=",
"''",
",",
"$",
"permanent",
"=",
"false",
")",
"{",
"// No view rendering!",
"$",
"this",
"->",
"render",
"=",
"false",
";",
"if",
"(",
"empty",
"(",
"$",
"location",
")",
")",
"{",
"$",
"location",
"=",
"BASEURL",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'~^(ftp|http)[s]?://~'",
",",
"$",
"location",
")",
"==",
"0",
"&&",
"substr",
"(",
"$",
"location",
",",
"0",
",",
"6",
")",
"!=",
"'about:'",
")",
"{",
"$",
"location",
"=",
"BASEURL",
".",
"$",
"location",
";",
"}",
"$",
"_SESSION",
"[",
"'Core'",
"]",
"[",
"'redirect'",
"]",
"=",
"[",
"'location'",
"=>",
"$",
"location",
",",
"'permanent'",
"=>",
"$",
"permanent",
"]",
";",
"}"
] | Redirect function to make sure the browser doesn't come back and repost the form data
@param string $location
Location we redirtect to
@param bool $permanent
Is this a permanent redirection? | [
"Redirect",
"function",
"to",
"make",
"sure",
"the",
"browser",
"doesn",
"t",
"come",
"back",
"and",
"repost",
"the",
"form",
"data"
] | ad69e9f15ee3644b6ca376edc30d8f5555399892 | https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/Controller/Controller.php#L565-L582 |
2,013 | arvici/framework | src/Arvici/Heart/Database/Database.php | Database.connection | public static function connection($name = 'default')
{
$databaseConfig = self::getConnectionConfiguration($name);
/** @var Driver $driver */
$driver = self::driver($name);
$username = isset($databaseConfig['username']) ? $databaseConfig['username'] : null;
$password = isset($databaseConfig['password']) ? $databaseConfig['password'] : null;
$options = isset($databaseConfig['options']) ? $databaseConfig['options'] : array();
// Create connection if we don't have it already
if (! isset(self::$connections[$name])) {
$connection = $driver->connect($databaseConfig, $username, $password, $options);
self::$connections[$name] = $connection;
}
return self::$connections[$name];
} | php | public static function connection($name = 'default')
{
$databaseConfig = self::getConnectionConfiguration($name);
/** @var Driver $driver */
$driver = self::driver($name);
$username = isset($databaseConfig['username']) ? $databaseConfig['username'] : null;
$password = isset($databaseConfig['password']) ? $databaseConfig['password'] : null;
$options = isset($databaseConfig['options']) ? $databaseConfig['options'] : array();
// Create connection if we don't have it already
if (! isset(self::$connections[$name])) {
$connection = $driver->connect($databaseConfig, $username, $password, $options);
self::$connections[$name] = $connection;
}
return self::$connections[$name];
} | [
"public",
"static",
"function",
"connection",
"(",
"$",
"name",
"=",
"'default'",
")",
"{",
"$",
"databaseConfig",
"=",
"self",
"::",
"getConnectionConfiguration",
"(",
"$",
"name",
")",
";",
"/** @var Driver $driver */",
"$",
"driver",
"=",
"self",
"::",
"driver",
"(",
"$",
"name",
")",
";",
"$",
"username",
"=",
"isset",
"(",
"$",
"databaseConfig",
"[",
"'username'",
"]",
")",
"?",
"$",
"databaseConfig",
"[",
"'username'",
"]",
":",
"null",
";",
"$",
"password",
"=",
"isset",
"(",
"$",
"databaseConfig",
"[",
"'password'",
"]",
")",
"?",
"$",
"databaseConfig",
"[",
"'password'",
"]",
":",
"null",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"databaseConfig",
"[",
"'options'",
"]",
")",
"?",
"$",
"databaseConfig",
"[",
"'options'",
"]",
":",
"array",
"(",
")",
";",
"// Create connection if we don't have it already",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"connections",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"connection",
"=",
"$",
"driver",
"->",
"connect",
"(",
"$",
"databaseConfig",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"self",
"::",
"$",
"connections",
"[",
"$",
"name",
"]",
"=",
"$",
"connection",
";",
"}",
"return",
"self",
"::",
"$",
"connections",
"[",
"$",
"name",
"]",
";",
"}"
] | Get connection instance for connection name.
@param string $name
@return Connection
@throws ConfigurationException | [
"Get",
"connection",
"instance",
"for",
"connection",
"name",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Database.php#L58-L77 |
2,014 | arvici/framework | src/Arvici/Heart/Database/Database.php | Database.entityManager | public static function entityManager($name = 'default')
{
if (isset(self::$entityManagers[$name])) {
return self::$entityManagers[$name];
}
$databaseConnection = self::connection($name)->getDbalConnection();
if (Configuration::get('app.env') == 'development') {
$cache = new ArrayCache();
} else { // @codeCoverageIgnore
$cache = new FilesystemCache(Configuration::get('app.cache')); // @codeCoverageIgnore
}
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl($cache);
$driver = $config->newDefaultAnnotationDriver([APPPATH . 'Entity'], false);
$config->setMetadataDriverImpl($driver);
$config->setQueryCacheImpl($cache);
$proxyDir = APPPATH . 'Proxy';
$proxyNamespace = 'App\Proxy';
$config->setProxyDir($proxyDir);
$config->setProxyNamespace($proxyNamespace);
Autoloader::register($proxyDir, $proxyNamespace);
$loggerChain = new LoggerChain();
if (Configuration::get('app.env') == 'development') {
$config->setAutoGenerateProxyClasses(true);
$loggerChain->addLogger(new DoctrineLogBridge(\Logger::getInstance()->getMonologInstance()));
$loggerChain->addLogger(DebugBarHelper::getInstance()->getDebugStack());
} else { // @codeCoverageIgnore
$config->setAutoGenerateProxyClasses(false); // @codeCoverageIgnore
}
$em = EntityManager::create($databaseConnection, $config);
$em->getConnection()->getConfiguration()->setSQLLogger($loggerChain);
$em->getConfiguration()->setSQLLogger($loggerChain);
self::$entityManagers[$name] = $em;
return $em;
} | php | public static function entityManager($name = 'default')
{
if (isset(self::$entityManagers[$name])) {
return self::$entityManagers[$name];
}
$databaseConnection = self::connection($name)->getDbalConnection();
if (Configuration::get('app.env') == 'development') {
$cache = new ArrayCache();
} else { // @codeCoverageIgnore
$cache = new FilesystemCache(Configuration::get('app.cache')); // @codeCoverageIgnore
}
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl($cache);
$driver = $config->newDefaultAnnotationDriver([APPPATH . 'Entity'], false);
$config->setMetadataDriverImpl($driver);
$config->setQueryCacheImpl($cache);
$proxyDir = APPPATH . 'Proxy';
$proxyNamespace = 'App\Proxy';
$config->setProxyDir($proxyDir);
$config->setProxyNamespace($proxyNamespace);
Autoloader::register($proxyDir, $proxyNamespace);
$loggerChain = new LoggerChain();
if (Configuration::get('app.env') == 'development') {
$config->setAutoGenerateProxyClasses(true);
$loggerChain->addLogger(new DoctrineLogBridge(\Logger::getInstance()->getMonologInstance()));
$loggerChain->addLogger(DebugBarHelper::getInstance()->getDebugStack());
} else { // @codeCoverageIgnore
$config->setAutoGenerateProxyClasses(false); // @codeCoverageIgnore
}
$em = EntityManager::create($databaseConnection, $config);
$em->getConnection()->getConfiguration()->setSQLLogger($loggerChain);
$em->getConfiguration()->setSQLLogger($loggerChain);
self::$entityManagers[$name] = $em;
return $em;
} | [
"public",
"static",
"function",
"entityManager",
"(",
"$",
"name",
"=",
"'default'",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"entityManagers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"entityManagers",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"databaseConnection",
"=",
"self",
"::",
"connection",
"(",
"$",
"name",
")",
"->",
"getDbalConnection",
"(",
")",
";",
"if",
"(",
"Configuration",
"::",
"get",
"(",
"'app.env'",
")",
"==",
"'development'",
")",
"{",
"$",
"cache",
"=",
"new",
"ArrayCache",
"(",
")",
";",
"}",
"else",
"{",
"// @codeCoverageIgnore",
"$",
"cache",
"=",
"new",
"FilesystemCache",
"(",
"Configuration",
"::",
"get",
"(",
"'app.cache'",
")",
")",
";",
"// @codeCoverageIgnore",
"}",
"$",
"config",
"=",
"new",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Configuration",
"(",
")",
";",
"$",
"config",
"->",
"setMetadataCacheImpl",
"(",
"$",
"cache",
")",
";",
"$",
"driver",
"=",
"$",
"config",
"->",
"newDefaultAnnotationDriver",
"(",
"[",
"APPPATH",
".",
"'Entity'",
"]",
",",
"false",
")",
";",
"$",
"config",
"->",
"setMetadataDriverImpl",
"(",
"$",
"driver",
")",
";",
"$",
"config",
"->",
"setQueryCacheImpl",
"(",
"$",
"cache",
")",
";",
"$",
"proxyDir",
"=",
"APPPATH",
".",
"'Proxy'",
";",
"$",
"proxyNamespace",
"=",
"'App\\Proxy'",
";",
"$",
"config",
"->",
"setProxyDir",
"(",
"$",
"proxyDir",
")",
";",
"$",
"config",
"->",
"setProxyNamespace",
"(",
"$",
"proxyNamespace",
")",
";",
"Autoloader",
"::",
"register",
"(",
"$",
"proxyDir",
",",
"$",
"proxyNamespace",
")",
";",
"$",
"loggerChain",
"=",
"new",
"LoggerChain",
"(",
")",
";",
"if",
"(",
"Configuration",
"::",
"get",
"(",
"'app.env'",
")",
"==",
"'development'",
")",
"{",
"$",
"config",
"->",
"setAutoGenerateProxyClasses",
"(",
"true",
")",
";",
"$",
"loggerChain",
"->",
"addLogger",
"(",
"new",
"DoctrineLogBridge",
"(",
"\\",
"Logger",
"::",
"getInstance",
"(",
")",
"->",
"getMonologInstance",
"(",
")",
")",
")",
";",
"$",
"loggerChain",
"->",
"addLogger",
"(",
"DebugBarHelper",
"::",
"getInstance",
"(",
")",
"->",
"getDebugStack",
"(",
")",
")",
";",
"}",
"else",
"{",
"// @codeCoverageIgnore",
"$",
"config",
"->",
"setAutoGenerateProxyClasses",
"(",
"false",
")",
";",
"// @codeCoverageIgnore",
"}",
"$",
"em",
"=",
"EntityManager",
"::",
"create",
"(",
"$",
"databaseConnection",
",",
"$",
"config",
")",
";",
"$",
"em",
"->",
"getConnection",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"setSQLLogger",
"(",
"$",
"loggerChain",
")",
";",
"$",
"em",
"->",
"getConfiguration",
"(",
")",
"->",
"setSQLLogger",
"(",
"$",
"loggerChain",
")",
";",
"self",
"::",
"$",
"entityManagers",
"[",
"$",
"name",
"]",
"=",
"$",
"em",
";",
"return",
"$",
"em",
";",
"}"
] | Get entity manager for the connection and apps.
@param string $name
@return EntityManager | [
"Get",
"entity",
"manager",
"for",
"the",
"connection",
"and",
"apps",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Database.php#L85-L128 |
2,015 | arvici/framework | src/Arvici/Heart/Database/Database.php | Database.driver | public static function driver($name = 'default', $driverName = null)
{
if ($name !== null && $driverName === null) {
$databaseConfig = self::getConnectionConfiguration($name);
$driverName = $databaseConfig['driver'];
}
// Make the driver if we don't have it already this run.
if (! isset(self::$drivers[$driverName])) {
// We will make the driver class first, prepare the full class name.
$driverClass = new \ReflectionClass("\\Arvici\\Heart\\Database\\Driver\\$driverName\\Driver");
self::$drivers[$driverName] = $driverClass->newInstance();
}
return self::$drivers[$driverName];
} | php | public static function driver($name = 'default', $driverName = null)
{
if ($name !== null && $driverName === null) {
$databaseConfig = self::getConnectionConfiguration($name);
$driverName = $databaseConfig['driver'];
}
// Make the driver if we don't have it already this run.
if (! isset(self::$drivers[$driverName])) {
// We will make the driver class first, prepare the full class name.
$driverClass = new \ReflectionClass("\\Arvici\\Heart\\Database\\Driver\\$driverName\\Driver");
self::$drivers[$driverName] = $driverClass->newInstance();
}
return self::$drivers[$driverName];
} | [
"public",
"static",
"function",
"driver",
"(",
"$",
"name",
"=",
"'default'",
",",
"$",
"driverName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
"&&",
"$",
"driverName",
"===",
"null",
")",
"{",
"$",
"databaseConfig",
"=",
"self",
"::",
"getConnectionConfiguration",
"(",
"$",
"name",
")",
";",
"$",
"driverName",
"=",
"$",
"databaseConfig",
"[",
"'driver'",
"]",
";",
"}",
"// Make the driver if we don't have it already this run.",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"drivers",
"[",
"$",
"driverName",
"]",
")",
")",
"{",
"// We will make the driver class first, prepare the full class name.",
"$",
"driverClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"\"\\\\Arvici\\\\Heart\\\\Database\\\\Driver\\\\$driverName\\\\Driver\"",
")",
";",
"self",
"::",
"$",
"drivers",
"[",
"$",
"driverName",
"]",
"=",
"$",
"driverClass",
"->",
"newInstance",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"drivers",
"[",
"$",
"driverName",
"]",
";",
"}"
] | Get driver instance for connection name or driver name.
@param string $name Connection name.
@param string $driverName Driver name.
@return Driver | [
"Get",
"driver",
"instance",
"for",
"connection",
"name",
"or",
"driver",
"name",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Database.php#L138-L154 |
2,016 | arvici/framework | src/Arvici/Heart/Database/Database.php | Database.typeOfValue | public static function typeOfValue($value)
{
if (is_null($value)) {
return self::TYPE_NULL;
}
if (is_int($value)) {
return self::TYPE_INT;
}
if (is_bool($value)) {
return self::TYPE_BOOL;
}
return self::TYPE_STR;
} | php | public static function typeOfValue($value)
{
if (is_null($value)) {
return self::TYPE_NULL;
}
if (is_int($value)) {
return self::TYPE_INT;
}
if (is_bool($value)) {
return self::TYPE_BOOL;
}
return self::TYPE_STR;
} | [
"public",
"static",
"function",
"typeOfValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_NULL",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_INT",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_BOOL",
";",
"}",
"return",
"self",
"::",
"TYPE_STR",
";",
"}"
] | Get type of value.
@param mixed $value
@return int | [
"Get",
"type",
"of",
"value",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Database.php#L225-L237 |
2,017 | cfxmarkets/php-jsonapi-objects | src/AbstractResource.php | AbstractResource.setError | protected function setError($field, $errorType, $error) {
if (is_array($error)) {
if (!array_key_exists('status', $error)) {
$error['status'] = 400;
}
$error = $this->getFactory()->newError($error);
}
return $this->setJsonApiError($field, $errorType, $error);
} | php | protected function setError($field, $errorType, $error) {
if (is_array($error)) {
if (!array_key_exists('status', $error)) {
$error['status'] = 400;
}
$error = $this->getFactory()->newError($error);
}
return $this->setJsonApiError($field, $errorType, $error);
} | [
"protected",
"function",
"setError",
"(",
"$",
"field",
",",
"$",
"errorType",
",",
"$",
"error",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"error",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'status'",
",",
"$",
"error",
")",
")",
"{",
"$",
"error",
"[",
"'status'",
"]",
"=",
"400",
";",
"}",
"$",
"error",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"newError",
"(",
"$",
"error",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setJsonApiError",
"(",
"$",
"field",
",",
"$",
"errorType",
",",
"$",
"error",
")",
";",
"}"
] | Make it easier to set errors on objects
@param string $field The field name to which to attach the error
@param string $errorType An arbitrary type specifier for adding multiple different types of errors
to a field
@param array $error An array of JSON API-compatible error fields (like "title" and "detail")
@return static | [
"Make",
"it",
"easier",
"to",
"set",
"errors",
"on",
"objects"
] | 29ef92e229044568b8604ee8e43240a5fd392519 | https://github.com/cfxmarkets/php-jsonapi-objects/blob/29ef92e229044568b8604ee8e43240a5fd392519/src/AbstractResource.php#L877-L886 |
2,018 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.indexAction | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$roles = $em->getRepository('CoreBundle:Role')->findAll();
return array(
'roles' => $roles,
);
} | php | public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$roles = $em->getRepository('CoreBundle:Role')->findAll();
return array(
'roles' => $roles,
);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"roles",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'CoreBundle:Role'",
")",
"->",
"findAll",
"(",
")",
";",
"return",
"array",
"(",
"'roles'",
"=>",
"$",
"roles",
",",
")",
";",
"}"
] | Lists all role entities.
@Route("/")
@Method("GET")
@Template() | [
"Lists",
"all",
"role",
"entities",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L28-L37 |
2,019 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.addAction | public function addAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$actor = $em->getRepository($this->get('core_manager')->getActorBundleName().':Actor')->findOneById($id);
$trans = $this->get('translator');
$form = $this->container->get('form.factory')->create('CoreBundle\Form\ActorRoleType');
$form->handleRequest($request);
if ($form->isSubmitted()) {
$em = $this->getDoctrine()->getManager();
$data = $request->request->get($form->getName());
$role = $em->getRepository('CoreBundle:Role')->find($data['roles']);
$actor->addRole($role);
try {
$em->persist($actor);
$em->flush($actor);
return new JsonResponse(array('status' => 'success', 'id'=> $actor->getId(), 'message'=> $trans->trans('role.created')));
} catch (\Exception $exc) {
return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.duplicate')));
}
}
return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.form.notsubmit')));
} | php | public function addAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager();
$actor = $em->getRepository($this->get('core_manager')->getActorBundleName().':Actor')->findOneById($id);
$trans = $this->get('translator');
$form = $this->container->get('form.factory')->create('CoreBundle\Form\ActorRoleType');
$form->handleRequest($request);
if ($form->isSubmitted()) {
$em = $this->getDoctrine()->getManager();
$data = $request->request->get($form->getName());
$role = $em->getRepository('CoreBundle:Role')->find($data['roles']);
$actor->addRole($role);
try {
$em->persist($actor);
$em->flush($actor);
return new JsonResponse(array('status' => 'success', 'id'=> $actor->getId(), 'message'=> $trans->trans('role.created')));
} catch (\Exception $exc) {
return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.duplicate')));
}
}
return new JsonResponse(array('status' => 'error', 'message'=> $trans->trans('role.form.notsubmit')));
} | [
"public",
"function",
"addAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"actor",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"get",
"(",
"'core_manager'",
")",
"->",
"getActorBundleName",
"(",
")",
".",
"':Actor'",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"trans",
"=",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"create",
"(",
"'CoreBundle\\Form\\ActorRoleType'",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"data",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"$",
"form",
"->",
"getName",
"(",
")",
")",
";",
"$",
"role",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'CoreBundle:Role'",
")",
"->",
"find",
"(",
"$",
"data",
"[",
"'roles'",
"]",
")",
";",
"$",
"actor",
"->",
"addRole",
"(",
"$",
"role",
")",
";",
"try",
"{",
"$",
"em",
"->",
"persist",
"(",
"$",
"actor",
")",
";",
"$",
"em",
"->",
"flush",
"(",
"$",
"actor",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'status'",
"=>",
"'success'",
",",
"'id'",
"=>",
"$",
"actor",
"->",
"getId",
"(",
")",
",",
"'message'",
"=>",
"$",
"trans",
"->",
"trans",
"(",
"'role.created'",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exc",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'status'",
"=>",
"'error'",
",",
"'message'",
"=>",
"$",
"trans",
"->",
"trans",
"(",
"'role.duplicate'",
")",
")",
")",
";",
"}",
"}",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'status'",
"=>",
"'error'",
",",
"'message'",
"=>",
"$",
"trans",
"->",
"trans",
"(",
"'role.form.notsubmit'",
")",
")",
")",
";",
"}"
] | Add role by ajax
@Route("/{id}/role/add")
@Method("POST") | [
"Add",
"role",
"by",
"ajax"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L90-L113 |
2,020 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.newAction | public function newAction(Request $request)
{
$role = new Role();
$form = $this->createForm('CoreBundle\Form\RoleType', $role);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($role);
$em->flush($role);
//if come from popup
if ($request->isXMLHttpRequest()) {
return new JsonResponse(array(
'id' => $role->getId(),
));
}
$this->get('session')->getFlashBag()->add('success', 'role.created');
return $this->redirectToRoute('core_role_show', array('id' => $role->getId()));
}
return array(
'role' => $role,
'form' => $form->createView(),
);
} | php | public function newAction(Request $request)
{
$role = new Role();
$form = $this->createForm('CoreBundle\Form\RoleType', $role);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($role);
$em->flush($role);
//if come from popup
if ($request->isXMLHttpRequest()) {
return new JsonResponse(array(
'id' => $role->getId(),
));
}
$this->get('session')->getFlashBag()->add('success', 'role.created');
return $this->redirectToRoute('core_role_show', array('id' => $role->getId()));
}
return array(
'role' => $role,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"role",
"=",
"new",
"Role",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'CoreBundle\\Form\\RoleType'",
",",
"$",
"role",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"role",
")",
";",
"$",
"em",
"->",
"flush",
"(",
"$",
"role",
")",
";",
"//if come from popup",
"if",
"(",
"$",
"request",
"->",
"isXMLHttpRequest",
"(",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"role",
"->",
"getId",
"(",
")",
",",
")",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'role.created'",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'core_role_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"role",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'role'",
"=>",
"$",
"role",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Creates a new role entity.
@Route("/new")
@Method({"GET", "POST"})
@Template() | [
"Creates",
"a",
"new",
"role",
"entity",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L122-L148 |
2,021 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.showAction | public function showAction(Role $role)
{
$deleteForm = $this->createDeleteForm($role);
return array(
'role' => $role,
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction(Role $role)
{
$deleteForm = $this->createDeleteForm($role);
return array(
'role' => $role,
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"Role",
"$",
"role",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"role",
")",
";",
"return",
"array",
"(",
"'role'",
"=>",
"$",
"role",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Finds and displays a role entity.
@Route("/{id}")
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"role",
"entity",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L157-L165 |
2,022 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.editAction | public function editAction(Request $request, Role $role)
{
$deleteForm = $this->createDeleteForm($role);
$editForm = $this->createForm('CoreBundle\Form\RoleType', $role);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
//if come from popup
if ($request->isXMLHttpRequest()) {
return new JsonResponse(array(
'id' => $role->getId(),
));
}
$this->get('session')->getFlashBag()->add('success', 'role.edited');
return $this->redirectToRoute('core_role_edit', array('id' => $role->getId()));
}
return array(
'role' => $role,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function editAction(Request $request, Role $role)
{
$deleteForm = $this->createDeleteForm($role);
$editForm = $this->createForm('CoreBundle\Form\RoleType', $role);
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
//if come from popup
if ($request->isXMLHttpRequest()) {
return new JsonResponse(array(
'id' => $role->getId(),
));
}
$this->get('session')->getFlashBag()->add('success', 'role.edited');
return $this->redirectToRoute('core_role_edit', array('id' => $role->getId()));
}
return array(
'role' => $role,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"Role",
"$",
"role",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"role",
")",
";",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"'CoreBundle\\Form\\RoleType'",
",",
"$",
"role",
")",
";",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"editForm",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"//if come from popup",
"if",
"(",
"$",
"request",
"->",
"isXMLHttpRequest",
"(",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"role",
"->",
"getId",
"(",
")",
",",
")",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'role.edited'",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'core_role_edit'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"role",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'role'",
"=>",
"$",
"role",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] | Displays a form to edit an existing role entity.
@Route("/{id}/edit")
@Method({"GET", "POST"})
@Template() | [
"Displays",
"a",
"form",
"to",
"edit",
"an",
"existing",
"role",
"entity",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L174-L199 |
2,023 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.deleteRoleActorAction | public function deleteRoleActorAction(Request $request, Role $role, $actor)
{
$em = $this->getDoctrine()->getManager();
$actor = $em->getRepository($this->get('core_manager')->getActorBundleName().':Actor')->findOneById($actor);
$actor->getRolesCollection()->removeElement($role);
$em->flush();
$this->get('session')->getFlashBag()->add('success', 'role.deleted');
if($request->query->get('redirect')!=''){
return $this->redirect($request->query->get('redirect'));
}
return $this->redirectToRoute('core_role_index');
} | php | public function deleteRoleActorAction(Request $request, Role $role, $actor)
{
$em = $this->getDoctrine()->getManager();
$actor = $em->getRepository($this->get('core_manager')->getActorBundleName().':Actor')->findOneById($actor);
$actor->getRolesCollection()->removeElement($role);
$em->flush();
$this->get('session')->getFlashBag()->add('success', 'role.deleted');
if($request->query->get('redirect')!=''){
return $this->redirect($request->query->get('redirect'));
}
return $this->redirectToRoute('core_role_index');
} | [
"public",
"function",
"deleteRoleActorAction",
"(",
"Request",
"$",
"request",
",",
"Role",
"$",
"role",
",",
"$",
"actor",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"actor",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"get",
"(",
"'core_manager'",
")",
"->",
"getActorBundleName",
"(",
")",
".",
"':Actor'",
")",
"->",
"findOneById",
"(",
"$",
"actor",
")",
";",
"$",
"actor",
"->",
"getRolesCollection",
"(",
")",
"->",
"removeElement",
"(",
"$",
"role",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'role.deleted'",
")",
";",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'redirect'",
")",
"!=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'redirect'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'core_role_index'",
")",
";",
"}"
] | Deletes a role entity.
@Route("/{actor}/{role}/delete") | [
"Deletes",
"a",
"role",
"entity",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L228-L243 |
2,024 | sebardo/core | CoreBundle/Controller/RoleController.php | RoleController.createDeleteForm | private function createDeleteForm(Role $role)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('core_role_delete', array('id' => $role->getId())))
->setMethod('DELETE')
->getForm()
;
} | php | private function createDeleteForm(Role $role)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('core_role_delete', array('id' => $role->getId())))
->setMethod('DELETE')
->getForm()
;
} | [
"private",
"function",
"createDeleteForm",
"(",
"Role",
"$",
"role",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'core_role_delete'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"role",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setMethod",
"(",
"'DELETE'",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | Creates a form to delete a role entity.
@param Role $role The role entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"delete",
"a",
"role",
"entity",
"."
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Controller/RoleController.php#L252-L259 |
2,025 | gregorybesson/PlaygroundFacebook | src/PlaygroundFacebook/Module.php | Module.populateAppIds | public function populateAppIds($e)
{
$appsArray = $e->getParam('apps');
$appService = $e->getTarget()
->getServiceManager()
->get('playgroundfacebook_app_service');
$apps = $appService->getAvailableApps();
foreach ($apps as $app) {
$app_label = '';
if ($app->getAppName()) {
$app_label .= $app->getAppName();
}
if ($app->getAppId()) {
$app_label .= ' ('.$app->getAppId().')';
}
$appsArray[$app->getAppId()] = $app_label;
}
return $appsArray;
} | php | public function populateAppIds($e)
{
$appsArray = $e->getParam('apps');
$appService = $e->getTarget()
->getServiceManager()
->get('playgroundfacebook_app_service');
$apps = $appService->getAvailableApps();
foreach ($apps as $app) {
$app_label = '';
if ($app->getAppName()) {
$app_label .= $app->getAppName();
}
if ($app->getAppId()) {
$app_label .= ' ('.$app->getAppId().')';
}
$appsArray[$app->getAppId()] = $app_label;
}
return $appsArray;
} | [
"public",
"function",
"populateAppIds",
"(",
"$",
"e",
")",
"{",
"$",
"appsArray",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'apps'",
")",
";",
"$",
"appService",
"=",
"$",
"e",
"->",
"getTarget",
"(",
")",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"'playgroundfacebook_app_service'",
")",
";",
"$",
"apps",
"=",
"$",
"appService",
"->",
"getAvailableApps",
"(",
")",
";",
"foreach",
"(",
"$",
"apps",
"as",
"$",
"app",
")",
"{",
"$",
"app_label",
"=",
"''",
";",
"if",
"(",
"$",
"app",
"->",
"getAppName",
"(",
")",
")",
"{",
"$",
"app_label",
".=",
"$",
"app",
"->",
"getAppName",
"(",
")",
";",
"}",
"if",
"(",
"$",
"app",
"->",
"getAppId",
"(",
")",
")",
"{",
"$",
"app_label",
".=",
"' ('",
".",
"$",
"app",
"->",
"getAppId",
"(",
")",
".",
"')'",
";",
"}",
"$",
"appsArray",
"[",
"$",
"app",
"->",
"getAppId",
"(",
")",
"]",
"=",
"$",
"app_label",
";",
"}",
"return",
"$",
"appsArray",
";",
"}"
] | This method get the Fb apps and add them as array to PlaygroundGame form so
that there is non adherence between modules...
not that satisfied neither
@param EventManager $e
@return array | [
"This",
"method",
"get",
"the",
"Fb",
"apps",
"and",
"add",
"them",
"as",
"array",
"to",
"PlaygroundGame",
"form",
"so",
"that",
"there",
"is",
"non",
"adherence",
"between",
"modules",
"...",
"not",
"that",
"satisfied",
"neither"
] | 35d9561af5af6ccda8a02f4c61a55ff0107e8efd | https://github.com/gregorybesson/PlaygroundFacebook/blob/35d9561af5af6ccda8a02f4c61a55ff0107e8efd/src/PlaygroundFacebook/Module.php#L95-L116 |
2,026 | mszewcz/php-light-framework | src/Validator/Specific/Number.php | Number.validateType | private function validateType(): bool
{
switch ($this->options['type']) {
case 'integer':
$isValid = \is_int($this->value) ? true : false;
break;
case 'float':
$isValid = \is_int($this->value) || \is_float($this->value) ? true : false;
break;
default:
$isValid = \is_int($this->value) || \is_float($this->value) ? true : false;
break;
}
if (!$isValid) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_INCORRECT_TYPE);
}
return $isValid;
} | php | private function validateType(): bool
{
switch ($this->options['type']) {
case 'integer':
$isValid = \is_int($this->value) ? true : false;
break;
case 'float':
$isValid = \is_int($this->value) || \is_float($this->value) ? true : false;
break;
default:
$isValid = \is_int($this->value) || \is_float($this->value) ? true : false;
break;
}
if (!$isValid) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_INCORRECT_TYPE);
}
return $isValid;
} | [
"private",
"function",
"validateType",
"(",
")",
":",
"bool",
"{",
"switch",
"(",
"$",
"this",
"->",
"options",
"[",
"'type'",
"]",
")",
"{",
"case",
"'integer'",
":",
"$",
"isValid",
"=",
"\\",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
"?",
"true",
":",
"false",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"isValid",
"=",
"\\",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
"||",
"\\",
"is_float",
"(",
"$",
"this",
"->",
"value",
")",
"?",
"true",
":",
"false",
";",
"break",
";",
"default",
":",
"$",
"isValid",
"=",
"\\",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
"||",
"\\",
"is_float",
"(",
"$",
"this",
"->",
"value",
")",
"?",
"true",
":",
"false",
";",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"isValid",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"self",
"::",
"VALIDATOR_ERROR_NUMBER_INCORRECT_TYPE",
")",
";",
"}",
"return",
"$",
"isValid",
";",
"}"
] | Checks whether number is of required type. Integers are treated as valid floats.
@return bool | [
"Checks",
"whether",
"number",
"is",
"of",
"required",
"type",
".",
"Integers",
"are",
"treated",
"as",
"valid",
"floats",
"."
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Number.php#L49-L66 |
2,027 | mszewcz/php-light-framework | src/Validator/Specific/Number.php | Number.validateGreaterThan | private function validateGreaterThan(): bool
{
if ($this->options['min'] !== null) {
if ($this->options['inclusive'] === false && $this->value <= $this->options['min']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN);
return false;
}
if ($this->value < $this->options['min']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN);
return false;
}
}
return true;
} | php | private function validateGreaterThan(): bool
{
if ($this->options['min'] !== null) {
if ($this->options['inclusive'] === false && $this->value <= $this->options['min']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN);
return false;
}
if ($this->value < $this->options['min']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN);
return false;
}
}
return true;
} | [
"private",
"function",
"validateGreaterThan",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'min'",
"]",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'inclusive'",
"]",
"===",
"false",
"&&",
"$",
"this",
"->",
"value",
"<=",
"$",
"this",
"->",
"options",
"[",
"'min'",
"]",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"self",
"::",
"VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"value",
"<",
"$",
"this",
"->",
"options",
"[",
"'min'",
"]",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"self",
"::",
"VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks whether number is greater than specified min number
@return bool | [
"Checks",
"whether",
"number",
"is",
"greater",
"than",
"specified",
"min",
"number"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Number.php#L73-L87 |
2,028 | mszewcz/php-light-framework | src/Validator/Specific/Number.php | Number.validateLowerThan | private function validateLowerThan(): bool
{
if ($this->options['max'] !== null) {
if ($this->options['inclusive'] === false && $this->value >= $this->options['max']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_THAN_MAX);
return false;
}
if ($this->value > $this->options['max']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_OR_EQUAL_TO_MAX);
return false;
}
}
return true;
} | php | private function validateLowerThan(): bool
{
if ($this->options['max'] !== null) {
if ($this->options['inclusive'] === false && $this->value >= $this->options['max']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_THAN_MAX);
return false;
}
if ($this->value > $this->options['max']) {
$this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_OR_EQUAL_TO_MAX);
return false;
}
}
return true;
} | [
"private",
"function",
"validateLowerThan",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'max'",
"]",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'inclusive'",
"]",
"===",
"false",
"&&",
"$",
"this",
"->",
"value",
">=",
"$",
"this",
"->",
"options",
"[",
"'max'",
"]",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"self",
"::",
"VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_THAN_MAX",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"value",
">",
"$",
"this",
"->",
"options",
"[",
"'max'",
"]",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"self",
"::",
"VALIDATOR_ERROR_NUMBER_MUST_BE_LOWER_OR_EQUAL_TO_MAX",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks whether number is lower than specified max number
@return bool | [
"Checks",
"whether",
"number",
"is",
"lower",
"than",
"specified",
"max",
"number"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Number.php#L94-L108 |
2,029 | ItinerisLtd/preflight-command | src/Validators/RequiredConstants.php | RequiredConstants.validate | public function validate(string ...$constantNames): ResultInterface
{
$notDefined = array_filter(
$constantNames,
function (string $key): bool {
// phpcs:ignore WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName
return ! defined($key);
}
);
return $this->report(...$notDefined);
} | php | public function validate(string ...$constantNames): ResultInterface
{
$notDefined = array_filter(
$constantNames,
function (string $key): bool {
// phpcs:ignore WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName
return ! defined($key);
}
);
return $this->report(...$notDefined);
} | [
"public",
"function",
"validate",
"(",
"string",
"...",
"$",
"constantNames",
")",
":",
"ResultInterface",
"{",
"$",
"notDefined",
"=",
"array_filter",
"(",
"$",
"constantNames",
",",
"function",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"// phpcs:ignore WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName",
"return",
"!",
"defined",
"(",
"$",
"key",
")",
";",
"}",
")",
";",
"return",
"$",
"this",
"->",
"report",
"(",
"...",
"$",
"notDefined",
")",
";",
"}"
] | Validates constants are defined.
@param string|string[] ...$constantNames Constants to be checked.
@return Success|Failure | [
"Validates",
"constants",
"are",
"defined",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/Validators/RequiredConstants.php#L21-L32 |
2,030 | chippyash/Validation | src/Chippyash/Validation/Exceptions/ValidationException.php | ValidationException.assert | public static function assert($test, $message, $code = null)
{
if (!is_callable($test)) {
throw new self('Test for assert is not callable', 500);
}
if ($test() === true) {
throw new static($message, $code);
}
} | php | public static function assert($test, $message, $code = null)
{
if (!is_callable($test)) {
throw new self('Test for assert is not callable', 500);
}
if ($test() === true) {
throw new static($message, $code);
}
} | [
"public",
"static",
"function",
"assert",
"(",
"$",
"test",
",",
"$",
"message",
",",
"$",
"code",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"test",
")",
")",
"{",
"throw",
"new",
"self",
"(",
"'Test for assert is not callable'",
",",
"500",
")",
";",
"}",
"if",
"(",
"$",
"test",
"(",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"static",
"(",
"$",
"message",
",",
"$",
"code",
")",
";",
"}",
"}"
] | Assert a test and throw this exception if it returns true
@param callable $test Function returning true if error condition exists
@param string $message Message for exception
@param int $code Code for exception
@throws ValidationException
@throws static | [
"Assert",
"a",
"test",
"and",
"throw",
"this",
"exception",
"if",
"it",
"returns",
"true"
] | 8e2373ce968e84077f67101404ea74b997e3ccf3 | https://github.com/chippyash/Validation/blob/8e2373ce968e84077f67101404ea74b997e3ccf3/src/Chippyash/Validation/Exceptions/ValidationException.php#L41-L49 |
2,031 | BapCat/Hashing | src/Hash.php | Hash.validate | private function validate($hash, string $validation_regex): void {
if(!is_string($hash) || preg_match($validation_regex, $hash) === 0) {
throw new InvalidArgumentException('Expected hash, but got ' . var_export($hash, true) . '] instead');
}
} | php | private function validate($hash, string $validation_regex): void {
if(!is_string($hash) || preg_match($validation_regex, $hash) === 0) {
throw new InvalidArgumentException('Expected hash, but got ' . var_export($hash, true) . '] instead');
}
} | [
"private",
"function",
"validate",
"(",
"$",
"hash",
",",
"string",
"$",
"validation_regex",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"hash",
")",
"||",
"preg_match",
"(",
"$",
"validation_regex",
",",
"$",
"hash",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Expected hash, but got '",
".",
"var_export",
"(",
"$",
"hash",
",",
"true",
")",
".",
"'] instead'",
")",
";",
"}",
"}"
] | Ensures the hash passed in is valid
@param string $hash
@param string $validation_regex | [
"Ensures",
"the",
"hash",
"passed",
"in",
"is",
"valid"
] | cf61f3e8c4bc25232507a2873d08bd78e3917e26 | https://github.com/BapCat/Hashing/blob/cf61f3e8c4bc25232507a2873d08bd78e3917e26/src/Hash.php#L36-L40 |
2,032 | mizmoz/container | src/ProviderContainer.php | ProviderContainer.done | public function done()
{
if (array_diff($this->registered, $this->serviceProvider->provides())) {
throw new ServiceProviderException(
get_class($this->serviceProvider) . ' said it would provide: "' .
join(', ', $this->serviceProvider->provides()) . '" but ended up providing "' .
join(', ', $this->registered) . '"'
);
}
} | php | public function done()
{
if (array_diff($this->registered, $this->serviceProvider->provides())) {
throw new ServiceProviderException(
get_class($this->serviceProvider) . ' said it would provide: "' .
join(', ', $this->serviceProvider->provides()) . '" but ended up providing "' .
join(', ', $this->registered) . '"'
);
}
} | [
"public",
"function",
"done",
"(",
")",
"{",
"if",
"(",
"array_diff",
"(",
"$",
"this",
"->",
"registered",
",",
"$",
"this",
"->",
"serviceProvider",
"->",
"provides",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ServiceProviderException",
"(",
"get_class",
"(",
"$",
"this",
"->",
"serviceProvider",
")",
".",
"' said it would provide: \"'",
".",
"join",
"(",
"', '",
",",
"$",
"this",
"->",
"serviceProvider",
"->",
"provides",
"(",
")",
")",
".",
"'\" but ended up providing \"'",
".",
"join",
"(",
"', '",
",",
"$",
"this",
"->",
"registered",
")",
".",
"'\"'",
")",
";",
"}",
"}"
] | Check all the items that were promised were actually registered | [
"Check",
"all",
"the",
"items",
"that",
"were",
"promised",
"were",
"actually",
"registered"
] | 7ae194189595fbcd392445bb41ac8ddb118b5b7c | https://github.com/mizmoz/container/blob/7ae194189595fbcd392445bb41ac8ddb118b5b7c/src/ProviderContainer.php#L120-L129 |
2,033 | setrun/setrun-component-sys | src/helpers/ArrayHelper.php | ArrayHelper.assoc_to_keyval | public static function assoc_to_keyval($assoc, $keyField, $valField)
{
if (!is_array($assoc) and ! $assoc instanceof Iterator) {
throw new InvalidArgumentException('The first parameter must be an array.');
}
$output = [];
foreach ($assoc as $row) {
if (isset($row[$keyField]) and isset($row[$valField])) {
$output[$row[$keyField]] = $row[$valField];
}
}
return $output;
} | php | public static function assoc_to_keyval($assoc, $keyField, $valField)
{
if (!is_array($assoc) and ! $assoc instanceof Iterator) {
throw new InvalidArgumentException('The first parameter must be an array.');
}
$output = [];
foreach ($assoc as $row) {
if (isset($row[$keyField]) and isset($row[$valField])) {
$output[$row[$keyField]] = $row[$valField];
}
}
return $output;
} | [
"public",
"static",
"function",
"assoc_to_keyval",
"(",
"$",
"assoc",
",",
"$",
"keyField",
",",
"$",
"valField",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"assoc",
")",
"and",
"!",
"$",
"assoc",
"instanceof",
"Iterator",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The first parameter must be an array.'",
")",
";",
"}",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"assoc",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"keyField",
"]",
")",
"and",
"isset",
"(",
"$",
"row",
"[",
"$",
"valField",
"]",
")",
")",
"{",
"$",
"output",
"[",
"$",
"row",
"[",
"$",
"keyField",
"]",
"]",
"=",
"$",
"row",
"[",
"$",
"valField",
"]",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Converts a multi-dimensional associative array into an array of key => values with the provided field names.
@param array $assoc the array to convert.
@param string $keyField the field name of the key field.
@param string $valField the field name of the value field.
@return array
@throws InvalidArgumentException | [
"Converts",
"a",
"multi",
"-",
"dimensional",
"associative",
"array",
"into",
"an",
"array",
"of",
"key",
"=",
">",
"values",
"with",
"the",
"provided",
"field",
"names",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/helpers/ArrayHelper.php#L191-L203 |
2,034 | setrun/setrun-component-sys | src/helpers/ArrayHelper.php | ArrayHelper.reverse_flatten | public static function reverse_flatten($array, $glue = ':')
{
$return = [];
foreach ($array as $key => $value) {
if (stripos($key, $glue) !== false) {
$keys = explode($glue, $key);
$temp =& $return;
while (count($keys) > 1) {
$key = array_shift($keys);
$key = is_numeric($key) ? (int) $key : $key;
if (!isset($temp[$key]) or !is_array($temp[$key])) {
$temp[$key] = [];
}
$temp =& $temp[$key];
}
$key = array_shift($keys);
$key = is_numeric($key) ? (int) $key : $key;
$temp[$key] = $value;
} else {
$key = is_numeric($key) ? (int) $key : $key;
$return[$key] = $value;
}
}
return $return;
} | php | public static function reverse_flatten($array, $glue = ':')
{
$return = [];
foreach ($array as $key => $value) {
if (stripos($key, $glue) !== false) {
$keys = explode($glue, $key);
$temp =& $return;
while (count($keys) > 1) {
$key = array_shift($keys);
$key = is_numeric($key) ? (int) $key : $key;
if (!isset($temp[$key]) or !is_array($temp[$key])) {
$temp[$key] = [];
}
$temp =& $temp[$key];
}
$key = array_shift($keys);
$key = is_numeric($key) ? (int) $key : $key;
$temp[$key] = $value;
} else {
$key = is_numeric($key) ? (int) $key : $key;
$return[$key] = $value;
}
}
return $return;
} | [
"public",
"static",
"function",
"reverse_flatten",
"(",
"$",
"array",
",",
"$",
"glue",
"=",
"':'",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"key",
",",
"$",
"glue",
")",
"!==",
"false",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"$",
"glue",
",",
"$",
"key",
")",
";",
"$",
"temp",
"=",
"&",
"$",
"return",
";",
"while",
"(",
"count",
"(",
"$",
"keys",
")",
">",
"1",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keys",
")",
";",
"$",
"key",
"=",
"is_numeric",
"(",
"$",
"key",
")",
"?",
"(",
"int",
")",
"$",
"key",
":",
"$",
"key",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"temp",
"[",
"$",
"key",
"]",
")",
"or",
"!",
"is_array",
"(",
"$",
"temp",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"temp",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"temp",
"=",
"&",
"$",
"temp",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keys",
")",
";",
"$",
"key",
"=",
"is_numeric",
"(",
"$",
"key",
")",
"?",
"(",
"int",
")",
"$",
"key",
":",
"$",
"key",
";",
"$",
"temp",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"is_numeric",
"(",
"$",
"key",
")",
"?",
"(",
"int",
")",
"$",
"key",
":",
"$",
"key",
";",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Reverse a flattened array in its original form.
@param array $array flattened array.
@param string $glue glue used in flattening.
@return array the unflattened array | [
"Reverse",
"a",
"flattened",
"array",
"in",
"its",
"original",
"form",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/helpers/ArrayHelper.php#L317-L341 |
2,035 | setrun/setrun-component-sys | src/helpers/ArrayHelper.php | ArrayHelper.filter_prefixed | public static function filter_prefixed($array, $prefix, $removePrefix = true)
{
$return =[];
foreach ($array as $key => $val) {
if (preg_match('/^'.$prefix.'/', $key)) {
if ($removePrefix === true) {
$key = preg_replace('/^'.$prefix.'/','',$key);
}
$return[$key] = $val;
}
}
return $return;
} | php | public static function filter_prefixed($array, $prefix, $removePrefix = true)
{
$return =[];
foreach ($array as $key => $val) {
if (preg_match('/^'.$prefix.'/', $key)) {
if ($removePrefix === true) {
$key = preg_replace('/^'.$prefix.'/','',$key);
}
$return[$key] = $val;
}
}
return $return;
} | [
"public",
"static",
"function",
"filter_prefixed",
"(",
"$",
"array",
",",
"$",
"prefix",
",",
"$",
"removePrefix",
"=",
"true",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^'",
".",
"$",
"prefix",
".",
"'/'",
",",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"removePrefix",
"===",
"true",
")",
"{",
"$",
"key",
"=",
"preg_replace",
"(",
"'/^'",
".",
"$",
"prefix",
".",
"'/'",
",",
"''",
",",
"$",
"key",
")",
";",
"}",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Filters an array on prefixed associative keys.
@param array $array the array to filter.
@param string $prefix prefix to filter on.
@param bool $removePrefix whether to remove the prefix.
@return array | [
"Filters",
"an",
"array",
"on",
"prefixed",
"associative",
"keys",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/helpers/ArrayHelper.php#L350-L362 |
2,036 | setrun/setrun-component-sys | src/helpers/ArrayHelper.php | ArrayHelper.replaceAssoc | public static function replaceAssoc(array $replace, string $subject){
return str_replace(array_keys($replace), array_values($replace), $subject);
} | php | public static function replaceAssoc(array $replace, string $subject){
return str_replace(array_keys($replace), array_values($replace), $subject);
} | [
"public",
"static",
"function",
"replaceAssoc",
"(",
"array",
"$",
"replace",
",",
"string",
"$",
"subject",
")",
"{",
"return",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"subject",
")",
";",
"}"
] | Associative analogue str_replace.
@param array $replace
@param string $subject
@return string | [
"Associative",
"analogue",
"str_replace",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/helpers/ArrayHelper.php#L943-L945 |
2,037 | osflab/view | Helper/Bootstrap/ListGroup.php | ListGroup.badge | public function badge($label, $colorOrStatus = null, $toolTipLabel = null) {
switch (true) {
case !isset($this->list[$this->listCount - 1]) :
Checkers::notice('Unable to put badge [' . $label . '] in list group, no element.');
break;
case $this->list[$this->listCount - 1] instanceof Button :
Checkers::notice('Unable to badge a list group button. Use an element instead.');
break;
case is_array($this->list[$this->listCount - 1]) :
$this->badges[$this->listCount - 1][] = $this->getBadgeHtml($label, $colorOrStatus, $toolTipLabel);
break;
default :
Checkers::notice('Unable to find what to do with your badge [' . $label . ']...');
}
return $this;
} | php | public function badge($label, $colorOrStatus = null, $toolTipLabel = null) {
switch (true) {
case !isset($this->list[$this->listCount - 1]) :
Checkers::notice('Unable to put badge [' . $label . '] in list group, no element.');
break;
case $this->list[$this->listCount - 1] instanceof Button :
Checkers::notice('Unable to badge a list group button. Use an element instead.');
break;
case is_array($this->list[$this->listCount - 1]) :
$this->badges[$this->listCount - 1][] = $this->getBadgeHtml($label, $colorOrStatus, $toolTipLabel);
break;
default :
Checkers::notice('Unable to find what to do with your badge [' . $label . ']...');
}
return $this;
} | [
"public",
"function",
"badge",
"(",
"$",
"label",
",",
"$",
"colorOrStatus",
"=",
"null",
",",
"$",
"toolTipLabel",
"=",
"null",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"this",
"->",
"listCount",
"-",
"1",
"]",
")",
":",
"Checkers",
"::",
"notice",
"(",
"'Unable to put badge ['",
".",
"$",
"label",
".",
"'] in list group, no element.'",
")",
";",
"break",
";",
"case",
"$",
"this",
"->",
"list",
"[",
"$",
"this",
"->",
"listCount",
"-",
"1",
"]",
"instanceof",
"Button",
":",
"Checkers",
"::",
"notice",
"(",
"'Unable to badge a list group button. Use an element instead.'",
")",
";",
"break",
";",
"case",
"is_array",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"this",
"->",
"listCount",
"-",
"1",
"]",
")",
":",
"$",
"this",
"->",
"badges",
"[",
"$",
"this",
"->",
"listCount",
"-",
"1",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getBadgeHtml",
"(",
"$",
"label",
",",
"$",
"colorOrStatus",
",",
"$",
"toolTipLabel",
")",
";",
"break",
";",
"default",
":",
"Checkers",
"::",
"notice",
"(",
"'Unable to find what to do with your badge ['",
".",
"$",
"label",
".",
"']...'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a badge to current item
@param string $label
@param string $colorOrStatus
@param string $toolTipLabel
@return $this | [
"Add",
"a",
"badge",
"to",
"current",
"item"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/ListGroup.php#L43-L58 |
2,038 | osflab/view | Helper/Bootstrap/ListGroup.php | ListGroup.addItem | public function addItem($label, $url = null, $status = null, $active = false, array $cssClasses = [], array $attrs = [])
{
return $this->addContentItem($label, null, $url, $status, $active, $cssClasses, $attrs);
} | php | public function addItem($label, $url = null, $status = null, $active = false, array $cssClasses = [], array $attrs = [])
{
return $this->addContentItem($label, null, $url, $status, $active, $cssClasses, $attrs);
} | [
"public",
"function",
"addItem",
"(",
"$",
"label",
",",
"$",
"url",
"=",
"null",
",",
"$",
"status",
"=",
"null",
",",
"$",
"active",
"=",
"false",
",",
"array",
"$",
"cssClasses",
"=",
"[",
"]",
",",
"array",
"$",
"attrs",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"addContentItem",
"(",
"$",
"label",
",",
"null",
",",
"$",
"url",
",",
"$",
"status",
",",
"$",
"active",
",",
"$",
"cssClasses",
",",
"$",
"attrs",
")",
";",
"}"
] | Simple list item
@param string $label
@param string $url
@param bool $active
@return $this | [
"Simple",
"list",
"item"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/ListGroup.php#L67-L70 |
2,039 | osflab/view | Helper/Bootstrap/ListGroup.php | ListGroup.addContentItem | public function addContentItem($label, $content, $url = null, $status = null, $active = false, array $cssClasses = [], array $attrs = [])
{
Checkers::checkUrl($url);
$status === null || Checkers::checkStatus($status, null, true);
$url === null || $this->ulList = false;
$this->list[] = [(string) $label, $url, (string) $content, $status, (bool) $active, $cssClasses, $attrs];
$this->listCount++;
return $this;
} | php | public function addContentItem($label, $content, $url = null, $status = null, $active = false, array $cssClasses = [], array $attrs = [])
{
Checkers::checkUrl($url);
$status === null || Checkers::checkStatus($status, null, true);
$url === null || $this->ulList = false;
$this->list[] = [(string) $label, $url, (string) $content, $status, (bool) $active, $cssClasses, $attrs];
$this->listCount++;
return $this;
} | [
"public",
"function",
"addContentItem",
"(",
"$",
"label",
",",
"$",
"content",
",",
"$",
"url",
"=",
"null",
",",
"$",
"status",
"=",
"null",
",",
"$",
"active",
"=",
"false",
",",
"array",
"$",
"cssClasses",
"=",
"[",
"]",
",",
"array",
"$",
"attrs",
"=",
"[",
"]",
")",
"{",
"Checkers",
"::",
"checkUrl",
"(",
"$",
"url",
")",
";",
"$",
"status",
"===",
"null",
"||",
"Checkers",
"::",
"checkStatus",
"(",
"$",
"status",
",",
"null",
",",
"true",
")",
";",
"$",
"url",
"===",
"null",
"||",
"$",
"this",
"->",
"ulList",
"=",
"false",
";",
"$",
"this",
"->",
"list",
"[",
"]",
"=",
"[",
"(",
"string",
")",
"$",
"label",
",",
"$",
"url",
",",
"(",
"string",
")",
"$",
"content",
",",
"$",
"status",
",",
"(",
"bool",
")",
"$",
"active",
",",
"$",
"cssClasses",
",",
"$",
"attrs",
"]",
";",
"$",
"this",
"->",
"listCount",
"++",
";",
"return",
"$",
"this",
";",
"}"
] | List item with content
@param string $label
@param string $content
@param string $url
@param bool $active
@return $this | [
"List",
"item",
"with",
"content"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/ListGroup.php#L80-L88 |
2,040 | ManifestWebDesign/dabl-adapter | src/Propel/Platform/DefaultPlatform.php | DefaultPlatform.getColumnDDL | public function getColumnDDL(Column $col)
{
$domain = $col->getDomain();
$ddl = array($this->quoteIdentifier($col->getName()));
$sqlType = $domain->getSqlType();
if ($this->hasSize($sqlType)) {
$ddl []= $sqlType . $domain->printSize();
} else {
$ddl []= $sqlType;
}
if ($default = $this->getColumnDefaultValueDDL($col)) {
$ddl []= $default;
}
if ($notNull = $this->getNullString($col->isNotNull())) {
$ddl []= $notNull;
}
if ($autoIncrement = $col->getAutoIncrementString()) {
$ddl []= $autoIncrement;
}
return implode(' ', $ddl);
} | php | public function getColumnDDL(Column $col)
{
$domain = $col->getDomain();
$ddl = array($this->quoteIdentifier($col->getName()));
$sqlType = $domain->getSqlType();
if ($this->hasSize($sqlType)) {
$ddl []= $sqlType . $domain->printSize();
} else {
$ddl []= $sqlType;
}
if ($default = $this->getColumnDefaultValueDDL($col)) {
$ddl []= $default;
}
if ($notNull = $this->getNullString($col->isNotNull())) {
$ddl []= $notNull;
}
if ($autoIncrement = $col->getAutoIncrementString()) {
$ddl []= $autoIncrement;
}
return implode(' ', $ddl);
} | [
"public",
"function",
"getColumnDDL",
"(",
"Column",
"$",
"col",
")",
"{",
"$",
"domain",
"=",
"$",
"col",
"->",
"getDomain",
"(",
")",
";",
"$",
"ddl",
"=",
"array",
"(",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"col",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"sqlType",
"=",
"$",
"domain",
"->",
"getSqlType",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasSize",
"(",
"$",
"sqlType",
")",
")",
"{",
"$",
"ddl",
"[",
"]",
"=",
"$",
"sqlType",
".",
"$",
"domain",
"->",
"printSize",
"(",
")",
";",
"}",
"else",
"{",
"$",
"ddl",
"[",
"]",
"=",
"$",
"sqlType",
";",
"}",
"if",
"(",
"$",
"default",
"=",
"$",
"this",
"->",
"getColumnDefaultValueDDL",
"(",
"$",
"col",
")",
")",
"{",
"$",
"ddl",
"[",
"]",
"=",
"$",
"default",
";",
"}",
"if",
"(",
"$",
"notNull",
"=",
"$",
"this",
"->",
"getNullString",
"(",
"$",
"col",
"->",
"isNotNull",
"(",
")",
")",
")",
"{",
"$",
"ddl",
"[",
"]",
"=",
"$",
"notNull",
";",
"}",
"if",
"(",
"$",
"autoIncrement",
"=",
"$",
"col",
"->",
"getAutoIncrementString",
"(",
")",
")",
"{",
"$",
"ddl",
"[",
"]",
"=",
"$",
"autoIncrement",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"ddl",
")",
";",
"}"
] | Builds the DDL SQL for a Column object.
@return string | [
"Builds",
"the",
"DDL",
"SQL",
"for",
"a",
"Column",
"object",
"."
] | 98579ed23bec832d764e762ee2f93f0a88ef9cd3 | https://github.com/ManifestWebDesign/dabl-adapter/blob/98579ed23bec832d764e762ee2f93f0a88ef9cd3/src/Propel/Platform/DefaultPlatform.php#L322-L344 |
2,041 | vinala/kernel | src/Database/InOut/Mysql/Importer.php | Importer.last | public static function last($name)
{
if (!$name) {
$database = config('database.database');
$path = root().'database/backup';
$files = glob($path.'/*.sql');
if (!is_null($files)) {
for ($i = count($files) - 1; $i >= 0; $i--) {
$file = $files[$i];
//
$file = explode(root().'database/backup/'.$database.'_', $file);
$file = $file[1];
$file = explode('.sql', $file);
$file = $file[0];
//
if (is_numeric($file)) {
return root().'database/backup/'.$database.'_'.$file.'.sql';
}
}
}
} elseif ($name) {
return root().'database/backup/'.$name.'.sql';
}
} | php | public static function last($name)
{
if (!$name) {
$database = config('database.database');
$path = root().'database/backup';
$files = glob($path.'/*.sql');
if (!is_null($files)) {
for ($i = count($files) - 1; $i >= 0; $i--) {
$file = $files[$i];
//
$file = explode(root().'database/backup/'.$database.'_', $file);
$file = $file[1];
$file = explode('.sql', $file);
$file = $file[0];
//
if (is_numeric($file)) {
return root().'database/backup/'.$database.'_'.$file.'.sql';
}
}
}
} elseif ($name) {
return root().'database/backup/'.$name.'.sql';
}
} | [
"public",
"static",
"function",
"last",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"database",
"=",
"config",
"(",
"'database.database'",
")",
";",
"$",
"path",
"=",
"root",
"(",
")",
".",
"'database/backup'",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"path",
".",
"'/*.sql'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"files",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"files",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"file",
"=",
"$",
"files",
"[",
"$",
"i",
"]",
";",
"//",
"$",
"file",
"=",
"explode",
"(",
"root",
"(",
")",
".",
"'database/backup/'",
".",
"$",
"database",
".",
"'_'",
",",
"$",
"file",
")",
";",
"$",
"file",
"=",
"$",
"file",
"[",
"1",
"]",
";",
"$",
"file",
"=",
"explode",
"(",
"'.sql'",
",",
"$",
"file",
")",
";",
"$",
"file",
"=",
"$",
"file",
"[",
"0",
"]",
";",
"//",
"if",
"(",
"is_numeric",
"(",
"$",
"file",
")",
")",
"{",
"return",
"root",
"(",
")",
".",
"'database/backup/'",
".",
"$",
"database",
".",
"'_'",
".",
"$",
"file",
".",
"'.sql'",
";",
"}",
"}",
"}",
"}",
"elseif",
"(",
"$",
"name",
")",
"{",
"return",
"root",
"(",
")",
".",
"'database/backup/'",
".",
"$",
"name",
".",
"'.sql'",
";",
"}",
"}"
] | Get the last database save.
@param string $name
@return string | [
"Get",
"the",
"last",
"database",
"save",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Importer.php#L30-L54 |
2,042 | vinala/kernel | src/Database/InOut/Mysql/Importer.php | Importer.import | public static function import($name = null)
{
$file = static::last($name);
if (!is_null($file)) {
$query = (new Filesystem())->get($file);
//
Database::exec($query);
return true;
}
} | php | public static function import($name = null)
{
$file = static::last($name);
if (!is_null($file)) {
$query = (new Filesystem())->get($file);
//
Database::exec($query);
return true;
}
} | [
"public",
"static",
"function",
"import",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"static",
"::",
"last",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"file",
")",
")",
"{",
"$",
"query",
"=",
"(",
"new",
"Filesystem",
"(",
")",
")",
"->",
"get",
"(",
"$",
"file",
")",
";",
"//",
"Database",
"::",
"exec",
"(",
"$",
"query",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Import the last save or custom save.
@param string $name
@return bool | [
"Import",
"the",
"last",
"save",
"or",
"custom",
"save",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/InOut/Mysql/Importer.php#L63-L74 |
2,043 | samurai-fw/samurai | src/Raikiri/ContainerFactory.php | ContainerFactory.create | public static function create($name = null)
{
$name = $name ? $name : self::generateName();
$container = new Container($name);
$container->register('Container', $container);
self::$containers[$name] = $container;
return $container;
} | php | public static function create($name = null)
{
$name = $name ? $name : self::generateName();
$container = new Container($name);
$container->register('Container', $container);
self::$containers[$name] = $container;
return $container;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"?",
"$",
"name",
":",
"self",
"::",
"generateName",
"(",
")",
";",
"$",
"container",
"=",
"new",
"Container",
"(",
"$",
"name",
")",
";",
"$",
"container",
"->",
"register",
"(",
"'Container'",
",",
"$",
"container",
")",
";",
"self",
"::",
"$",
"containers",
"[",
"$",
"name",
"]",
"=",
"$",
"container",
";",
"return",
"$",
"container",
";",
"}"
] | Create container.
@access public
@return Container | [
"Create",
"container",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/ContainerFactory.php#L58-L65 |
2,044 | samurai-fw/samurai | src/Raikiri/ContainerFactory.php | ContainerFactory.get | public static function get($name = null)
{
if ($name === null) {
$name = array_shift(array_keys(self::$containers));
}
return self::$containers[$name] ? self::$containers[$name] : null;
} | php | public static function get($name = null)
{
if ($name === null) {
$name = array_shift(array_keys(self::$containers));
}
return self::$containers[$name] ? self::$containers[$name] : null;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"$",
"name",
"=",
"array_shift",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"containers",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"containers",
"[",
"$",
"name",
"]",
"?",
"self",
"::",
"$",
"containers",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Get container.
@access public
@param string $name
@return Container | [
"Get",
"container",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Raikiri/ContainerFactory.php#L75-L81 |
2,045 | angel-project/core | src/str/str.php | str.utf8 | public static function utf8(string $in_p)
{
$value = str_replace("<br>", "\n", $in_p);
$value = str_replace(" ", " ", $value);
$value = preg_replace('/<([\s\S]*?)>/u', '', $value);
$value = preg_replace('/<\/([\s\S]*?)>/u', '', $value);
return $value;
} | php | public static function utf8(string $in_p)
{
$value = str_replace("<br>", "\n", $in_p);
$value = str_replace(" ", " ", $value);
$value = preg_replace('/<([\s\S]*?)>/u', '', $value);
$value = preg_replace('/<\/([\s\S]*?)>/u', '', $value);
return $value;
} | [
"public",
"static",
"function",
"utf8",
"(",
"string",
"$",
"in_p",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"\"<br>\"",
",",
"\"\\n\"",
",",
"$",
"in_p",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"\" \"",
",",
"\" \"",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/<([\\s\\S]*?)>/u'",
",",
"''",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/<\\/([\\s\\S]*?)>/u'",
",",
"''",
",",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}"
] | transform the given string into utf8 format strings | [
"transform",
"the",
"given",
"string",
"into",
"utf8",
"format",
"strings"
] | c806d175a6825afc243cd680b81d651412cb83d7 | https://github.com/angel-project/core/blob/c806d175a6825afc243cd680b81d651412cb83d7/src/str/str.php#L80-L87 |
2,046 | angel-project/core | src/str/str.php | str.unix_dir | public static function unix_dir(string $path)
{
$path = str_replace('\\', '/', $path);
$path = preg_replace('|(?<=.)/+|', '/', $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
return $path;
} | php | public static function unix_dir(string $path)
{
$path = str_replace('\\', '/', $path);
$path = preg_replace('|(?<=.)/+|', '/', $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
return $path;
} | [
"public",
"static",
"function",
"unix_dir",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'|(?<=.)/+|'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"if",
"(",
"':'",
"===",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"1",
")",
")",
"{",
"$",
"path",
"=",
"ucfirst",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | change windows directory into unix directory | [
"change",
"windows",
"directory",
"into",
"unix",
"directory"
] | c806d175a6825afc243cd680b81d651412cb83d7 | https://github.com/angel-project/core/blob/c806d175a6825afc243cd680b81d651412cb83d7/src/str/str.php#L153-L161 |
2,047 | angel-project/core | src/str/str.php | str.windows_dir | public static function windows_dir(string $path)
{
$path = str_replace('/', '\\', $path);
$path = preg_replace('|(?<=.)/+|', '\\', $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
return $path;
} | php | public static function windows_dir(string $path)
{
$path = str_replace('/', '\\', $path);
$path = preg_replace('|(?<=.)/+|', '\\', $path);
if (':' === substr($path, 1, 1)) {
$path = ucfirst($path);
}
return $path;
} | [
"public",
"static",
"function",
"windows_dir",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"'|(?<=.)/+|'",
",",
"'\\\\'",
",",
"$",
"path",
")",
";",
"if",
"(",
"':'",
"===",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"1",
")",
")",
"{",
"$",
"path",
"=",
"ucfirst",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | change unix directory into windows directory | [
"change",
"unix",
"directory",
"into",
"windows",
"directory"
] | c806d175a6825afc243cd680b81d651412cb83d7 | https://github.com/angel-project/core/blob/c806d175a6825afc243cd680b81d651412cb83d7/src/str/str.php#L163-L171 |
2,048 | timonf/static-deploy | src/StaticDeploy/Parser/Twig/Extension.php | Extension.getCurrentPage | public function getCurrentPage()
{
$givenRelativeFile = str_replace(
$this->environment->getSourceDirectory(),
'',
$this->environment->getSourceFile()
);
return str_replace('.twig', '', $givenRelativeFile);
} | php | public function getCurrentPage()
{
$givenRelativeFile = str_replace(
$this->environment->getSourceDirectory(),
'',
$this->environment->getSourceFile()
);
return str_replace('.twig', '', $givenRelativeFile);
} | [
"public",
"function",
"getCurrentPage",
"(",
")",
"{",
"$",
"givenRelativeFile",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"environment",
"->",
"getSourceDirectory",
"(",
")",
",",
"''",
",",
"$",
"this",
"->",
"environment",
"->",
"getSourceFile",
"(",
")",
")",
";",
"return",
"str_replace",
"(",
"'.twig'",
",",
"''",
",",
"$",
"givenRelativeFile",
")",
";",
"}"
] | will return current parsed page
@return string | [
"will",
"return",
"current",
"parsed",
"page"
] | 1d0cbc34dfeddcaadabe6975d683daedf313a674 | https://github.com/timonf/static-deploy/blob/1d0cbc34dfeddcaadabe6975d683daedf313a674/src/StaticDeploy/Parser/Twig/Extension.php#L47-L56 |
2,049 | timonf/static-deploy | src/StaticDeploy/Parser/Twig/Extension.php | Extension.getBasepath | public function getBasepath($suffix = null)
{
$relativeDirectory = '.';
$givenRelativePath = dirname($this->getCurrentPage());
if ($givenRelativePath === '/') {
$givenRelativePath = '';
}
$depth = substr_count($givenRelativePath, '/');
for ($i = 0; $i < $depth; $i++) {
$relativeDirectory .= '/..';
}
if ($suffix) {
return $relativeDirectory . '/' . $suffix;
} else {
return $relativeDirectory;
}
} | php | public function getBasepath($suffix = null)
{
$relativeDirectory = '.';
$givenRelativePath = dirname($this->getCurrentPage());
if ($givenRelativePath === '/') {
$givenRelativePath = '';
}
$depth = substr_count($givenRelativePath, '/');
for ($i = 0; $i < $depth; $i++) {
$relativeDirectory .= '/..';
}
if ($suffix) {
return $relativeDirectory . '/' . $suffix;
} else {
return $relativeDirectory;
}
} | [
"public",
"function",
"getBasepath",
"(",
"$",
"suffix",
"=",
"null",
")",
"{",
"$",
"relativeDirectory",
"=",
"'.'",
";",
"$",
"givenRelativePath",
"=",
"dirname",
"(",
"$",
"this",
"->",
"getCurrentPage",
"(",
")",
")",
";",
"if",
"(",
"$",
"givenRelativePath",
"===",
"'/'",
")",
"{",
"$",
"givenRelativePath",
"=",
"''",
";",
"}",
"$",
"depth",
"=",
"substr_count",
"(",
"$",
"givenRelativePath",
",",
"'/'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"depth",
";",
"$",
"i",
"++",
")",
"{",
"$",
"relativeDirectory",
".=",
"'/..'",
";",
"}",
"if",
"(",
"$",
"suffix",
")",
"{",
"return",
"$",
"relativeDirectory",
".",
"'/'",
".",
"$",
"suffix",
";",
"}",
"else",
"{",
"return",
"$",
"relativeDirectory",
";",
"}",
"}"
] | calculates the relative basepath
@param string $suffix if a suffix given, it will return basepath + filename, otherwise just the basepath
@return string | [
"calculates",
"the",
"relative",
"basepath"
] | 1d0cbc34dfeddcaadabe6975d683daedf313a674 | https://github.com/timonf/static-deploy/blob/1d0cbc34dfeddcaadabe6975d683daedf313a674/src/StaticDeploy/Parser/Twig/Extension.php#L63-L84 |
2,050 | b01/slib | src/JsonModel.php | JsonModel.jsonSerialize | public function jsonSerialize() {
$data = new stdClass();
$vars = get_object_vars($this);
foreach ($vars as $property => $value) {
if ($value === null) {
continue;
}
$data->{$property} = $value;
}
return $data;
} | php | public function jsonSerialize() {
$data = new stdClass();
$vars = get_object_vars($this);
foreach ($vars as $property => $value) {
if ($value === null) {
continue;
}
$data->{$property} = $value;
}
return $data;
} | [
"public",
"function",
"jsonSerialize",
"(",
")",
"{",
"$",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"data",
"->",
"{",
"$",
"property",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Get data for JSON serialization.
Properties set to NULL will be omitted from the output.
@return string | [
"Get",
"data",
"for",
"JSON",
"serialization",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/JsonModel.php#L31-L44 |
2,051 | b01/slib | src/JsonModel.php | JsonModel.validateProperty | public function validateProperty($property, $type, $value, $class = __CLASS__)
{
$aType = gettype($value);
if ($aType !== $type) {
throw new JsonModelException(
JsonModelException::BAD_PROPERTY_TYPE,
[$property, $type, $aType]
);
}
if ($value === null) {
throw new JsonModelException(
JsonModelException::PROPERTY_EMPTY,
[$class, $property, $aType]
);
}
return true;
} | php | public function validateProperty($property, $type, $value, $class = __CLASS__)
{
$aType = gettype($value);
if ($aType !== $type) {
throw new JsonModelException(
JsonModelException::BAD_PROPERTY_TYPE,
[$property, $type, $aType]
);
}
if ($value === null) {
throw new JsonModelException(
JsonModelException::PROPERTY_EMPTY,
[$class, $property, $aType]
);
}
return true;
} | [
"public",
"function",
"validateProperty",
"(",
"$",
"property",
",",
"$",
"type",
",",
"$",
"value",
",",
"$",
"class",
"=",
"__CLASS__",
")",
"{",
"$",
"aType",
"=",
"gettype",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"aType",
"!==",
"$",
"type",
")",
"{",
"throw",
"new",
"JsonModelException",
"(",
"JsonModelException",
"::",
"BAD_PROPERTY_TYPE",
",",
"[",
"$",
"property",
",",
"$",
"type",
",",
"$",
"aType",
"]",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"throw",
"new",
"JsonModelException",
"(",
"JsonModelException",
"::",
"PROPERTY_EMPTY",
",",
"[",
"$",
"class",
",",
"$",
"property",
",",
"$",
"aType",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Verify that a property exists and its value is of a specified type.
@param string $property
@param string $type
@param mixed $value
@param string $class
@return true
@throws \Jtp\JtpException | [
"Verify",
"that",
"a",
"property",
"exists",
"and",
"its",
"value",
"is",
"of",
"a",
"specified",
"type",
"."
] | 56149adcd85f1493c11651a50dda4612a3705cbb | https://github.com/b01/slib/blob/56149adcd85f1493c11651a50dda4612a3705cbb/src/JsonModel.php#L113-L131 |
2,052 | GodsDev/backyard | GodsDev/Backyard/BackyardBriefApiClient.php | BackyardBriefApiClient.sendJsonLoad | public function sendJsonLoad($json, $httpVerb = 'POST')
{
$communicationId = uniqid(date("Y-m-d-His_"));
$this->logCommunication($json, $httpVerb, $communicationId);
$ch = curl_init($this->apiUrl);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $json, //json_encode($postData)
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false, //accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it
));
switch ($httpVerb) {
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
case 'GET':
case 'DELETE':
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
//'Authorization: '.$authToken,
'Content-Type: application/json'
),
));
if (in_array($httpVerb, array('GET', 'DELETE'))) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
}
break;
case 'PUT':
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
//'Authorization: '.$authToken,
'Content-Type: application/json',
'Content-Length: ' . strlen($json)
),
CURLOPT_CUSTOMREQUEST => 'PUT',
));
break;
default:
$this->logger->error("Unknown verb {$httpVerb}");
return false;
}
$result = curl_exec($ch);
if ($result) {
$this->logCommunication($result, 'resp', $communicationId);
} elseif (!is_null($this->logger)) {
$this->logger->error("Curl failed with (" . curl_errno($ch) . ") " . curl_error($ch));
}
return $result;
} | php | public function sendJsonLoad($json, $httpVerb = 'POST')
{
$communicationId = uniqid(date("Y-m-d-His_"));
$this->logCommunication($json, $httpVerb, $communicationId);
$ch = curl_init($this->apiUrl);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $json, //json_encode($postData)
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false, //accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it
));
switch ($httpVerb) {
case 'POST':
curl_setopt($ch, CURLOPT_POST, true);
case 'GET':
case 'DELETE':
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
//'Authorization: '.$authToken,
'Content-Type: application/json'
),
));
if (in_array($httpVerb, array('GET', 'DELETE'))) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
}
break;
case 'PUT':
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
//'Authorization: '.$authToken,
'Content-Type: application/json',
'Content-Length: ' . strlen($json)
),
CURLOPT_CUSTOMREQUEST => 'PUT',
));
break;
default:
$this->logger->error("Unknown verb {$httpVerb}");
return false;
}
$result = curl_exec($ch);
if ($result) {
$this->logCommunication($result, 'resp', $communicationId);
} elseif (!is_null($this->logger)) {
$this->logger->error("Curl failed with (" . curl_errno($ch) . ") " . curl_error($ch));
}
return $result;
} | [
"public",
"function",
"sendJsonLoad",
"(",
"$",
"json",
",",
"$",
"httpVerb",
"=",
"'POST'",
")",
"{",
"$",
"communicationId",
"=",
"uniqid",
"(",
"date",
"(",
"\"Y-m-d-His_\"",
")",
")",
";",
"$",
"this",
"->",
"logCommunication",
"(",
"$",
"json",
",",
"$",
"httpVerb",
",",
"$",
"communicationId",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"this",
"->",
"apiUrl",
")",
";",
"curl_setopt_array",
"(",
"$",
"ch",
",",
"array",
"(",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"json",
",",
"//json_encode($postData)",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"false",
",",
"CURLOPT_SSL_VERIFYHOST",
"=>",
"false",
",",
"//accepts also private SSL certificates //@todo it could be possible to try without that option and if it fails, it may try with this option and inform about it",
")",
")",
";",
"switch",
"(",
"$",
"httpVerb",
")",
"{",
"case",
"'POST'",
":",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"case",
"'GET'",
":",
"case",
"'DELETE'",
":",
"curl_setopt_array",
"(",
"$",
"ch",
",",
"array",
"(",
"CURLOPT_HTTPHEADER",
"=>",
"array",
"(",
"//'Authorization: '.$authToken,",
"'Content-Type: application/json'",
")",
",",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"httpVerb",
",",
"array",
"(",
"'GET'",
",",
"'DELETE'",
")",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"httpVerb",
")",
";",
"}",
"break",
";",
"case",
"'PUT'",
":",
"curl_setopt_array",
"(",
"$",
"ch",
",",
"array",
"(",
"CURLOPT_HTTPHEADER",
"=>",
"array",
"(",
"//'Authorization: '.$authToken,",
"'Content-Type: application/json'",
",",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"json",
")",
")",
",",
"CURLOPT_CUSTOMREQUEST",
"=>",
"'PUT'",
",",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"\"Unknown verb {$httpVerb}\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"logCommunication",
"(",
"$",
"result",
",",
"'resp'",
",",
"$",
"communicationId",
")",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"logger",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"\"Curl failed with (\"",
".",
"curl_errno",
"(",
"$",
"ch",
")",
".",
"\") \"",
".",
"curl_error",
"(",
"$",
"ch",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Send a JSON to the API and returns whatever is to return
@param string $json
@param string $httpVerb POST default, or PUT/DELETE/GET
@return mixed <b>TRUE</b> on success or <b>FALSE</b> on failure. However, if the <b>CURLOPT_RETURNTRANSFER</b>
option is set, it will return
the result on success, <b>FALSE</b> on failure. | [
"Send",
"a",
"JSON",
"to",
"the",
"API",
"and",
"returns",
"whatever",
"is",
"to",
"return"
] | 992da766a50fca04e9c6e963cbe98d37e3d47f8f | https://github.com/GodsDev/backyard/blob/992da766a50fca04e9c6e963cbe98d37e3d47f8f/GodsDev/Backyard/BackyardBriefApiClient.php#L59-L106 |
2,053 | GodsDev/backyard | GodsDev/Backyard/BackyardBriefApiClient.php | BackyardBriefApiClient.getJsonArray | public function getJsonArray($json)
{
$response = $this->sendJsonLoad($json);
$result = json_decode($response, true);
if (!$result && !is_null($this->logger)) {
$this->logger->error("json decode failed for " . substr($response, 0, 100) . " that resulted from " . substr($json, 0, 100));
}
return $result;
} | php | public function getJsonArray($json)
{
$response = $this->sendJsonLoad($json);
$result = json_decode($response, true);
if (!$result && !is_null($this->logger)) {
$this->logger->error("json decode failed for " . substr($response, 0, 100) . " that resulted from " . substr($json, 0, 100));
}
return $result;
} | [
"public",
"function",
"getJsonArray",
"(",
"$",
"json",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendJsonLoad",
"(",
"$",
"json",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"result",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"logger",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"\"json decode failed for \"",
".",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"100",
")",
".",
"\" that resulted from \"",
".",
"substr",
"(",
"$",
"json",
",",
"0",
",",
"100",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Sends JSON and return array decoded from the received JSON response
@param string $json
@return array | [
"Sends",
"JSON",
"and",
"return",
"array",
"decoded",
"from",
"the",
"received",
"JSON",
"response"
] | 992da766a50fca04e9c6e963cbe98d37e3d47f8f | https://github.com/GodsDev/backyard/blob/992da766a50fca04e9c6e963cbe98d37e3d47f8f/GodsDev/Backyard/BackyardBriefApiClient.php#L132-L140 |
2,054 | phproberto/joomla-common | src/Traits/HasInstances.php | HasInstances.instance | public static function instance($id)
{
$class = get_called_class();
if (empty(static::$instances[$class][$id]))
{
static::$instances[$class][$id] = new static($id);
}
return static::$instances[$class][$id];
} | php | public static function instance($id)
{
$class = get_called_class();
if (empty(static::$instances[$class][$id]))
{
static::$instances[$class][$id] = new static($id);
}
return static::$instances[$class][$id];
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"id",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"instances",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
")",
")",
"{",
"static",
"::",
"$",
"instances",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
"=",
"new",
"static",
"(",
"$",
"id",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"class",
"]",
"[",
"$",
"id",
"]",
";",
"}"
] | Create and return a cached instance
@param integer $id Identifier of the instance
@return $this | [
"Create",
"and",
"return",
"a",
"cached",
"instance"
] | bbb37df453bfcb545c3a2c6f14340f0a27e448b2 | https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Traits/HasInstances.php#L70-L80 |
2,055 | Cheezykins/RestAPICore | lib/DataModel.php | DataModel.getNullableDataModel | protected function getNullableDataModel($type, $shallow, $object, ...$properties)
{
$object = $this->getNullable($object, ...$properties);
if ($object == null) {
return null;
}
return $this->getDataModel($object, $type, $shallow);
} | php | protected function getNullableDataModel($type, $shallow, $object, ...$properties)
{
$object = $this->getNullable($object, ...$properties);
if ($object == null) {
return null;
}
return $this->getDataModel($object, $type, $shallow);
} | [
"protected",
"function",
"getNullableDataModel",
"(",
"$",
"type",
",",
"$",
"shallow",
",",
"$",
"object",
",",
"...",
"$",
"properties",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getNullable",
"(",
"$",
"object",
",",
"...",
"$",
"properties",
")",
";",
"if",
"(",
"$",
"object",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"getDataModel",
"(",
"$",
"object",
",",
"$",
"type",
",",
"$",
"shallow",
")",
";",
"}"
] | Returns a data object that can be a null
@param $type
@param $shallow
@param $object
@param array ...$properties
@return mixed|null | [
"Returns",
"a",
"data",
"object",
"that",
"can",
"be",
"a",
"null"
] | 35c0b40b9b71db93da1ff8ecd1849f18b616705a | https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/lib/DataModel.php#L43-L51 |
2,056 | bestit/hipchat-api | src/Room.php | Room.notify | public function notify(
$message,
$color = Client::COLOR_YELLOW,
$alert = false,
$format = Client::FORMAT_TEXT
) {
$query = json_encode([
'message' => $message,
'color' => $color,
'notify' => $alert,
'format' => $format
]);
$response = $this->client->post("/v2/room/{$this->room}/notification", $query);
if ($response->getStatusCode() === 204) {
return true;
}
//TODO: add proper exception.
throw new \Exception($response->getBody(), $response->getStatusCode());
} | php | public function notify(
$message,
$color = Client::COLOR_YELLOW,
$alert = false,
$format = Client::FORMAT_TEXT
) {
$query = json_encode([
'message' => $message,
'color' => $color,
'notify' => $alert,
'format' => $format
]);
$response = $this->client->post("/v2/room/{$this->room}/notification", $query);
if ($response->getStatusCode() === 204) {
return true;
}
//TODO: add proper exception.
throw new \Exception($response->getBody(), $response->getStatusCode());
} | [
"public",
"function",
"notify",
"(",
"$",
"message",
",",
"$",
"color",
"=",
"Client",
"::",
"COLOR_YELLOW",
",",
"$",
"alert",
"=",
"false",
",",
"$",
"format",
"=",
"Client",
"::",
"FORMAT_TEXT",
")",
"{",
"$",
"query",
"=",
"json_encode",
"(",
"[",
"'message'",
"=>",
"$",
"message",
",",
"'color'",
"=>",
"$",
"color",
",",
"'notify'",
"=>",
"$",
"alert",
",",
"'format'",
"=>",
"$",
"format",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"\"/v2/room/{$this->room}/notification\"",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"===",
"204",
")",
"{",
"return",
"true",
";",
"}",
"//TODO: add proper exception.",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
";",
"}"
] | Send a notification to the given room.
@param string $message
@param string $color
@param bool $alert
@param string $format
@return bool
@throws \Exception | [
"Send",
"a",
"notification",
"to",
"the",
"given",
"room",
"."
] | 2ad37856da53c17ac52e6e1c04392f6e0665d402 | https://github.com/bestit/hipchat-api/blob/2ad37856da53c17ac52e6e1c04392f6e0665d402/src/Room.php#L34-L55 |
2,057 | marando/phpSOFA | src/Marando/IAU/iauA2tf.php | iauA2tf.A2tf | public static function A2tf($ndp, $angle, &$sign, array &$ihmsf) {
/* Scale then use days to h,m,s function. */
static::D2tf($ndp, $angle / D2PI, $sign, $ihmsf);
return;
} | php | public static function A2tf($ndp, $angle, &$sign, array &$ihmsf) {
/* Scale then use days to h,m,s function. */
static::D2tf($ndp, $angle / D2PI, $sign, $ihmsf);
return;
} | [
"public",
"static",
"function",
"A2tf",
"(",
"$",
"ndp",
",",
"$",
"angle",
",",
"&",
"$",
"sign",
",",
"array",
"&",
"$",
"ihmsf",
")",
"{",
"/* Scale then use days to h,m,s function. */",
"static",
"::",
"D2tf",
"(",
"$",
"ndp",
",",
"$",
"angle",
"/",
"D2PI",
",",
"$",
"sign",
",",
"$",
"ihmsf",
")",
";",
"return",
";",
"}"
] | - - - - - - - -
i a u A 2 t f
- - - - - - - -
Decompose radians into hours, minutes, seconds, fraction.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: vector/matrix support function.
Given:
ndp int resolution (Note 1)
angle double angle in radians
Returned:
sign char '+' or '-'
ihmsf int[4] hours, minutes, seconds, fraction
Called:
iauD2tf decompose days to hms
Notes:
1) The argument ndp is interpreted as follows:
ndp resolution
: ...0000 00 00
-7 1000 00 00
-6 100 00 00
-5 10 00 00
-4 1 00 00
-3 0 10 00
-2 0 01 00
-1 0 00 10
0 0 00 01
1 0 00 00.1
2 0 00 00.01
3 0 00 00.001
: 0 00 00.000...
2) The largest positive useful value for ndp is determined by the
size of angle, the format of doubles on the target platform, and
the risk of overflowing ihmsf[3]. On a typical platform, for
angle up to 2pi, the available floating-point precision might
correspond to ndp=12. However, the practical limit is typically
ndp=9, set by the capacity of a 32-bit int, or ndp=4 if int is
only 16 bits.
3) The absolute value of angle may exceed 2pi. In cases where it
does not, it is up to the caller to test for and handle the
case where angle is very nearly 2pi and rounds up to 24 hours,
by testing for ihmsf[0]=24 and setting ihmsf[0-3] to zero.
This revision: 2013 July 31
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"2",
"t",
"f",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauA2tf.php#L68-L73 |
2,058 | phlexible/access-control | Permission/PermissionRegistry.php | PermissionRegistry.get | public function get($objectType)
{
do {
if (isset($this->permissionCollections[$objectType])) {
return $this->permissionCollections[$objectType];
}
$actualObjectType = $objectType;
$objectType = get_parent_class($objectType);
} while ($objectType !== false);
throw new InvalidArgumentException("No permissions for type $actualObjectType found.");
} | php | public function get($objectType)
{
do {
if (isset($this->permissionCollections[$objectType])) {
return $this->permissionCollections[$objectType];
}
$actualObjectType = $objectType;
$objectType = get_parent_class($objectType);
} while ($objectType !== false);
throw new InvalidArgumentException("No permissions for type $actualObjectType found.");
} | [
"public",
"function",
"get",
"(",
"$",
"objectType",
")",
"{",
"do",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"permissionCollections",
"[",
"$",
"objectType",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"permissionCollections",
"[",
"$",
"objectType",
"]",
";",
"}",
"$",
"actualObjectType",
"=",
"$",
"objectType",
";",
"$",
"objectType",
"=",
"get_parent_class",
"(",
"$",
"objectType",
")",
";",
"}",
"while",
"(",
"$",
"objectType",
"!==",
"false",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"No permissions for type $actualObjectType found.\"",
")",
";",
"}"
] | Return permissions for object type.
@param string $objectType
@throws InvalidArgumentException
@return PermissionCollection | [
"Return",
"permissions",
"for",
"object",
"type",
"."
] | 0c78a1b67b508997f6c9053ba47eb5dfb1d46810 | https://github.com/phlexible/access-control/blob/0c78a1b67b508997f6c9053ba47eb5dfb1d46810/Permission/PermissionRegistry.php#L81-L92 |
2,059 | jurchiks/commons | src/collections/ArrayList.php | ArrayList.toMap | public function toMap(bool $mutable): ArrayMap
{
if ($mutable)
{
return new MutableMap($this->data);
}
else
{
return new ImmutableMap($this->data);
}
} | php | public function toMap(bool $mutable): ArrayMap
{
if ($mutable)
{
return new MutableMap($this->data);
}
else
{
return new ImmutableMap($this->data);
}
} | [
"public",
"function",
"toMap",
"(",
"bool",
"$",
"mutable",
")",
":",
"ArrayMap",
"{",
"if",
"(",
"$",
"mutable",
")",
"{",
"return",
"new",
"MutableMap",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"else",
"{",
"return",
"new",
"ImmutableMap",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"}"
] | Copy the data of this list into a map. Keys are preserved.
@param bool $mutable : if true, will return a MutableMap, otherwise an ImmutableMap
@return ArrayMap | [
"Copy",
"the",
"data",
"of",
"this",
"list",
"into",
"a",
"map",
".",
"Keys",
"are",
"preserved",
"."
] | be9e1eca6a94380647160a882b8476bee3e4d8f8 | https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/collections/ArrayList.php#L51-L61 |
2,060 | jurchiks/commons | src/collections/ArrayList.php | ArrayList.reduce | public function reduce(callable $callback, $initialValue = null)
{
$data = $initialValue;
foreach ($this->data as $value)
{
$data = $callback($value, $data);
}
return $data;
} | php | public function reduce(callable $callback, $initialValue = null)
{
$data = $initialValue;
foreach ($this->data as $value)
{
$data = $callback($value, $data);
}
return $data;
} | [
"public",
"function",
"reduce",
"(",
"callable",
"$",
"callback",
",",
"$",
"initialValue",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"initialValue",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"value",
")",
"{",
"$",
"data",
"=",
"$",
"callback",
"(",
"$",
"value",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Reduce the list to a single value using a user-provided callback.
@param callable $callback : the callback function to apply.
Callback signature - ($value, $previous) => mixed
@param mixed $initialValue : the initial value to provide for parameter $previous
@return mixed | [
"Reduce",
"the",
"list",
"to",
"a",
"single",
"value",
"using",
"a",
"user",
"-",
"provided",
"callback",
"."
] | be9e1eca6a94380647160a882b8476bee3e4d8f8 | https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/collections/ArrayList.php#L131-L141 |
2,061 | encorephp/giml | src/Reservation/RequireReservation.php | RequireReservation.getElement | public function getElement(Parser $parser, ElementInterface $parent = null)
{
$parser->getReader()->open($this->src);
$parsed = $parser->getReader()->parse();
return $parser->parseElements($parsed['value'], $parent);
} | php | public function getElement(Parser $parser, ElementInterface $parent = null)
{
$parser->getReader()->open($this->src);
$parsed = $parser->getReader()->parse();
return $parser->parseElements($parsed['value'], $parent);
} | [
"public",
"function",
"getElement",
"(",
"Parser",
"$",
"parser",
",",
"ElementInterface",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"parser",
"->",
"getReader",
"(",
")",
"->",
"open",
"(",
"$",
"this",
"->",
"src",
")",
";",
"$",
"parsed",
"=",
"$",
"parser",
"->",
"getReader",
"(",
")",
"->",
"parse",
"(",
")",
";",
"return",
"$",
"parser",
"->",
"parseElements",
"(",
"$",
"parsed",
"[",
"'value'",
"]",
",",
"$",
"parent",
")",
";",
"}"
] | Get an instance of ElementInterface for this reservation
@param Parser $parser
@param ElementInterface $parent
@return array | [
"Get",
"an",
"instance",
"of",
"ElementInterface",
"for",
"this",
"reservation"
] | 68ce7ebbf12b32dc3901974382e829d7b8808b8e | https://github.com/encorephp/giml/blob/68ce7ebbf12b32dc3901974382e829d7b8808b8e/src/Reservation/RequireReservation.php#L19-L25 |
2,062 | phlexible/task-bundle | Mailer/Mailer.php | Mailer.sendNewTaskEmailMessage | public function sendNewTaskEmailMessage(
Task $task,
UserInterface $createUser,
UserInterface $assignUser,
TypeInterface $type)
{
// $createUser, $recipientUser, $task, $link
$template = $this->parameters['new_task']['template'];
$from = $this->parameters['new_task']['from_email'];
$text = $type->getText($task);
$url = $type->getLink($task);
$content = $this->templating->render(
$template,
[
'createUser' => $createUser,
'assignUser' => $assignUser,
'task' => $task,
'text' => $text,
'url' => $url,
]
);
$this->sendEmailMessage($content, $from, $assignUser->getEmail());
} | php | public function sendNewTaskEmailMessage(
Task $task,
UserInterface $createUser,
UserInterface $assignUser,
TypeInterface $type)
{
// $createUser, $recipientUser, $task, $link
$template = $this->parameters['new_task']['template'];
$from = $this->parameters['new_task']['from_email'];
$text = $type->getText($task);
$url = $type->getLink($task);
$content = $this->templating->render(
$template,
[
'createUser' => $createUser,
'assignUser' => $assignUser,
'task' => $task,
'text' => $text,
'url' => $url,
]
);
$this->sendEmailMessage($content, $from, $assignUser->getEmail());
} | [
"public",
"function",
"sendNewTaskEmailMessage",
"(",
"Task",
"$",
"task",
",",
"UserInterface",
"$",
"createUser",
",",
"UserInterface",
"$",
"assignUser",
",",
"TypeInterface",
"$",
"type",
")",
"{",
"// $createUser, $recipientUser, $task, $link",
"$",
"template",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'new_task'",
"]",
"[",
"'template'",
"]",
";",
"$",
"from",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'new_task'",
"]",
"[",
"'from_email'",
"]",
";",
"$",
"text",
"=",
"$",
"type",
"->",
"getText",
"(",
"$",
"task",
")",
";",
"$",
"url",
"=",
"$",
"type",
"->",
"getLink",
"(",
"$",
"task",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"$",
"template",
",",
"[",
"'createUser'",
"=>",
"$",
"createUser",
",",
"'assignUser'",
"=>",
"$",
"assignUser",
",",
"'task'",
"=>",
"$",
"task",
",",
"'text'",
"=>",
"$",
"text",
",",
"'url'",
"=>",
"$",
"url",
",",
"]",
")",
";",
"$",
"this",
"->",
"sendEmailMessage",
"(",
"$",
"content",
",",
"$",
"from",
",",
"$",
"assignUser",
"->",
"getEmail",
"(",
")",
")",
";",
"}"
] | Send a new task email.
@param Task $task
@param UserInterface $createUser
@param UserInterface $assignUser
@param TypeInterface $type | [
"Send",
"a",
"new",
"task",
"email",
"."
] | 7f111ba992d40b30a1ae99ca4f06bcbed3fc6af2 | https://github.com/phlexible/task-bundle/blob/7f111ba992d40b30a1ae99ca4f06bcbed3fc6af2/Mailer/Mailer.php#L63-L87 |
2,063 | phlexible/task-bundle | Mailer/Mailer.php | Mailer.sendUpdateEmailMessage | public function sendUpdateEmailMessage(Task $task, UserInterface $byUser, array $involvedUsers, array $changes, TypeInterface $type)
{
$template = $this->parameters['update']['template'];
$from = $this->parameters['update']['from_email'];
$text = $type->getText($task);
$url = $type->getLink($task);
$content = $this->templating->render(
$template,
[
'byUser' => $byUser,
'involvedUsers' => $involvedUsers,
'changes' => $changes,
'text' => $text,
'url' => $url,
]
);
foreach ($involvedUsers as $involvedUser) {
$this->sendEmailMessage($content, $from, $involvedUser->getEmail());
}
} | php | public function sendUpdateEmailMessage(Task $task, UserInterface $byUser, array $involvedUsers, array $changes, TypeInterface $type)
{
$template = $this->parameters['update']['template'];
$from = $this->parameters['update']['from_email'];
$text = $type->getText($task);
$url = $type->getLink($task);
$content = $this->templating->render(
$template,
[
'byUser' => $byUser,
'involvedUsers' => $involvedUsers,
'changes' => $changes,
'text' => $text,
'url' => $url,
]
);
foreach ($involvedUsers as $involvedUser) {
$this->sendEmailMessage($content, $from, $involvedUser->getEmail());
}
} | [
"public",
"function",
"sendUpdateEmailMessage",
"(",
"Task",
"$",
"task",
",",
"UserInterface",
"$",
"byUser",
",",
"array",
"$",
"involvedUsers",
",",
"array",
"$",
"changes",
",",
"TypeInterface",
"$",
"type",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'update'",
"]",
"[",
"'template'",
"]",
";",
"$",
"from",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'update'",
"]",
"[",
"'from_email'",
"]",
";",
"$",
"text",
"=",
"$",
"type",
"->",
"getText",
"(",
"$",
"task",
")",
";",
"$",
"url",
"=",
"$",
"type",
"->",
"getLink",
"(",
"$",
"task",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"$",
"template",
",",
"[",
"'byUser'",
"=>",
"$",
"byUser",
",",
"'involvedUsers'",
"=>",
"$",
"involvedUsers",
",",
"'changes'",
"=>",
"$",
"changes",
",",
"'text'",
"=>",
"$",
"text",
",",
"'url'",
"=>",
"$",
"url",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"involvedUsers",
"as",
"$",
"involvedUser",
")",
"{",
"$",
"this",
"->",
"sendEmailMessage",
"(",
"$",
"content",
",",
"$",
"from",
",",
"$",
"involvedUser",
"->",
"getEmail",
"(",
")",
")",
";",
"}",
"}"
] | Send an update email.
@param Task $task
@param UserInterface $byUser
@param UserInterface[] $involvedUsers
@param array $changes
@param TypeInterface $type | [
"Send",
"an",
"update",
"email",
"."
] | 7f111ba992d40b30a1ae99ca4f06bcbed3fc6af2 | https://github.com/phlexible/task-bundle/blob/7f111ba992d40b30a1ae99ca4f06bcbed3fc6af2/Mailer/Mailer.php#L98-L120 |
2,064 | ManifestWebDesign/dabl-adapter | src/DBRedshift.php | DBRedshift.rollBack | public function rollBack() {
if ($this->_transactionDepth == 0) {
throw new PDOException('Rollback error : There is no transaction started');
}
$this->_transactionDepth--;
if ($this->_transactionDepth == 0) {
parent::rollBack();
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
}
} | php | public function rollBack() {
if ($this->_transactionDepth == 0) {
throw new PDOException('Rollback error : There is no transaction started');
}
$this->_transactionDepth--;
if ($this->_transactionDepth == 0) {
parent::rollBack();
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}");
}
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_transactionDepth",
"==",
"0",
")",
"{",
"throw",
"new",
"PDOException",
"(",
"'Rollback error : There is no transaction started'",
")",
";",
"}",
"$",
"this",
"->",
"_transactionDepth",
"--",
";",
"if",
"(",
"$",
"this",
"->",
"_transactionDepth",
"==",
"0",
")",
"{",
"parent",
"::",
"rollBack",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"exec",
"(",
"\"ROLLBACK TO SAVEPOINT LEVEL{$this->_transactionDepth}\"",
")",
";",
"}",
"}"
] | Rollback current transaction,
@throws PDOException if there is no transaction started
@return bool|void | [
"Rollback",
"current",
"transaction"
] | 98579ed23bec832d764e762ee2f93f0a88ef9cd3 | https://github.com/ManifestWebDesign/dabl-adapter/blob/98579ed23bec832d764e762ee2f93f0a88ef9cd3/src/DBRedshift.php#L223-L235 |
2,065 | consigliere/components | src/Commands/PublishAssetCommand.php | PublishAssetCommand.publish | public function publish($name)
{
if ($name instanceof Component) {
$component = $name;
} else {
$component = $this->laravel['components']->findOrFail($name);
}
with(new AssetPublisher($component))
->setRepository($this->laravel['components'])
->setConsole($this)
->publish();
$this->line("<info>Published</info>: {$component->getStudlyName()}");
} | php | public function publish($name)
{
if ($name instanceof Component) {
$component = $name;
} else {
$component = $this->laravel['components']->findOrFail($name);
}
with(new AssetPublisher($component))
->setRepository($this->laravel['components'])
->setConsole($this)
->publish();
$this->line("<info>Published</info>: {$component->getStudlyName()}");
} | [
"public",
"function",
"publish",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"instanceof",
"Component",
")",
"{",
"$",
"component",
"=",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'components'",
"]",
"->",
"findOrFail",
"(",
"$",
"name",
")",
";",
"}",
"with",
"(",
"new",
"AssetPublisher",
"(",
"$",
"component",
")",
")",
"->",
"setRepository",
"(",
"$",
"this",
"->",
"laravel",
"[",
"'components'",
"]",
")",
"->",
"setConsole",
"(",
"$",
"this",
")",
"->",
"publish",
"(",
")",
";",
"$",
"this",
"->",
"line",
"(",
"\"<info>Published</info>: {$component->getStudlyName()}\"",
")",
";",
"}"
] | Publish assets from the specified component.
@param string $name | [
"Publish",
"assets",
"from",
"the",
"specified",
"component",
"."
] | 9b08bb111f0b55b0a860ed9c3407eda0d9cc1252 | https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Commands/PublishAssetCommand.php#L55-L69 |
2,066 | marando/phpSOFA | src/Marando/IAU/iauPn.php | iauPn.Pn | public static function Pn(array $p, &$r, array &$u) {
$w;
/* Obtain the modulus and test for zero. */
$w = static::Pm($p);
if ($w == 0.0) {
/* Null vector. */
static::Zp($u);
}
else {
/* Unit vector. */
static::Sxp(1.0 / $w, $p, $u);
}
/* Return the modulus. */
$r = $w;
return;
} | php | public static function Pn(array $p, &$r, array &$u) {
$w;
/* Obtain the modulus and test for zero. */
$w = static::Pm($p);
if ($w == 0.0) {
/* Null vector. */
static::Zp($u);
}
else {
/* Unit vector. */
static::Sxp(1.0 / $w, $p, $u);
}
/* Return the modulus. */
$r = $w;
return;
} | [
"public",
"static",
"function",
"Pn",
"(",
"array",
"$",
"p",
",",
"&",
"$",
"r",
",",
"array",
"&",
"$",
"u",
")",
"{",
"$",
"w",
";",
"/* Obtain the modulus and test for zero. */",
"$",
"w",
"=",
"static",
"::",
"Pm",
"(",
"$",
"p",
")",
";",
"if",
"(",
"$",
"w",
"==",
"0.0",
")",
"{",
"/* Null vector. */",
"static",
"::",
"Zp",
"(",
"$",
"u",
")",
";",
"}",
"else",
"{",
"/* Unit vector. */",
"static",
"::",
"Sxp",
"(",
"1.0",
"/",
"$",
"w",
",",
"$",
"p",
",",
"$",
"u",
")",
";",
"}",
"/* Return the modulus. */",
"$",
"r",
"=",
"$",
"w",
";",
"return",
";",
"}"
] | - - - - - -
i a u P n
- - - - - -
Convert a p-vector into modulus and unit vector.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: vector/matrix support function.
Given:
p double[3] p-vector
Returned:
r double modulus
u double[3] unit vector
Notes:
1) If p is null, the result is null. Otherwise the result is a unit
vector.
2) It is permissible to re-use the same array for any of the
arguments.
Called:
iauPm modulus of p-vector
iauZp zero p-vector
iauSxp multiply p-vector by scalar
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"P",
"n",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauPn.php#L45-L65 |
2,067 | MicroSymfony/connector | src/ConnectionAdapters/AbstractAdapter.php | AbstractAdapter.getServiceIp | protected function getServiceIp(string $serviceName, bool $force = false): string
{
if (!isset($this->serviceIps[$serviceName]) || $force) {
$serviceIp = $this->discovery->discover($serviceName);
$this->serviceIps[$serviceName] = $serviceIp;
}
return $this->serviceIps[$serviceName];
} | php | protected function getServiceIp(string $serviceName, bool $force = false): string
{
if (!isset($this->serviceIps[$serviceName]) || $force) {
$serviceIp = $this->discovery->discover($serviceName);
$this->serviceIps[$serviceName] = $serviceIp;
}
return $this->serviceIps[$serviceName];
} | [
"protected",
"function",
"getServiceIp",
"(",
"string",
"$",
"serviceName",
",",
"bool",
"$",
"force",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"serviceIps",
"[",
"$",
"serviceName",
"]",
")",
"||",
"$",
"force",
")",
"{",
"$",
"serviceIp",
"=",
"$",
"this",
"->",
"discovery",
"->",
"discover",
"(",
"$",
"serviceName",
")",
";",
"$",
"this",
"->",
"serviceIps",
"[",
"$",
"serviceName",
"]",
"=",
"$",
"serviceIp",
";",
"}",
"return",
"$",
"this",
"->",
"serviceIps",
"[",
"$",
"serviceName",
"]",
";",
"}"
] | Get service IP from service discovery
@param string $serviceName
@param bool $force
@return string | [
"Get",
"service",
"IP",
"from",
"service",
"discovery"
] | 764e9f19c55b5252bbe749702e2f763385e1b74b | https://github.com/MicroSymfony/connector/blob/764e9f19c55b5252bbe749702e2f763385e1b74b/src/ConnectionAdapters/AbstractAdapter.php#L74-L82 |
2,068 | scandio/scandiojs | php/Scandio/js/Bridge.php | Bridge.setByDotNotation | private static function setByDotNotation($dots, $value, $scalar = true)
{
if ($dots == null) { static::$store = $value; }
$exploded = explode('.', $dots);
$valuePointer = &static::$store;
# Loop until end of explodes and reset store's pointer to $valuePointer by reference
$length = count($exploded);
for ($i = 0; $i < $length; $i++) {
$key = $exploded[$i];
$valuePointer = &$valuePointer[$key];
}
if ($scalar === true) {
$valuePointer = $value;
} else {
(array) $valuePointer;
$valuePointer[] = $value;
}
return $valuePointer;
} | php | private static function setByDotNotation($dots, $value, $scalar = true)
{
if ($dots == null) { static::$store = $value; }
$exploded = explode('.', $dots);
$valuePointer = &static::$store;
# Loop until end of explodes and reset store's pointer to $valuePointer by reference
$length = count($exploded);
for ($i = 0; $i < $length; $i++) {
$key = $exploded[$i];
$valuePointer = &$valuePointer[$key];
}
if ($scalar === true) {
$valuePointer = $value;
} else {
(array) $valuePointer;
$valuePointer[] = $value;
}
return $valuePointer;
} | [
"private",
"static",
"function",
"setByDotNotation",
"(",
"$",
"dots",
",",
"$",
"value",
",",
"$",
"scalar",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"dots",
"==",
"null",
")",
"{",
"static",
"::",
"$",
"store",
"=",
"$",
"value",
";",
"}",
"$",
"exploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"dots",
")",
";",
"$",
"valuePointer",
"=",
"&",
"static",
"::",
"$",
"store",
";",
"# Loop until end of explodes and reset store's pointer to $valuePointer by reference",
"$",
"length",
"=",
"count",
"(",
"$",
"exploded",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"key",
"=",
"$",
"exploded",
"[",
"$",
"i",
"]",
";",
"$",
"valuePointer",
"=",
"&",
"$",
"valuePointer",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"scalar",
"===",
"true",
")",
"{",
"$",
"valuePointer",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"(",
"array",
")",
"$",
"valuePointer",
";",
"$",
"valuePointer",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"valuePointer",
";",
"}"
] | Sets a value in the data-store by dot notation.
@param string $dots notation for value to be set
@param $value value to be set
@param boolean $scalar indicating if value shall be written as scalar or inserted into array | [
"Sets",
"a",
"value",
"in",
"the",
"data",
"-",
"store",
"by",
"dot",
"notation",
"."
] | 1287b3aa751862bf7ab0a8664a0bc44cec323048 | https://github.com/scandio/scandiojs/blob/1287b3aa751862bf7ab0a8664a0bc44cec323048/php/Scandio/js/Bridge.php#L102-L126 |
2,069 | DripsPHP/HTTP | src/Session.php | Session.delete | public function delete($key)
{
if ($this->has($key)) {
unset($this->collection[$this->id_info][$key]);
unset($this->collection[$this->id][$key]);
return true;
}
return false;
} | php | public function delete($key)
{
if ($this->has($key)) {
unset($this->collection[$this->id_info][$key]);
unset($this->collection[$this->id][$key]);
return true;
}
return false;
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"this",
"->",
"id_info",
"]",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"this",
"->",
"id",
"]",
"[",
"$",
"key",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Entfernt den gesetzten Wert, sofern er bereits vorhanden ist.
@param string $key Der Schlüssel der gelöscht werden soll
@return bool | [
"Entfernt",
"den",
"gesetzten",
"Wert",
"sofern",
"er",
"bereits",
"vorhanden",
"ist",
"."
] | 6c571427231f95f3a26f4893fc50a251d1a29aba | https://github.com/DripsPHP/HTTP/blob/6c571427231f95f3a26f4893fc50a251d1a29aba/src/Session.php#L160-L170 |
2,070 | andrelohmann/silverstripe-extended-file | code/extensions/ExtendedFile.php | ExtendedFile.load | public function load($tmpFile, $folderPath = false) {
if(!$folderPath) $folderPath = Config::inst()->get('Upload', 'uploads_folder');
// @TODO This puts a HUGE limitation on files especially when lots
// have been uploaded.
$base = Director::baseFolder();
$parentFolder = Folder::find_or_make($folderPath);
// Generate default filename
$fileArray = explode('/', $tmpFile);
$fileName = $fileArray[(count($fileArray)-1)];
$nameFilter = FileNameFilter::create();
$file = $nameFilter->filter($fileName);
$fileName = basename($file);
$relativeFilePath = ASSETS_DIR . "/" . $folderPath . "/$fileName";
// if filename already exists, version the filename (e.g. test.gif to test1.gif)
while(file_exists("$base/$relativeFilePath")) {
$i = isset($i) ? ($i+1) : 2;
$oldFilePath = $relativeFilePath;
// make sure archives retain valid extensions
if(substr($relativeFilePath, strlen($relativeFilePath) - strlen('.tar.gz')) == '.tar.gz' ||
substr($relativeFilePath, strlen($relativeFilePath) - strlen('.tar.bz2')) == '.tar.bz2') {
$relativeFilePath = preg_replace('/[0-9]*(\.tar\.[^.]+$)/', $i . '\\1', $relativeFilePath);
} else if (strpos($relativeFilePath, '.') !== false) {
$relativeFilePath = preg_replace('/[0-9]*(\.[^.]+$)/', $i . '\\1', $relativeFilePath);
} else if (strpos($relativeFilePath, '_') !== false) {
$relativeFilePath = preg_replace('/_([^_]+$)/', '_'.$i, $relativeFilePath);
} else {
$relativeFilePath .= '_'.$i;
}
if($oldFilePath == $relativeFilePath && $i > 2) {
user_error("Couldn't fix $relativeFilePath with $i tries", E_USER_ERROR);
}
}
if(file_exists($tmpFile) && copy($tmpFile, $base."/".$relativeFilePath)) {
$this->owner->ParentID = $parentFolder->ID;
// This is to prevent it from trying to rename the file
$this->owner->Name = basename($relativeFilePath);
$this->owner->write();
return true;
} else {
return false;
}
} | php | public function load($tmpFile, $folderPath = false) {
if(!$folderPath) $folderPath = Config::inst()->get('Upload', 'uploads_folder');
// @TODO This puts a HUGE limitation on files especially when lots
// have been uploaded.
$base = Director::baseFolder();
$parentFolder = Folder::find_or_make($folderPath);
// Generate default filename
$fileArray = explode('/', $tmpFile);
$fileName = $fileArray[(count($fileArray)-1)];
$nameFilter = FileNameFilter::create();
$file = $nameFilter->filter($fileName);
$fileName = basename($file);
$relativeFilePath = ASSETS_DIR . "/" . $folderPath . "/$fileName";
// if filename already exists, version the filename (e.g. test.gif to test1.gif)
while(file_exists("$base/$relativeFilePath")) {
$i = isset($i) ? ($i+1) : 2;
$oldFilePath = $relativeFilePath;
// make sure archives retain valid extensions
if(substr($relativeFilePath, strlen($relativeFilePath) - strlen('.tar.gz')) == '.tar.gz' ||
substr($relativeFilePath, strlen($relativeFilePath) - strlen('.tar.bz2')) == '.tar.bz2') {
$relativeFilePath = preg_replace('/[0-9]*(\.tar\.[^.]+$)/', $i . '\\1', $relativeFilePath);
} else if (strpos($relativeFilePath, '.') !== false) {
$relativeFilePath = preg_replace('/[0-9]*(\.[^.]+$)/', $i . '\\1', $relativeFilePath);
} else if (strpos($relativeFilePath, '_') !== false) {
$relativeFilePath = preg_replace('/_([^_]+$)/', '_'.$i, $relativeFilePath);
} else {
$relativeFilePath .= '_'.$i;
}
if($oldFilePath == $relativeFilePath && $i > 2) {
user_error("Couldn't fix $relativeFilePath with $i tries", E_USER_ERROR);
}
}
if(file_exists($tmpFile) && copy($tmpFile, $base."/".$relativeFilePath)) {
$this->owner->ParentID = $parentFolder->ID;
// This is to prevent it from trying to rename the file
$this->owner->Name = basename($relativeFilePath);
$this->owner->write();
return true;
} else {
return false;
}
} | [
"public",
"function",
"load",
"(",
"$",
"tmpFile",
",",
"$",
"folderPath",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"folderPath",
")",
"$",
"folderPath",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'Upload'",
",",
"'uploads_folder'",
")",
";",
"// @TODO This puts a HUGE limitation on files especially when lots",
"// have been uploaded.",
"$",
"base",
"=",
"Director",
"::",
"baseFolder",
"(",
")",
";",
"$",
"parentFolder",
"=",
"Folder",
"::",
"find_or_make",
"(",
"$",
"folderPath",
")",
";",
"// Generate default filename",
"$",
"fileArray",
"=",
"explode",
"(",
"'/'",
",",
"$",
"tmpFile",
")",
";",
"$",
"fileName",
"=",
"$",
"fileArray",
"[",
"(",
"count",
"(",
"$",
"fileArray",
")",
"-",
"1",
")",
"]",
";",
"$",
"nameFilter",
"=",
"FileNameFilter",
"::",
"create",
"(",
")",
";",
"$",
"file",
"=",
"$",
"nameFilter",
"->",
"filter",
"(",
"$",
"fileName",
")",
";",
"$",
"fileName",
"=",
"basename",
"(",
"$",
"file",
")",
";",
"$",
"relativeFilePath",
"=",
"ASSETS_DIR",
".",
"\"/\"",
".",
"$",
"folderPath",
".",
"\"/$fileName\"",
";",
"// if filename already exists, version the filename (e.g. test.gif to test1.gif)",
"while",
"(",
"file_exists",
"(",
"\"$base/$relativeFilePath\"",
")",
")",
"{",
"$",
"i",
"=",
"isset",
"(",
"$",
"i",
")",
"?",
"(",
"$",
"i",
"+",
"1",
")",
":",
"2",
";",
"$",
"oldFilePath",
"=",
"$",
"relativeFilePath",
";",
"// make sure archives retain valid extensions",
"if",
"(",
"substr",
"(",
"$",
"relativeFilePath",
",",
"strlen",
"(",
"$",
"relativeFilePath",
")",
"-",
"strlen",
"(",
"'.tar.gz'",
")",
")",
"==",
"'.tar.gz'",
"||",
"substr",
"(",
"$",
"relativeFilePath",
",",
"strlen",
"(",
"$",
"relativeFilePath",
")",
"-",
"strlen",
"(",
"'.tar.bz2'",
")",
")",
"==",
"'.tar.bz2'",
")",
"{",
"$",
"relativeFilePath",
"=",
"preg_replace",
"(",
"'/[0-9]*(\\.tar\\.[^.]+$)/'",
",",
"$",
"i",
".",
"'\\\\1'",
",",
"$",
"relativeFilePath",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"relativeFilePath",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"relativeFilePath",
"=",
"preg_replace",
"(",
"'/[0-9]*(\\.[^.]+$)/'",
",",
"$",
"i",
".",
"'\\\\1'",
",",
"$",
"relativeFilePath",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"relativeFilePath",
",",
"'_'",
")",
"!==",
"false",
")",
"{",
"$",
"relativeFilePath",
"=",
"preg_replace",
"(",
"'/_([^_]+$)/'",
",",
"'_'",
".",
"$",
"i",
",",
"$",
"relativeFilePath",
")",
";",
"}",
"else",
"{",
"$",
"relativeFilePath",
".=",
"'_'",
".",
"$",
"i",
";",
"}",
"if",
"(",
"$",
"oldFilePath",
"==",
"$",
"relativeFilePath",
"&&",
"$",
"i",
">",
"2",
")",
"{",
"user_error",
"(",
"\"Couldn't fix $relativeFilePath with $i tries\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"tmpFile",
")",
"&&",
"copy",
"(",
"$",
"tmpFile",
",",
"$",
"base",
".",
"\"/\"",
".",
"$",
"relativeFilePath",
")",
")",
"{",
"$",
"this",
"->",
"owner",
"->",
"ParentID",
"=",
"$",
"parentFolder",
"->",
"ID",
";",
"// This is to prevent it from trying to rename the file",
"$",
"this",
"->",
"owner",
"->",
"Name",
"=",
"basename",
"(",
"$",
"relativeFilePath",
")",
";",
"$",
"this",
"->",
"owner",
"->",
"write",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Save an file passed from a form post into this object.
@param $tmpFile array Indexed array that PHP generated for every file it uploads.
@param $folderPath string Folder path relative to /assets
@return Boolean|string Either success or error-message. | [
"Save",
"an",
"file",
"passed",
"from",
"a",
"form",
"post",
"into",
"this",
"object",
"."
] | 44106023451b7bd18483cf17006e445abe08f389 | https://github.com/andrelohmann/silverstripe-extended-file/blob/44106023451b7bd18483cf17006e445abe08f389/code/extensions/ExtendedFile.php#L21-L68 |
2,071 | andrelohmann/silverstripe-extended-file | code/extensions/ExtendedFile.php | ExtendedFile.getCloudURL | public function getCloudURL() {
if($CloudUrl = Config::inst()->get('ExtendedFile', 'cloud_url'))
return $CloudUrl.$this->owner->getURL();
else
return $this->owner->getAbsoluteURL();
} | php | public function getCloudURL() {
if($CloudUrl = Config::inst()->get('ExtendedFile', 'cloud_url'))
return $CloudUrl.$this->owner->getURL();
else
return $this->owner->getAbsoluteURL();
} | [
"public",
"function",
"getCloudURL",
"(",
")",
"{",
"if",
"(",
"$",
"CloudUrl",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'ExtendedFile'",
",",
"'cloud_url'",
")",
")",
"return",
"$",
"CloudUrl",
".",
"$",
"this",
"->",
"owner",
"->",
"getURL",
"(",
")",
";",
"else",
"return",
"$",
"this",
"->",
"owner",
"->",
"getAbsoluteURL",
"(",
")",
";",
"}"
] | Gets the Cloud URL accessible through the web.
Concatenates the relative URL with the ExtendedFile CloudUrl Config
@return string | [
"Gets",
"the",
"Cloud",
"URL",
"accessible",
"through",
"the",
"web",
"."
] | 44106023451b7bd18483cf17006e445abe08f389 | https://github.com/andrelohmann/silverstripe-extended-file/blob/44106023451b7bd18483cf17006e445abe08f389/code/extensions/ExtendedFile.php#L77-L82 |
2,072 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/Module.php | Module.init | public function init($moduleManager)
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');
$serviceListener->addServiceManager(
'FilterManager',
'filters',
'Zend\ModuleManager\Feature\FilterProviderInterface',
'getFilterConfig'
);
} | php | public function init($moduleManager)
{
$event = $moduleManager->getEvent();
$container = $event->getParam('ServiceManager');
$serviceListener = $container->get('ServiceListener');
$serviceListener->addServiceManager(
'FilterManager',
'filters',
'Zend\ModuleManager\Feature\FilterProviderInterface',
'getFilterConfig'
);
} | [
"public",
"function",
"init",
"(",
"$",
"moduleManager",
")",
"{",
"$",
"event",
"=",
"$",
"moduleManager",
"->",
"getEvent",
"(",
")",
";",
"$",
"container",
"=",
"$",
"event",
"->",
"getParam",
"(",
"'ServiceManager'",
")",
";",
"$",
"serviceListener",
"=",
"$",
"container",
"->",
"get",
"(",
"'ServiceListener'",
")",
";",
"$",
"serviceListener",
"->",
"addServiceManager",
"(",
"'FilterManager'",
",",
"'filters'",
",",
"'Zend\\ModuleManager\\Feature\\FilterProviderInterface'",
",",
"'getFilterConfig'",
")",
";",
"}"
] | Register a specification for the FilterManager with the ServiceListener.
@param \Zend\ModuleManager\ModuleManager $moduleManager
@return void | [
"Register",
"a",
"specification",
"for",
"the",
"FilterManager",
"with",
"the",
"ServiceListener",
"."
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Module.php#L30-L42 |
2,073 | mszewcz/php-light-framework | src/Html/Form/FormFieldset.php | FormFieldset.generate | public function generate(): string
{
$elements = [];
if ($this->label != '') {
$elements[] = Tags::legend($this->label, []);
}
foreach ($this->elements as $element) {
/** @noinspection PhpUndefinedMethodInspection */
$elements[] = $element->generate();
}
return Tags::fieldset($elements, $this->attributes);
} | php | public function generate(): string
{
$elements = [];
if ($this->label != '') {
$elements[] = Tags::legend($this->label, []);
}
foreach ($this->elements as $element) {
/** @noinspection PhpUndefinedMethodInspection */
$elements[] = $element->generate();
}
return Tags::fieldset($elements, $this->attributes);
} | [
"public",
"function",
"generate",
"(",
")",
":",
"string",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"label",
"!=",
"''",
")",
"{",
"$",
"elements",
"[",
"]",
"=",
"Tags",
"::",
"legend",
"(",
"$",
"this",
"->",
"label",
",",
"[",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"elements",
"[",
"]",
"=",
"$",
"element",
"->",
"generate",
"(",
")",
";",
"}",
"return",
"Tags",
"::",
"fieldset",
"(",
"$",
"elements",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"}"
] | Generates from fieldset and returns it
@return string | [
"Generates",
"from",
"fieldset",
"and",
"returns",
"it"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Form/FormFieldset.php#L49-L60 |
2,074 | heyday/heystack-ecommerce-core | src/Currency/Output/Processor.php | Processor.process | public function process(\Controller $controller, $result = null)
{
if ($controller->getRequest()->isAjax()) {
$response = $controller->getResponse();
$response->setStatusCode(200);
if (is_array($result)) {
$response->addHeader('Content-Type', 'application/json');
$response->setBody(json_encode($result));
}
return $response;
} else {
$controller->redirectBack();
}
return null;
} | php | public function process(\Controller $controller, $result = null)
{
if ($controller->getRequest()->isAjax()) {
$response = $controller->getResponse();
$response->setStatusCode(200);
if (is_array($result)) {
$response->addHeader('Content-Type', 'application/json');
$response->setBody(json_encode($result));
}
return $response;
} else {
$controller->redirectBack();
}
return null;
} | [
"public",
"function",
"process",
"(",
"\\",
"Controller",
"$",
"controller",
",",
"$",
"result",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"controller",
"->",
"getRequest",
"(",
")",
"->",
"isAjax",
"(",
")",
")",
"{",
"$",
"response",
"=",
"$",
"controller",
"->",
"getResponse",
"(",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"200",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"$",
"response",
"->",
"addHeader",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"$",
"response",
"->",
"setBody",
"(",
"json_encode",
"(",
"$",
"result",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}",
"else",
"{",
"$",
"controller",
"->",
"redirectBack",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Method used to determine how to handle the output based on the InputProcessor's result
@param \Controller $controller
@param array|void $result
@return \SS_HTTPResponse | [
"Method",
"used",
"to",
"determine",
"how",
"to",
"handle",
"the",
"output",
"based",
"on",
"the",
"InputProcessor",
"s",
"result"
] | b56c83839cd3396da6bc881d843fcb4f28b74685 | https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Currency/Output/Processor.php#L60-L77 |
2,075 | donbidon/lib-array | src/Arrays.php | Arrays.sortByCol | public static function sortByCol(
array &$array, $column, $sort = SORT_STRING, $direction = SORT_ASC
)
{
if (!sizeof($array)) {
return;
}
$index = [];
$i = 0;
foreach ($array as $key => $row) {
if (is_array($row)) {
$index['pos'][$i] = $key;
$index['name'][$i] = $row[$column];
++$i;
}
}
array_multisort($index['name'], $sort, $direction, $index['pos']);
$result = array();
for ($j = 0; $j < $i; ++$j) {
$result[$index['pos'][$j]] = $array[$index['pos'][$j]];
}
$array = $result;
} | php | public static function sortByCol(
array &$array, $column, $sort = SORT_STRING, $direction = SORT_ASC
)
{
if (!sizeof($array)) {
return;
}
$index = [];
$i = 0;
foreach ($array as $key => $row) {
if (is_array($row)) {
$index['pos'][$i] = $key;
$index['name'][$i] = $row[$column];
++$i;
}
}
array_multisort($index['name'], $sort, $direction, $index['pos']);
$result = array();
for ($j = 0; $j < $i; ++$j) {
$result[$index['pos'][$j]] = $array[$index['pos'][$j]];
}
$array = $result;
} | [
"public",
"static",
"function",
"sortByCol",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"column",
",",
"$",
"sort",
"=",
"SORT_STRING",
",",
"$",
"direction",
"=",
"SORT_ASC",
")",
"{",
"if",
"(",
"!",
"sizeof",
"(",
"$",
"array",
")",
")",
"{",
"return",
";",
"}",
"$",
"index",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"$",
"index",
"[",
"'pos'",
"]",
"[",
"$",
"i",
"]",
"=",
"$",
"key",
";",
"$",
"index",
"[",
"'name'",
"]",
"[",
"$",
"i",
"]",
"=",
"$",
"row",
"[",
"$",
"column",
"]",
";",
"++",
"$",
"i",
";",
"}",
"}",
"array_multisort",
"(",
"$",
"index",
"[",
"'name'",
"]",
",",
"$",
"sort",
",",
"$",
"direction",
",",
"$",
"index",
"[",
"'pos'",
"]",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"i",
";",
"++",
"$",
"j",
")",
"{",
"$",
"result",
"[",
"$",
"index",
"[",
"'pos'",
"]",
"[",
"$",
"j",
"]",
"]",
"=",
"$",
"array",
"[",
"$",
"index",
"[",
"'pos'",
"]",
"[",
"$",
"j",
"]",
"]",
";",
"}",
"$",
"array",
"=",
"$",
"result",
";",
"}"
] | Sort two-dimensional array by column preserving row keys.
@param array $array <b>[by ref]</b> Array
@param string $column Sort column
@param int $sort Sort type
@param int $direction Sort direction: SORT_ASC or SORT_DESC
@return void
@link http://php.net/manual/en/function.array-multisort.php
PHP documentation for sort types | [
"Sort",
"two",
"-",
"dimensional",
"array",
"by",
"column",
"preserving",
"row",
"keys",
"."
] | a770e7fc20443eff736831828f0b189cabff0e5e | https://github.com/donbidon/lib-array/blob/a770e7fc20443eff736831828f0b189cabff0e5e/src/Arrays.php#L216-L239 |
2,076 | ferguson-mr/yii2-base | behaviors/AttributeTypecastBehavior.php | AttributeTypecastBehavior.typecastValue | protected function typecastValue($value, $type)
{
if (is_scalar($type)) {
if (is_object($value) && method_exists($value, '__toString')) {
$value = $value->__toString();
}
switch ($type) {
case self::TYPE_INTEGER:
return (int)$value;
case self::TYPE_FLOAT:
return (float)$value;
case self::TYPE_BOOLEAN:
return (bool)$value;
case self::TYPE_STRING:
return (string)$value;
case self::TYPE_JSON:
return is_string($value) ? $value : json_encode($value);
case self::TYPE_IMPLODE:
return is_string($value) ? $value : (string)implode($this->delimiter, $value);
case self::TYPE_SERIALIZE:
return is_string($value) ? $value : serialize($value);
default:
throw new InvalidParamException("Unsupported type '{$type}'");
}
}
return call_user_func($type, $value);
} | php | protected function typecastValue($value, $type)
{
if (is_scalar($type)) {
if (is_object($value) && method_exists($value, '__toString')) {
$value = $value->__toString();
}
switch ($type) {
case self::TYPE_INTEGER:
return (int)$value;
case self::TYPE_FLOAT:
return (float)$value;
case self::TYPE_BOOLEAN:
return (bool)$value;
case self::TYPE_STRING:
return (string)$value;
case self::TYPE_JSON:
return is_string($value) ? $value : json_encode($value);
case self::TYPE_IMPLODE:
return is_string($value) ? $value : (string)implode($this->delimiter, $value);
case self::TYPE_SERIALIZE:
return is_string($value) ? $value : serialize($value);
default:
throw new InvalidParamException("Unsupported type '{$type}'");
}
}
return call_user_func($type, $value);
} | [
"protected",
"function",
"typecastValue",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"type",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"method_exists",
"(",
"$",
"value",
",",
"'__toString'",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"__toString",
"(",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_INTEGER",
":",
"return",
"(",
"int",
")",
"$",
"value",
";",
"case",
"self",
"::",
"TYPE_FLOAT",
":",
"return",
"(",
"float",
")",
"$",
"value",
";",
"case",
"self",
"::",
"TYPE_BOOLEAN",
":",
"return",
"(",
"bool",
")",
"$",
"value",
";",
"case",
"self",
"::",
"TYPE_STRING",
":",
"return",
"(",
"string",
")",
"$",
"value",
";",
"case",
"self",
"::",
"TYPE_JSON",
":",
"return",
"is_string",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"json_encode",
"(",
"$",
"value",
")",
";",
"case",
"self",
"::",
"TYPE_IMPLODE",
":",
"return",
"is_string",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"(",
"string",
")",
"implode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"value",
")",
";",
"case",
"self",
"::",
"TYPE_SERIALIZE",
":",
"return",
"is_string",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"serialize",
"(",
"$",
"value",
")",
";",
"default",
":",
"throw",
"new",
"InvalidParamException",
"(",
"\"Unsupported type '{$type}'\"",
")",
";",
"}",
"}",
"return",
"call_user_func",
"(",
"$",
"type",
",",
"$",
"value",
")",
";",
"}"
] | Casts the given value to the specified type.
@param mixed $value value to be type-casted.
@param string|callable $type type name or typecast callable.
@return mixed typecast result. | [
"Casts",
"the",
"given",
"value",
"to",
"the",
"specified",
"type",
"."
] | 627a6907003421d6db48f400d878bce33db79c50 | https://github.com/ferguson-mr/yii2-base/blob/627a6907003421d6db48f400d878bce33db79c50/behaviors/AttributeTypecastBehavior.php#L231-L259 |
2,077 | wucdbm/wucdbm-bundle | Form/Doctrine/EntityHiddenType.php | EntityHiddenType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options) {
/** @var ClassAwareDataTransformerInterface $entityTransformer */
$entityTransformer = new $options['transformer']($this->om, $options['class']);
$builder->addModelTransformer($entityTransformer);
} | php | public function buildForm(FormBuilderInterface $builder, array $options) {
/** @var ClassAwareDataTransformerInterface $entityTransformer */
$entityTransformer = new $options['transformer']($this->om, $options['class']);
$builder->addModelTransformer($entityTransformer);
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"/** @var ClassAwareDataTransformerInterface $entityTransformer */",
"$",
"entityTransformer",
"=",
"new",
"$",
"options",
"[",
"'transformer'",
"]",
"(",
"$",
"this",
"->",
"om",
",",
"$",
"options",
"[",
"'class'",
"]",
")",
";",
"$",
"builder",
"->",
"addModelTransformer",
"(",
"$",
"entityTransformer",
")",
";",
"}"
] | Add the data transformer to the field setting the entity repository
@param FormBuilderInterface $builder
@param array $options | [
"Add",
"the",
"data",
"transformer",
"to",
"the",
"field",
"setting",
"the",
"entity",
"repository"
] | 7479e7a864b58b03c7b1045d4021f683b5396245 | https://github.com/wucdbm/wucdbm-bundle/blob/7479e7a864b58b03c7b1045d4021f683b5396245/Form/Doctrine/EntityHiddenType.php#L30-L34 |
2,078 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element._build_items | private function _build_items(array $items)
{
foreach ($items as $key => $item) {
$this->_items[$key] = new Element_Item($item, $this, $key);
}
return $this;
} | php | private function _build_items(array $items)
{
foreach ($items as $key => $item) {
$this->_items[$key] = new Element_Item($item, $this, $key);
}
return $this;
} | [
"private",
"function",
"_build_items",
"(",
"array",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"_items",
"[",
"$",
"key",
"]",
"=",
"new",
"Element_Item",
"(",
"$",
"item",
",",
"$",
"this",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Transform Element items from an array to objects
@since 3.0
@param array $items An array of Element items
@return \Kohana_Element | [
"Transform",
"Element",
"items",
"from",
"an",
"array",
"to",
"objects"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L81-L88 |
2,079 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element._get_element_config | protected static function _get_element_config($config)
{
if (Kohana::find_file('config'.DIRECTORY_SEPARATOR.self::CONFIG_DIR, $config) === FALSE) {
throw new Kohana_Exception('Element configuration file ":path" not found!', [
':path' => APPPATH.'config'.DIRECTORY_SEPARATOR.self::CONFIG_DIR.DIRECTORY_SEPARATOR.$config.EXT
]);
}
return Kohana::$config->load(self::CONFIG_DIR.DIRECTORY_SEPARATOR.$config)
->as_array();
} | php | protected static function _get_element_config($config)
{
if (Kohana::find_file('config'.DIRECTORY_SEPARATOR.self::CONFIG_DIR, $config) === FALSE) {
throw new Kohana_Exception('Element configuration file ":path" not found!', [
':path' => APPPATH.'config'.DIRECTORY_SEPARATOR.self::CONFIG_DIR.DIRECTORY_SEPARATOR.$config.EXT
]);
}
return Kohana::$config->load(self::CONFIG_DIR.DIRECTORY_SEPARATOR.$config)
->as_array();
} | [
"protected",
"static",
"function",
"_get_element_config",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"Kohana",
"::",
"find_file",
"(",
"'config'",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"CONFIG_DIR",
",",
"$",
"config",
")",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"Kohana_Exception",
"(",
"'Element configuration file \":path\" not found!'",
",",
"[",
"':path'",
"=>",
"APPPATH",
".",
"'config'",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"CONFIG_DIR",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"config",
".",
"EXT",
"]",
")",
";",
"}",
"return",
"Kohana",
"::",
"$",
"config",
"->",
"load",
"(",
"self",
"::",
"CONFIG_DIR",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"config",
")",
"->",
"as_array",
"(",
")",
";",
"}"
] | Read Element configuration file
@param string $config File name in config/navigation dir
@return array Element configuration array
@throws Kohana_Exception | [
"Read",
"Element",
"configuration",
"file"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L97-L107 |
2,080 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element.factory | public static function factory($config_file = 'bootstrap')
{
if(is_a($config_file, 'Config_Group')) {
$config_file->set('cfg_name', $config_file->group_name());
$element_config = $config_file->as_array();
}
else {
// Load element config
$element_config = self::_get_element_config($config_file);
$element_config['cfg_name'] = $config_file;
}
return new Element($element_config);
} | php | public static function factory($config_file = 'bootstrap')
{
if(is_a($config_file, 'Config_Group')) {
$config_file->set('cfg_name', $config_file->group_name());
$element_config = $config_file->as_array();
}
else {
// Load element config
$element_config = self::_get_element_config($config_file);
$element_config['cfg_name'] = $config_file;
}
return new Element($element_config);
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"config_file",
"=",
"'bootstrap'",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"config_file",
",",
"'Config_Group'",
")",
")",
"{",
"$",
"config_file",
"->",
"set",
"(",
"'cfg_name'",
",",
"$",
"config_file",
"->",
"group_name",
"(",
")",
")",
";",
"$",
"element_config",
"=",
"$",
"config_file",
"->",
"as_array",
"(",
")",
";",
"}",
"else",
"{",
"// Load element config",
"$",
"element_config",
"=",
"self",
"::",
"_get_element_config",
"(",
"$",
"config_file",
")",
";",
"$",
"element_config",
"[",
"'cfg_name'",
"]",
"=",
"$",
"config_file",
";",
"}",
"return",
"new",
"Element",
"(",
"$",
"element_config",
")",
";",
"}"
] | Instantiate a new Element
@param string $config_file File name in config/navigation/ or a Config_Group instance
@throws Kohana_Exception
@return Element
@since 2.0 | [
"Instantiate",
"a",
"new",
"Element"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L117-L131 |
2,081 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element.render | public function render($driver='Menu', $tpl=null, $active_recursive=false)
{
// Try to guess the current active Element item
if ($this->_active_item_index === NULL)
{
$this->set_current(Route::name(Request::$initial->route()), $active_recursive);
}
return Kohana_Element_Render::factory($driver, $this, $tpl)->render();
} | php | public function render($driver='Menu', $tpl=null, $active_recursive=false)
{
// Try to guess the current active Element item
if ($this->_active_item_index === NULL)
{
$this->set_current(Route::name(Request::$initial->route()), $active_recursive);
}
return Kohana_Element_Render::factory($driver, $this, $tpl)->render();
} | [
"public",
"function",
"render",
"(",
"$",
"driver",
"=",
"'Menu'",
",",
"$",
"tpl",
"=",
"null",
",",
"$",
"active_recursive",
"=",
"false",
")",
"{",
"// Try to guess the current active Element item",
"if",
"(",
"$",
"this",
"->",
"_active_item_index",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"set_current",
"(",
"Route",
"::",
"name",
"(",
"Request",
"::",
"$",
"initial",
"->",
"route",
"(",
")",
")",
",",
"$",
"active_recursive",
")",
";",
"}",
"return",
"Kohana_Element_Render",
"::",
"factory",
"(",
"$",
"driver",
",",
"$",
"this",
",",
"$",
"tpl",
")",
"->",
"render",
"(",
")",
";",
"}"
] | Render the Element into HTML
@since 2.0
@return string the rendered view | [
"Render",
"the",
"Element",
"into",
"HTML"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L139-L148 |
2,082 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element.get_visible_items | public function get_visible_items()
{
if ($this->_items === NULL) {
return array();
}
$visible_items = [];
foreach ($this->_items as $key => $item)
{
if (! $item->is_visible())
{
continue;
}
$visible_items[$key] = $item;
}
return $visible_items;
} | php | public function get_visible_items()
{
if ($this->_items === NULL) {
return array();
}
$visible_items = [];
foreach ($this->_items as $key => $item)
{
if (! $item->is_visible())
{
continue;
}
$visible_items[$key] = $item;
}
return $visible_items;
} | [
"public",
"function",
"get_visible_items",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_items",
"===",
"NULL",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"visible_items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"item",
"->",
"is_visible",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"visible_items",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"visible_items",
";",
"}"
] | Get only visible Element items
@return array | [
"Get",
"only",
"visible",
"Element",
"items"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L188-L206 |
2,083 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element.get_item | public function get_item($id)
{
// Element empty!
if (count($this->_items) === 0)
return FALSE;
if (array_key_exists($id, $this->_items))
{ // By ID
return $this->_items[$id];
} else
{ // By route
$path = $this->get_tree_index(Route::get($id));
if($path != false)
{
$levels = count($path);
$item = $this->_items[$path[0]];
if($levels > 1)
{
for($i=1; $i<$levels; $i++)
{
$item = $item->siblings[$path[$i]];
}
}
return $item;
}
}
return FALSE;
} | php | public function get_item($id)
{
// Element empty!
if (count($this->_items) === 0)
return FALSE;
if (array_key_exists($id, $this->_items))
{ // By ID
return $this->_items[$id];
} else
{ // By route
$path = $this->get_tree_index(Route::get($id));
if($path != false)
{
$levels = count($path);
$item = $this->_items[$path[0]];
if($levels > 1)
{
for($i=1; $i<$levels; $i++)
{
$item = $item->siblings[$path[$i]];
}
}
return $item;
}
}
return FALSE;
} | [
"public",
"function",
"get_item",
"(",
"$",
"id",
")",
"{",
"// Element empty!",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_items",
")",
"===",
"0",
")",
"return",
"FALSE",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"_items",
")",
")",
"{",
"// By ID",
"return",
"$",
"this",
"->",
"_items",
"[",
"$",
"id",
"]",
";",
"}",
"else",
"{",
"// By route",
"$",
"path",
"=",
"$",
"this",
"->",
"get_tree_index",
"(",
"Route",
"::",
"get",
"(",
"$",
"id",
")",
")",
";",
"if",
"(",
"$",
"path",
"!=",
"false",
")",
"{",
"$",
"levels",
"=",
"count",
"(",
"$",
"path",
")",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"_items",
"[",
"$",
"path",
"[",
"0",
"]",
"]",
";",
"if",
"(",
"$",
"levels",
">",
"1",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"levels",
";",
"$",
"i",
"++",
")",
"{",
"$",
"item",
"=",
"$",
"item",
"->",
"siblings",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
";",
"}",
"}",
"return",
"$",
"item",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Get an instance of Element_Item based on its ID
@param int|string $id Item ID or route name
@return Element_Item | [
"Get",
"an",
"instance",
"of",
"Element_Item",
"based",
"on",
"its",
"ID"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L249-L279 |
2,084 | happyDemon/elements | classes/Kohana/Element.php | Kohana_Element.get_tree_index | public function get_tree_index(Route $route)
{
$name = Route::name($route);
if(isset($this->routes[$name]))
return explode('.', $this->routes[$name]);
return false;
} | php | public function get_tree_index(Route $route)
{
$name = Route::name($route);
if(isset($this->routes[$name]))
return explode('.', $this->routes[$name]);
return false;
} | [
"public",
"function",
"get_tree_index",
"(",
"Route",
"$",
"route",
")",
"{",
"$",
"name",
"=",
"Route",
"::",
"name",
"(",
"$",
"route",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
")",
")",
"return",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
")",
";",
"return",
"false",
";",
"}"
] | Return an array to traverse to possibly get sibling items based on a given route
@param Route $route
@return array|bool | [
"Return",
"an",
"array",
"to",
"traverse",
"to",
"possibly",
"get",
"sibling",
"items",
"based",
"on",
"a",
"given",
"route"
] | 19534fcbf4735a12a0219f8aada49f30e3b690e1 | https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element.php#L287-L295 |
2,085 | chenwenzhang/initially-rpc | src/Initially/Rpc/Core/Engine/ComposerScriptHandler.php | ComposerScriptHandler.rebuildClientServiceProxy | public static function rebuildClientServiceProxy(Event $event)
{
$io = $event->getIO();
$extra = $event->getComposer()->getPackage()->getExtra();
if (isset($extra["initially-rpc-config-file"])) {
$rootDir = getcwd();
$configFile = $rootDir . "/" . $extra["initially-rpc-config-file"];
if (is_file($configFile)) {
$client = new Client($configFile);
$builder = $client->getBuilder();
$config = $client->getConfig();
$services = $config->getServices();
$io->write("Initially Rpc: build proxy start");
foreach ($services as $service) {
$io->write("Initially Rpc: build {$service->getInterface()}");
$builder->create($service->getInterface());
}
$io->write("Initially Rpc: build proxy end");
} else {
$io->write("Initially Rpc: client config file error [\"{$configFile}\"]");
}
} else {
$io->write("Initially Rpc: not configured composer extra [\"initially-rpc-config-file\"]");
}
} | php | public static function rebuildClientServiceProxy(Event $event)
{
$io = $event->getIO();
$extra = $event->getComposer()->getPackage()->getExtra();
if (isset($extra["initially-rpc-config-file"])) {
$rootDir = getcwd();
$configFile = $rootDir . "/" . $extra["initially-rpc-config-file"];
if (is_file($configFile)) {
$client = new Client($configFile);
$builder = $client->getBuilder();
$config = $client->getConfig();
$services = $config->getServices();
$io->write("Initially Rpc: build proxy start");
foreach ($services as $service) {
$io->write("Initially Rpc: build {$service->getInterface()}");
$builder->create($service->getInterface());
}
$io->write("Initially Rpc: build proxy end");
} else {
$io->write("Initially Rpc: client config file error [\"{$configFile}\"]");
}
} else {
$io->write("Initially Rpc: not configured composer extra [\"initially-rpc-config-file\"]");
}
} | [
"public",
"static",
"function",
"rebuildClientServiceProxy",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"io",
"=",
"$",
"event",
"->",
"getIO",
"(",
")",
";",
"$",
"extra",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
"->",
"getPackage",
"(",
")",
"->",
"getExtra",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"extra",
"[",
"\"initially-rpc-config-file\"",
"]",
")",
")",
"{",
"$",
"rootDir",
"=",
"getcwd",
"(",
")",
";",
"$",
"configFile",
"=",
"$",
"rootDir",
".",
"\"/\"",
".",
"$",
"extra",
"[",
"\"initially-rpc-config-file\"",
"]",
";",
"if",
"(",
"is_file",
"(",
"$",
"configFile",
")",
")",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
"$",
"configFile",
")",
";",
"$",
"builder",
"=",
"$",
"client",
"->",
"getBuilder",
"(",
")",
";",
"$",
"config",
"=",
"$",
"client",
"->",
"getConfig",
"(",
")",
";",
"$",
"services",
"=",
"$",
"config",
"->",
"getServices",
"(",
")",
";",
"$",
"io",
"->",
"write",
"(",
"\"Initially Rpc: build proxy start\"",
")",
";",
"foreach",
"(",
"$",
"services",
"as",
"$",
"service",
")",
"{",
"$",
"io",
"->",
"write",
"(",
"\"Initially Rpc: build {$service->getInterface()}\"",
")",
";",
"$",
"builder",
"->",
"create",
"(",
"$",
"service",
"->",
"getInterface",
"(",
")",
")",
";",
"}",
"$",
"io",
"->",
"write",
"(",
"\"Initially Rpc: build proxy end\"",
")",
";",
"}",
"else",
"{",
"$",
"io",
"->",
"write",
"(",
"\"Initially Rpc: client config file error [\\\"{$configFile}\\\"]\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"io",
"->",
"write",
"(",
"\"Initially Rpc: not configured composer extra [\\\"initially-rpc-config-file\\\"]\"",
")",
";",
"}",
"}"
] | Rebuild client service proxy | [
"Rebuild",
"client",
"service",
"proxy"
] | 43d56eb3749bedd3f4ee83e57676f7bb6b89e682 | https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Core/Engine/ComposerScriptHandler.php#L17-L41 |
2,086 | Thuata/FrameworkBundle | Document/AbstractDocument.php | AbstractDocument.getMongoDocumentData | protected function getMongoDocumentData($name)
{
if (array_key_exists($name, $this->document)) {
return $this->document[$name];
}
return null;
} | php | protected function getMongoDocumentData($name)
{
if (array_key_exists($name, $this->document)) {
return $this->document[$name];
}
return null;
} | [
"protected",
"function",
"getMongoDocumentData",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"document",
")",
")",
"{",
"return",
"$",
"this",
"->",
"document",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Gets data from the document
@param string $name
@return mixed | [
"Gets",
"data",
"from",
"the",
"document"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Document/AbstractDocument.php#L88-L95 |
2,087 | endorphin-studio/browser-detector-tools | src/Tools.php | Tools.getVersion | public static function getVersion(string $phrase, string $ua): string
{
$version = static::getVersionPattern($phrase);
$uaString = str_replace(' NT', '', $ua);
if (preg_match($version, $uaString)) {
preg_match($version, $uaString, $v);
$version = $v[0];
$version = preg_replace('/' . $phrase . '/', '', $version);
$version = str_replace(';', '', $version);
$version = str_replace(' ', '', $version);
$version = str_replace('/', '', $version);
$version = str_replace('_', '.', $version);
if(preg_match('/ Windows /', $uaString)) {
$version = static::getWindowsVersion($version);
}
return $version;
}
return "not available";
} | php | public static function getVersion(string $phrase, string $ua): string
{
$version = static::getVersionPattern($phrase);
$uaString = str_replace(' NT', '', $ua);
if (preg_match($version, $uaString)) {
preg_match($version, $uaString, $v);
$version = $v[0];
$version = preg_replace('/' . $phrase . '/', '', $version);
$version = str_replace(';', '', $version);
$version = str_replace(' ', '', $version);
$version = str_replace('/', '', $version);
$version = str_replace('_', '.', $version);
if(preg_match('/ Windows /', $uaString)) {
$version = static::getWindowsVersion($version);
}
return $version;
}
return "not available";
} | [
"public",
"static",
"function",
"getVersion",
"(",
"string",
"$",
"phrase",
",",
"string",
"$",
"ua",
")",
":",
"string",
"{",
"$",
"version",
"=",
"static",
"::",
"getVersionPattern",
"(",
"$",
"phrase",
")",
";",
"$",
"uaString",
"=",
"str_replace",
"(",
"' NT'",
",",
"''",
",",
"$",
"ua",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"version",
",",
"$",
"uaString",
")",
")",
"{",
"preg_match",
"(",
"$",
"version",
",",
"$",
"uaString",
",",
"$",
"v",
")",
";",
"$",
"version",
"=",
"$",
"v",
"[",
"0",
"]",
";",
"$",
"version",
"=",
"preg_replace",
"(",
"'/'",
".",
"$",
"phrase",
".",
"'/'",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"version",
"=",
"str_replace",
"(",
"';'",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"version",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"version",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"version",
")",
";",
"$",
"version",
"=",
"str_replace",
"(",
"'_'",
",",
"'.'",
",",
"$",
"version",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/ Windows /'",
",",
"$",
"uaString",
")",
")",
"{",
"$",
"version",
"=",
"static",
"::",
"getWindowsVersion",
"(",
"$",
"version",
")",
";",
"}",
"return",
"$",
"version",
";",
"}",
"return",
"\"not available\"",
";",
"}"
] | Return version from UA string
@param string $phrase
@param string $ua
@return string | [
"Return",
"version",
"from",
"UA",
"string"
] | 30a6973e6c6dc97e2526b11614505bf862c24875 | https://github.com/endorphin-studio/browser-detector-tools/blob/30a6973e6c6dc97e2526b11614505bf862c24875/src/Tools.php#L38-L57 |
2,088 | endorphin-studio/browser-detector-tools | src/Tools.php | Tools.getWindowsVersion | public static function getWindowsVersion(string $version)
{
$config = static::$windowsConfig;
return \array_key_exists($version, $config) ? $config[$version] : $version;
} | php | public static function getWindowsVersion(string $version)
{
$config = static::$windowsConfig;
return \array_key_exists($version, $config) ? $config[$version] : $version;
} | [
"public",
"static",
"function",
"getWindowsVersion",
"(",
"string",
"$",
"version",
")",
"{",
"$",
"config",
"=",
"static",
"::",
"$",
"windowsConfig",
";",
"return",
"\\",
"array_key_exists",
"(",
"$",
"version",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"$",
"version",
"]",
":",
"$",
"version",
";",
"}"
] | Return windows version
@param string $version
@return mixed|string | [
"Return",
"windows",
"version"
] | 30a6973e6c6dc97e2526b11614505bf862c24875 | https://github.com/endorphin-studio/browser-detector-tools/blob/30a6973e6c6dc97e2526b11614505bf862c24875/src/Tools.php#L74-L78 |
2,089 | endorphin-studio/browser-detector-tools | src/Tools.php | Tools.runSetter | public static function runSetter(&$object, string $key, $value)
{
$methodName = static::getMethodName($key);
if (method_exists($object, $methodName)) {
$object->$methodName($value);
}
} | php | public static function runSetter(&$object, string $key, $value)
{
$methodName = static::getMethodName($key);
if (method_exists($object, $methodName)) {
$object->$methodName($value);
}
} | [
"public",
"static",
"function",
"runSetter",
"(",
"&",
"$",
"object",
",",
"string",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"methodName",
"=",
"static",
"::",
"getMethodName",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"object",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"object",
"->",
"$",
"methodName",
"(",
"$",
"value",
")",
";",
"}",
"}"
] | Execute setter method
@param $object
@param string $key
@param $value | [
"Execute",
"setter",
"method"
] | 30a6973e6c6dc97e2526b11614505bf862c24875 | https://github.com/endorphin-studio/browser-detector-tools/blob/30a6973e6c6dc97e2526b11614505bf862c24875/src/Tools.php#L97-L103 |
2,090 | endorphin-studio/browser-detector-tools | src/Tools.php | Tools.resolvePath | public static function resolvePath(array &$files, $path)
{
if (is_array($path)) {
$files = \array_merge($files, $path);
} else {
$files[] = $path;
}
return \array_unique($files);
} | php | public static function resolvePath(array &$files, $path)
{
if (is_array($path)) {
$files = \array_merge($files, $path);
} else {
$files[] = $path;
}
return \array_unique($files);
} | [
"public",
"static",
"function",
"resolvePath",
"(",
"array",
"&",
"$",
"files",
",",
"$",
"path",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"$",
"files",
"=",
"\\",
"array_merge",
"(",
"$",
"files",
",",
"$",
"path",
")",
";",
"}",
"else",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"return",
"\\",
"array_unique",
"(",
"$",
"files",
")",
";",
"}"
] | Add path to list
@param array $files
@param $path
@return array | [
"Add",
"path",
"to",
"list"
] | 30a6973e6c6dc97e2526b11614505bf862c24875 | https://github.com/endorphin-studio/browser-detector-tools/blob/30a6973e6c6dc97e2526b11614505bf862c24875/src/Tools.php#L126-L134 |
2,091 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.map | public function map(callable $converter)
{
return new Enumerator(
function () use($converter) {
foreach ($this->each() as $k => $v) {
$v = call_user_func($converter, $v, $k);
yield $k => $v;
}
}
);
} | php | public function map(callable $converter)
{
return new Enumerator(
function () use($converter) {
foreach ($this->each() as $k => $v) {
$v = call_user_func($converter, $v, $k);
yield $k => $v;
}
}
);
} | [
"public",
"function",
"map",
"(",
"callable",
"$",
"converter",
")",
"{",
"return",
"new",
"Enumerator",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"converter",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"v",
"=",
"call_user_func",
"(",
"$",
"converter",
",",
"$",
"v",
",",
"$",
"k",
")",
";",
"yield",
"$",
"k",
"=>",
"$",
"v",
";",
"}",
"}",
")",
";",
"}"
] | Return Enumerator which convert values
@param callable $converter
@return \dooaki\Container\Lazy\Enumerator | [
"Return",
"Enumerator",
"which",
"convert",
"values"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L47-L57 |
2,092 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.mapKeyValue | public function mapKeyValue(callable $converter)
{
return new Enumerator(
function () use($converter) {
foreach ($this->each() as $k => $v) {
$r = call_user_func($converter, $k, $v);
yield key($r) => current($r);
}
}
);
} | php | public function mapKeyValue(callable $converter)
{
return new Enumerator(
function () use($converter) {
foreach ($this->each() as $k => $v) {
$r = call_user_func($converter, $k, $v);
yield key($r) => current($r);
}
}
);
} | [
"public",
"function",
"mapKeyValue",
"(",
"callable",
"$",
"converter",
")",
"{",
"return",
"new",
"Enumerator",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"converter",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"call_user_func",
"(",
"$",
"converter",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"yield",
"key",
"(",
"$",
"r",
")",
"=>",
"current",
"(",
"$",
"r",
")",
";",
"}",
"}",
")",
";",
"}"
] | Return Enumerator which convert keys and values
@param callable $converter
@return \dooaki\Container\Lazy\Enumerator | [
"Return",
"Enumerator",
"which",
"convert",
"keys",
"and",
"values"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L83-L93 |
2,093 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.transpose | public function transpose()
{
return new Enumerator(
function () {
$ret = [];
foreach ($this->each() as $row) {
foreach ($row as $k => $col) {
$ret[$k][] = $col;
}
}
foreach ($ret as $k => $r) {
yield $k => $r;
}
}
);
} | php | public function transpose()
{
return new Enumerator(
function () {
$ret = [];
foreach ($this->each() as $row) {
foreach ($row as $k => $col) {
$ret[$k][] = $col;
}
}
foreach ($ret as $k => $r) {
yield $k => $r;
}
}
);
} | [
"public",
"function",
"transpose",
"(",
")",
"{",
"return",
"new",
"Enumerator",
"(",
"function",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"k",
"=>",
"$",
"col",
")",
"{",
"$",
"ret",
"[",
"$",
"k",
"]",
"[",
"]",
"=",
"$",
"col",
";",
"}",
"}",
"foreach",
"(",
"$",
"ret",
"as",
"$",
"k",
"=>",
"$",
"r",
")",
"{",
"yield",
"$",
"k",
"=>",
"$",
"r",
";",
"}",
"}",
")",
";",
"}"
] | Return Enumerator which returns transposed Array
@return \dooaki\Container\Lazy\Enumerator|\Generator | [
"Return",
"Enumerator",
"which",
"returns",
"transposed",
"Array"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L180-L196 |
2,094 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.flatten | public function flatten()
{
return new Enumerator(
function () {
foreach ($this->each() as $k => $v) {
if (($v instanceof \Traversable) || is_array($v)) {
yield $k => Enumerator::from($v)->flatten();
} else {
yield $k => $v;
}
}
}
);
} | php | public function flatten()
{
return new Enumerator(
function () {
foreach ($this->each() as $k => $v) {
if (($v instanceof \Traversable) || is_array($v)) {
yield $k => Enumerator::from($v)->flatten();
} else {
yield $k => $v;
}
}
}
);
} | [
"public",
"function",
"flatten",
"(",
")",
"{",
"return",
"new",
"Enumerator",
"(",
"function",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"(",
"$",
"v",
"instanceof",
"\\",
"Traversable",
")",
"||",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"yield",
"$",
"k",
"=>",
"Enumerator",
"::",
"from",
"(",
"$",
"v",
")",
"->",
"flatten",
"(",
")",
";",
"}",
"else",
"{",
"yield",
"$",
"k",
"=>",
"$",
"v",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Return Enumerator which flatten values
@return \dooaki\Container\Lazy\Enumerator|\Generator | [
"Return",
"Enumerator",
"which",
"flatten",
"values"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L203-L216 |
2,095 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.unique | public function unique(callable $func = null)
{
return new Enumerator(
function () use ($func) {
$exists = [];
foreach ($this->each() as $k => $v) {
$comp = $func ? $func($v) : $v;
if (!in_array($comp, $exists, true)) {
$exists[] = $comp;
yield $k => $v;
}
}
}
);
} | php | public function unique(callable $func = null)
{
return new Enumerator(
function () use ($func) {
$exists = [];
foreach ($this->each() as $k => $v) {
$comp = $func ? $func($v) : $v;
if (!in_array($comp, $exists, true)) {
$exists[] = $comp;
yield $k => $v;
}
}
}
);
} | [
"public",
"function",
"unique",
"(",
"callable",
"$",
"func",
"=",
"null",
")",
"{",
"return",
"new",
"Enumerator",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"func",
")",
"{",
"$",
"exists",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"comp",
"=",
"$",
"func",
"?",
"$",
"func",
"(",
"$",
"v",
")",
":",
"$",
"v",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"comp",
",",
"$",
"exists",
",",
"true",
")",
")",
"{",
"$",
"exists",
"[",
"]",
"=",
"$",
"comp",
";",
"yield",
"$",
"k",
"=>",
"$",
"v",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Return Enumerator which returns unique values
@param callable $func
@return Enumerator | [
"Return",
"Enumerator",
"which",
"returns",
"unique",
"values"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L224-L238 |
2,096 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable.groupBy | public function groupBy(callable $func)
{
$result = [];
foreach ($this->each() as $k => $v) {
$this->_groupBy($result, $k, $v, $func);
}
return $result;
} | php | public function groupBy(callable $func)
{
$result = [];
foreach ($this->each() as $k => $v) {
$this->_groupBy($result, $k, $v, $func);
}
return $result;
} | [
"public",
"function",
"groupBy",
"(",
"callable",
"$",
"func",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"each",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_groupBy",
"(",
"$",
"result",
",",
"$",
"k",
",",
"$",
"v",
",",
"$",
"func",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Return an array which aggregated by func
@param callable $func
@return array | [
"Return",
"an",
"array",
"which",
"aggregated",
"by",
"func"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L334-L341 |
2,097 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable._groupBy | private function _groupBy(&$result, $k, $v, $func)
{
if ($v instanceof self) {
foreach ($v->each() as $kk => $vv) {
$this->_groupBy($result, $kk, $vv, $func);
}
} else {
$aggregate_key = call_user_func($func, $v, $k);
$result[$aggregate_key][] = $v;
}
} | php | private function _groupBy(&$result, $k, $v, $func)
{
if ($v instanceof self) {
foreach ($v->each() as $kk => $vv) {
$this->_groupBy($result, $kk, $vv, $func);
}
} else {
$aggregate_key = call_user_func($func, $v, $k);
$result[$aggregate_key][] = $v;
}
} | [
"private",
"function",
"_groupBy",
"(",
"&",
"$",
"result",
",",
"$",
"k",
",",
"$",
"v",
",",
"$",
"func",
")",
"{",
"if",
"(",
"$",
"v",
"instanceof",
"self",
")",
"{",
"foreach",
"(",
"$",
"v",
"->",
"each",
"(",
")",
"as",
"$",
"kk",
"=>",
"$",
"vv",
")",
"{",
"$",
"this",
"->",
"_groupBy",
"(",
"$",
"result",
",",
"$",
"kk",
",",
"$",
"vv",
",",
"$",
"func",
")",
";",
"}",
"}",
"else",
"{",
"$",
"aggregate_key",
"=",
"call_user_func",
"(",
"$",
"func",
",",
"$",
"v",
",",
"$",
"k",
")",
";",
"$",
"result",
"[",
"$",
"aggregate_key",
"]",
"[",
"]",
"=",
"$",
"v",
";",
"}",
"}"
] | call by groupBy method
@see groupBy
@param array &$result
@param mixed $k
@param mixed $v
@param callable $func
@return void | [
"call",
"by",
"groupBy",
"method"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L353-L363 |
2,098 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable._toArray | private function _toArray(&$result, $k, $v)
{
if ($v instanceof self) {
foreach ($v->each() as $kk => $vv) {
$this->_toArray($result, $kk, $vv);
}
} else {
$result[$k] = $v;
}
} | php | private function _toArray(&$result, $k, $v)
{
if ($v instanceof self) {
foreach ($v->each() as $kk => $vv) {
$this->_toArray($result, $kk, $vv);
}
} else {
$result[$k] = $v;
}
} | [
"private",
"function",
"_toArray",
"(",
"&",
"$",
"result",
",",
"$",
"k",
",",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"instanceof",
"self",
")",
"{",
"foreach",
"(",
"$",
"v",
"->",
"each",
"(",
")",
"as",
"$",
"kk",
"=>",
"$",
"vv",
")",
"{",
"$",
"this",
"->",
"_toArray",
"(",
"$",
"result",
",",
"$",
"kk",
",",
"$",
"vv",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}"
] | call by toArray method
@see toArray
@param array &$result
@param mixed $k
@param mixed $v
@return void | [
"call",
"by",
"toArray",
"method"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L388-L397 |
2,099 | do-aki/php-container | src/Lazy/Enumerable.php | Enumerable._toArrayValues | private function _toArrayValues(&$result, $v)
{
if ($v instanceof self) {
foreach ($v->each() as $vv) {
$this->_toArrayValues($result, $vv);
}
} else {
$result[] = $v;
}
} | php | private function _toArrayValues(&$result, $v)
{
if ($v instanceof self) {
foreach ($v->each() as $vv) {
$this->_toArrayValues($result, $vv);
}
} else {
$result[] = $v;
}
} | [
"private",
"function",
"_toArrayValues",
"(",
"&",
"$",
"result",
",",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"instanceof",
"self",
")",
"{",
"foreach",
"(",
"$",
"v",
"->",
"each",
"(",
")",
"as",
"$",
"vv",
")",
"{",
"$",
"this",
"->",
"_toArrayValues",
"(",
"$",
"result",
",",
"$",
"vv",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"v",
";",
"}",
"}"
] | call by toArrayValues method
@see toArray
@param array &$result
@param mixed $v
@return void | [
"call",
"by",
"toArrayValues",
"method"
] | f7c74430c37d8915a586a0673c7d32015512b8d3 | https://github.com/do-aki/php-container/blob/f7c74430c37d8915a586a0673c7d32015512b8d3/src/Lazy/Enumerable.php#L421-L430 |
Subsets and Splits