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
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,500 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.boot | public function boot() {
$this->emitter = new Emitter;
$this->query = new QueryRepository();
//Busca las acciones definidas en el plugin y las agrega como acciones de Wordpress
$this->add_actions();
add_action('cmb2_admin_init', array($this, 'add_metaboxes'), 1000);
} | php | public function boot() {
$this->emitter = new Emitter;
$this->query = new QueryRepository();
//Busca las acciones definidas en el plugin y las agrega como acciones de Wordpress
$this->add_actions();
add_action('cmb2_admin_init', array($this, 'add_metaboxes'), 1000);
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"emitter",
"=",
"new",
"Emitter",
";",
"$",
"this",
"->",
"query",
"=",
"new",
"QueryRepository",
"(",
")",
";",
"//Busca las acciones definidas en el plugin y las agrega como acciones de Wordpress",
"$",
"this",
"->",
"add_actions",
"(",
")",
";",
"add_action",
"(",
"'cmb2_admin_init'",
",",
"array",
"(",
"$",
"this",
",",
"'add_metaboxes'",
")",
",",
"1000",
")",
";",
"}"
] | Boot class Inicializa el plugin
@return void | [
"Boot",
"class",
"Inicializa",
"el",
"plugin"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L164-L170 |
9,501 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.add_metaboxes | public function add_metaboxes() {
$methos = $this->getMethods("/^metabox_/");
sort($methos); //Se ordenas los metodos por prioridad
if ($methos) {
foreach ($methos as $metabox) {
call_user_func(array($this, $metabox));
}
}
} | php | public function add_metaboxes() {
$methos = $this->getMethods("/^metabox_/");
sort($methos); //Se ordenas los metodos por prioridad
if ($methos) {
foreach ($methos as $metabox) {
call_user_func(array($this, $metabox));
}
}
} | [
"public",
"function",
"add_metaboxes",
"(",
")",
"{",
"$",
"methos",
"=",
"$",
"this",
"->",
"getMethods",
"(",
"\"/^metabox_/\"",
")",
";",
"sort",
"(",
"$",
"methos",
")",
";",
"//Se ordenas los metodos por prioridad",
"if",
"(",
"$",
"methos",
")",
"{",
"foreach",
"(",
"$",
"methos",
"as",
"$",
"metabox",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"metabox",
")",
")",
";",
"}",
"}",
"}"
] | Registra y encola todos los metabox para los metodos definidos | [
"Registra",
"y",
"encola",
"todos",
"los",
"metabox",
"para",
"los",
"metodos",
"definidos"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L175-L183 |
9,502 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.add_actions | protected function add_actions() {
do_action('app_before_actions');
$actionMethos = $this->getMethods("/^action_/");
sort($actionMethos); //Se ordenas las acciones por prioridad
$actions = array_map(array($this, 'describeActions'), $actionMethos);
if ($actions) {
foreach ($actions as $action) {
add_action($action->tag, array($this, $action->method), $act->priority, 1);
}
do_action('app_after_textdomain');
}
} | php | protected function add_actions() {
do_action('app_before_actions');
$actionMethos = $this->getMethods("/^action_/");
sort($actionMethos); //Se ordenas las acciones por prioridad
$actions = array_map(array($this, 'describeActions'), $actionMethos);
if ($actions) {
foreach ($actions as $action) {
add_action($action->tag, array($this, $action->method), $act->priority, 1);
}
do_action('app_after_textdomain');
}
} | [
"protected",
"function",
"add_actions",
"(",
")",
"{",
"do_action",
"(",
"'app_before_actions'",
")",
";",
"$",
"actionMethos",
"=",
"$",
"this",
"->",
"getMethods",
"(",
"\"/^action_/\"",
")",
";",
"sort",
"(",
"$",
"actionMethos",
")",
";",
"//Se ordenas las acciones por prioridad",
"$",
"actions",
"=",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'describeActions'",
")",
",",
"$",
"actionMethos",
")",
";",
"if",
"(",
"$",
"actions",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"add_action",
"(",
"$",
"action",
"->",
"tag",
",",
"array",
"(",
"$",
"this",
",",
"$",
"action",
"->",
"method",
")",
",",
"$",
"act",
"->",
"priority",
",",
"1",
")",
";",
"}",
"do_action",
"(",
"'app_after_textdomain'",
")",
";",
"}",
"}"
] | Registra las acciones para los metodos definidos en el plugin | [
"Registra",
"las",
"acciones",
"para",
"los",
"metodos",
"definidos",
"en",
"el",
"plugin"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L188-L199 |
9,503 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.getMethods | private function getMethods($pattern = "/^action_/") {
$methos = get_class_methods($this->class);
$actions = array();
foreach ($methos as $methodName) {
if (preg_match($pattern, $methodName)) {
array_push($actions, $methodName);
}
}
return $actions;
} | php | private function getMethods($pattern = "/^action_/") {
$methos = get_class_methods($this->class);
$actions = array();
foreach ($methos as $methodName) {
if (preg_match($pattern, $methodName)) {
array_push($actions, $methodName);
}
}
return $actions;
} | [
"private",
"function",
"getMethods",
"(",
"$",
"pattern",
"=",
"\"/^action_/\"",
")",
"{",
"$",
"methos",
"=",
"get_class_methods",
"(",
"$",
"this",
"->",
"class",
")",
";",
"$",
"actions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"methos",
"as",
"$",
"methodName",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"methodName",
")",
")",
"{",
"array_push",
"(",
"$",
"actions",
",",
"$",
"methodName",
")",
";",
"}",
"}",
"return",
"$",
"actions",
";",
"}"
] | Obtiene un array con las acciones que se encuentras definidas en la clase del plugin
@return array Array de string con los nombres de los metodos definidos en la clase del plugin | [
"Obtiene",
"un",
"array",
"con",
"las",
"acciones",
"que",
"se",
"encuentras",
"definidas",
"en",
"la",
"clase",
"del",
"plugin"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L205-L215 |
9,504 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.describeActions | private function describeActions($action = "") {
if (!empty($action)) {
$parts = explode('_', $action);
unset($parts[0]);
$parts = array_values($parts);
$act = new \stdClass();
$act->method = $action;
switch (count($parts)) {
case 1:
case 2:
case 3:
$act->name = $parts[0];
case 2:
case 3:
$act->tag = $parts[1];
case 3:
$act->priority = intval($parts[2]);
break;
}
if (count($parts) == 1) {
$act->tag = 'initi';
$act->priority = 10;
}
return $act;
}
return null;
} | php | private function describeActions($action = "") {
if (!empty($action)) {
$parts = explode('_', $action);
unset($parts[0]);
$parts = array_values($parts);
$act = new \stdClass();
$act->method = $action;
switch (count($parts)) {
case 1:
case 2:
case 3:
$act->name = $parts[0];
case 2:
case 3:
$act->tag = $parts[1];
case 3:
$act->priority = intval($parts[2]);
break;
}
if (count($parts) == 1) {
$act->tag = 'initi';
$act->priority = 10;
}
return $act;
}
return null;
} | [
"private",
"function",
"describeActions",
"(",
"$",
"action",
"=",
"\"\"",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"action",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'_'",
",",
"$",
"action",
")",
";",
"unset",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"$",
"parts",
"=",
"array_values",
"(",
"$",
"parts",
")",
";",
"$",
"act",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"act",
"->",
"method",
"=",
"$",
"action",
";",
"switch",
"(",
"count",
"(",
"$",
"parts",
")",
")",
"{",
"case",
"1",
":",
"case",
"2",
":",
"case",
"3",
":",
"$",
"act",
"->",
"name",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"case",
"2",
":",
"case",
"3",
":",
"$",
"act",
"->",
"tag",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"case",
"3",
":",
"$",
"act",
"->",
"priority",
"=",
"intval",
"(",
"$",
"parts",
"[",
"2",
"]",
")",
";",
"break",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"==",
"1",
")",
"{",
"$",
"act",
"->",
"tag",
"=",
"'initi'",
";",
"$",
"act",
"->",
"priority",
"=",
"10",
";",
"}",
"return",
"$",
"act",
";",
"}",
"return",
"null",
";",
"}"
] | Descrive una accion para el nombre del metodo de la accion resibido
@param string $action Nombre o metodo de la accion
@return stdClass
{
"method": "action_postypes_init_10"
"name": "postypes"
"tag": "init"
"priority": 10
} | [
"Descrive",
"una",
"accion",
"para",
"el",
"nombre",
"del",
"metodo",
"de",
"la",
"accion",
"resibido"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L228-L260 |
9,505 | faustbrian/binary | src/Buffer/Writer/Concerns/Hex.php | Hex.writeHex | public function writeHex(string $value): self
{
$this->bytes .= Writer::high($value, strlen($value));
return $this;
} | php | public function writeHex(string $value): self
{
$this->bytes .= Writer::high($value, strlen($value));
return $this;
} | [
"public",
"function",
"writeHex",
"(",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"bytes",
".=",
"Writer",
"::",
"high",
"(",
"$",
"value",
",",
"strlen",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Write the given hex value as binary with a high nibble.
@param string $value
@return \BrianFaust\Binary\Buffer\Writer\Buffer | [
"Write",
"the",
"given",
"hex",
"value",
"as",
"binary",
"with",
"a",
"high",
"nibble",
"."
] | 7d845497460c2dabf7e369ec8e55baf989ef74cb | https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Writer/Concerns/Hex.php#L27-L32 |
9,506 | mszewcz/php-light-framework | src/Variables/Specific/AbstractReadOnly.php | AbstractReadOnly.getDefault | protected function getDefault(int $type = Variables::TYPE_STRING)
{
switch ($type) {
case Variables::TYPE_INT:
$value = (int)0;
break;
case Variables::TYPE_FLOAT:
$value = (float)0;
break;
case Variables::TYPE_STRING:
$value = '';
break;
case Variables::TYPE_ARRAY:
$value = [];
break;
case Variables::TYPE_JSON_DECODED:
$value = '';
break;
case Variables::TYPE_AUTO:
$value = '';
break;
default:
throw new DomainException('Invalid variable type specified');
break;
}
return $value;
} | php | protected function getDefault(int $type = Variables::TYPE_STRING)
{
switch ($type) {
case Variables::TYPE_INT:
$value = (int)0;
break;
case Variables::TYPE_FLOAT:
$value = (float)0;
break;
case Variables::TYPE_STRING:
$value = '';
break;
case Variables::TYPE_ARRAY:
$value = [];
break;
case Variables::TYPE_JSON_DECODED:
$value = '';
break;
case Variables::TYPE_AUTO:
$value = '';
break;
default:
throw new DomainException('Invalid variable type specified');
break;
}
return $value;
} | [
"protected",
"function",
"getDefault",
"(",
"int",
"$",
"type",
"=",
"Variables",
"::",
"TYPE_STRING",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"Variables",
"::",
"TYPE_INT",
":",
"$",
"value",
"=",
"(",
"int",
")",
"0",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_FLOAT",
":",
"$",
"value",
"=",
"(",
"float",
")",
"0",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_STRING",
":",
"$",
"value",
"=",
"''",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_ARRAY",
":",
"$",
"value",
"=",
"[",
"]",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_JSON_DECODED",
":",
"$",
"value",
"=",
"''",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_AUTO",
":",
"$",
"value",
"=",
"''",
";",
"break",
";",
"default",
":",
"throw",
"new",
"DomainException",
"(",
"'Invalid variable type specified'",
")",
";",
"break",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Returns default value for specified type
@param int $type
@return array|float|int|string | [
"Returns",
"default",
"value",
"for",
"specified",
"type"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/AbstractReadOnly.php#L30-L56 |
9,507 | mszewcz/php-light-framework | src/Variables/Specific/AbstractReadOnly.php | AbstractReadOnly.cast | protected function cast($value = null, int $type = Variables::TYPE_STRING)
{
if ($value === null) {
return $this->getDefault($type);
}
switch ($type) {
case Variables::TYPE_INT:
$value = @\intval($value);
break;
case Variables::TYPE_FLOAT:
$value = @\floatval($value);
break;
case Variables::TYPE_STRING:
$value = @\strval($value);
break;
case Variables::TYPE_ARRAY:
$value = (array)$value;
break;
case Variables::TYPE_JSON_DECODED:
$value = @\json_decode(@\strval($value), true, 512) ?: '';
break;
case Variables::TYPE_AUTO:
break;
default:
throw new DomainException('Invalid variable type specified');
break;
}
return $value;
} | php | protected function cast($value = null, int $type = Variables::TYPE_STRING)
{
if ($value === null) {
return $this->getDefault($type);
}
switch ($type) {
case Variables::TYPE_INT:
$value = @\intval($value);
break;
case Variables::TYPE_FLOAT:
$value = @\floatval($value);
break;
case Variables::TYPE_STRING:
$value = @\strval($value);
break;
case Variables::TYPE_ARRAY:
$value = (array)$value;
break;
case Variables::TYPE_JSON_DECODED:
$value = @\json_decode(@\strval($value), true, 512) ?: '';
break;
case Variables::TYPE_AUTO:
break;
default:
throw new DomainException('Invalid variable type specified');
break;
}
return $value;
} | [
"protected",
"function",
"cast",
"(",
"$",
"value",
"=",
"null",
",",
"int",
"$",
"type",
"=",
"Variables",
"::",
"TYPE_STRING",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getDefault",
"(",
"$",
"type",
")",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"Variables",
"::",
"TYPE_INT",
":",
"$",
"value",
"=",
"@",
"\\",
"intval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_FLOAT",
":",
"$",
"value",
"=",
"@",
"\\",
"floatval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_STRING",
":",
"$",
"value",
"=",
"@",
"\\",
"strval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_ARRAY",
":",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_JSON_DECODED",
":",
"$",
"value",
"=",
"@",
"\\",
"json_decode",
"(",
"@",
"\\",
"strval",
"(",
"$",
"value",
")",
",",
"true",
",",
"512",
")",
"?",
":",
"''",
";",
"break",
";",
"case",
"Variables",
"::",
"TYPE_AUTO",
":",
"break",
";",
"default",
":",
"throw",
"new",
"DomainException",
"(",
"'Invalid variable type specified'",
")",
";",
"break",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Method casting value to specified type. If provided value is null, then default value for specified type will
be returned.
@param null $value
@param int $type
@return array|float|int|mixed|null|string | [
"Method",
"casting",
"value",
"to",
"specified",
"type",
".",
"If",
"provided",
"value",
"is",
"null",
"then",
"default",
"value",
"for",
"specified",
"type",
"will",
"be",
"returned",
"."
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Variables/Specific/AbstractReadOnly.php#L66-L94 |
9,508 | Dhii/tokenizer-abstract | src/LineNumberAwareTrait.php | LineNumberAwareTrait._setLineNumber | protected function _setLineNumber($lineNumber)
{
if ($lineNumber !== null) {
try {
$lineNumber = $this->_normalizeInt($lineNumber);
} catch (RootException $e) {
throw $this->_createInvalidArgumentException($this->__('Invalid line number'), null, $e, $lineNumber);
}
if ($lineNumber < 1) {
throw $this->_createInvalidArgumentException($this->__('Line number must be positive'), null, null, $lineNumber);
}
}
$this->lineNumber = $lineNumber;
} | php | protected function _setLineNumber($lineNumber)
{
if ($lineNumber !== null) {
try {
$lineNumber = $this->_normalizeInt($lineNumber);
} catch (RootException $e) {
throw $this->_createInvalidArgumentException($this->__('Invalid line number'), null, $e, $lineNumber);
}
if ($lineNumber < 1) {
throw $this->_createInvalidArgumentException($this->__('Line number must be positive'), null, null, $lineNumber);
}
}
$this->lineNumber = $lineNumber;
} | [
"protected",
"function",
"_setLineNumber",
"(",
"$",
"lineNumber",
")",
"{",
"if",
"(",
"$",
"lineNumber",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"lineNumber",
"=",
"$",
"this",
"->",
"_normalizeInt",
"(",
"$",
"lineNumber",
")",
";",
"}",
"catch",
"(",
"RootException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid line number'",
")",
",",
"null",
",",
"$",
"e",
",",
"$",
"lineNumber",
")",
";",
"}",
"if",
"(",
"$",
"lineNumber",
"<",
"1",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Line number must be positive'",
")",
",",
"null",
",",
"null",
",",
"$",
"lineNumber",
")",
";",
"}",
"}",
"$",
"this",
"->",
"lineNumber",
"=",
"$",
"lineNumber",
";",
"}"
] | Assigns a line number to this instance.
@since [*next-version*]
@param int|string|Stringable|float|null $lineNumber The line number.
Must be a whole positive number. | [
"Assigns",
"a",
"line",
"number",
"to",
"this",
"instance",
"."
] | 45588113b1fca6daf62b776aade8627d08970565 | https://github.com/Dhii/tokenizer-abstract/blob/45588113b1fca6daf62b776aade8627d08970565/src/LineNumberAwareTrait.php#L42-L57 |
9,509 | mtils/collection | src/Collection/NestedArray.php | NestedArray.get | public static function get(array $nested, $key, $delimiter='.')
{
if (is_null($key)) return $nested;
if (isset($nested[$key])) return $nested[$key];
foreach (explode($delimiter, $key) as $segment) {
if ( ! is_array($nested) || ! array_key_exists($segment, $nested))
{
return;
}
$nested = $nested[$segment];
}
return $nested;
} | php | public static function get(array $nested, $key, $delimiter='.')
{
if (is_null($key)) return $nested;
if (isset($nested[$key])) return $nested[$key];
foreach (explode($delimiter, $key) as $segment) {
if ( ! is_array($nested) || ! array_key_exists($segment, $nested))
{
return;
}
$nested = $nested[$segment];
}
return $nested;
} | [
"public",
"static",
"function",
"get",
"(",
"array",
"$",
"nested",
",",
"$",
"key",
",",
"$",
"delimiter",
"=",
"'.'",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"return",
"$",
"nested",
";",
"if",
"(",
"isset",
"(",
"$",
"nested",
"[",
"$",
"key",
"]",
")",
")",
"return",
"$",
"nested",
"[",
"$",
"key",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"key",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"nested",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"nested",
")",
")",
"{",
"return",
";",
"}",
"$",
"nested",
"=",
"$",
"nested",
"[",
"$",
"segment",
"]",
";",
"}",
"return",
"$",
"nested",
";",
"}"
] | Get a key from a nested array. Query a deeply nested array with
property.child.name
@param array $nested
@param string $key
@param string $delimiter | [
"Get",
"a",
"key",
"from",
"a",
"nested",
"array",
".",
"Query",
"a",
"deeply",
"nested",
"array",
"with",
"property",
".",
"child",
".",
"name"
] | 186f8a6cc68fef1babc486438aa6d6c643186cc8 | https://github.com/mtils/collection/blob/186f8a6cc68fef1babc486438aa6d6c643186cc8/src/Collection/NestedArray.php#L370-L387 |
9,510 | easy-system/es-http | src/ServerRequest.php | ServerRequest.getServerParam | public function getServerParam($name, $default = null)
{
if (isset($this->serverParams[$name])) {
return $this->serverParams[$name];
}
return $default;
} | php | public function getServerParam($name, $default = null)
{
if (isset($this->serverParams[$name])) {
return $this->serverParams[$name];
}
return $default;
} | [
"public",
"function",
"getServerParam",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serverParams",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"serverParams",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Gets the server parameter.
@param string $name The name of parameter
@param mixed $default The default value
@return mixed Returns the parameter value if parameter exists,
$default otherwise | [
"Gets",
"the",
"server",
"parameter",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/ServerRequest.php#L139-L146 |
9,511 | easy-system/es-http | src/ServerRequest.php | ServerRequest.getCookieParam | public function getCookieParam($name, $default = null)
{
if (isset($this->cookieParams[$name])) {
return $this->cookieParams[$name];
}
return $default;
} | php | public function getCookieParam($name, $default = null)
{
if (isset($this->cookieParams[$name])) {
return $this->cookieParams[$name];
}
return $default;
} | [
"public",
"function",
"getCookieParam",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cookieParams",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cookieParams",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Gets the cookie parameter.
@param string $name The name of parameter
@param mixed $default The default value
@return mixed Returns the parameter value if parameter exists,
$default otherwise | [
"Gets",
"the",
"cookie",
"parameter",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/ServerRequest.php#L172-L179 |
9,512 | easy-system/es-http | src/ServerRequest.php | ServerRequest.getQueryParam | public function getQueryParam($name, $default = null)
{
if (isset($this->queryParams[$name])) {
return $this->queryParams[$name];
}
return $default;
} | php | public function getQueryParam($name, $default = null)
{
if (isset($this->queryParams[$name])) {
return $this->queryParams[$name];
}
return $default;
} | [
"public",
"function",
"getQueryParam",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queryParams",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"queryParams",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Gets the query parameter.
@param string $name The name of parameter
@param mixed $default The default value
@return mixed Returns the parameter value if parameter exists,
$default otherwise | [
"Gets",
"the",
"query",
"parameter",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/ServerRequest.php#L220-L227 |
9,513 | easy-system/es-http | src/ServerRequest.php | ServerRequest.setParsedBody | protected function setParsedBody($data)
{
if (! is_null($data) && ! is_array($data) && ! is_object($data)) {
throw new InvalidArgumentException(sprintf(
'Invalid parsed body provided; must be an null, or array, '
. 'or object, "%s" provided.',
gettype($data)
));
}
$this->parsedBody = $data;
return $this;
} | php | protected function setParsedBody($data)
{
if (! is_null($data) && ! is_array($data) && ! is_object($data)) {
throw new InvalidArgumentException(sprintf(
'Invalid parsed body provided; must be an null, or array, '
. 'or object, "%s" provided.',
gettype($data)
));
}
$this->parsedBody = $data;
return $this;
} | [
"protected",
"function",
"setParsedBody",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"data",
")",
"&&",
"!",
"is_array",
"(",
"$",
"data",
")",
"&&",
"!",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid parsed body provided; must be an null, or array, '",
".",
"'or object, \"%s\" provided.'",
",",
"gettype",
"(",
"$",
"data",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"parsedBody",
"=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the parsed body.
@param null|array|object $data The parsed body
@throws \InvalidArgumentException If an unsupported argument type is
provided
@return self | [
"Sets",
"the",
"parsed",
"body",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/ServerRequest.php#L446-L458 |
9,514 | phpzm/kernel | src/Kernel/App.php | App.log | public static function log(...$data)
{
$filename = static::options('root') . '/storage/log/access';
if (is_array($data) && count($data) === 1) {
$data = $data[0];
}
return File::write($filename, $data, true);
} | php | public static function log(...$data)
{
$filename = static::options('root') . '/storage/log/access';
if (is_array($data) && count($data) === 1) {
$data = $data[0];
}
return File::write($filename, $data, true);
} | [
"public",
"static",
"function",
"log",
"(",
"...",
"$",
"data",
")",
"{",
"$",
"filename",
"=",
"static",
"::",
"options",
"(",
"'root'",
")",
".",
"'/storage/log/access'",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"count",
"(",
"$",
"data",
")",
"===",
"1",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"}",
"return",
"File",
"::",
"write",
"(",
"$",
"filename",
",",
"$",
"data",
",",
"true",
")",
";",
"}"
] | Create a file with data to be analysed
@param array ...$data
@return int | [
"Create",
"a",
"file",
"with",
"data",
"to",
"be",
"analysed"
] | e75da67a7815ddca56468dff75e50b614f823fad | https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/App.php#L123-L130 |
9,515 | phpzm/kernel | src/Kernel/App.php | App.pipe | public function pipe(Middleware $middleware, string $alias = ''): App
{
$alias = $alias ? $alias : $middleware->alias();
if (isset($this->pipe[$alias])) {
throw new SimplesAlreadyRegisteredError("The middleware `{$alias}` is already registered");
}
$this->pipe[$alias] = $middleware;
return $this;
} | php | public function pipe(Middleware $middleware, string $alias = ''): App
{
$alias = $alias ? $alias : $middleware->alias();
if (isset($this->pipe[$alias])) {
throw new SimplesAlreadyRegisteredError("The middleware `{$alias}` is already registered");
}
$this->pipe[$alias] = $middleware;
return $this;
} | [
"public",
"function",
"pipe",
"(",
"Middleware",
"$",
"middleware",
",",
"string",
"$",
"alias",
"=",
"''",
")",
":",
"App",
"{",
"$",
"alias",
"=",
"$",
"alias",
"?",
"$",
"alias",
":",
"$",
"middleware",
"->",
"alias",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"pipe",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"SimplesAlreadyRegisteredError",
"(",
"\"The middleware `{$alias}` is already registered\"",
")",
";",
"}",
"$",
"this",
"->",
"pipe",
"[",
"$",
"alias",
"]",
"=",
"$",
"middleware",
";",
"return",
"$",
"this",
";",
"}"
] | Add middleware's to pipe
@param Middleware $middleware
@param string $alias
@return App
@throws SimplesAlreadyRegisteredError | [
"Add",
"middleware",
"s",
"to",
"pipe"
] | e75da67a7815ddca56468dff75e50b614f823fad | https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/App.php#L140-L149 |
9,516 | phpzm/kernel | src/Kernel/App.php | App.pipes | public function pipes(array $middlewares): App
{
foreach ($middlewares as $key => $middleware) {
if (is_numeric($key)) {
$this->pipe($middleware);
continue;
}
$this->pipe($middleware, $key);
}
return $this;
} | php | public function pipes(array $middlewares): App
{
foreach ($middlewares as $key => $middleware) {
if (is_numeric($key)) {
$this->pipe($middleware);
continue;
}
$this->pipe($middleware, $key);
}
return $this;
} | [
"public",
"function",
"pipes",
"(",
"array",
"$",
"middlewares",
")",
":",
"App",
"{",
"foreach",
"(",
"$",
"middlewares",
"as",
"$",
"key",
"=>",
"$",
"middleware",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"pipe",
"(",
"$",
"middleware",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"pipe",
"(",
"$",
"middleware",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a list of middlewares to pipe
@param array $middlewares
@return $this | [
"Add",
"a",
"list",
"of",
"middlewares",
"to",
"pipe"
] | e75da67a7815ddca56468dff75e50b614f823fad | https://github.com/phpzm/kernel/blob/e75da67a7815ddca56468dff75e50b614f823fad/src/Kernel/App.php#L157-L167 |
9,517 | easy-system/es-http | src/UploadedFile.php | UploadedFile.setError | protected function setError($error)
{
if (! is_int($error) || 0 > $error || 8 < $error) {
throw new InvalidArgumentException(
'Invalid error status provided; must be an UPLOAD_ERR_* constant.'
);
}
$this->error = $error;
} | php | protected function setError($error)
{
if (! is_int($error) || 0 > $error || 8 < $error) {
throw new InvalidArgumentException(
'Invalid error status provided; must be an UPLOAD_ERR_* constant.'
);
}
$this->error = $error;
} | [
"protected",
"function",
"setError",
"(",
"$",
"error",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"error",
")",
"||",
"0",
">",
"$",
"error",
"||",
"8",
"<",
"$",
"error",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid error status provided; must be an UPLOAD_ERR_* constant.'",
")",
";",
"}",
"$",
"this",
"->",
"error",
"=",
"$",
"error",
";",
"}"
] | Sets the error.
@param int $error One of PHP's UPLOAD_ERR_XXX constants
@throws \InvalidArgumentException If the received error is not one of
PHP's UPLOAD_ERR_XXX constants | [
"Sets",
"the",
"error",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/UploadedFile.php#L363-L371 |
9,518 | 3tnet/pictureManager | src/PictureUrlManager.php | PictureUrlManager.getConfig | protected function getConfig($name)
{
$config = $this->app['config']['picture'];
$driverConfig = isset($config['disks'][$name]) ? $config['disks'][$name] : [];
if (!isset($driverConfig['sizeList'])) {
$driverConfig['sizeList'] = $config['sizeList'];
}
if (!isset($driverConfig['quality'])) {
$driverConfig['quality'] = $config['quality'];
}
return $driverConfig;
} | php | protected function getConfig($name)
{
$config = $this->app['config']['picture'];
$driverConfig = isset($config['disks'][$name]) ? $config['disks'][$name] : [];
if (!isset($driverConfig['sizeList'])) {
$driverConfig['sizeList'] = $config['sizeList'];
}
if (!isset($driverConfig['quality'])) {
$driverConfig['quality'] = $config['quality'];
}
return $driverConfig;
} | [
"protected",
"function",
"getConfig",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"[",
"'picture'",
"]",
";",
"$",
"driverConfig",
"=",
"isset",
"(",
"$",
"config",
"[",
"'disks'",
"]",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"config",
"[",
"'disks'",
"]",
"[",
"$",
"name",
"]",
":",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"driverConfig",
"[",
"'sizeList'",
"]",
")",
")",
"{",
"$",
"driverConfig",
"[",
"'sizeList'",
"]",
"=",
"$",
"config",
"[",
"'sizeList'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"driverConfig",
"[",
"'quality'",
"]",
")",
")",
"{",
"$",
"driverConfig",
"[",
"'quality'",
"]",
"=",
"$",
"config",
"[",
"'quality'",
"]",
";",
"}",
"return",
"$",
"driverConfig",
";",
"}"
] | Get configuration.
@param string $name
@return array | [
"Get",
"configuration",
"."
] | c26f2e4f83e1fb9bd7dd700032be6ca8dc65a923 | https://github.com/3tnet/pictureManager/blob/c26f2e4f83e1fb9bd7dd700032be6ca8dc65a923/src/PictureUrlManager.php#L83-L94 |
9,519 | adrenth/tvrage | lib/Adrenth/Tvrage/Response/Handler/ResponseHandlerFactory.php | ResponseHandlerFactory.create | public static function create($handler, $xml)
{
switch ($handler) {
case 'Search':
return new SearchResponseHandler($xml);
case 'FullSearch':
return new FullSearchResponseHandler($xml);
case 'ShowInfo':
return new ShowInfoResponseHandler($xml);
case 'EpisodeList':
return new EpisodeListResponseHandler($xml);
case 'EpisodeInfo':
return new EpisodeInfoResponseHandler($xml);
default:
throw new InvalidHandlerException('Unknown handler ' . $handler);
}
} | php | public static function create($handler, $xml)
{
switch ($handler) {
case 'Search':
return new SearchResponseHandler($xml);
case 'FullSearch':
return new FullSearchResponseHandler($xml);
case 'ShowInfo':
return new ShowInfoResponseHandler($xml);
case 'EpisodeList':
return new EpisodeListResponseHandler($xml);
case 'EpisodeInfo':
return new EpisodeInfoResponseHandler($xml);
default:
throw new InvalidHandlerException('Unknown handler ' . $handler);
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"handler",
",",
"$",
"xml",
")",
"{",
"switch",
"(",
"$",
"handler",
")",
"{",
"case",
"'Search'",
":",
"return",
"new",
"SearchResponseHandler",
"(",
"$",
"xml",
")",
";",
"case",
"'FullSearch'",
":",
"return",
"new",
"FullSearchResponseHandler",
"(",
"$",
"xml",
")",
";",
"case",
"'ShowInfo'",
":",
"return",
"new",
"ShowInfoResponseHandler",
"(",
"$",
"xml",
")",
";",
"case",
"'EpisodeList'",
":",
"return",
"new",
"EpisodeListResponseHandler",
"(",
"$",
"xml",
")",
";",
"case",
"'EpisodeInfo'",
":",
"return",
"new",
"EpisodeInfoResponseHandler",
"(",
"$",
"xml",
")",
";",
"default",
":",
"throw",
"new",
"InvalidHandlerException",
"(",
"'Unknown handler '",
".",
"$",
"handler",
")",
";",
"}",
"}"
] | Creates an instance of ResponseHandler
@param string $handler
@param string $xml
@return ResponseHandlerInterface
@throws InvalidHandlerException | [
"Creates",
"an",
"instance",
"of",
"ResponseHandler"
] | 291043219e95689f609323f476a25293a53453b0 | https://github.com/adrenth/tvrage/blob/291043219e95689f609323f476a25293a53453b0/lib/Adrenth/Tvrage/Response/Handler/ResponseHandlerFactory.php#L39-L55 |
9,520 | mooti/framework | src/Application/AbstractApplication.php | AbstractApplication.registerModules | public function registerModules($modules = [])
{
for($i = 0; $i < sizeof($modules); $i++) {
$moduleName = $modules[$i];
$module = $this->createNew($moduleName);
if (!$module instanceof ModuleInterface) {
throw new InvalidModuleException('The module at position '.($i+1).' is invalid');
}
$serviceProvider = $module->getServiceProvider();
$this->getContainer()->registerServices($serviceProvider);
}
} | php | public function registerModules($modules = [])
{
for($i = 0; $i < sizeof($modules); $i++) {
$moduleName = $modules[$i];
$module = $this->createNew($moduleName);
if (!$module instanceof ModuleInterface) {
throw new InvalidModuleException('The module at position '.($i+1).' is invalid');
}
$serviceProvider = $module->getServiceProvider();
$this->getContainer()->registerServices($serviceProvider);
}
} | [
"public",
"function",
"registerModules",
"(",
"$",
"modules",
"=",
"[",
"]",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"modules",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"moduleName",
"=",
"$",
"modules",
"[",
"$",
"i",
"]",
";",
"$",
"module",
"=",
"$",
"this",
"->",
"createNew",
"(",
"$",
"moduleName",
")",
";",
"if",
"(",
"!",
"$",
"module",
"instanceof",
"ModuleInterface",
")",
"{",
"throw",
"new",
"InvalidModuleException",
"(",
"'The module at position '",
".",
"(",
"$",
"i",
"+",
"1",
")",
".",
"' is invalid'",
")",
";",
"}",
"$",
"serviceProvider",
"=",
"$",
"module",
"->",
"getServiceProvider",
"(",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"registerServices",
"(",
"$",
"serviceProvider",
")",
";",
"}",
"}"
] | Register some modules | [
"Register",
"some",
"modules"
] | 078da6699c5c6c7ac4e5a3d36751d645ad8aa93e | https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Application/AbstractApplication.php#L78-L92 |
9,521 | bishopb/vanilla | applications/dashboard/controllers/class.sessioncontroller.php | SessionController.Stash | public function Stash() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
$Name = TrueStripSlashes(GetValue('Name', $_POST, ''));
$Value = TrueStripSlashes(GetValue('Value', $_POST, ''));
$Response = Gdn::Session()->Stash($Name, $Value);
if ($Name != '' && $Value == '')
$this->SetJson('Unstash', $Response);
$this->Render();
} | php | public function Stash() {
$this->DeliveryType(DELIVERY_TYPE_BOOL);
$this->DeliveryMethod(DELIVERY_METHOD_JSON);
$Name = TrueStripSlashes(GetValue('Name', $_POST, ''));
$Value = TrueStripSlashes(GetValue('Value', $_POST, ''));
$Response = Gdn::Session()->Stash($Name, $Value);
if ($Name != '' && $Value == '')
$this->SetJson('Unstash', $Response);
$this->Render();
} | [
"public",
"function",
"Stash",
"(",
")",
"{",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_BOOL",
")",
";",
"$",
"this",
"->",
"DeliveryMethod",
"(",
"DELIVERY_METHOD_JSON",
")",
";",
"$",
"Name",
"=",
"TrueStripSlashes",
"(",
"GetValue",
"(",
"'Name'",
",",
"$",
"_POST",
",",
"''",
")",
")",
";",
"$",
"Value",
"=",
"TrueStripSlashes",
"(",
"GetValue",
"(",
"'Value'",
",",
"$",
"_POST",
",",
"''",
")",
")",
";",
"$",
"Response",
"=",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"Stash",
"(",
"$",
"Name",
",",
"$",
"Value",
")",
";",
"if",
"(",
"$",
"Name",
"!=",
"''",
"&&",
"$",
"Value",
"==",
"''",
")",
"$",
"this",
"->",
"SetJson",
"(",
"'Unstash'",
",",
"$",
"Response",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}"
] | Stash a value in the user's session, or unstash it if no value was provided to stash.
Looks for Name and Value POST/GET variables to pass along to Gdn_Session. | [
"Stash",
"a",
"value",
"in",
"the",
"user",
"s",
"session",
"or",
"unstash",
"it",
"if",
"no",
"value",
"was",
"provided",
"to",
"stash",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.sessioncontroller.php#L28-L38 |
9,522 | ExSituMarketing/EXS-LanderTrackingHouseBundle | Service/TrackingParameterPersister.php | TrackingParameterPersister.persist | public function persist(Response $response)
{
$trackingParameters = $this->trackingParameters->all();
foreach ($trackingParameters as $trackingParameter => $value) {
if (
(null !== $value)
&& (true === in_array($trackingParameter, $this->cookiesToSave))
) {
$response->headers->setCookie(new Cookie(
$trackingParameter,
$value,
new \DateTime('+1 year'),
'/',
null,
false,
false
));
}
}
return $response;
} | php | public function persist(Response $response)
{
$trackingParameters = $this->trackingParameters->all();
foreach ($trackingParameters as $trackingParameter => $value) {
if (
(null !== $value)
&& (true === in_array($trackingParameter, $this->cookiesToSave))
) {
$response->headers->setCookie(new Cookie(
$trackingParameter,
$value,
new \DateTime('+1 year'),
'/',
null,
false,
false
));
}
}
return $response;
} | [
"public",
"function",
"persist",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"trackingParameters",
"=",
"$",
"this",
"->",
"trackingParameters",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"trackingParameters",
"as",
"$",
"trackingParameter",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"(",
"null",
"!==",
"$",
"value",
")",
"&&",
"(",
"true",
"===",
"in_array",
"(",
"$",
"trackingParameter",
",",
"$",
"this",
"->",
"cookiesToSave",
")",
")",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"setCookie",
"(",
"new",
"Cookie",
"(",
"$",
"trackingParameter",
",",
"$",
"value",
",",
"new",
"\\",
"DateTime",
"(",
"'+1 year'",
")",
",",
"'/'",
",",
"null",
",",
"false",
",",
"false",
")",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | Persists tracking parameters in cookies.
@param Response $response
@return Response | [
"Persists",
"tracking",
"parameters",
"in",
"cookies",
"."
] | 404ce51ec1ee0bf5e669eb1f4cd04746e244f61a | https://github.com/ExSituMarketing/EXS-LanderTrackingHouseBundle/blob/404ce51ec1ee0bf5e669eb1f4cd04746e244f61a/Service/TrackingParameterPersister.php#L96-L118 |
9,523 | maestrano/maestrano-php | lib/Sso/Service.php | Maestrano_Sso_Service.getInitUrl | public function getInitUrl() {
$host = Maestrano::with($this->_preset)->param('app.host');
$path = $this->getInitPath();
return "${host}${path}";
} | php | public function getInitUrl() {
$host = Maestrano::with($this->_preset)->param('app.host');
$path = $this->getInitPath();
return "${host}${path}";
} | [
"public",
"function",
"getInitUrl",
"(",
")",
"{",
"$",
"host",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'app.host'",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getInitPath",
"(",
")",
";",
"return",
"\"${host}${path}\"",
";",
"}"
] | Return where the app should redirect internally to initiate SSO request
@return string Init Url | [
"Return",
"where",
"the",
"app",
"should",
"redirect",
"internally",
"to",
"initiate",
"SSO",
"request"
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Sso/Service.php#L48-L52 |
9,524 | maestrano/maestrano-php | lib/Sso/Service.php | Maestrano_Sso_Service.getConsumeUrl | public function getConsumeUrl() {
$host = Maestrano::with($this->_preset)->param('app.host');
$path = $this->getConsumePath();
return "${host}${path}";
} | php | public function getConsumeUrl() {
$host = Maestrano::with($this->_preset)->param('app.host');
$path = $this->getConsumePath();
return "${host}${path}";
} | [
"public",
"function",
"getConsumeUrl",
"(",
")",
"{",
"$",
"host",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'app.host'",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getConsumePath",
"(",
")",
";",
"return",
"\"${host}${path}\"",
";",
"}"
] | The URL where the SSO response will be posted and consumed.
@return string | [
"The",
"URL",
"where",
"the",
"SSO",
"response",
"will",
"be",
"posted",
"and",
"consumed",
"."
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Sso/Service.php#L68-L72 |
9,525 | maestrano/maestrano-php | lib/Sso/Service.php | Maestrano_Sso_Service.getIdpUrl | public function getIdpUrl() {
$host = Maestrano::with($this->_preset)->param('sso.idp');
$api_base = Maestrano::with($this->_preset)->param('api.base');
$endpoint = 'auth/saml';
return "${host}${api_base}${endpoint}";
} | php | public function getIdpUrl() {
$host = Maestrano::with($this->_preset)->param('sso.idp');
$api_base = Maestrano::with($this->_preset)->param('api.base');
$endpoint = 'auth/saml';
return "${host}${api_base}${endpoint}";
} | [
"public",
"function",
"getIdpUrl",
"(",
")",
"{",
"$",
"host",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'sso.idp'",
")",
";",
"$",
"api_base",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'api.base'",
")",
";",
"$",
"endpoint",
"=",
"'auth/saml'",
";",
"return",
"\"${host}${api_base}${endpoint}\"",
";",
"}"
] | Maestrano Single Sign-On processing URL
@return string url | [
"Maestrano",
"Single",
"Sign",
"-",
"On",
"processing",
"URL"
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Sso/Service.php#L101-L106 |
9,526 | maestrano/maestrano-php | lib/Sso/Service.php | Maestrano_Sso_Service.getSessionCheckUrl | public function getSessionCheckUrl($user_id, $sso_session) {
$host = Maestrano::with($this->_preset)->param('sso.idp');
$api_base = Maestrano::with($this->_preset)->param('api.base');
$endpoint = 'auth/saml';
return "${host}${api_base}${endpoint}/${user_id}?session=${sso_session}";
} | php | public function getSessionCheckUrl($user_id, $sso_session) {
$host = Maestrano::with($this->_preset)->param('sso.idp');
$api_base = Maestrano::with($this->_preset)->param('api.base');
$endpoint = 'auth/saml';
return "${host}${api_base}${endpoint}/${user_id}?session=${sso_session}";
} | [
"public",
"function",
"getSessionCheckUrl",
"(",
"$",
"user_id",
",",
"$",
"sso_session",
")",
"{",
"$",
"host",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'sso.idp'",
")",
";",
"$",
"api_base",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'api.base'",
")",
";",
"$",
"endpoint",
"=",
"'auth/saml'",
";",
"return",
"\"${host}${api_base}${endpoint}/${user_id}?session=${sso_session}\"",
";",
"}"
] | The Maestrano endpoint in charge of providing session information
@param $user_id string Current user id
@param $sso_session string SSO session
@return string url | [
"The",
"Maestrano",
"endpoint",
"in",
"charge",
"of",
"providing",
"session",
"information"
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Sso/Service.php#L115-L121 |
9,527 | maestrano/maestrano-php | lib/Sso/Service.php | Maestrano_Sso_Service.getSamlSettings | public function getSamlSettings() {
$settings = new Maestrano_Saml_Settings();
// Configure SAML
$settings->idpPublicCertificate = Maestrano::with($this->_preset)->param('sso.x509_certificate');
$settings->spIssuer = Maestrano::with($this->_preset)->param('api.id');
// TODO: default value?
// $settings->requestedNameIdFormat = Maestrano::with($this->_preset)->param('sso.name_id_format');
$settings->idpSingleSignOnUrl = $this->getIdpUrl();
$settings->spReturnUrl = $this->getConsumeUrl();
return $settings;
} | php | public function getSamlSettings() {
$settings = new Maestrano_Saml_Settings();
// Configure SAML
$settings->idpPublicCertificate = Maestrano::with($this->_preset)->param('sso.x509_certificate');
$settings->spIssuer = Maestrano::with($this->_preset)->param('api.id');
// TODO: default value?
// $settings->requestedNameIdFormat = Maestrano::with($this->_preset)->param('sso.name_id_format');
$settings->idpSingleSignOnUrl = $this->getIdpUrl();
$settings->spReturnUrl = $this->getConsumeUrl();
return $settings;
} | [
"public",
"function",
"getSamlSettings",
"(",
")",
"{",
"$",
"settings",
"=",
"new",
"Maestrano_Saml_Settings",
"(",
")",
";",
"// Configure SAML",
"$",
"settings",
"->",
"idpPublicCertificate",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'sso.x509_certificate'",
")",
";",
"$",
"settings",
"->",
"spIssuer",
"=",
"Maestrano",
"::",
"with",
"(",
"$",
"this",
"->",
"_preset",
")",
"->",
"param",
"(",
"'api.id'",
")",
";",
"// TODO: default value?",
"// $settings->requestedNameIdFormat = Maestrano::with($this->_preset)->param('sso.name_id_format');",
"$",
"settings",
"->",
"idpSingleSignOnUrl",
"=",
"$",
"this",
"->",
"getIdpUrl",
"(",
")",
";",
"$",
"settings",
"->",
"spReturnUrl",
"=",
"$",
"this",
"->",
"getConsumeUrl",
"(",
")",
";",
"return",
"$",
"settings",
";",
"}"
] | Return a settings object for php-saml
@return Maestrano_Saml_Settings SAML settings | [
"Return",
"a",
"settings",
"object",
"for",
"php",
"-",
"saml"
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Sso/Service.php#L128-L140 |
9,528 | phramework/query-log | src/QueryLogAdapter.php | QueryLogAdapter.log | protected function log(
$query,
$parameters,
$startTimestamp,
$exception = null
) {
$endTimestamp = time();
$duration = $endTimestamp - $startTimestamp;
$user = \Phramework\Phramework::getUser();
$user_id = ($user ? $user->id : null);
//Get request URI
list($URI) = \Phramework\URIStrategy\URITemplate::URI();
//Get request method
$method = \Phramework\Phramework::getMethod();
$debugBacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
//Function used by database adapter
$adapterFunction = $debugBacktrace[1]['function'];
//Remove current log function call
//Remove QueryLogAdapter execute* function call
array_splice($debugBacktrace, 0, 2);
foreach ($debugBacktrace as $k => &$v) {
if (isset($v['class'])) {
$class = $v['class'];
$function = $v['function'];
//Check if matrix has an entry for this class
if (property_exists($this->matrix, $class)) {
$matrixEntry = $this->matrix->{$class};
if (is_object($matrixEntry) || is_array($matrixEntry)) {
//If vector, then is vector contains values for multiple methods of this class
//Work with objects
if (is_array($matrixEntry)) {
$matrixEntry = (object)$matrixEntry;
}
if (property_exists($matrixEntry, $function)) {
//If non positive value, dont log current query
if (!$matrixEntry->{$function}) {
return self::LOG_INGORED;
}
}
} else {
//scalar, this entry has a single value for all methods of this class
//If non positive value, dont log current query
if (!$matrixEntry) {
return self::LOG_INGORED;
}
}
}
$v = $v['class'] . '::' . $v['function'];
} else {
$v = $v['function'];
}
}
$schemaTable = (
$this->schema //if schema is set
? '"' . $this->schema . '"."' . $this->table . '"'
: '"' . $this->table . '"'
);
//Insert query log record into table
return $this->logAdapter->execute(
'INSERT INTO ' . $schemaTable .
'(
"request_id",
"query",
"parameters",
"start_timestamp",
"duration",
"function",
"URI",
"method",
"additional_parameters",
"call_trace",
"user_id",
"exception"
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[
\Phramework\Phramework::getRequestUUID(),
$query,
(
$parameters
? json_encode($parameters)
: null
),
$startTimestamp,
$duration,
$adapterFunction,
$URI,
$method,
(
$this->additionalParameters
? json_encode($this->additionalParameters)
: null
),
json_encode($debugBacktrace),
$user_id,
(
$exception
? serialize(QueryLog::flattenExceptionBacktrace($exception))
: null
)
]
);
} | php | protected function log(
$query,
$parameters,
$startTimestamp,
$exception = null
) {
$endTimestamp = time();
$duration = $endTimestamp - $startTimestamp;
$user = \Phramework\Phramework::getUser();
$user_id = ($user ? $user->id : null);
//Get request URI
list($URI) = \Phramework\URIStrategy\URITemplate::URI();
//Get request method
$method = \Phramework\Phramework::getMethod();
$debugBacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
//Function used by database adapter
$adapterFunction = $debugBacktrace[1]['function'];
//Remove current log function call
//Remove QueryLogAdapter execute* function call
array_splice($debugBacktrace, 0, 2);
foreach ($debugBacktrace as $k => &$v) {
if (isset($v['class'])) {
$class = $v['class'];
$function = $v['function'];
//Check if matrix has an entry for this class
if (property_exists($this->matrix, $class)) {
$matrixEntry = $this->matrix->{$class};
if (is_object($matrixEntry) || is_array($matrixEntry)) {
//If vector, then is vector contains values for multiple methods of this class
//Work with objects
if (is_array($matrixEntry)) {
$matrixEntry = (object)$matrixEntry;
}
if (property_exists($matrixEntry, $function)) {
//If non positive value, dont log current query
if (!$matrixEntry->{$function}) {
return self::LOG_INGORED;
}
}
} else {
//scalar, this entry has a single value for all methods of this class
//If non positive value, dont log current query
if (!$matrixEntry) {
return self::LOG_INGORED;
}
}
}
$v = $v['class'] . '::' . $v['function'];
} else {
$v = $v['function'];
}
}
$schemaTable = (
$this->schema //if schema is set
? '"' . $this->schema . '"."' . $this->table . '"'
: '"' . $this->table . '"'
);
//Insert query log record into table
return $this->logAdapter->execute(
'INSERT INTO ' . $schemaTable .
'(
"request_id",
"query",
"parameters",
"start_timestamp",
"duration",
"function",
"URI",
"method",
"additional_parameters",
"call_trace",
"user_id",
"exception"
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[
\Phramework\Phramework::getRequestUUID(),
$query,
(
$parameters
? json_encode($parameters)
: null
),
$startTimestamp,
$duration,
$adapterFunction,
$URI,
$method,
(
$this->additionalParameters
? json_encode($this->additionalParameters)
: null
),
json_encode($debugBacktrace),
$user_id,
(
$exception
? serialize(QueryLog::flattenExceptionBacktrace($exception))
: null
)
]
);
} | [
"protected",
"function",
"log",
"(",
"$",
"query",
",",
"$",
"parameters",
",",
"$",
"startTimestamp",
",",
"$",
"exception",
"=",
"null",
")",
"{",
"$",
"endTimestamp",
"=",
"time",
"(",
")",
";",
"$",
"duration",
"=",
"$",
"endTimestamp",
"-",
"$",
"startTimestamp",
";",
"$",
"user",
"=",
"\\",
"Phramework",
"\\",
"Phramework",
"::",
"getUser",
"(",
")",
";",
"$",
"user_id",
"=",
"(",
"$",
"user",
"?",
"$",
"user",
"->",
"id",
":",
"null",
")",
";",
"//Get request URI",
"list",
"(",
"$",
"URI",
")",
"=",
"\\",
"Phramework",
"\\",
"URIStrategy",
"\\",
"URITemplate",
"::",
"URI",
"(",
")",
";",
"//Get request method",
"$",
"method",
"=",
"\\",
"Phramework",
"\\",
"Phramework",
"::",
"getMethod",
"(",
")",
";",
"$",
"debugBacktrace",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
")",
";",
"//Function used by database adapter",
"$",
"adapterFunction",
"=",
"$",
"debugBacktrace",
"[",
"1",
"]",
"[",
"'function'",
"]",
";",
"//Remove current log function call",
"//Remove QueryLogAdapter execute* function call",
"array_splice",
"(",
"$",
"debugBacktrace",
",",
"0",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"debugBacktrace",
"as",
"$",
"k",
"=>",
"&",
"$",
"v",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"v",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"v",
"[",
"'class'",
"]",
";",
"$",
"function",
"=",
"$",
"v",
"[",
"'function'",
"]",
";",
"//Check if matrix has an entry for this class",
"if",
"(",
"property_exists",
"(",
"$",
"this",
"->",
"matrix",
",",
"$",
"class",
")",
")",
"{",
"$",
"matrixEntry",
"=",
"$",
"this",
"->",
"matrix",
"->",
"{",
"$",
"class",
"}",
";",
"if",
"(",
"is_object",
"(",
"$",
"matrixEntry",
")",
"||",
"is_array",
"(",
"$",
"matrixEntry",
")",
")",
"{",
"//If vector, then is vector contains values for multiple methods of this class",
"//Work with objects",
"if",
"(",
"is_array",
"(",
"$",
"matrixEntry",
")",
")",
"{",
"$",
"matrixEntry",
"=",
"(",
"object",
")",
"$",
"matrixEntry",
";",
"}",
"if",
"(",
"property_exists",
"(",
"$",
"matrixEntry",
",",
"$",
"function",
")",
")",
"{",
"//If non positive value, dont log current query",
"if",
"(",
"!",
"$",
"matrixEntry",
"->",
"{",
"$",
"function",
"}",
")",
"{",
"return",
"self",
"::",
"LOG_INGORED",
";",
"}",
"}",
"}",
"else",
"{",
"//scalar, this entry has a single value for all methods of this class",
"//If non positive value, dont log current query",
"if",
"(",
"!",
"$",
"matrixEntry",
")",
"{",
"return",
"self",
"::",
"LOG_INGORED",
";",
"}",
"}",
"}",
"$",
"v",
"=",
"$",
"v",
"[",
"'class'",
"]",
".",
"'::'",
".",
"$",
"v",
"[",
"'function'",
"]",
";",
"}",
"else",
"{",
"$",
"v",
"=",
"$",
"v",
"[",
"'function'",
"]",
";",
"}",
"}",
"$",
"schemaTable",
"=",
"(",
"$",
"this",
"->",
"schema",
"//if schema is set",
"?",
"'\"'",
".",
"$",
"this",
"->",
"schema",
".",
"'\".\"'",
".",
"$",
"this",
"->",
"table",
".",
"'\"'",
":",
"'\"'",
".",
"$",
"this",
"->",
"table",
".",
"'\"'",
")",
";",
"//Insert query log record into table",
"return",
"$",
"this",
"->",
"logAdapter",
"->",
"execute",
"(",
"'INSERT INTO '",
".",
"$",
"schemaTable",
".",
"'(\n \"request_id\",\n \"query\",\n \"parameters\",\n \"start_timestamp\",\n \"duration\",\n \"function\",\n \"URI\",\n \"method\",\n \"additional_parameters\",\n \"call_trace\",\n \"user_id\",\n \"exception\"\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'",
",",
"[",
"\\",
"Phramework",
"\\",
"Phramework",
"::",
"getRequestUUID",
"(",
")",
",",
"$",
"query",
",",
"(",
"$",
"parameters",
"?",
"json_encode",
"(",
"$",
"parameters",
")",
":",
"null",
")",
",",
"$",
"startTimestamp",
",",
"$",
"duration",
",",
"$",
"adapterFunction",
",",
"$",
"URI",
",",
"$",
"method",
",",
"(",
"$",
"this",
"->",
"additionalParameters",
"?",
"json_encode",
"(",
"$",
"this",
"->",
"additionalParameters",
")",
":",
"null",
")",
",",
"json_encode",
"(",
"$",
"debugBacktrace",
")",
",",
"$",
"user_id",
",",
"(",
"$",
"exception",
"?",
"serialize",
"(",
"QueryLog",
"::",
"flattenExceptionBacktrace",
"(",
"$",
"exception",
")",
")",
":",
"null",
")",
"]",
")",
";",
"}"
] | Log query to database
@param string $query
@param array $parameters
Query parameters
@param integer $startTimestamp
Timestamp before query was executed
@param null|Exception $exception
*[Optional]* Exception object if any | [
"Log",
"query",
"to",
"database"
] | ca0dc58ba11f02e427cad66a2d1b558ac88f0b92 | https://github.com/phramework/query-log/blob/ca0dc58ba11f02e427cad66a2d1b558ac88f0b92/src/QueryLogAdapter.php#L120-L238 |
9,529 | seyon/Teamspeak3Framework | libraries/TeamSpeak3/Node/Host.php | TeamSpeak3_Node_Host.serverSelect | public function serverSelect($sid, $virtual = null)
{
if($this->whoami !== null && $this->serverSelectedId() == $sid) return;
$virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
$getargs = func_get_args();
$this->execute("use", array("sid" => $sid, $virtual ? "-virtual" : null));
if($sid != 0 && $this->predefined_query_name !== null)
{
$this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
}
$this->whoamiReset();
$this->setStorage("_server_use", array(__FUNCTION__, $getargs));
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
} | php | public function serverSelect($sid, $virtual = null)
{
if($this->whoami !== null && $this->serverSelectedId() == $sid) return;
$virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
$getargs = func_get_args();
$this->execute("use", array("sid" => $sid, $virtual ? "-virtual" : null));
if($sid != 0 && $this->predefined_query_name !== null)
{
$this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
}
$this->whoamiReset();
$this->setStorage("_server_use", array(__FUNCTION__, $getargs));
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
} | [
"public",
"function",
"serverSelect",
"(",
"$",
"sid",
",",
"$",
"virtual",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"whoami",
"!==",
"null",
"&&",
"$",
"this",
"->",
"serverSelectedId",
"(",
")",
"==",
"$",
"sid",
")",
"return",
";",
"$",
"virtual",
"=",
"(",
"$",
"virtual",
"!==",
"null",
")",
"?",
"$",
"virtual",
":",
"$",
"this",
"->",
"start_offline_virtual",
";",
"$",
"getargs",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"\"use\"",
",",
"array",
"(",
"\"sid\"",
"=>",
"$",
"sid",
",",
"$",
"virtual",
"?",
"\"-virtual\"",
":",
"null",
")",
")",
";",
"if",
"(",
"$",
"sid",
"!=",
"0",
"&&",
"$",
"this",
"->",
"predefined_query_name",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"execute",
"(",
"\"clientupdate\"",
",",
"array",
"(",
"\"client_nickname\"",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"predefined_query_name",
")",
")",
";",
"}",
"$",
"this",
"->",
"whoamiReset",
"(",
")",
";",
"$",
"this",
"->",
"setStorage",
"(",
"\"_server_use\"",
",",
"array",
"(",
"__FUNCTION__",
",",
"$",
"getargs",
")",
")",
";",
"TeamSpeak3_Helper_Signal",
"::",
"getInstance",
"(",
")",
"->",
"emit",
"(",
"\"notifyServerselected\"",
",",
"$",
"this",
")",
";",
"}"
] | Selects a virtual server by ID to allow further interaction.
@param integer $sid
@param boolean $virtual
@return void | [
"Selects",
"a",
"virtual",
"server",
"by",
"ID",
"to",
"allow",
"further",
"interaction",
"."
] | 03f57dbac2197f3fe7cf95ae0124152d19d78832 | https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/libraries/TeamSpeak3/Node/Host.php#L138-L157 |
9,530 | seyon/Teamspeak3Framework | libraries/TeamSpeak3/Node/Host.php | TeamSpeak3_Node_Host.serverSelectByPort | public function serverSelectByPort($port, $virtual = null)
{
if($this->whoami !== null && $this->serverSelectedPort() == $port) return;
$virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
$getargs = func_get_args();
$this->execute("use", array("port" => $port, $virtual ? "-virtual" : null));
if($port != 0 && $this->predefined_query_name !== null)
{
$this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
}
$this->whoamiReset();
$this->setStorage("_server_use", array(__FUNCTION__, $getargs));
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
} | php | public function serverSelectByPort($port, $virtual = null)
{
if($this->whoami !== null && $this->serverSelectedPort() == $port) return;
$virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
$getargs = func_get_args();
$this->execute("use", array("port" => $port, $virtual ? "-virtual" : null));
if($port != 0 && $this->predefined_query_name !== null)
{
$this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
}
$this->whoamiReset();
$this->setStorage("_server_use", array(__FUNCTION__, $getargs));
TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
} | [
"public",
"function",
"serverSelectByPort",
"(",
"$",
"port",
",",
"$",
"virtual",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"whoami",
"!==",
"null",
"&&",
"$",
"this",
"->",
"serverSelectedPort",
"(",
")",
"==",
"$",
"port",
")",
"return",
";",
"$",
"virtual",
"=",
"(",
"$",
"virtual",
"!==",
"null",
")",
"?",
"$",
"virtual",
":",
"$",
"this",
"->",
"start_offline_virtual",
";",
"$",
"getargs",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"\"use\"",
",",
"array",
"(",
"\"port\"",
"=>",
"$",
"port",
",",
"$",
"virtual",
"?",
"\"-virtual\"",
":",
"null",
")",
")",
";",
"if",
"(",
"$",
"port",
"!=",
"0",
"&&",
"$",
"this",
"->",
"predefined_query_name",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"execute",
"(",
"\"clientupdate\"",
",",
"array",
"(",
"\"client_nickname\"",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"predefined_query_name",
")",
")",
";",
"}",
"$",
"this",
"->",
"whoamiReset",
"(",
")",
";",
"$",
"this",
"->",
"setStorage",
"(",
"\"_server_use\"",
",",
"array",
"(",
"__FUNCTION__",
",",
"$",
"getargs",
")",
")",
";",
"TeamSpeak3_Helper_Signal",
"::",
"getInstance",
"(",
")",
"->",
"emit",
"(",
"\"notifyServerselected\"",
",",
"$",
"this",
")",
";",
"}"
] | Selects a virtual server by UDP port to allow further interaction.
@param integer $port
@param boolean $virtual
@return void | [
"Selects",
"a",
"virtual",
"server",
"by",
"UDP",
"port",
"to",
"allow",
"further",
"interaction",
"."
] | 03f57dbac2197f3fe7cf95ae0124152d19d78832 | https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/libraries/TeamSpeak3/Node/Host.php#L178-L197 |
9,531 | sharkodlak/php-gettext | src/ExpandMethodsTrait.php | ExpandMethodsTrait.ngettext | public function ngettext($singular, $plural, $count) {
$domain = $this->getDefaultDomain();
return $this->dngettext($domain, $singular, $plural, $count);
} | php | public function ngettext($singular, $plural, $count) {
$domain = $this->getDefaultDomain();
return $this->dngettext($domain, $singular, $plural, $count);
} | [
"public",
"function",
"ngettext",
"(",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"count",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"getDefaultDomain",
"(",
")",
";",
"return",
"$",
"this",
"->",
"dngettext",
"(",
"$",
"domain",
",",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"count",
")",
";",
"}"
] | Plural version of gettext.
Some languages have more than one form for plural messages dependent on the count.
@param string $singular Message in singular form.
@param string $plural Message in plural form.
@param int $count The number (e.g. item count) to determine the translation for the respective grammatical number.
@return string Returns correct plural form of message if found, otherwise it returns $singular for $count == 1
or $plural for rest.
@see ExpandMethodsTrait::gettext() To view message in the current domain lookup. | [
"Plural",
"version",
"of",
"gettext",
".",
"Some",
"languages",
"have",
"more",
"than",
"one",
"form",
"for",
"plural",
"messages",
"dependent",
"on",
"the",
"count",
"."
] | 383162b6cd4d3f33787f7cc614dafe5509b4924d | https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/ExpandMethodsTrait.php#L38-L41 |
9,532 | sharkodlak/php-gettext | src/ExpandMethodsTrait.php | ExpandMethodsTrait.npgettext | public function npgettext($context, $singular, $plural, $count) {
$domain = $this->getDefaultDomain();
return $this->dnpgettext($domain, $context, $singular, $plural, $count);
} | php | public function npgettext($context, $singular, $plural, $count) {
$domain = $this->getDefaultDomain();
return $this->dnpgettext($domain, $context, $singular, $plural, $count);
} | [
"public",
"function",
"npgettext",
"(",
"$",
"context",
",",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"count",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"getDefaultDomain",
"(",
")",
";",
"return",
"$",
"this",
"->",
"dnpgettext",
"(",
"$",
"domain",
",",
"$",
"context",
",",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"count",
")",
";",
"}"
] | Plural version of pgettext.
Some languages have more than one form for plural messages dependent on the count.
@param string $context Context name that distinguishes particular translation. Should be short and rarely need to change.
@param string $singular Message in singular form.
@param string $plural Message in plural form.
@param int $count The number (e.g. item count) to determine the translation for the respective grammatical number.
@return string Returns correct plural form of message if found, otherwise it returns $singular for $count == 1
or $plural for rest.
@see ExpandMethodsTrait::ngettext() To view plural version of gettext.
@see ExpandMethodsTrait::pgettext() To view contextual (particular) message in the current domain lookup. | [
"Plural",
"version",
"of",
"pgettext",
".",
"Some",
"languages",
"have",
"more",
"than",
"one",
"form",
"for",
"plural",
"messages",
"dependent",
"on",
"the",
"count",
"."
] | 383162b6cd4d3f33787f7cc614dafe5509b4924d | https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/ExpandMethodsTrait.php#L57-L60 |
9,533 | kambo-1st/Enum | src/Enum.php | Enum.inEnum | public static function inEnum($value)
{
$allItems = array_flip(self::toArray());
return isset($allItems[$value]) ? true : false;
} | php | public static function inEnum($value)
{
$allItems = array_flip(self::toArray());
return isset($allItems[$value]) ? true : false;
} | [
"public",
"static",
"function",
"inEnum",
"(",
"$",
"value",
")",
"{",
"$",
"allItems",
"=",
"array_flip",
"(",
"self",
"::",
"toArray",
"(",
")",
")",
";",
"return",
"isset",
"(",
"$",
"allItems",
"[",
"$",
"value",
"]",
")",
"?",
"true",
":",
"false",
";",
"}"
] | Check if a value is in enum
@return boolean True if the value is in enum false if not | [
"Check",
"if",
"a",
"value",
"is",
"in",
"enum"
] | 502e03f53328e51b18785e020881ab736f260474 | https://github.com/kambo-1st/Enum/blob/502e03f53328e51b18785e020881ab736f260474/src/Enum.php#L53-L58 |
9,534 | sgtlambda/jvwp | src/admin/pages/AdminPage.php | AdminPage.resetView | public static function resetView (ModeBasedUrlProvider $urlProvider)
{
$redirectHeader = 'Location: ' . $urlProvider->getModeUrl(self::MODE_DEFAULT);
header($redirectHeader);
exit;
} | php | public static function resetView (ModeBasedUrlProvider $urlProvider)
{
$redirectHeader = 'Location: ' . $urlProvider->getModeUrl(self::MODE_DEFAULT);
header($redirectHeader);
exit;
} | [
"public",
"static",
"function",
"resetView",
"(",
"ModeBasedUrlProvider",
"$",
"urlProvider",
")",
"{",
"$",
"redirectHeader",
"=",
"'Location: '",
".",
"$",
"urlProvider",
"->",
"getModeUrl",
"(",
"self",
"::",
"MODE_DEFAULT",
")",
";",
"header",
"(",
"$",
"redirectHeader",
")",
";",
"exit",
";",
"}"
] | Redirect to the default view
@param ModeBasedUrlProvider $urlProvider | [
"Redirect",
"to",
"the",
"default",
"view"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/pages/AdminPage.php#L69-L74 |
9,535 | sgtlambda/jvwp | src/admin/pages/AdminPage.php | AdminPage.renderLog | public function renderLog ()
{
$output = '';
foreach ($this->log as $message)
$output .= $message->render();
return $output;
} | php | public function renderLog ()
{
$output = '';
foreach ($this->log as $message)
$output .= $message->render();
return $output;
} | [
"public",
"function",
"renderLog",
"(",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"log",
"as",
"$",
"message",
")",
"$",
"output",
".=",
"$",
"message",
"->",
"render",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Gets the HTML markup to display of all consecutive log messages
@return string | [
"Gets",
"the",
"HTML",
"markup",
"to",
"display",
"of",
"all",
"consecutive",
"log",
"messages"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/pages/AdminPage.php#L91-L97 |
9,536 | sgtlambda/jvwp | src/admin/pages/AdminPage.php | AdminPage.addActions | protected function addActions ()
{
add_action(Hooks::ADMIN_MENU, array($this, 'addPage'));
if ($this->currentlyOnPage()) {
add_action(Hooks::ADMIN_INIT, [$this, 'adminInit']);
}
} | php | protected function addActions ()
{
add_action(Hooks::ADMIN_MENU, array($this, 'addPage'));
if ($this->currentlyOnPage()) {
add_action(Hooks::ADMIN_INIT, [$this, 'adminInit']);
}
} | [
"protected",
"function",
"addActions",
"(",
")",
"{",
"add_action",
"(",
"Hooks",
"::",
"ADMIN_MENU",
",",
"array",
"(",
"$",
"this",
",",
"'addPage'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentlyOnPage",
"(",
")",
")",
"{",
"add_action",
"(",
"Hooks",
"::",
"ADMIN_INIT",
",",
"[",
"$",
"this",
",",
"'adminInit'",
"]",
")",
";",
"}",
"}"
] | Sets up the WP hooks | [
"Sets",
"up",
"the",
"WP",
"hooks"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/pages/AdminPage.php#L102-L108 |
9,537 | sgtlambda/jvwp | src/admin/pages/AdminPage.php | AdminPage.doUserFunc | private function doUserFunc ($getMode)
{
if (($activeMode = $this->getActiveMode()) !== null && ($userFunc = call_user_func($getMode, $activeMode)) !== null) {
call_user_func($userFunc, $activeMode);
}
} | php | private function doUserFunc ($getMode)
{
if (($activeMode = $this->getActiveMode()) !== null && ($userFunc = call_user_func($getMode, $activeMode)) !== null) {
call_user_func($userFunc, $activeMode);
}
} | [
"private",
"function",
"doUserFunc",
"(",
"$",
"getMode",
")",
"{",
"if",
"(",
"(",
"$",
"activeMode",
"=",
"$",
"this",
"->",
"getActiveMode",
"(",
")",
")",
"!==",
"null",
"&&",
"(",
"$",
"userFunc",
"=",
"call_user_func",
"(",
"$",
"getMode",
",",
"$",
"activeMode",
")",
")",
"!==",
"null",
")",
"{",
"call_user_func",
"(",
"$",
"userFunc",
",",
"$",
"activeMode",
")",
";",
"}",
"}"
] | Performs a user func on the active mode
@param callable $getMode A callable that retrieves the user func from the mode
@throws Exception | [
"Performs",
"a",
"user",
"func",
"on",
"the",
"active",
"mode"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/pages/AdminPage.php#L116-L121 |
9,538 | sgtlambda/jvwp | src/admin/pages/AdminPage.php | AdminPage.removeMode | public function removeMode ($mode)
{
if ($mode instanceof AdminPageMode)
$mode = $mode->getSlug();
unset($this->modes[$mode]);
} | php | public function removeMode ($mode)
{
if ($mode instanceof AdminPageMode)
$mode = $mode->getSlug();
unset($this->modes[$mode]);
} | [
"public",
"function",
"removeMode",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"instanceof",
"AdminPageMode",
")",
"$",
"mode",
"=",
"$",
"mode",
"->",
"getSlug",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"modes",
"[",
"$",
"mode",
"]",
")",
";",
"}"
] | Removes a display mode
@param AdminPageMode|string $mode | [
"Removes",
"a",
"display",
"mode"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/pages/AdminPage.php#L252-L257 |
9,539 | simonhamp/network-elements | src/RatchetServer.php | RatchetServer.onMessage | public function onMessage(ConnectionInterface $from, $message)
{
$message = json_decode($message);
// TODO: Various auth checks and safety. We don't want to try to handle anything/everything from the client!
$channel = $message->message->channel;
if ($message->event == 'subscribe') {
// Tie the connection to the channel
$this->subscribedTopics[$channel][] = $from;
}
} | php | public function onMessage(ConnectionInterface $from, $message)
{
$message = json_decode($message);
// TODO: Various auth checks and safety. We don't want to try to handle anything/everything from the client!
$channel = $message->message->channel;
if ($message->event == 'subscribe') {
// Tie the connection to the channel
$this->subscribedTopics[$channel][] = $from;
}
} | [
"public",
"function",
"onMessage",
"(",
"ConnectionInterface",
"$",
"from",
",",
"$",
"message",
")",
"{",
"$",
"message",
"=",
"json_decode",
"(",
"$",
"message",
")",
";",
"// TODO: Various auth checks and safety. We don't want to try to handle anything/everything from the client!",
"$",
"channel",
"=",
"$",
"message",
"->",
"message",
"->",
"channel",
";",
"if",
"(",
"$",
"message",
"->",
"event",
"==",
"'subscribe'",
")",
"{",
"// Tie the connection to the channel",
"$",
"this",
"->",
"subscribedTopics",
"[",
"$",
"channel",
"]",
"[",
"]",
"=",
"$",
"from",
";",
"}",
"}"
] | Client-side message from Echo | [
"Client",
"-",
"side",
"message",
"from",
"Echo"
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/RatchetServer.php#L15-L26 |
9,540 | simonhamp/network-elements | src/RatchetServer.php | RatchetServer.onEntry | public function onEntry($entry)
{
if (is_array($entry)) {
// First item from laravel-zmq is the channel name
$channel = $entry[0];
// Second is the actual message (in JSON format)
$entry = json_decode($entry[1], true);
// Put the channel name back into the payload
$entry['channel'] = $channel;
// And re-encode so it can be sent to clients
$entry = json_encode($entry);
}
// No channel found in the payload or channel doesn't have any subscribers
if (! $channel || ! array_key_exists($channel, $this->subscribedTopics)) {
return;
}
if (starts_with($channel, 'private-')) {
// Only get the subscribers to the channel that this should be published on
$subs = $this->subscribedTopics[$channel];
foreach ($subs as $to) {
$this->send($to, $entry);
}
} else {
// If it's public, send to all clients
$this->sendAll($entry);
}
} | php | public function onEntry($entry)
{
if (is_array($entry)) {
// First item from laravel-zmq is the channel name
$channel = $entry[0];
// Second is the actual message (in JSON format)
$entry = json_decode($entry[1], true);
// Put the channel name back into the payload
$entry['channel'] = $channel;
// And re-encode so it can be sent to clients
$entry = json_encode($entry);
}
// No channel found in the payload or channel doesn't have any subscribers
if (! $channel || ! array_key_exists($channel, $this->subscribedTopics)) {
return;
}
if (starts_with($channel, 'private-')) {
// Only get the subscribers to the channel that this should be published on
$subs = $this->subscribedTopics[$channel];
foreach ($subs as $to) {
$this->send($to, $entry);
}
} else {
// If it's public, send to all clients
$this->sendAll($entry);
}
} | [
"public",
"function",
"onEntry",
"(",
"$",
"entry",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"entry",
")",
")",
"{",
"// First item from laravel-zmq is the channel name",
"$",
"channel",
"=",
"$",
"entry",
"[",
"0",
"]",
";",
"// Second is the actual message (in JSON format)",
"$",
"entry",
"=",
"json_decode",
"(",
"$",
"entry",
"[",
"1",
"]",
",",
"true",
")",
";",
"// Put the channel name back into the payload",
"$",
"entry",
"[",
"'channel'",
"]",
"=",
"$",
"channel",
";",
"// And re-encode so it can be sent to clients",
"$",
"entry",
"=",
"json_encode",
"(",
"$",
"entry",
")",
";",
"}",
"// No channel found in the payload or channel doesn't have any subscribers",
"if",
"(",
"!",
"$",
"channel",
"||",
"!",
"array_key_exists",
"(",
"$",
"channel",
",",
"$",
"this",
"->",
"subscribedTopics",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"starts_with",
"(",
"$",
"channel",
",",
"'private-'",
")",
")",
"{",
"// Only get the subscribers to the channel that this should be published on",
"$",
"subs",
"=",
"$",
"this",
"->",
"subscribedTopics",
"[",
"$",
"channel",
"]",
";",
"foreach",
"(",
"$",
"subs",
"as",
"$",
"to",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"$",
"to",
",",
"$",
"entry",
")",
";",
"}",
"}",
"else",
"{",
"// If it's public, send to all clients",
"$",
"this",
"->",
"sendAll",
"(",
"$",
"entry",
")",
";",
"}",
"}"
] | Server-side message from ZMQ | [
"Server",
"-",
"side",
"message",
"from",
"ZMQ"
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/RatchetServer.php#L31-L63 |
9,541 | hamjoint/mustard-commerce | src/lib/Http/Controllers/AccountController.php | AccountController.postPostalAddress | public function postPostalAddress(Request $request)
{
$this->validates(
$request->all(),
[
'name' => 'required',
'street1' => 'required',
'city' => 'required',
'county' => 'required',
'postcode' => 'required',
'country' => 'required',
]
);
$pa = new PostalAddress;
$pa->name = $request->input('name');
$pa->street1 = $request->input('street1');
$pa->street2 = $request->input('street2');
$pa->city = $request->input('city');
$pa->county = $request->input('county');
$pa->postcode = $request->input('postcode');
$pa->country = $this->country($request->input('country'))['alpha2'];
$pa->added = time();
$pa->user()->associate(Auth::user());
$pa->save();
return redirect('/account/postal-addresses')->withStatus('Postal address added.');
} | php | public function postPostalAddress(Request $request)
{
$this->validates(
$request->all(),
[
'name' => 'required',
'street1' => 'required',
'city' => 'required',
'county' => 'required',
'postcode' => 'required',
'country' => 'required',
]
);
$pa = new PostalAddress;
$pa->name = $request->input('name');
$pa->street1 = $request->input('street1');
$pa->street2 = $request->input('street2');
$pa->city = $request->input('city');
$pa->county = $request->input('county');
$pa->postcode = $request->input('postcode');
$pa->country = $this->country($request->input('country'))['alpha2'];
$pa->added = time();
$pa->user()->associate(Auth::user());
$pa->save();
return redirect('/account/postal-addresses')->withStatus('Postal address added.');
} | [
"public",
"function",
"postPostalAddress",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validates",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"[",
"'name'",
"=>",
"'required'",
",",
"'street1'",
"=>",
"'required'",
",",
"'city'",
"=>",
"'required'",
",",
"'county'",
"=>",
"'required'",
",",
"'postcode'",
"=>",
"'required'",
",",
"'country'",
"=>",
"'required'",
",",
"]",
")",
";",
"$",
"pa",
"=",
"new",
"PostalAddress",
";",
"$",
"pa",
"->",
"name",
"=",
"$",
"request",
"->",
"input",
"(",
"'name'",
")",
";",
"$",
"pa",
"->",
"street1",
"=",
"$",
"request",
"->",
"input",
"(",
"'street1'",
")",
";",
"$",
"pa",
"->",
"street2",
"=",
"$",
"request",
"->",
"input",
"(",
"'street2'",
")",
";",
"$",
"pa",
"->",
"city",
"=",
"$",
"request",
"->",
"input",
"(",
"'city'",
")",
";",
"$",
"pa",
"->",
"county",
"=",
"$",
"request",
"->",
"input",
"(",
"'county'",
")",
";",
"$",
"pa",
"->",
"postcode",
"=",
"$",
"request",
"->",
"input",
"(",
"'postcode'",
")",
";",
"$",
"pa",
"->",
"country",
"=",
"$",
"this",
"->",
"country",
"(",
"$",
"request",
"->",
"input",
"(",
"'country'",
")",
")",
"[",
"'alpha2'",
"]",
";",
"$",
"pa",
"->",
"added",
"=",
"time",
"(",
")",
";",
"$",
"pa",
"->",
"user",
"(",
")",
"->",
"associate",
"(",
"Auth",
"::",
"user",
"(",
")",
")",
";",
"$",
"pa",
"->",
"save",
"(",
")",
";",
"return",
"redirect",
"(",
"'/account/postal-addresses'",
")",
"->",
"withStatus",
"(",
"'Postal address added.'",
")",
";",
"}"
] | Add a postal address.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse | [
"Add",
"a",
"postal",
"address",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/AccountController.php#L68-L98 |
9,542 | hamjoint/mustard-commerce | src/lib/Http/Controllers/AccountController.php | AccountController.postDeletePostalAddress | public function postDeletePostalAddress(Request $request)
{
$pa = PostalAddress::findOrFail($request->input('postal_address_id'));
if ($pa->user->userId != Auth::user()->userId) {
return redirect('/account/postal-addresses')
->withErrors(["You can only delete your own postal addresses."]);
}
if ($pa->purchases()->count()) {
return redirect('/account/postal-addresses')
->withErrors(["You cannot delete postal addresses that are associated with purchases."]);
}
$pa->delete();
return redirect('/account/postal-addresses')
->withStatus('Postal address deleted.');
} | php | public function postDeletePostalAddress(Request $request)
{
$pa = PostalAddress::findOrFail($request->input('postal_address_id'));
if ($pa->user->userId != Auth::user()->userId) {
return redirect('/account/postal-addresses')
->withErrors(["You can only delete your own postal addresses."]);
}
if ($pa->purchases()->count()) {
return redirect('/account/postal-addresses')
->withErrors(["You cannot delete postal addresses that are associated with purchases."]);
}
$pa->delete();
return redirect('/account/postal-addresses')
->withStatus('Postal address deleted.');
} | [
"public",
"function",
"postDeletePostalAddress",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"pa",
"=",
"PostalAddress",
"::",
"findOrFail",
"(",
"$",
"request",
"->",
"input",
"(",
"'postal_address_id'",
")",
")",
";",
"if",
"(",
"$",
"pa",
"->",
"user",
"->",
"userId",
"!=",
"Auth",
"::",
"user",
"(",
")",
"->",
"userId",
")",
"{",
"return",
"redirect",
"(",
"'/account/postal-addresses'",
")",
"->",
"withErrors",
"(",
"[",
"\"You can only delete your own postal addresses.\"",
"]",
")",
";",
"}",
"if",
"(",
"$",
"pa",
"->",
"purchases",
"(",
")",
"->",
"count",
"(",
")",
")",
"{",
"return",
"redirect",
"(",
"'/account/postal-addresses'",
")",
"->",
"withErrors",
"(",
"[",
"\"You cannot delete postal addresses that are associated with purchases.\"",
"]",
")",
";",
"}",
"$",
"pa",
"->",
"delete",
"(",
")",
";",
"return",
"redirect",
"(",
"'/account/postal-addresses'",
")",
"->",
"withStatus",
"(",
"'Postal address deleted.'",
")",
";",
"}"
] | Delete a postal address.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse | [
"Delete",
"a",
"postal",
"address",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/AccountController.php#L106-L124 |
9,543 | hamjoint/mustard-commerce | src/lib/Http/Controllers/AccountController.php | AccountController.postBankDetails | public function postBankDetails(Request $request)
{
$this->validates(
$request->all(),
[
'account_number' => 'required|accountnumber',
'sort_code' => 'required|sortcode',
]
);
$bank_details = Auth::user()->bankDetails ? Auth::user()->bankDetails : new BankDetail;
$bank_details->accountNumber = $request->input('account_number');
$bank_details->sortCode = $request->input('sort_code');
if (!$bank_details->exists) {
$bank_details->user()->associate(Auth::user());
}
$bank_details->save();
Auth::user()->sendEmail(
'Your bank details have been changed',
'emails.account.bank-details-changed'
);
return redirect('/account/bank-details')
->withStatus('Your bank details have been changed.');
} | php | public function postBankDetails(Request $request)
{
$this->validates(
$request->all(),
[
'account_number' => 'required|accountnumber',
'sort_code' => 'required|sortcode',
]
);
$bank_details = Auth::user()->bankDetails ? Auth::user()->bankDetails : new BankDetail;
$bank_details->accountNumber = $request->input('account_number');
$bank_details->sortCode = $request->input('sort_code');
if (!$bank_details->exists) {
$bank_details->user()->associate(Auth::user());
}
$bank_details->save();
Auth::user()->sendEmail(
'Your bank details have been changed',
'emails.account.bank-details-changed'
);
return redirect('/account/bank-details')
->withStatus('Your bank details have been changed.');
} | [
"public",
"function",
"postBankDetails",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validates",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"[",
"'account_number'",
"=>",
"'required|accountnumber'",
",",
"'sort_code'",
"=>",
"'required|sortcode'",
",",
"]",
")",
";",
"$",
"bank_details",
"=",
"Auth",
"::",
"user",
"(",
")",
"->",
"bankDetails",
"?",
"Auth",
"::",
"user",
"(",
")",
"->",
"bankDetails",
":",
"new",
"BankDetail",
";",
"$",
"bank_details",
"->",
"accountNumber",
"=",
"$",
"request",
"->",
"input",
"(",
"'account_number'",
")",
";",
"$",
"bank_details",
"->",
"sortCode",
"=",
"$",
"request",
"->",
"input",
"(",
"'sort_code'",
")",
";",
"if",
"(",
"!",
"$",
"bank_details",
"->",
"exists",
")",
"{",
"$",
"bank_details",
"->",
"user",
"(",
")",
"->",
"associate",
"(",
"Auth",
"::",
"user",
"(",
")",
")",
";",
"}",
"$",
"bank_details",
"->",
"save",
"(",
")",
";",
"Auth",
"::",
"user",
"(",
")",
"->",
"sendEmail",
"(",
"'Your bank details have been changed'",
",",
"'emails.account.bank-details-changed'",
")",
";",
"return",
"redirect",
"(",
"'/account/bank-details'",
")",
"->",
"withStatus",
"(",
"'Your bank details have been changed.'",
")",
";",
"}"
] | Add bank details.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse | [
"Add",
"bank",
"details",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Http/Controllers/AccountController.php#L132-L160 |
9,544 | dotkernel/dot-mail | src/Event/MailEventListenerAwareTrait.php | MailEventListenerAwareTrait.clearListeners | public function clearListeners()
{
foreach ($this->listeners as $listener) {
$listener->detach($this->getEventManager());
}
$this->listeners = [];
} | php | public function clearListeners()
{
foreach ($this->listeners as $listener) {
$listener->detach($this->getEventManager());
}
$this->listeners = [];
} | [
"public",
"function",
"clearListeners",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"detach",
"(",
"$",
"this",
"->",
"getEventManager",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"listeners",
"=",
"[",
"]",
";",
"}"
] | Detach an clear listeners array | [
"Detach",
"an",
"clear",
"listeners",
"array"
] | 8874ef0b39e2cc3a8021debc1c7966d63298c189 | https://github.com/dotkernel/dot-mail/blob/8874ef0b39e2cc3a8021debc1c7966d63298c189/src/Event/MailEventListenerAwareTrait.php#L58-L65 |
9,545 | fructify/robo | Tasks.php | Tasks.fructifyInstall | public function fructifyInstall(string $versionContraint = '*')
{
// Lets check if wordpress actually exists
if (!file_exists('./wp-includes/version.php'))
{
// Grab the resolved version number
$version = $this->wpResolveVersionNo($versionContraint);
// Download the core wordpress files
$this->_exec('./vendor/bin/wp core download --version='.$version);
// Remove a few things we don't need
@unlink('./license.txt');
@unlink('./readme.html');
@unlink('./wp-config-sample.php');
@unlink('./wp-content/plugins/hello.php');
// Read in the composer file and remove some of the bundled plugins
// and themes unless of course they are actually referenced in the
// composer requirements.
$composer = Str::s(file_get_contents('./composer.json'));
if (!$composer->contains('wpackagist-plugin/akismet'))
{
$this->_deleteDir(['./wp-content/plugins/akismet']);
}
if (!$composer->contains('wpackagist-theme/twentyseventeen'))
{
$this->_deleteDir(['./wp-content/themes/twentyseventeen']);
}
if (!$composer->contains('wpackagist-theme/twentysixteen'))
{
$this->_deleteDir(['./wp-content/themes/twentysixteen']);
}
if (!$composer->contains('wpackagist-theme/twentyfifteen'))
{
$this->_deleteDir(['./wp-content/themes/twentyfifteen']);
}
if (!$composer->contains('wpackagist-theme/twentyfourteen'))
{
$this->_deleteDir(['./wp-content/themes/twentyfourteen']);
}
}
} | php | public function fructifyInstall(string $versionContraint = '*')
{
// Lets check if wordpress actually exists
if (!file_exists('./wp-includes/version.php'))
{
// Grab the resolved version number
$version = $this->wpResolveVersionNo($versionContraint);
// Download the core wordpress files
$this->_exec('./vendor/bin/wp core download --version='.$version);
// Remove a few things we don't need
@unlink('./license.txt');
@unlink('./readme.html');
@unlink('./wp-config-sample.php');
@unlink('./wp-content/plugins/hello.php');
// Read in the composer file and remove some of the bundled plugins
// and themes unless of course they are actually referenced in the
// composer requirements.
$composer = Str::s(file_get_contents('./composer.json'));
if (!$composer->contains('wpackagist-plugin/akismet'))
{
$this->_deleteDir(['./wp-content/plugins/akismet']);
}
if (!$composer->contains('wpackagist-theme/twentyseventeen'))
{
$this->_deleteDir(['./wp-content/themes/twentyseventeen']);
}
if (!$composer->contains('wpackagist-theme/twentysixteen'))
{
$this->_deleteDir(['./wp-content/themes/twentysixteen']);
}
if (!$composer->contains('wpackagist-theme/twentyfifteen'))
{
$this->_deleteDir(['./wp-content/themes/twentyfifteen']);
}
if (!$composer->contains('wpackagist-theme/twentyfourteen'))
{
$this->_deleteDir(['./wp-content/themes/twentyfourteen']);
}
}
} | [
"public",
"function",
"fructifyInstall",
"(",
"string",
"$",
"versionContraint",
"=",
"'*'",
")",
"{",
"// Lets check if wordpress actually exists",
"if",
"(",
"!",
"file_exists",
"(",
"'./wp-includes/version.php'",
")",
")",
"{",
"// Grab the resolved version number",
"$",
"version",
"=",
"$",
"this",
"->",
"wpResolveVersionNo",
"(",
"$",
"versionContraint",
")",
";",
"// Download the core wordpress files",
"$",
"this",
"->",
"_exec",
"(",
"'./vendor/bin/wp core download --version='",
".",
"$",
"version",
")",
";",
"// Remove a few things we don't need",
"@",
"unlink",
"(",
"'./license.txt'",
")",
";",
"@",
"unlink",
"(",
"'./readme.html'",
")",
";",
"@",
"unlink",
"(",
"'./wp-config-sample.php'",
")",
";",
"@",
"unlink",
"(",
"'./wp-content/plugins/hello.php'",
")",
";",
"// Read in the composer file and remove some of the bundled plugins",
"// and themes unless of course they are actually referenced in the",
"// composer requirements.",
"$",
"composer",
"=",
"Str",
"::",
"s",
"(",
"file_get_contents",
"(",
"'./composer.json'",
")",
")",
";",
"if",
"(",
"!",
"$",
"composer",
"->",
"contains",
"(",
"'wpackagist-plugin/akismet'",
")",
")",
"{",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-content/plugins/akismet'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"composer",
"->",
"contains",
"(",
"'wpackagist-theme/twentyseventeen'",
")",
")",
"{",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-content/themes/twentyseventeen'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"composer",
"->",
"contains",
"(",
"'wpackagist-theme/twentysixteen'",
")",
")",
"{",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-content/themes/twentysixteen'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"composer",
"->",
"contains",
"(",
"'wpackagist-theme/twentyfifteen'",
")",
")",
"{",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-content/themes/twentyfifteen'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"composer",
"->",
"contains",
"(",
"'wpackagist-theme/twentyfourteen'",
")",
")",
"{",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-content/themes/twentyfourteen'",
"]",
")",
";",
"}",
"}",
"}"
] | Installs Wordpress.
This task will download the core wordpress files for you. It is
automatically run by composer as a post-install-cmd so you really
shouldn't need to worry about it.
But if you do want to call it, usage would look like:
```
./robo fructify:install v4.*
```
@param string $versionContraint A semantic version contraint.
@return void | [
"Installs",
"Wordpress",
"."
] | d247b5c0679eb746813638502f2cfcc64ab19d0d | https://github.com/fructify/robo/blob/d247b5c0679eb746813638502f2cfcc64ab19d0d/Tasks.php#L51-L98 |
9,546 | fructify/robo | Tasks.php | Tasks.fructifyUpdate | public function fructifyUpdate(string $versionContraint = '*')
{
// Lets attempt to update wordpress
if (file_exists('./wp-includes/version.php'))
{
// Grab the version of wordpress that is installed
require('./wp-includes/version.php');
$installed_version = $wp_version;
// Get the version we want to update to
$new_version = $this->wpResolveVersionNo($versionContraint);
// Nothing to do, same version.
if ($installed_version == $new_version) return;
// Now lets download the version of wordpress that we already have,
// sounds silly I know but it will make sense soon I promise.
$temp = sys_get_temp_dir().'/'.md5(microtime());
$this->_mkdir($temp);
$this->_exec
(
'./vendor/bin/wp core download'.
' --version='.$installed_version.
' --path='.$temp
);
// Now lets delete all the files that are stock wordpress files
$finder = new Finder();
$finder->files()->in($temp);
foreach ($finder as $file)
{
if (file_exists($file->getRelativePathname()))
{
unlink($file->getRelativePathname());
}
}
// Clean up
$this->_deleteDir(['./wp-admin', './wp-includes', $temp]);
}
// Either we just deleted the old wordpress files or it didn't exist.
// Regardless lets run the install functionality.
$this->fructifyInstall($versionContraint);
} | php | public function fructifyUpdate(string $versionContraint = '*')
{
// Lets attempt to update wordpress
if (file_exists('./wp-includes/version.php'))
{
// Grab the version of wordpress that is installed
require('./wp-includes/version.php');
$installed_version = $wp_version;
// Get the version we want to update to
$new_version = $this->wpResolveVersionNo($versionContraint);
// Nothing to do, same version.
if ($installed_version == $new_version) return;
// Now lets download the version of wordpress that we already have,
// sounds silly I know but it will make sense soon I promise.
$temp = sys_get_temp_dir().'/'.md5(microtime());
$this->_mkdir($temp);
$this->_exec
(
'./vendor/bin/wp core download'.
' --version='.$installed_version.
' --path='.$temp
);
// Now lets delete all the files that are stock wordpress files
$finder = new Finder();
$finder->files()->in($temp);
foreach ($finder as $file)
{
if (file_exists($file->getRelativePathname()))
{
unlink($file->getRelativePathname());
}
}
// Clean up
$this->_deleteDir(['./wp-admin', './wp-includes', $temp]);
}
// Either we just deleted the old wordpress files or it didn't exist.
// Regardless lets run the install functionality.
$this->fructifyInstall($versionContraint);
} | [
"public",
"function",
"fructifyUpdate",
"(",
"string",
"$",
"versionContraint",
"=",
"'*'",
")",
"{",
"// Lets attempt to update wordpress",
"if",
"(",
"file_exists",
"(",
"'./wp-includes/version.php'",
")",
")",
"{",
"// Grab the version of wordpress that is installed",
"require",
"(",
"'./wp-includes/version.php'",
")",
";",
"$",
"installed_version",
"=",
"$",
"wp_version",
";",
"// Get the version we want to update to",
"$",
"new_version",
"=",
"$",
"this",
"->",
"wpResolveVersionNo",
"(",
"$",
"versionContraint",
")",
";",
"// Nothing to do, same version.",
"if",
"(",
"$",
"installed_version",
"==",
"$",
"new_version",
")",
"return",
";",
"// Now lets download the version of wordpress that we already have,",
"// sounds silly I know but it will make sense soon I promise.",
"$",
"temp",
"=",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"md5",
"(",
"microtime",
"(",
")",
")",
";",
"$",
"this",
"->",
"_mkdir",
"(",
"$",
"temp",
")",
";",
"$",
"this",
"->",
"_exec",
"(",
"'./vendor/bin/wp core download'",
".",
"' --version='",
".",
"$",
"installed_version",
".",
"' --path='",
".",
"$",
"temp",
")",
";",
"// Now lets delete all the files that are stock wordpress files",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"temp",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
"->",
"getRelativePathname",
"(",
")",
")",
")",
"{",
"unlink",
"(",
"$",
"file",
"->",
"getRelativePathname",
"(",
")",
")",
";",
"}",
"}",
"// Clean up",
"$",
"this",
"->",
"_deleteDir",
"(",
"[",
"'./wp-admin'",
",",
"'./wp-includes'",
",",
"$",
"temp",
"]",
")",
";",
"}",
"// Either we just deleted the old wordpress files or it didn't exist.",
"// Regardless lets run the install functionality.",
"$",
"this",
"->",
"fructifyInstall",
"(",
"$",
"versionContraint",
")",
";",
"}"
] | Updates Wordpress.
This task will update the core wordpress files for you. It is
automatically run by composer as a post-update-cmd so you really
shouldn't need to worry about it.
But if you do want to call it, usage would look like:
```
./robo fructify:update v4.*
```
@param string $versionContraint A semantic version contraint.
@return void | [
"Updates",
"Wordpress",
"."
] | d247b5c0679eb746813638502f2cfcc64ab19d0d | https://github.com/fructify/robo/blob/d247b5c0679eb746813638502f2cfcc64ab19d0d/Tasks.php#L116-L160 |
9,547 | fructify/robo | Tasks.php | Tasks.fructifySalts | public function fructifySalts()
{
$this->taskWriteToFile('./.salts.php')
->line('<?php')
->text((new Http)->request('GET', self::$WP_SALTS_URL)->getBody())
->run();
} | php | public function fructifySalts()
{
$this->taskWriteToFile('./.salts.php')
->line('<?php')
->text((new Http)->request('GET', self::$WP_SALTS_URL)->getBody())
->run();
} | [
"public",
"function",
"fructifySalts",
"(",
")",
"{",
"$",
"this",
"->",
"taskWriteToFile",
"(",
"'./.salts.php'",
")",
"->",
"line",
"(",
"'<?php'",
")",
"->",
"text",
"(",
"(",
"new",
"Http",
")",
"->",
"request",
"(",
"'GET'",
",",
"self",
"::",
"$",
"WP_SALTS_URL",
")",
"->",
"getBody",
"(",
")",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Creates New Salts, used for encryption by Wordpress.
This task will create a new set of salts and write them to the
.salts.php file for you. Again this is tied into composer as a
post-install-cmd so you really shouldn't need to worry about it.
But if you do want to call it, usage would look like:
```
./robo fructify:salts
```
@return void | [
"Creates",
"New",
"Salts",
"used",
"for",
"encryption",
"by",
"Wordpress",
"."
] | d247b5c0679eb746813638502f2cfcc64ab19d0d | https://github.com/fructify/robo/blob/d247b5c0679eb746813638502f2cfcc64ab19d0d/Tasks.php#L177-L183 |
9,548 | fructify/robo | Tasks.php | Tasks.fructifyPermissions | public function fructifyPermissions()
{
// These folders will be given full write permissions
$folders =
[
'./wp-content/uploads'
];
// Loop through each folder
foreach ($folders as $folder)
{
$this->taskFileSystemStack()
->mkdir($folder)
->chmod($folder, 0777)
->run();
}
} | php | public function fructifyPermissions()
{
// These folders will be given full write permissions
$folders =
[
'./wp-content/uploads'
];
// Loop through each folder
foreach ($folders as $folder)
{
$this->taskFileSystemStack()
->mkdir($folder)
->chmod($folder, 0777)
->run();
}
} | [
"public",
"function",
"fructifyPermissions",
"(",
")",
"{",
"// These folders will be given full write permissions",
"$",
"folders",
"=",
"[",
"'./wp-content/uploads'",
"]",
";",
"// Loop through each folder",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"this",
"->",
"taskFileSystemStack",
"(",
")",
"->",
"mkdir",
"(",
"$",
"folder",
")",
"->",
"chmod",
"(",
"$",
"folder",
",",
"0777",
")",
"->",
"run",
"(",
")",
";",
"}",
"}"
] | Sets permissions on "special" Wordpress folders.
This task simply loops through some folders and ensures they exist and
have the correct permissions. It is automatically run by composer as a
post-install-cmd so you really shouldn't need to worry about it.
But if you do want to call it, usage would look like:
```
./robo fructify:permissions
```
@return void | [
"Sets",
"permissions",
"on",
"special",
"Wordpress",
"folders",
"."
] | d247b5c0679eb746813638502f2cfcc64ab19d0d | https://github.com/fructify/robo/blob/d247b5c0679eb746813638502f2cfcc64ab19d0d/Tasks.php#L200-L216 |
9,549 | fructify/robo | Tasks.php | Tasks.wpResolveVersionNo | private function wpResolveVersionNo(string $versionContraint)
{
// Remove a v at the start if it exists
$versionContraint = str_replace('v', '', $versionContraint);
// If the constraint it a single wildcard, lets just
// return the latest stable release of wordpress.
if ($versionContraint == '*')
{
$json = (new Http)->request('GET', self::$WP_VERSION_URL)->getBody();
return json_decode($json, true)['offers'][0]['version'];
}
// Download the releases from the wordpress site.
$html = (new Http)->request('GET', self::$WP_RELEASES_URL)->getBody()->getContents();
// Extract a list of download links, these contain the versions.
preg_match_all("#><a href='https://wordpress\.org/wordpress-[^>]+#",
$html, $matches
);
// Filter the links to obtain a list of just versions
$versions = Linq::from($matches[0])
->select(function(string $v){ return Str::s($v); })
->where(function(Str $v){ return $v->endsWith(".zip'"); })
->where(function(Str $v){ return !$v->contains('IIS'); })
->where(function(Str $v){ return !$v->contains('mu'); })
->select(function(Str $v){ return $v->between('wordpress-', '.zip'); })
->where(function(Str $v)
{
if ($v->contains('-'))
{
return preg_match("#.*-(dev|beta|alpha|rc).*#i", (string)$v) === 1;
}
return true;
})
->toArray();
// Let semver take over and work it's magic
return (string) Semver::satisfiedBy($versions, $versionContraint)[0];
} | php | private function wpResolveVersionNo(string $versionContraint)
{
// Remove a v at the start if it exists
$versionContraint = str_replace('v', '', $versionContraint);
// If the constraint it a single wildcard, lets just
// return the latest stable release of wordpress.
if ($versionContraint == '*')
{
$json = (new Http)->request('GET', self::$WP_VERSION_URL)->getBody();
return json_decode($json, true)['offers'][0]['version'];
}
// Download the releases from the wordpress site.
$html = (new Http)->request('GET', self::$WP_RELEASES_URL)->getBody()->getContents();
// Extract a list of download links, these contain the versions.
preg_match_all("#><a href='https://wordpress\.org/wordpress-[^>]+#",
$html, $matches
);
// Filter the links to obtain a list of just versions
$versions = Linq::from($matches[0])
->select(function(string $v){ return Str::s($v); })
->where(function(Str $v){ return $v->endsWith(".zip'"); })
->where(function(Str $v){ return !$v->contains('IIS'); })
->where(function(Str $v){ return !$v->contains('mu'); })
->select(function(Str $v){ return $v->between('wordpress-', '.zip'); })
->where(function(Str $v)
{
if ($v->contains('-'))
{
return preg_match("#.*-(dev|beta|alpha|rc).*#i", (string)$v) === 1;
}
return true;
})
->toArray();
// Let semver take over and work it's magic
return (string) Semver::satisfiedBy($versions, $versionContraint)[0];
} | [
"private",
"function",
"wpResolveVersionNo",
"(",
"string",
"$",
"versionContraint",
")",
"{",
"// Remove a v at the start if it exists",
"$",
"versionContraint",
"=",
"str_replace",
"(",
"'v'",
",",
"''",
",",
"$",
"versionContraint",
")",
";",
"// If the constraint it a single wildcard, lets just",
"// return the latest stable release of wordpress.",
"if",
"(",
"$",
"versionContraint",
"==",
"'*'",
")",
"{",
"$",
"json",
"=",
"(",
"new",
"Http",
")",
"->",
"request",
"(",
"'GET'",
",",
"self",
"::",
"$",
"WP_VERSION_URL",
")",
"->",
"getBody",
"(",
")",
";",
"return",
"json_decode",
"(",
"$",
"json",
",",
"true",
")",
"[",
"'offers'",
"]",
"[",
"0",
"]",
"[",
"'version'",
"]",
";",
"}",
"// Download the releases from the wordpress site.",
"$",
"html",
"=",
"(",
"new",
"Http",
")",
"->",
"request",
"(",
"'GET'",
",",
"self",
"::",
"$",
"WP_RELEASES_URL",
")",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"// Extract a list of download links, these contain the versions.",
"preg_match_all",
"(",
"\"#><a href='https://wordpress\\.org/wordpress-[^>]+#\"",
",",
"$",
"html",
",",
"$",
"matches",
")",
";",
"// Filter the links to obtain a list of just versions",
"$",
"versions",
"=",
"Linq",
"::",
"from",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
"->",
"select",
"(",
"function",
"(",
"string",
"$",
"v",
")",
"{",
"return",
"Str",
"::",
"s",
"(",
"$",
"v",
")",
";",
"}",
")",
"->",
"where",
"(",
"function",
"(",
"Str",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"endsWith",
"(",
"\".zip'\"",
")",
";",
"}",
")",
"->",
"where",
"(",
"function",
"(",
"Str",
"$",
"v",
")",
"{",
"return",
"!",
"$",
"v",
"->",
"contains",
"(",
"'IIS'",
")",
";",
"}",
")",
"->",
"where",
"(",
"function",
"(",
"Str",
"$",
"v",
")",
"{",
"return",
"!",
"$",
"v",
"->",
"contains",
"(",
"'mu'",
")",
";",
"}",
")",
"->",
"select",
"(",
"function",
"(",
"Str",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"between",
"(",
"'wordpress-'",
",",
"'.zip'",
")",
";",
"}",
")",
"->",
"where",
"(",
"function",
"(",
"Str",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"->",
"contains",
"(",
"'-'",
")",
")",
"{",
"return",
"preg_match",
"(",
"\"#.*-(dev|beta|alpha|rc).*#i\"",
",",
"(",
"string",
")",
"$",
"v",
")",
"===",
"1",
";",
"}",
"return",
"true",
";",
"}",
")",
"->",
"toArray",
"(",
")",
";",
"// Let semver take over and work it's magic",
"return",
"(",
"string",
")",
"Semver",
"::",
"satisfiedBy",
"(",
"$",
"versions",
",",
"$",
"versionContraint",
")",
"[",
"0",
"]",
";",
"}"
] | Resolves a Wordpress Version Contraint.
This is a private helper method. It takes a semantic version contraint,
parsable by [Composer's Semver](https://github.com/composer/semver) and
resolves an actual wordpress version number.
We use this page: http://wordpress.org/download/release-archive/
As an offical list of released versions.
@param string $versionContraint A semantic version contraint.
@return string A semantic version number. | [
"Resolves",
"a",
"Wordpress",
"Version",
"Contraint",
"."
] | d247b5c0679eb746813638502f2cfcc64ab19d0d | https://github.com/fructify/robo/blob/d247b5c0679eb746813638502f2cfcc64ab19d0d/Tasks.php#L231-L272 |
9,550 | awakenweb/beverage | src/Beverage.php | Beverage.files | public static function files($filepattern, $directory = [__DIR__], $excludepattern = false)
{
return new self($filepattern, $directory, $excludepattern);
} | php | public static function files($filepattern, $directory = [__DIR__], $excludepattern = false)
{
return new self($filepattern, $directory, $excludepattern);
} | [
"public",
"static",
"function",
"files",
"(",
"$",
"filepattern",
",",
"$",
"directory",
"=",
"[",
"__DIR__",
"]",
",",
"$",
"excludepattern",
"=",
"false",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"filepattern",
",",
"$",
"directory",
",",
"$",
"excludepattern",
")",
";",
"}"
] | Factory method. Return a new instance of the Beverage task runner
@param string $filepattern
@param array $directory
@param string $excludepattern
@return Beverage | [
"Factory",
"method",
".",
"Return",
"a",
"new",
"instance",
"of",
"the",
"Beverage",
"task",
"runner"
] | 819d2fadc2ddada63cc23e749c5260d0d77ac32b | https://github.com/awakenweb/beverage/blob/819d2fadc2ddada63cc23e749c5260d0d77ac32b/src/Beverage.php#L31-L34 |
9,551 | awakenweb/beverage | src/Beverage.php | Beverage.then | public function then(Module $module)
{
$this->current_state = $module->process($this->current_state);
return $this;
} | php | public function then(Module $module)
{
$this->current_state = $module->process($this->current_state);
return $this;
} | [
"public",
"function",
"then",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"current_state",
"=",
"$",
"module",
"->",
"process",
"(",
"$",
"this",
"->",
"current_state",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Run the modules
@param Module module
@return Beverage | [
"Run",
"the",
"modules"
] | 819d2fadc2ddada63cc23e749c5260d0d77ac32b | https://github.com/awakenweb/beverage/blob/819d2fadc2ddada63cc23e749c5260d0d77ac32b/src/Beverage.php#L55-L60 |
9,552 | awakenweb/beverage | src/Beverage.php | Beverage.destination | public function destination($directory)
{
$filesystem = new Filesystem();
foreach ($this->current_state as $filename => $file_content) {
$filesystem->dumpFile($directory . '/' . $filename, $file_content);
}
unset($this->current_state);
return $this;
} | php | public function destination($directory)
{
$filesystem = new Filesystem();
foreach ($this->current_state as $filename => $file_content) {
$filesystem->dumpFile($directory . '/' . $filename, $file_content);
}
unset($this->current_state);
return $this;
} | [
"public",
"function",
"destination",
"(",
"$",
"directory",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"current_state",
"as",
"$",
"filename",
"=>",
"$",
"file_content",
")",
"{",
"$",
"filesystem",
"->",
"dumpFile",
"(",
"$",
"directory",
".",
"'/'",
".",
"$",
"filename",
",",
"$",
"file_content",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"current_state",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Define the directory where the files will be saved.
Once the files have been saves, the current state of files is unset to
save memory
@param string $directory | [
"Define",
"the",
"directory",
"where",
"the",
"files",
"will",
"be",
"saved",
"."
] | 819d2fadc2ddada63cc23e749c5260d0d77ac32b | https://github.com/awakenweb/beverage/blob/819d2fadc2ddada63cc23e749c5260d0d77ac32b/src/Beverage.php#L70-L81 |
9,553 | wookieb/type-check | src/Wookieb/TypeCheck/SimpleTypeCheck.php | SimpleTypeCheck.registerTypeAlias | public static function registerTypeAlias($alias, $type)
{
Assert::notBlank($alias, 'Alias name cannot be blank');
Assert::notBlank($type, 'Target type name cannot be blank');
self::$aliases[strtolower($alias)] = $type;
} | php | public static function registerTypeAlias($alias, $type)
{
Assert::notBlank($alias, 'Alias name cannot be blank');
Assert::notBlank($type, 'Target type name cannot be blank');
self::$aliases[strtolower($alias)] = $type;
} | [
"public",
"static",
"function",
"registerTypeAlias",
"(",
"$",
"alias",
",",
"$",
"type",
")",
"{",
"Assert",
"::",
"notBlank",
"(",
"$",
"alias",
",",
"'Alias name cannot be blank'",
")",
";",
"Assert",
"::",
"notBlank",
"(",
"$",
"type",
",",
"'Target type name cannot be blank'",
")",
";",
"self",
"::",
"$",
"aliases",
"[",
"strtolower",
"(",
"$",
"alias",
")",
"]",
"=",
"$",
"type",
";",
"}"
] | Registers alias for a type
@param string $alias
@param string $type
@throws \InvalidArgumentException when alias or type is blank | [
"Registers",
"alias",
"for",
"a",
"type"
] | 70316f47c5a92d1699f710e2a936475aa3e38700 | https://github.com/wookieb/type-check/blob/70316f47c5a92d1699f710e2a936475aa3e38700/src/Wookieb/TypeCheck/SimpleTypeCheck.php#L64-L69 |
9,554 | easy-system/es-controller-plugins | src/ControllerPlugins.php | ControllerPlugins.getPlugin | public function getPlugin($name, array $options = [])
{
$plugin = $this->get($name);
if (! empty($options) && is_callable([$plugin, 'setOptions'])) {
$plugin->setOptions($options);
}
return $plugin;
} | php | public function getPlugin($name, array $options = [])
{
$plugin = $this->get($name);
if (! empty($options) && is_callable([$plugin, 'setOptions'])) {
$plugin->setOptions($options);
}
return $plugin;
} | [
"public",
"function",
"getPlugin",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"plugin",
",",
"'setOptions'",
"]",
")",
")",
"{",
"$",
"plugin",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"}",
"return",
"$",
"plugin",
";",
"}"
] | Gets the plugin and sets its options.
@param string $name The plugin name
@param array $options Optional; the plugin options
@return mixed The requested plugin | [
"Gets",
"the",
"plugin",
"and",
"sets",
"its",
"options",
"."
] | b1f58b0e62bb24d936aac15d34002826af7ee9b6 | https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/ControllerPlugins.php#L58-L66 |
9,555 | subins2000/Francium-Process | src/Process.php | Process.start | public function start($callback = null){
if(self::$os === "linux" || self::$os === "mac"){
return $this->startOnNix($callback);
}else if(self::$os === "windows"){
return $this->startOnWindows($callback);
}
} | php | public function start($callback = null){
if(self::$os === "linux" || self::$os === "mac"){
return $this->startOnNix($callback);
}else if(self::$os === "windows"){
return $this->startOnWindows($callback);
}
} | [
"public",
"function",
"start",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"os",
"===",
"\"linux\"",
"||",
"self",
"::",
"$",
"os",
"===",
"\"mac\"",
")",
"{",
"return",
"$",
"this",
"->",
"startOnNix",
"(",
"$",
"callback",
")",
";",
"}",
"else",
"if",
"(",
"self",
"::",
"$",
"os",
"===",
"\"windows\"",
")",
"{",
"return",
"$",
"this",
"->",
"startOnWindows",
"(",
"$",
"callback",
")",
";",
"}",
"}"
] | Callback is called when process is started | [
"Callback",
"is",
"called",
"when",
"process",
"is",
"started"
] | e38a55541679374d2658dede74e6535533184d65 | https://github.com/subins2000/Francium-Process/blob/e38a55541679374d2658dede74e6535533184d65/src/Process.php#L82-L88 |
9,556 | nours/TableBundle | Extension/DoctrineORMExtension.php | DoctrineORMExtension.resolveFieldOption | protected function resolveFieldOption(array $fields, $option, $expected = true)
{
foreach ($fields as $field) {
if ($field->getOption($option) === $expected) {
return $expected;
}
}
return null;
} | php | protected function resolveFieldOption(array $fields, $option, $expected = true)
{
foreach ($fields as $field) {
if ($field->getOption($option) === $expected) {
return $expected;
}
}
return null;
} | [
"protected",
"function",
"resolveFieldOption",
"(",
"array",
"$",
"fields",
",",
"$",
"option",
",",
"$",
"expected",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"getOption",
"(",
"$",
"option",
")",
"===",
"$",
"expected",
")",
"{",
"return",
"$",
"expected",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Resolves option from fields
@param FieldInterface[] $fields
@param $option
@param mixed $expected
@return mixed | [
"Resolves",
"option",
"from",
"fields"
] | 0fb5bd7cc13008fb7890037b1a1ccb02d047c329 | https://github.com/nours/TableBundle/blob/0fb5bd7cc13008fb7890037b1a1ccb02d047c329/Extension/DoctrineORMExtension.php#L212-L221 |
9,557 | nours/TableBundle | Extension/DoctrineORMExtension.php | DoctrineORMExtension.orderQueryBuilderBy | private function orderQueryBuilderBy(QueryBuilder $queryBuilder, TableInterface $table, $sort)
{
if (!is_array($sort)) {
$sort = array($sort => $table->getOption('order', 'DESC'));
}
foreach ($sort as $fieldName => $order) {
// Check field is sortable
$field = $table->getField($fieldName);
if (!$field->getOption('sortable')) {
throw new InvalidArgumentException("Field $fieldName is not sortable in table " . $table->getName());
}
foreach ((array)$field->getOption('order_path') as $orderBy) {
$queryBuilder->addOrderBy($this->fixQueryPath($orderBy, $field), $order);
}
}
} | php | private function orderQueryBuilderBy(QueryBuilder $queryBuilder, TableInterface $table, $sort)
{
if (!is_array($sort)) {
$sort = array($sort => $table->getOption('order', 'DESC'));
}
foreach ($sort as $fieldName => $order) {
// Check field is sortable
$field = $table->getField($fieldName);
if (!$field->getOption('sortable')) {
throw new InvalidArgumentException("Field $fieldName is not sortable in table " . $table->getName());
}
foreach ((array)$field->getOption('order_path') as $orderBy) {
$queryBuilder->addOrderBy($this->fixQueryPath($orderBy, $field), $order);
}
}
} | [
"private",
"function",
"orderQueryBuilderBy",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"TableInterface",
"$",
"table",
",",
"$",
"sort",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"sort",
")",
")",
"{",
"$",
"sort",
"=",
"array",
"(",
"$",
"sort",
"=>",
"$",
"table",
"->",
"getOption",
"(",
"'order'",
",",
"'DESC'",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"sort",
"as",
"$",
"fieldName",
"=>",
"$",
"order",
")",
"{",
"// Check field is sortable",
"$",
"field",
"=",
"$",
"table",
"->",
"getField",
"(",
"$",
"fieldName",
")",
";",
"if",
"(",
"!",
"$",
"field",
"->",
"getOption",
"(",
"'sortable'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Field $fieldName is not sortable in table \"",
".",
"$",
"table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"field",
"->",
"getOption",
"(",
"'order_path'",
")",
"as",
"$",
"orderBy",
")",
"{",
"$",
"queryBuilder",
"->",
"addOrderBy",
"(",
"$",
"this",
"->",
"fixQueryPath",
"(",
"$",
"orderBy",
",",
"$",
"field",
")",
",",
"$",
"order",
")",
";",
"}",
"}",
"}"
] | Sets the order by
@param QueryBuilder $queryBuilder
@param TableInterface $table
@param $sort | [
"Sets",
"the",
"order",
"by"
] | 0fb5bd7cc13008fb7890037b1a1ccb02d047c329 | https://github.com/nours/TableBundle/blob/0fb5bd7cc13008fb7890037b1a1ccb02d047c329/Extension/DoctrineORMExtension.php#L385-L402 |
9,558 | nours/TableBundle | Extension/DoctrineORMExtension.php | DoctrineORMExtension.fieldFilter | public function fieldFilter(QueryBuilder $queryBuilder, FieldInterface $field, $value)
{
if ($value) {
$name = $field->getName();
$path = $field->getOption('association_path');
/**
* Handle array or collections of items
*/
if (is_array($value) || $value instanceof \Traversable) {
$expr = $queryBuilder->expr()->orX();
foreach ($value as $index => $v) {
$param = 'filter_' . $name . '_' . $index;
$queryBuilder->setParameter($param, $v);
if (is_object($v)) {
$expr->add(":$param MEMBER OF $path");
} else {
$expr->add("$path = :$param");
}
}
$queryBuilder->andWhere($expr);
} else {
/**
* Single value filter.
*/
$operator = $field->getOption('filter_operator');
$comparison = new Query\Expr\Comparison($path, $operator, ':filter_' . $name);
// Fix LIKE operators value (append and prepend %)
// todo : parameterize this ?
if ($operator == 'LIKE' || $operator == 'NOT LIKE') {
$value = '%' . $value . '%';
}
$queryBuilder
->andWhere($comparison)
->setParameter('filter_' . $name, $value)
;
}
}
} | php | public function fieldFilter(QueryBuilder $queryBuilder, FieldInterface $field, $value)
{
if ($value) {
$name = $field->getName();
$path = $field->getOption('association_path');
/**
* Handle array or collections of items
*/
if (is_array($value) || $value instanceof \Traversable) {
$expr = $queryBuilder->expr()->orX();
foreach ($value as $index => $v) {
$param = 'filter_' . $name . '_' . $index;
$queryBuilder->setParameter($param, $v);
if (is_object($v)) {
$expr->add(":$param MEMBER OF $path");
} else {
$expr->add("$path = :$param");
}
}
$queryBuilder->andWhere($expr);
} else {
/**
* Single value filter.
*/
$operator = $field->getOption('filter_operator');
$comparison = new Query\Expr\Comparison($path, $operator, ':filter_' . $name);
// Fix LIKE operators value (append and prepend %)
// todo : parameterize this ?
if ($operator == 'LIKE' || $operator == 'NOT LIKE') {
$value = '%' . $value . '%';
}
$queryBuilder
->andWhere($comparison)
->setParameter('filter_' . $name, $value)
;
}
}
} | [
"public",
"function",
"fieldFilter",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"FieldInterface",
"$",
"field",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"$",
"field",
"->",
"getName",
"(",
")",
";",
"$",
"path",
"=",
"$",
"field",
"->",
"getOption",
"(",
"'association_path'",
")",
";",
"/**\n * Handle array or collections of items\n */",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"expr",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"index",
"=>",
"$",
"v",
")",
"{",
"$",
"param",
"=",
"'filter_'",
".",
"$",
"name",
".",
"'_'",
".",
"$",
"index",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"$",
"param",
",",
"$",
"v",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"v",
")",
")",
"{",
"$",
"expr",
"->",
"add",
"(",
"\":$param MEMBER OF $path\"",
")",
";",
"}",
"else",
"{",
"$",
"expr",
"->",
"add",
"(",
"\"$path = :$param\"",
")",
";",
"}",
"}",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"expr",
")",
";",
"}",
"else",
"{",
"/**\n * Single value filter.\n */",
"$",
"operator",
"=",
"$",
"field",
"->",
"getOption",
"(",
"'filter_operator'",
")",
";",
"$",
"comparison",
"=",
"new",
"Query",
"\\",
"Expr",
"\\",
"Comparison",
"(",
"$",
"path",
",",
"$",
"operator",
",",
"':filter_'",
".",
"$",
"name",
")",
";",
"// Fix LIKE operators value (append and prepend %)",
"// todo : parameterize this ?",
"if",
"(",
"$",
"operator",
"==",
"'LIKE'",
"||",
"$",
"operator",
"==",
"'NOT LIKE'",
")",
"{",
"$",
"value",
"=",
"'%'",
".",
"$",
"value",
".",
"'%'",
";",
"}",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"comparison",
")",
"->",
"setParameter",
"(",
"'filter_'",
".",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Default field filter implementation.
@param QueryBuilder $queryBuilder
@param FieldInterface $field
@param $value | [
"Default",
"field",
"filter",
"implementation",
"."
] | 0fb5bd7cc13008fb7890037b1a1ccb02d047c329 | https://github.com/nours/TableBundle/blob/0fb5bd7cc13008fb7890037b1a1ccb02d047c329/Extension/DoctrineORMExtension.php#L446-L489 |
9,559 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.floatalize | public static function floatalize($value)
{
$value = strtoupper($value);
if (strpos($value, 'E') === false) {
return $value;
}
$number = substr($value, 0, strpos($value, 'E'));
if (strpos($number, '.') !== false) {
$post = strlen(substr($number, strpos($number, '.') + 1));
$mantis = substr($value, strpos($value, 'E') + 1);
if ($mantis < 0) {
$post += abs((int) $mantis);
}
$value = number_format($value, $post, '.', '');
} else {
$value = number_format($value, 0, '.', '');
}
return $value;
} | php | public static function floatalize($value)
{
$value = strtoupper($value);
if (strpos($value, 'E') === false) {
return $value;
}
$number = substr($value, 0, strpos($value, 'E'));
if (strpos($number, '.') !== false) {
$post = strlen(substr($number, strpos($number, '.') + 1));
$mantis = substr($value, strpos($value, 'E') + 1);
if ($mantis < 0) {
$post += abs((int) $mantis);
}
$value = number_format($value, $post, '.', '');
} else {
$value = number_format($value, 0, '.', '');
}
return $value;
} | [
"public",
"static",
"function",
"floatalize",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'E'",
")",
"===",
"false",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"number",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"strpos",
"(",
"$",
"value",
",",
"'E'",
")",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"number",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"post",
"=",
"strlen",
"(",
"substr",
"(",
"$",
"number",
",",
"strpos",
"(",
"$",
"number",
",",
"'.'",
")",
"+",
"1",
")",
")",
";",
"$",
"mantis",
"=",
"substr",
"(",
"$",
"value",
",",
"strpos",
"(",
"$",
"value",
",",
"'E'",
")",
"+",
"1",
")",
";",
"if",
"(",
"$",
"mantis",
"<",
"0",
")",
"{",
"$",
"post",
"+=",
"abs",
"(",
"(",
"int",
")",
"$",
"mantis",
")",
";",
"}",
"$",
"value",
"=",
"number_format",
"(",
"$",
"value",
",",
"$",
"post",
",",
"'.'",
",",
"''",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"number_format",
"(",
"$",
"value",
",",
"0",
",",
"'.'",
",",
"''",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Convert a scientific notation to float
Additionally fixed a problem with PHP <= 5.2.x with big integers
@param string $value | [
"Convert",
"a",
"scientific",
"notation",
"to",
"float",
"Additionally",
"fixed",
"a",
"problem",
"with",
"PHP",
"<",
"=",
"5",
".",
"2",
".",
"x",
"with",
"big",
"integers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L144-L165 |
9,560 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.normalize | public static function normalize($value)
{
$convert = localeconv();
$value = str_replace($convert['thousands_sep'], "",(string) $value);
$value = str_replace($convert['positive_sign'], "", $value);
$value = str_replace($convert['decimal_point'], ".",$value);
if (!empty($convert['negative_sign']) and (strpos($value, $convert['negative_sign']))) {
$value = str_replace($convert['negative_sign'], "", $value);
$value = "-" . $value;
}
return $value;
} | php | public static function normalize($value)
{
$convert = localeconv();
$value = str_replace($convert['thousands_sep'], "",(string) $value);
$value = str_replace($convert['positive_sign'], "", $value);
$value = str_replace($convert['decimal_point'], ".",$value);
if (!empty($convert['negative_sign']) and (strpos($value, $convert['negative_sign']))) {
$value = str_replace($convert['negative_sign'], "", $value);
$value = "-" . $value;
}
return $value;
} | [
"public",
"static",
"function",
"normalize",
"(",
"$",
"value",
")",
"{",
"$",
"convert",
"=",
"localeconv",
"(",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"convert",
"[",
"'thousands_sep'",
"]",
",",
"\"\"",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"convert",
"[",
"'positive_sign'",
"]",
",",
"\"\"",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"convert",
"[",
"'decimal_point'",
"]",
",",
"\".\"",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"convert",
"[",
"'negative_sign'",
"]",
")",
"and",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"convert",
"[",
"'negative_sign'",
"]",
")",
")",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"convert",
"[",
"'negative_sign'",
"]",
",",
"\"\"",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"\"-\"",
".",
"$",
"value",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Normalizes an input to standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
@param integer $value Value to normalize
@return string Normalized string without BCMath problems | [
"Normalizes",
"an",
"input",
"to",
"standard",
"english",
"notation",
"Fixes",
"a",
"problem",
"of",
"BCMath",
"with",
"setLocale",
"which",
"is",
"PHP",
"related"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L174-L186 |
9,561 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.localize | public static function localize($value)
{
$convert = localeconv();
$value = str_replace(".", $convert['decimal_point'], (string) $value);
if (!empty($convert['negative_sign']) and (strpos($value, "-"))) {
$value = str_replace("-", $convert['negative_sign'], $value);
}
return $value;
} | php | public static function localize($value)
{
$convert = localeconv();
$value = str_replace(".", $convert['decimal_point'], (string) $value);
if (!empty($convert['negative_sign']) and (strpos($value, "-"))) {
$value = str_replace("-", $convert['negative_sign'], $value);
}
return $value;
} | [
"public",
"static",
"function",
"localize",
"(",
"$",
"value",
")",
"{",
"$",
"convert",
"=",
"localeconv",
"(",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"\".\"",
",",
"$",
"convert",
"[",
"'decimal_point'",
"]",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"convert",
"[",
"'negative_sign'",
"]",
")",
"and",
"(",
"strpos",
"(",
"$",
"value",
",",
"\"-\"",
")",
")",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"\"-\"",
",",
"$",
"convert",
"[",
"'negative_sign'",
"]",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Localizes an input from standard english notation
Fixes a problem of BCMath with setLocale which is PHP related
@param integer $value Value to normalize
@return string Normalized string without BCMath problems | [
"Localizes",
"an",
"input",
"from",
"standard",
"english",
"notation",
"Fixes",
"a",
"problem",
"of",
"BCMath",
"with",
"setLocale",
"which",
"is",
"PHP",
"related"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L195-L203 |
9,562 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.exponent | public static function exponent($value, $scale = null)
{
if (!extension_loaded('bcmath')) {
return $value;
}
$split = explode('e', $value);
if (count($split) == 1) {
$split = explode('E', $value);
}
if (count($split) > 1) {
$value = bcmul($split[0], bcpow(10, $split[1], $scale), $scale);
}
return $value;
} | php | public static function exponent($value, $scale = null)
{
if (!extension_loaded('bcmath')) {
return $value;
}
$split = explode('e', $value);
if (count($split) == 1) {
$split = explode('E', $value);
}
if (count($split) > 1) {
$value = bcmul($split[0], bcpow(10, $split[1], $scale), $scale);
}
return $value;
} | [
"public",
"static",
"function",
"exponent",
"(",
"$",
"value",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"'bcmath'",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"split",
"=",
"explode",
"(",
"'e'",
",",
"$",
"value",
")",
";",
"if",
"(",
"count",
"(",
"$",
"split",
")",
"==",
"1",
")",
"{",
"$",
"split",
"=",
"explode",
"(",
"'E'",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"split",
")",
">",
"1",
")",
"{",
"$",
"value",
"=",
"bcmul",
"(",
"$",
"split",
"[",
"0",
"]",
",",
"bcpow",
"(",
"10",
",",
"$",
"split",
"[",
"1",
"]",
",",
"$",
"scale",
")",
",",
"$",
"scale",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Changes exponential numbers to plain string numbers
Fixes a problem of BCMath with numbers containing exponents
@param integer $value Value to erase the exponent
@param integer $scale (Optional) Scale to use
@return string | [
"Changes",
"exponential",
"numbers",
"to",
"plain",
"string",
"numbers",
"Fixes",
"a",
"problem",
"of",
"BCMath",
"with",
"numbers",
"containing",
"exponents"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L213-L229 |
9,563 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Add | public static function Add($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcadd($op1, $op2, $scale);
} | php | public static function Add($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcadd($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Add",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bcadd",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCAdd - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCAdd",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L239-L245 |
9,564 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Sub | public static function Sub($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcsub($op1, $op2, $scale);
} | php | public static function Sub($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcsub($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Sub",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bcsub",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCSub - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCSub",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L255-L260 |
9,565 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Pow | public static function Pow($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcpow($op1, $op2, $scale);
} | php | public static function Pow($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcpow($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Pow",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bcpow",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCPow - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCPow",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L270-L275 |
9,566 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Mul | public static function Mul($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcmul($op1, $op2, $scale);
} | php | public static function Mul($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcmul($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Mul",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bcmul",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCMul - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCMul",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L285-L290 |
9,567 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Div | public static function Div($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcdiv($op1, $op2, $scale);
} | php | public static function Div($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bcdiv($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Div",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bcdiv",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCDiv - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCDiv",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L300-L305 |
9,568 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Sqrt | public static function Sqrt($op1, $scale = null)
{
$op1 = self::exponent($op1, $scale);
return bcsqrt($op1, $scale);
} | php | public static function Sqrt($op1, $scale = null)
{
$op1 = self::exponent($op1, $scale);
return bcsqrt($op1, $scale);
} | [
"public",
"static",
"function",
"Sqrt",
"(",
"$",
"op1",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"return",
"bcsqrt",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"}"
] | BCSqrt - fixes a problem of BCMath and exponential numbers
@param string $op1
@param integer $scale
@return string | [
"BCSqrt",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L314-L318 |
9,569 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Mod | public static function Mod($op1, $op2)
{
$op1 = self::exponent($op1);
$op2 = self::exponent($op2);
return bcmod($op1, $op2);
} | php | public static function Mod($op1, $op2)
{
$op1 = self::exponent($op1);
$op2 = self::exponent($op2);
return bcmod($op1, $op2);
} | [
"public",
"static",
"function",
"Mod",
"(",
"$",
"op1",
",",
"$",
"op2",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
")",
";",
"return",
"bcmod",
"(",
"$",
"op1",
",",
"$",
"op2",
")",
";",
"}"
] | BCMod - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@return string | [
"BCMod",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L327-L332 |
9,570 | joegreen88/zf1-component-locale | src/Zend/Locale/Math.php | Zend_Locale_Math.Comp | public static function Comp($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bccomp($op1, $op2, $scale);
} | php | public static function Comp($op1, $op2, $scale = null)
{
$op1 = self::exponent($op1, $scale);
$op2 = self::exponent($op2, $scale);
return bccomp($op1, $op2, $scale);
} | [
"public",
"static",
"function",
"Comp",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"$",
"op1",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op1",
",",
"$",
"scale",
")",
";",
"$",
"op2",
"=",
"self",
"::",
"exponent",
"(",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"return",
"bccomp",
"(",
"$",
"op1",
",",
"$",
"op2",
",",
"$",
"scale",
")",
";",
"}"
] | BCComp - fixes a problem of BCMath and exponential numbers
@param string $op1
@param string $op2
@param integer $scale
@return string | [
"BCComp",
"-",
"fixes",
"a",
"problem",
"of",
"BCMath",
"and",
"exponential",
"numbers"
] | 2e8dab3c9a1878f91ff2b934716638f4eb2e7f94 | https://github.com/joegreen88/zf1-component-locale/blob/2e8dab3c9a1878f91ff2b934716638f4eb2e7f94/src/Zend/Locale/Math.php#L342-L347 |
9,571 | scholtz/AsyncWeb | src/AsyncWeb/Api/REST/DB.php | DB.qbr | public function qbr($table, $mixed = array()) {
$mixed["Limit"] = 1;
$res = $this->qb($table, $mixed);
while ($row = DB::f($res)) {
return $row;
}
return false;
} | php | public function qbr($table, $mixed = array()) {
$mixed["Limit"] = 1;
$res = $this->qb($table, $mixed);
while ($row = DB::f($res)) {
return $row;
}
return false;
} | [
"public",
"function",
"qbr",
"(",
"$",
"table",
",",
"$",
"mixed",
"=",
"array",
"(",
")",
")",
"{",
"$",
"mixed",
"[",
"\"Limit\"",
"]",
"=",
"1",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"qb",
"(",
"$",
"table",
",",
"$",
"mixed",
")",
";",
"while",
"(",
"$",
"row",
"=",
"DB",
"::",
"f",
"(",
"$",
"res",
")",
")",
"{",
"return",
"$",
"row",
";",
"}",
"return",
"false",
";",
"}"
] | Returns one row from Query Builder | [
"Returns",
"one",
"row",
"from",
"Query",
"Builder"
] | 66a906298080c2c66d8f0fb85211b6100b3776bf | https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Api/REST/DB.php#L242-L249 |
9,572 | scholtz/AsyncWeb | src/AsyncWeb/Api/REST/DB.php | DB.get | public function get($table, $where = array(), $offset = null, $count = null, $time = null, $order = array(), $od = "ValidFrom", $do = "ValidUntil", $id2 = "ID", $cols = array(), $groupby = array(), $having = array(), $distinct = false, $fast = false) {
$data = array("QueryBuilder" => array("Where" => $where, "Offset" => $offset, "Limit" => $count, "Time" => $time, "Sort" => $order, "Cols" => $cols, "GroupBy" => $groupby, "Having" => $having, "Distinct" => $distinct));
$data["ApiKeySession"] = $this->Session;
$data["CRC"] = Client::MakeCRC($data, $this->ApiPass);
try {
$results = Client::Call($this->Server . "/" . $table . "/Request", $data);
return new APIResult($results);
}
catch(\Exception $exc) {
$this->lastError = $exc->getMessage();
if (self::$DEBUG_CRC) {
if (strpos($this->lastError, "CRC does not match")) {
$add = "Request failed! Client data: ";
$add.= \AsyncWeb\Api\REST\Client::MakeHashString($data);
$add.= " CRC: " . Client::MakeCRC($data, $this->ApiPass);
$this->lastError.= "<br>\n" . $add;
}
}
return false;
}
} | php | public function get($table, $where = array(), $offset = null, $count = null, $time = null, $order = array(), $od = "ValidFrom", $do = "ValidUntil", $id2 = "ID", $cols = array(), $groupby = array(), $having = array(), $distinct = false, $fast = false) {
$data = array("QueryBuilder" => array("Where" => $where, "Offset" => $offset, "Limit" => $count, "Time" => $time, "Sort" => $order, "Cols" => $cols, "GroupBy" => $groupby, "Having" => $having, "Distinct" => $distinct));
$data["ApiKeySession"] = $this->Session;
$data["CRC"] = Client::MakeCRC($data, $this->ApiPass);
try {
$results = Client::Call($this->Server . "/" . $table . "/Request", $data);
return new APIResult($results);
}
catch(\Exception $exc) {
$this->lastError = $exc->getMessage();
if (self::$DEBUG_CRC) {
if (strpos($this->lastError, "CRC does not match")) {
$add = "Request failed! Client data: ";
$add.= \AsyncWeb\Api\REST\Client::MakeHashString($data);
$add.= " CRC: " . Client::MakeCRC($data, $this->ApiPass);
$this->lastError.= "<br>\n" . $add;
}
}
return false;
}
} | [
"public",
"function",
"get",
"(",
"$",
"table",
",",
"$",
"where",
"=",
"array",
"(",
")",
",",
"$",
"offset",
"=",
"null",
",",
"$",
"count",
"=",
"null",
",",
"$",
"time",
"=",
"null",
",",
"$",
"order",
"=",
"array",
"(",
")",
",",
"$",
"od",
"=",
"\"ValidFrom\"",
",",
"$",
"do",
"=",
"\"ValidUntil\"",
",",
"$",
"id2",
"=",
"\"ID\"",
",",
"$",
"cols",
"=",
"array",
"(",
")",
",",
"$",
"groupby",
"=",
"array",
"(",
")",
",",
"$",
"having",
"=",
"array",
"(",
")",
",",
"$",
"distinct",
"=",
"false",
",",
"$",
"fast",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"\"QueryBuilder\"",
"=>",
"array",
"(",
"\"Where\"",
"=>",
"$",
"where",
",",
"\"Offset\"",
"=>",
"$",
"offset",
",",
"\"Limit\"",
"=>",
"$",
"count",
",",
"\"Time\"",
"=>",
"$",
"time",
",",
"\"Sort\"",
"=>",
"$",
"order",
",",
"\"Cols\"",
"=>",
"$",
"cols",
",",
"\"GroupBy\"",
"=>",
"$",
"groupby",
",",
"\"Having\"",
"=>",
"$",
"having",
",",
"\"Distinct\"",
"=>",
"$",
"distinct",
")",
")",
";",
"$",
"data",
"[",
"\"ApiKeySession\"",
"]",
"=",
"$",
"this",
"->",
"Session",
";",
"$",
"data",
"[",
"\"CRC\"",
"]",
"=",
"Client",
"::",
"MakeCRC",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"ApiPass",
")",
";",
"try",
"{",
"$",
"results",
"=",
"Client",
"::",
"Call",
"(",
"$",
"this",
"->",
"Server",
".",
"\"/\"",
".",
"$",
"table",
".",
"\"/Request\"",
",",
"$",
"data",
")",
";",
"return",
"new",
"APIResult",
"(",
"$",
"results",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exc",
")",
"{",
"$",
"this",
"->",
"lastError",
"=",
"$",
"exc",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"self",
"::",
"$",
"DEBUG_CRC",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"lastError",
",",
"\"CRC does not match\"",
")",
")",
"{",
"$",
"add",
"=",
"\"Request failed! Client data: \"",
";",
"$",
"add",
".=",
"\\",
"AsyncWeb",
"\\",
"Api",
"\\",
"REST",
"\\",
"Client",
"::",
"MakeHashString",
"(",
"$",
"data",
")",
";",
"$",
"add",
".=",
"\" CRC: \"",
".",
"Client",
"::",
"MakeCRC",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"ApiPass",
")",
";",
"$",
"this",
"->",
"lastError",
".=",
"\"<br>\\n\"",
".",
"$",
"add",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}"
] | Returns the resource object for the result. Please use fetch method to get the result for each row.
@return APIResult Result of the query | [
"Returns",
"the",
"resource",
"object",
"for",
"the",
"result",
".",
"Please",
"use",
"fetch",
"method",
"to",
"get",
"the",
"result",
"for",
"each",
"row",
"."
] | 66a906298080c2c66d8f0fb85211b6100b3776bf | https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Api/REST/DB.php#L290-L310 |
9,573 | bashilbers/domain | src/Snapshotting/InMemorySnapshotStore.php | InMemorySnapshotStore.save | public function save(AggregateRoot $root)
{
$snapshot = new Snapshot(
$root,
$root->getVersion(),
new \DateTime
);
$this->snapshots[(string) $root->getIdentity()][] = $snapshot;
} | php | public function save(AggregateRoot $root)
{
$snapshot = new Snapshot(
$root,
$root->getVersion(),
new \DateTime
);
$this->snapshots[(string) $root->getIdentity()][] = $snapshot;
} | [
"public",
"function",
"save",
"(",
"AggregateRoot",
"$",
"root",
")",
"{",
"$",
"snapshot",
"=",
"new",
"Snapshot",
"(",
"$",
"root",
",",
"$",
"root",
"->",
"getVersion",
"(",
")",
",",
"new",
"\\",
"DateTime",
")",
";",
"$",
"this",
"->",
"snapshots",
"[",
"(",
"string",
")",
"$",
"root",
"->",
"getIdentity",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"snapshot",
";",
"}"
] | Save given snapshot
@param AggregateRoot $root | [
"Save",
"given",
"snapshot"
] | 864736b8c409077706554b6ac4c574832678d316 | https://github.com/bashilbers/domain/blob/864736b8c409077706554b6ac4c574832678d316/src/Snapshotting/InMemorySnapshotStore.php#L42-L51 |
9,574 | leedave/codemonkey | src/Core/Folder.php | Folder.createFolderIfNotExists | public function createFolderIfNotExists($folderPath) {
if (file_exists($folderPath) && is_dir($folderPath)) {
return;
}
$arrFolder = explode(DIRECTORY_SEPARATOR, $folderPath);
$fullPath = "";
$first = true;
foreach ($arrFolder as $folder) {
if (!$folder) {
continue; //Happens if the first char is a slash
}
if (!$first) {
$fullPath .= DIRECTORY_SEPARATOR;
} else {
$first = false;
}
$fullPath .= $folder;
try {
$this->createSingleFolderIfNotExists($fullPath);
} catch (Exception $e) {
$msg = $e->getMessage();
echo "Could not generate folder '".$fullPath."' <br />\n"
. $msg
. "<br />";
}
}
} | php | public function createFolderIfNotExists($folderPath) {
if (file_exists($folderPath) && is_dir($folderPath)) {
return;
}
$arrFolder = explode(DIRECTORY_SEPARATOR, $folderPath);
$fullPath = "";
$first = true;
foreach ($arrFolder as $folder) {
if (!$folder) {
continue; //Happens if the first char is a slash
}
if (!$first) {
$fullPath .= DIRECTORY_SEPARATOR;
} else {
$first = false;
}
$fullPath .= $folder;
try {
$this->createSingleFolderIfNotExists($fullPath);
} catch (Exception $e) {
$msg = $e->getMessage();
echo "Could not generate folder '".$fullPath."' <br />\n"
. $msg
. "<br />";
}
}
} | [
"public",
"function",
"createFolderIfNotExists",
"(",
"$",
"folderPath",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"folderPath",
")",
"&&",
"is_dir",
"(",
"$",
"folderPath",
")",
")",
"{",
"return",
";",
"}",
"$",
"arrFolder",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"folderPath",
")",
";",
"$",
"fullPath",
"=",
"\"\"",
";",
"$",
"first",
"=",
"true",
";",
"foreach",
"(",
"$",
"arrFolder",
"as",
"$",
"folder",
")",
"{",
"if",
"(",
"!",
"$",
"folder",
")",
"{",
"continue",
";",
"//Happens if the first char is a slash",
"}",
"if",
"(",
"!",
"$",
"first",
")",
"{",
"$",
"fullPath",
".=",
"DIRECTORY_SEPARATOR",
";",
"}",
"else",
"{",
"$",
"first",
"=",
"false",
";",
"}",
"$",
"fullPath",
".=",
"$",
"folder",
";",
"try",
"{",
"$",
"this",
"->",
"createSingleFolderIfNotExists",
"(",
"$",
"fullPath",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"echo",
"\"Could not generate folder '\"",
".",
"$",
"fullPath",
".",
"\"' <br />\\n\"",
".",
"$",
"msg",
".",
"\"<br />\"",
";",
"}",
"}",
"}"
] | Creates a full folder path
@param string $folderPath
@return void | [
"Creates",
"a",
"full",
"folder",
"path"
] | 306f222c4329bf44d7fd7f91dade0a9594aa9243 | https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Folder.php#L21-L51 |
9,575 | leedave/codemonkey | src/Core/Folder.php | Folder.createSingleFolderIfNotExists | protected function createSingleFolderIfNotExists($fullPath) {
$tempDir = codemonkey_pathTempDir;
if (file_exists($tempDir.$fullPath) && is_dir($tempDir.$fullPath)) {
return;
}
mkdir($tempDir.$fullPath);
chmod($tempDir.$fullPath, 0775);
} | php | protected function createSingleFolderIfNotExists($fullPath) {
$tempDir = codemonkey_pathTempDir;
if (file_exists($tempDir.$fullPath) && is_dir($tempDir.$fullPath)) {
return;
}
mkdir($tempDir.$fullPath);
chmod($tempDir.$fullPath, 0775);
} | [
"protected",
"function",
"createSingleFolderIfNotExists",
"(",
"$",
"fullPath",
")",
"{",
"$",
"tempDir",
"=",
"codemonkey_pathTempDir",
";",
"if",
"(",
"file_exists",
"(",
"$",
"tempDir",
".",
"$",
"fullPath",
")",
"&&",
"is_dir",
"(",
"$",
"tempDir",
".",
"$",
"fullPath",
")",
")",
"{",
"return",
";",
"}",
"mkdir",
"(",
"$",
"tempDir",
".",
"$",
"fullPath",
")",
";",
"chmod",
"(",
"$",
"tempDir",
".",
"$",
"fullPath",
",",
"0775",
")",
";",
"}"
] | Creates a single folder
@param string $fullPath
@return void | [
"Creates",
"a",
"single",
"folder"
] | 306f222c4329bf44d7fd7f91dade0a9594aa9243 | https://github.com/leedave/codemonkey/blob/306f222c4329bf44d7fd7f91dade0a9594aa9243/src/Core/Folder.php#L59-L66 |
9,576 | ekyna/UserBundle | Extension/ExtensionRegistry.php | ExtensionRegistry.addExtension | public function addExtension(ExtensionInterface $extension)
{
if (array_key_exists($name = $extension->getName(), $this->extensions)) {
throw new \RuntimeException(sprintf('UserExtension "%s" is already registered.', $name));
}
$this->extensions[$name] = $extension;
} | php | public function addExtension(ExtensionInterface $extension)
{
if (array_key_exists($name = $extension->getName(), $this->extensions)) {
throw new \RuntimeException(sprintf('UserExtension "%s" is already registered.', $name));
}
$this->extensions[$name] = $extension;
} | [
"public",
"function",
"addExtension",
"(",
"ExtensionInterface",
"$",
"extension",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
"=",
"$",
"extension",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"extensions",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'UserExtension \"%s\" is already registered.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"extensions",
"[",
"$",
"name",
"]",
"=",
"$",
"extension",
";",
"}"
] | Adds the extension.
@param ExtensionInterface $extension | [
"Adds",
"the",
"extension",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Extension/ExtensionRegistry.php#L33-L40 |
9,577 | ekyna/UserBundle | Extension/ExtensionRegistry.php | ExtensionRegistry.getShowAdminTabs | public function getShowAdminTabs(UserInterface $user)
{
$tabs = [];
foreach ($this->extensions as $name => $extension) {
if (null !== $tab = $extension->getAdminShowTab($user)) {
$tabs[$name] = $tab;
}
}
uasort($tabs, function (ShowTabInterface $a, ShowTabInterface $b) {
if ($a->getPosition() == $b->getPosition()) {
return 0;
}
return $a->getPosition() > $b->getPosition() ? 1 : -1;
});
return $tabs;
} | php | public function getShowAdminTabs(UserInterface $user)
{
$tabs = [];
foreach ($this->extensions as $name => $extension) {
if (null !== $tab = $extension->getAdminShowTab($user)) {
$tabs[$name] = $tab;
}
}
uasort($tabs, function (ShowTabInterface $a, ShowTabInterface $b) {
if ($a->getPosition() == $b->getPosition()) {
return 0;
}
return $a->getPosition() > $b->getPosition() ? 1 : -1;
});
return $tabs;
} | [
"public",
"function",
"getShowAdminTabs",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"tabs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"extensions",
"as",
"$",
"name",
"=>",
"$",
"extension",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"tab",
"=",
"$",
"extension",
"->",
"getAdminShowTab",
"(",
"$",
"user",
")",
")",
"{",
"$",
"tabs",
"[",
"$",
"name",
"]",
"=",
"$",
"tab",
";",
"}",
"}",
"uasort",
"(",
"$",
"tabs",
",",
"function",
"(",
"ShowTabInterface",
"$",
"a",
",",
"ShowTabInterface",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getPosition",
"(",
")",
"==",
"$",
"b",
"->",
"getPosition",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"a",
"->",
"getPosition",
"(",
")",
">",
"$",
"b",
"->",
"getPosition",
"(",
")",
"?",
"1",
":",
"-",
"1",
";",
"}",
")",
";",
"return",
"$",
"tabs",
";",
"}"
] | Returns the show admin tabs.
@param UserInterface $user
@return array | [
"Returns",
"the",
"show",
"admin",
"tabs",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Extension/ExtensionRegistry.php#L58-L73 |
9,578 | ekyna/UserBundle | Extension/ExtensionRegistry.php | ExtensionRegistry.getAccountEntries | public function getAccountEntries()
{
$entries = [];
foreach ($this->extensions as $name => $extension) {
if (null !== $e = $extension->getAccountMenuEntries()) {
$entries = array_merge($entries, $e);
}
}
return $entries;
} | php | public function getAccountEntries()
{
$entries = [];
foreach ($this->extensions as $name => $extension) {
if (null !== $e = $extension->getAccountMenuEntries()) {
$entries = array_merge($entries, $e);
}
}
return $entries;
} | [
"public",
"function",
"getAccountEntries",
"(",
")",
"{",
"$",
"entries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"extensions",
"as",
"$",
"name",
"=>",
"$",
"extension",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"e",
"=",
"$",
"extension",
"->",
"getAccountMenuEntries",
"(",
")",
")",
"{",
"$",
"entries",
"=",
"array_merge",
"(",
"$",
"entries",
",",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"entries",
";",
"}"
] | Returns the account entries.
@return array | [
"Returns",
"the",
"account",
"entries",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Extension/ExtensionRegistry.php#L80-L89 |
9,579 | sebastianmonzel/webfiles-framework-php | source/core/datasystem/file/system/MFile.php | MFile.writeContent | public function writeContent($content, $overwrite = false)
{
if ($overwrite) {
$fh = fopen($this->getPath(), 'w');
} else {
$fh = fopen($this->getPath(), 'w+');
}
fwrite($fh, $content);
fclose($fh);
} | php | public function writeContent($content, $overwrite = false)
{
if ($overwrite) {
$fh = fopen($this->getPath(), 'w');
} else {
$fh = fopen($this->getPath(), 'w+');
}
fwrite($fh, $content);
fclose($fh);
} | [
"public",
"function",
"writeContent",
"(",
"$",
"content",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"overwrite",
")",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"'w'",
")",
";",
"}",
"else",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"'w+'",
")",
";",
"}",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"content",
")",
";",
"fclose",
"(",
"$",
"fh",
")",
";",
"}"
] | Writes content to harddrive.
@param string $content
@param bool $overwrite | [
"Writes",
"content",
"to",
"harddrive",
"."
] | 5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d | https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datasystem/file/system/MFile.php#L66-L76 |
9,580 | OpenBuildings/environment-backup | src/Environment_Group_Config.php | Environment_Group_Config.set | public function set($name, $value)
{
list($group, $name) = explode('.', $name, 2);
\Kohana::$config->load($group)->set($name, $value);
} | php | public function set($name, $value)
{
list($group, $name) = explode('.', $name, 2);
\Kohana::$config->load($group)->set($name, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"group",
",",
"$",
"name",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"\\",
"Kohana",
"::",
"$",
"config",
"->",
"load",
"(",
"$",
"group",
")",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | Set a kohana config variable
@param string $name
@param mixed $value | [
"Set",
"a",
"kohana",
"config",
"variable"
] | 531b220db2f6c1a9e639bcefb6cb97e16cc14629 | https://github.com/OpenBuildings/environment-backup/blob/531b220db2f6c1a9e639bcefb6cb97e16cc14629/src/Environment_Group_Config.php#L20-L25 |
9,581 | sebastianmonzel/webfiles-framework-php | source/core/datastore/types/googlecalendar/MGoogleCalendarDatastore.php | MGoogleCalendarDatastore.getWebfilesAsStream | public function getWebfilesAsStream()
{
$client = $this->getClientWithToken();
$service = new Google_Service_Calendar($client);
// Print the next 10 events on the user's calendar.
$optParams = array(
'maxResults' => 5,
'orderBy' => 'startTime',
'singleEvents' => TRUE,
'timeMin' => date('c'),
);
$results = $service->events->listEvents($this->m_sCalendarId, $optParams);
$webfiles = array();
foreach ($results->getItems() as $event) {
$webfile = $this->toWebfileEvent($event);
array_push($webfiles, $webfile);
}
return new MWebfileStream($webfiles);
} | php | public function getWebfilesAsStream()
{
$client = $this->getClientWithToken();
$service = new Google_Service_Calendar($client);
// Print the next 10 events on the user's calendar.
$optParams = array(
'maxResults' => 5,
'orderBy' => 'startTime',
'singleEvents' => TRUE,
'timeMin' => date('c'),
);
$results = $service->events->listEvents($this->m_sCalendarId, $optParams);
$webfiles = array();
foreach ($results->getItems() as $event) {
$webfile = $this->toWebfileEvent($event);
array_push($webfiles, $webfile);
}
return new MWebfileStream($webfiles);
} | [
"public",
"function",
"getWebfilesAsStream",
"(",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"getClientWithToken",
"(",
")",
";",
"$",
"service",
"=",
"new",
"Google_Service_Calendar",
"(",
"$",
"client",
")",
";",
"// Print the next 10 events on the user's calendar.",
"$",
"optParams",
"=",
"array",
"(",
"'maxResults'",
"=>",
"5",
",",
"'orderBy'",
"=>",
"'startTime'",
",",
"'singleEvents'",
"=>",
"TRUE",
",",
"'timeMin'",
"=>",
"date",
"(",
"'c'",
")",
",",
")",
";",
"$",
"results",
"=",
"$",
"service",
"->",
"events",
"->",
"listEvents",
"(",
"$",
"this",
"->",
"m_sCalendarId",
",",
"$",
"optParams",
")",
";",
"$",
"webfiles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"results",
"->",
"getItems",
"(",
")",
"as",
"$",
"event",
")",
"{",
"$",
"webfile",
"=",
"$",
"this",
"->",
"toWebfileEvent",
"(",
"$",
"event",
")",
";",
"array_push",
"(",
"$",
"webfiles",
",",
"$",
"webfile",
")",
";",
"}",
"return",
"new",
"MWebfileStream",
"(",
"$",
"webfiles",
")",
";",
"}"
] | Returns a webfiles stream with all webfiles from
the actual datastore.
@return MWebfileStream | [
"Returns",
"a",
"webfiles",
"stream",
"with",
"all",
"webfiles",
"from",
"the",
"actual",
"datastore",
"."
] | 5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d | https://github.com/sebastianmonzel/webfiles-framework-php/blob/5ac1fc99e8e9946080e3ba877b2320cd6a3e5b5d/source/core/datastore/types/googlecalendar/MGoogleCalendarDatastore.php#L58-L82 |
9,582 | studyportals/SQL | src/SQLEngineRW.php | SQLEngineRW.query | public function query($query, $return_set = false, $buffered = true){
if(strpos(ltrim($query), 'SELECT ') === 0){
return $this->_Reader->query($query, $return_set, $buffered);
}
else{
return $this->_Writer->query($query, $return_set, $buffered);
}
} | php | public function query($query, $return_set = false, $buffered = true){
if(strpos(ltrim($query), 'SELECT ') === 0){
return $this->_Reader->query($query, $return_set, $buffered);
}
else{
return $this->_Writer->query($query, $return_set, $buffered);
}
} | [
"public",
"function",
"query",
"(",
"$",
"query",
",",
"$",
"return_set",
"=",
"false",
",",
"$",
"buffered",
"=",
"true",
")",
"{",
"if",
"(",
"strpos",
"(",
"ltrim",
"(",
"$",
"query",
")",
",",
"'SELECT '",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"_Reader",
"->",
"query",
"(",
"$",
"query",
",",
"$",
"return_set",
",",
"$",
"buffered",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_Writer",
"->",
"query",
"(",
"$",
"query",
",",
"$",
"return_set",
",",
"$",
"buffered",
")",
";",
"}",
"}"
] | Send a query to the correct SQLEngine
<p>SELECT-queries are sent to the Reader-instance, all other queries are
send to the Writer-instance.</p>
@param string $query
@param boolean $return_set
@param boolean $buffered
@return SQLResult | [
"Send",
"a",
"query",
"to",
"the",
"correct",
"SQLEngine"
] | 4f038ced9a3738c1d4ad562f93547812931d9ed4 | https://github.com/studyportals/SQL/blob/4f038ced9a3738c1d4ad562f93547812931d9ed4/src/SQLEngineRW.php#L68-L78 |
9,583 | web-complete/core | src/utils/helpers/ArrayHelper.php | ArrayHelper.setValue | public static function setValue(array &$array, $path, $value)
{
if ($path === null) {
$array = $value;
return;
}
$keys = \is_array($path) ? $path : \explode('.', $path);
while (\count($keys) > 1) {
$key = \array_shift($keys);
if (!isset($array[$key])) {
$array[$key] = [];
}
if (!\is_array($array[$key])) {
$array[$key] = [$array[$key]];
}
$array = &$array[$key];
}
$array[\array_shift($keys)] = $value;
} | php | public static function setValue(array &$array, $path, $value)
{
if ($path === null) {
$array = $value;
return;
}
$keys = \is_array($path) ? $path : \explode('.', $path);
while (\count($keys) > 1) {
$key = \array_shift($keys);
if (!isset($array[$key])) {
$array[$key] = [];
}
if (!\is_array($array[$key])) {
$array[$key] = [$array[$key]];
}
$array = &$array[$key];
}
$array[\array_shift($keys)] = $value;
} | [
"public",
"static",
"function",
"setValue",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"path",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"array",
"=",
"$",
"value",
";",
"return",
";",
"}",
"$",
"keys",
"=",
"\\",
"is_array",
"(",
"$",
"path",
")",
"?",
"$",
"path",
":",
"\\",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"while",
"(",
"\\",
"count",
"(",
"$",
"keys",
")",
">",
"1",
")",
"{",
"$",
"key",
"=",
"\\",
"array_shift",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"$",
"array",
"[",
"$",
"key",
"]",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"array",
"[",
"\\",
"array_shift",
"(",
"$",
"keys",
")",
"]",
"=",
"$",
"value",
";",
"}"
] | Writes a value into an associative array at the key path specified.
If there is no such key path yet, it will be created recursively.
If the key exists, it will be overwritten.
```php
$array = [
'key' => [
'in' => [
'val1',
'key' => 'val'
]
]
];
```
The result of `ArrayHelper::setValue($array, 'key.in.0', ['arr' => 'val']);` will be the following:
```php
[
'key' => [
'in' => [
['arr' => 'val'],
'key' => 'val'
]
]
]
```
The result of
`ArrayHelper::setValue($array, 'key.in', ['arr' => 'val']);` or
`ArrayHelper::setValue($array, ['key', 'in'], ['arr' => 'val']);`
will be the following:
```php
[
'key' => [
'in' => [
'arr' => 'val'
]
]
]
```
@param array $array the array to write the value to
@param string|array|null $path the path of where do you want to write a value to `$array`
the path can be described by a string when each key should be separated by a dot
you can also describe the path as an array of keys
if the path is null then `$array` will be assigned the `$value`
@param mixed $value the value to be written
@since 2.0.13 | [
"Writes",
"a",
"value",
"into",
"an",
"associative",
"array",
"at",
"the",
"key",
"path",
"specified",
".",
"If",
"there",
"is",
"no",
"such",
"key",
"path",
"yet",
"it",
"will",
"be",
"created",
"recursively",
".",
"If",
"the",
"key",
"exists",
"it",
"will",
"be",
"overwritten",
"."
] | d6ccb7847a5aa084eccc547bb77fc3e70bac41c8 | https://github.com/web-complete/core/blob/d6ccb7847a5aa084eccc547bb77fc3e70bac41c8/src/utils/helpers/ArrayHelper.php#L135-L156 |
9,584 | douyacun/dyc-pay | src/Gateways/Alipay.php | Alipay.verify | public function verify($content = null, $refund = false): Collection
{
$request = Request::createFromGlobals();
$data = $request->request->count() > 0 ? $request->request->all() : $request->query->all();
$data = Support::encoding($data, 'utf-8', $data['charset'] ?? 'gb2312');
Log::debug('Receive Alipay Request:', $data);
if (Support::verifySign($data, $this->config->get('ali_public_key'))) {
return new Collection($data);
}
Log::warning('Alipay Sign Verify FAILED', $data);
throw new InvalidSignException('Alipay Sign Verify FAILED', $data);
} | php | public function verify($content = null, $refund = false): Collection
{
$request = Request::createFromGlobals();
$data = $request->request->count() > 0 ? $request->request->all() : $request->query->all();
$data = Support::encoding($data, 'utf-8', $data['charset'] ?? 'gb2312');
Log::debug('Receive Alipay Request:', $data);
if (Support::verifySign($data, $this->config->get('ali_public_key'))) {
return new Collection($data);
}
Log::warning('Alipay Sign Verify FAILED', $data);
throw new InvalidSignException('Alipay Sign Verify FAILED', $data);
} | [
"public",
"function",
"verify",
"(",
"$",
"content",
"=",
"null",
",",
"$",
"refund",
"=",
"false",
")",
":",
"Collection",
"{",
"$",
"request",
"=",
"Request",
"::",
"createFromGlobals",
"(",
")",
";",
"$",
"data",
"=",
"$",
"request",
"->",
"request",
"->",
"count",
"(",
")",
">",
"0",
"?",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
":",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
";",
"$",
"data",
"=",
"Support",
"::",
"encoding",
"(",
"$",
"data",
",",
"'utf-8'",
",",
"$",
"data",
"[",
"'charset'",
"]",
"??",
"'gb2312'",
")",
";",
"Log",
"::",
"debug",
"(",
"'Receive Alipay Request:'",
",",
"$",
"data",
")",
";",
"if",
"(",
"Support",
"::",
"verifySign",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'ali_public_key'",
")",
")",
")",
"{",
"return",
"new",
"Collection",
"(",
"$",
"data",
")",
";",
"}",
"Log",
"::",
"warning",
"(",
"'Alipay Sign Verify FAILED'",
",",
"$",
"data",
")",
";",
"throw",
"new",
"InvalidSignException",
"(",
"'Alipay Sign Verify FAILED'",
",",
"$",
"data",
")",
";",
"}"
] | Verfiy sign.
@author yansongda <[email protected]>
@return Collection | [
"Verfiy",
"sign",
"."
] | 9fac85d375bdd52b872c3fa8174920e40609f6f2 | https://github.com/douyacun/dyc-pay/blob/9fac85d375bdd52b872c3fa8174920e40609f6f2/src/Gateways/Alipay.php#L107-L124 |
9,585 | benkle-libs/feed-parser | src/Traits/WithFeedItemsTrait.php | WithFeedItemsTrait.removeItem | public function removeItem(ItemInterface $item)
{
foreach ($this->feedItems as $i => $feedItem) {
if ($feedItem == $item) {
unset($this->feedItems[$i]);
}
}
$this->feedItems = array_values($this->feedItems);
return $this;
} | php | public function removeItem(ItemInterface $item)
{
foreach ($this->feedItems as $i => $feedItem) {
if ($feedItem == $item) {
unset($this->feedItems[$i]);
}
}
$this->feedItems = array_values($this->feedItems);
return $this;
} | [
"public",
"function",
"removeItem",
"(",
"ItemInterface",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"feedItems",
"as",
"$",
"i",
"=>",
"$",
"feedItem",
")",
"{",
"if",
"(",
"$",
"feedItem",
"==",
"$",
"item",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"feedItems",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"feedItems",
"=",
"array_values",
"(",
"$",
"this",
"->",
"feedItems",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove an item from the feed.
@param ItemInterface $item
@return $this | [
"Remove",
"an",
"item",
"from",
"the",
"feed",
"."
] | 8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f | https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Traits/WithFeedItemsTrait.php#L45-L54 |
9,586 | samurai-fw/samurai | src/Onikiri/Database.php | Database.getUser | public function getUser()
{
if ($this->isSlave() && ! $this->user) {
return $this->_master->getUser();
}
return $this->user;
} | php | public function getUser()
{
if ($this->isSlave() && ! $this->user) {
return $this->_master->getUser();
}
return $this->user;
} | [
"public",
"function",
"getUser",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSlave",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"_master",
"->",
"getUser",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"user",
";",
"}"
] | Get user.
@return string | [
"Get",
"user",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Database.php#L220-L226 |
9,587 | samurai-fw/samurai | src/Onikiri/Database.php | Database.getPort | public function getPort()
{
if ($this->isSlave() && ! $this->port) {
return $this->_master->getPort();
}
return $this->port;
} | php | public function getPort()
{
if ($this->isSlave() && ! $this->port) {
return $this->_master->getPort();
}
return $this->port;
} | [
"public",
"function",
"getPort",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSlave",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"port",
")",
"{",
"return",
"$",
"this",
"->",
"_master",
"->",
"getPort",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"port",
";",
"}"
] | Get port number.
@return int | [
"Get",
"port",
"number",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Database.php#L259-L265 |
9,588 | samurai-fw/samurai | src/Onikiri/Database.php | Database.getDatabaseName | public function getDatabaseName()
{
if ($this->isSlave() && ! $this->database_name) {
return $this->_master->getDatabaseName();
}
// sqlite data file
if ($this->driver instanceof SqliteDriver) {
if ($this->isUseMemory()) {
return ':memory:';
}
if ($this->database_dir && $this->database_name[0] !== '/') {
return $this->database_dir . '/' . $this->database_name;
}
}
return $this->database_name;
} | php | public function getDatabaseName()
{
if ($this->isSlave() && ! $this->database_name) {
return $this->_master->getDatabaseName();
}
// sqlite data file
if ($this->driver instanceof SqliteDriver) {
if ($this->isUseMemory()) {
return ':memory:';
}
if ($this->database_dir && $this->database_name[0] !== '/') {
return $this->database_dir . '/' . $this->database_name;
}
}
return $this->database_name;
} | [
"public",
"function",
"getDatabaseName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSlave",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"database_name",
")",
"{",
"return",
"$",
"this",
"->",
"_master",
"->",
"getDatabaseName",
"(",
")",
";",
"}",
"// sqlite data file",
"if",
"(",
"$",
"this",
"->",
"driver",
"instanceof",
"SqliteDriver",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUseMemory",
"(",
")",
")",
"{",
"return",
"':memory:'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"database_dir",
"&&",
"$",
"this",
"->",
"database_name",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"return",
"$",
"this",
"->",
"database_dir",
".",
"'/'",
".",
"$",
"this",
"->",
"database_name",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"database_name",
";",
"}"
] | Get database name.
@return string | [
"Get",
"database",
"name",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Database.php#L273-L290 |
9,589 | samurai-fw/samurai | src/Onikiri/Database.php | Database.addSlave | public function addSlave(array $setting)
{
$database = new Database($setting);
$database->setMaster($this);
$this->_slaves[] = $database;
} | php | public function addSlave(array $setting)
{
$database = new Database($setting);
$database->setMaster($this);
$this->_slaves[] = $database;
} | [
"public",
"function",
"addSlave",
"(",
"array",
"$",
"setting",
")",
"{",
"$",
"database",
"=",
"new",
"Database",
"(",
"$",
"setting",
")",
";",
"$",
"database",
"->",
"setMaster",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"_slaves",
"[",
"]",
"=",
"$",
"database",
";",
"}"
] | Add slave.
@param array $setting | [
"Add",
"slave",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Database.php#L313-L318 |
9,590 | Niirrty/Niirrty.Core | src/ArrayHelper.php | ArrayHelper.IsSingleDepth | public static function IsSingleDepth( array $array ) : bool
{
if ( \count( $array ) < 1 )
{
return false;
}
foreach ( $array as $v )
{
if ( \is_array( $v ) && \count( $v ) > 0 )
{
return false;
}
}
return true;
} | php | public static function IsSingleDepth( array $array ) : bool
{
if ( \count( $array ) < 1 )
{
return false;
}
foreach ( $array as $v )
{
if ( \is_array( $v ) && \count( $v ) > 0 )
{
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"IsSingleDepth",
"(",
"array",
"$",
"array",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"array",
")",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"array",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"v",
")",
"&&",
"\\",
"count",
"(",
"$",
"v",
")",
">",
"0",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns if array has only a depth of 1 level.
@param array $array The array to check
@return bool | [
"Returns",
"if",
"array",
"has",
"only",
"a",
"depth",
"of",
"1",
"level",
"."
] | 6faede6ea051b42e8eb776cfa05808d5978cd730 | https://github.com/Niirrty/Niirrty.Core/blob/6faede6ea051b42e8eb776cfa05808d5978cd730/src/ArrayHelper.php#L417-L435 |
9,591 | soloproyectos-php/array | src/arr/Arr.php | Arr.add | public static function add(&$arr, $obj, $prepend = false)
{
if ($prepend) {
array_unshift($arr, $obj);
} else {
array_push($arr, $obj);
}
return $arr;
} | php | public static function add(&$arr, $obj, $prepend = false)
{
if ($prepend) {
array_unshift($arr, $obj);
} else {
array_push($arr, $obj);
}
return $arr;
} | [
"public",
"static",
"function",
"add",
"(",
"&",
"$",
"arr",
",",
"$",
"obj",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"arr",
",",
"$",
"obj",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"arr",
",",
"$",
"obj",
")",
";",
"}",
"return",
"$",
"arr",
";",
"}"
] | Appends or prepends an object into an array.
@param array $arr Array object (passed by reference)
@param mixed $obj Object
@param boolean $prepend Inserts at the beginning (default is false)
@return array | [
"Appends",
"or",
"prepends",
"an",
"object",
"into",
"an",
"array",
"."
] | de38c800f3388005cbd37e70ab055f22609a5eae | https://github.com/soloproyectos-php/array/blob/de38c800f3388005cbd37e70ab055f22609a5eae/src/arr/Arr.php#L88-L97 |
9,592 | soloproyectos-php/array | src/arr/Arr.php | Arr.fetch | public static function fetch($arr, $descriptors)
{
$args = new ArrArguments($arr);
foreach ($descriptors as $name => $descriptor) {
$types = array();
$default = null;
$required = false;
if (is_string($descriptor)) {
$types = explode("|", $descriptor);
} elseif (is_array($descriptor)) {
$types = explode("|", Arr::get($descriptor, "type"));
$default = Arr::get($descriptor, "default");
$required = Arr::get(
$descriptor, "required", !Arr::exist($descriptor, "default")
);
}
$desc = new ArrArgumentsDescriptor($types, $default, $required);
$args->registerDescriptor($name, $desc);
}
return $args->fetch();
} | php | public static function fetch($arr, $descriptors)
{
$args = new ArrArguments($arr);
foreach ($descriptors as $name => $descriptor) {
$types = array();
$default = null;
$required = false;
if (is_string($descriptor)) {
$types = explode("|", $descriptor);
} elseif (is_array($descriptor)) {
$types = explode("|", Arr::get($descriptor, "type"));
$default = Arr::get($descriptor, "default");
$required = Arr::get(
$descriptor, "required", !Arr::exist($descriptor, "default")
);
}
$desc = new ArrArgumentsDescriptor($types, $default, $required);
$args->registerDescriptor($name, $desc);
}
return $args->fetch();
} | [
"public",
"static",
"function",
"fetch",
"(",
"$",
"arr",
",",
"$",
"descriptors",
")",
"{",
"$",
"args",
"=",
"new",
"ArrArguments",
"(",
"$",
"arr",
")",
";",
"foreach",
"(",
"$",
"descriptors",
"as",
"$",
"name",
"=>",
"$",
"descriptor",
")",
"{",
"$",
"types",
"=",
"array",
"(",
")",
";",
"$",
"default",
"=",
"null",
";",
"$",
"required",
"=",
"false",
";",
"if",
"(",
"is_string",
"(",
"$",
"descriptor",
")",
")",
"{",
"$",
"types",
"=",
"explode",
"(",
"\"|\"",
",",
"$",
"descriptor",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"descriptor",
")",
")",
"{",
"$",
"types",
"=",
"explode",
"(",
"\"|\"",
",",
"Arr",
"::",
"get",
"(",
"$",
"descriptor",
",",
"\"type\"",
")",
")",
";",
"$",
"default",
"=",
"Arr",
"::",
"get",
"(",
"$",
"descriptor",
",",
"\"default\"",
")",
";",
"$",
"required",
"=",
"Arr",
"::",
"get",
"(",
"$",
"descriptor",
",",
"\"required\"",
",",
"!",
"Arr",
"::",
"exist",
"(",
"$",
"descriptor",
",",
"\"default\"",
")",
")",
";",
"}",
"$",
"desc",
"=",
"new",
"ArrArgumentsDescriptor",
"(",
"$",
"types",
",",
"$",
"default",
",",
"$",
"required",
")",
";",
"$",
"args",
"->",
"registerDescriptor",
"(",
"$",
"name",
",",
"$",
"desc",
")",
";",
"}",
"return",
"$",
"args",
"->",
"fetch",
"(",
")",
";",
"}"
] | Fetches elements from an array.
This function is especially suitable for getting optional arguments.
For example:
```php
function test($title, $message, $x, $y, $options) {
$args = Arr::fetch(func_get_args(), array(
// `title` is a required string
"title" => "string",
// `message` is an optional string and has a default value
"message" => array(
"type" => "string",
"default" => "Default message ..."
),
// `x` is an optional string or number and has a default value
"x" => array(
"type" => "string|number",
"default" => 0
),
// `y` is an optional string or number and has a default value
"y" => array(
"type" => "string|number",
"default" => 0
),
// `options` is an optional array
"options" => array(
"type" => "array",
required => false
)
);
print_r($args);
}
// this throws an InvalidArgumentException, as 'title' is required.
test(120, 250);
```
@param array $arr Array of mixed elements
@param array $descriptors Associative array of descriptors.
@throws InvalidArgumentException
@return array | [
"Fetches",
"elements",
"from",
"an",
"array",
"."
] | de38c800f3388005cbd37e70ab055f22609a5eae | https://github.com/soloproyectos-php/array/blob/de38c800f3388005cbd37e70ab055f22609a5eae/src/arr/Arr.php#L143-L167 |
9,593 | Gelembjuk/locale | src/Gelembjuk/Locale/TranslateManagement.php | TranslateManagement.checkKeyExists | public function checkKeyExists($key,$group,$allowempty = false) {
if (!$this->locale || $this->locale == '') {
return false;
}
$data = $this->loadDataForGroup($group,$allowempty);
if (isset($data[$key])) {
// check if data are in a file
if (strpos($data[$key],'file:') === 0) {
$filname = substr($data[$key],5);
$file_path = $this->localespath.$this->locale.'/files/'.$filname;
if (@file_exists($file_path)) {
return true;
}
return false;
}
return true;
}
return false;
} | php | public function checkKeyExists($key,$group,$allowempty = false) {
if (!$this->locale || $this->locale == '') {
return false;
}
$data = $this->loadDataForGroup($group,$allowempty);
if (isset($data[$key])) {
// check if data are in a file
if (strpos($data[$key],'file:') === 0) {
$filname = substr($data[$key],5);
$file_path = $this->localespath.$this->locale.'/files/'.$filname;
if (@file_exists($file_path)) {
return true;
}
return false;
}
return true;
}
return false;
} | [
"public",
"function",
"checkKeyExists",
"(",
"$",
"key",
",",
"$",
"group",
",",
"$",
"allowempty",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"locale",
"||",
"$",
"this",
"->",
"locale",
"==",
"''",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataForGroup",
"(",
"$",
"group",
",",
"$",
"allowempty",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// check if data are in a file",
"if",
"(",
"strpos",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
",",
"'file:'",
")",
"===",
"0",
")",
"{",
"$",
"filname",
"=",
"substr",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
",",
"5",
")",
";",
"$",
"file_path",
"=",
"$",
"this",
"->",
"localespath",
".",
"$",
"this",
"->",
"locale",
".",
"'/files/'",
".",
"$",
"filname",
";",
"if",
"(",
"@",
"file_exists",
"(",
"$",
"file_path",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Check if a key exists for a group. Is used for translations management
@param string $key Key of text to translate
@param string $group Group of keys
@param bool $allowempty Marker if empty key is allowed
@return bool | [
"Check",
"if",
"a",
"key",
"exists",
"for",
"a",
"group",
".",
"Is",
"used",
"for",
"translations",
"management"
] | 4d59f6518bf765c3653f3d2583e6e262ff8bfb29 | https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/TranslateManagement.php#L27-L50 |
9,594 | Gelembjuk/locale | src/Gelembjuk/Locale/TranslateManagement.php | TranslateManagement.getAllGroups | public function getAllGroups() {
if ($this->locale == '') {
throw new \Exception('Locale is not set');
}
$folder_path = $this->localespath.$this->locale.'/';
if (!is_dir($folder_path)) {
throw new \Exception('Locale folder not found');
}
$files = @scandir($folder_path);
$groups = array();
if (is_array($files)) {
foreach ($files as $file) {
if (is_file($folder_path.$file) && strtolower(pathinfo($folder_path.$file, PATHINFO_EXTENSION)) == 'txt') {
if (preg_match('!^(.+)\\.txt!i',$file,$m)) {
$groups[] = $m[1];
}
}
}
}
return $groups;
} | php | public function getAllGroups() {
if ($this->locale == '') {
throw new \Exception('Locale is not set');
}
$folder_path = $this->localespath.$this->locale.'/';
if (!is_dir($folder_path)) {
throw new \Exception('Locale folder not found');
}
$files = @scandir($folder_path);
$groups = array();
if (is_array($files)) {
foreach ($files as $file) {
if (is_file($folder_path.$file) && strtolower(pathinfo($folder_path.$file, PATHINFO_EXTENSION)) == 'txt') {
if (preg_match('!^(.+)\\.txt!i',$file,$m)) {
$groups[] = $m[1];
}
}
}
}
return $groups;
} | [
"public",
"function",
"getAllGroups",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locale",
"==",
"''",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Locale is not set'",
")",
";",
"}",
"$",
"folder_path",
"=",
"$",
"this",
"->",
"localespath",
".",
"$",
"this",
"->",
"locale",
".",
"'/'",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"folder_path",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Locale folder not found'",
")",
";",
"}",
"$",
"files",
"=",
"@",
"scandir",
"(",
"$",
"folder_path",
")",
";",
"$",
"groups",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"files",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"folder_path",
".",
"$",
"file",
")",
"&&",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"folder_path",
".",
"$",
"file",
",",
"PATHINFO_EXTENSION",
")",
")",
"==",
"'txt'",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'!^(.+)\\\\.txt!i'",
",",
"$",
"file",
",",
"$",
"m",
")",
")",
"{",
"$",
"groups",
"[",
"]",
"=",
"$",
"m",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"groups",
";",
"}"
] | Get array of all groups for current locale
@return array | [
"Get",
"array",
"of",
"all",
"groups",
"for",
"current",
"locale"
] | 4d59f6518bf765c3653f3d2583e6e262ff8bfb29 | https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/TranslateManagement.php#L56-L82 |
9,595 | Gelembjuk/locale | src/Gelembjuk/Locale/TranslateManagement.php | TranslateManagement.getDataForGroup | public function getDataForGroup($group, $includeemptykeys = true) {
if ($this->locale == '') {
throw new \Exception('Locale is not set');
}
$groupkeys = $this->loadDataForGroup($group,$includeemptykeys);
if (!$groupkeys) {
throw new \Exception('Group is not found');
}
return $groupkeys;
} | php | public function getDataForGroup($group, $includeemptykeys = true) {
if ($this->locale == '') {
throw new \Exception('Locale is not set');
}
$groupkeys = $this->loadDataForGroup($group,$includeemptykeys);
if (!$groupkeys) {
throw new \Exception('Group is not found');
}
return $groupkeys;
} | [
"public",
"function",
"getDataForGroup",
"(",
"$",
"group",
",",
"$",
"includeemptykeys",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locale",
"==",
"''",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Locale is not set'",
")",
";",
"}",
"$",
"groupkeys",
"=",
"$",
"this",
"->",
"loadDataForGroup",
"(",
"$",
"group",
",",
"$",
"includeemptykeys",
")",
";",
"if",
"(",
"!",
"$",
"groupkeys",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Group is not found'",
")",
";",
"}",
"return",
"$",
"groupkeys",
";",
"}"
] | Return list of all keys for a group with values
@param string $group Group name
@return array | [
"Return",
"list",
"of",
"all",
"keys",
"for",
"a",
"group",
"with",
"values"
] | 4d59f6518bf765c3653f3d2583e6e262ff8bfb29 | https://github.com/Gelembjuk/locale/blob/4d59f6518bf765c3653f3d2583e6e262ff8bfb29/src/Gelembjuk/Locale/TranslateManagement.php#L90-L102 |
9,596 | cmdweb/kernel | Kernel/Html.php | Html.select | static function select($name, array $values, $val, $text, $selected, $padrao = null, $attr = array())
{
$html = '<select ';
$attr = array_merge(array("name" => $name), $attr);
$html .= self::getAttributes($attr);
$html .= ">";
if ($padrao != null)
$html .= '<option value="">' . $padrao . '</option>';
foreach ($values as $value) {
if (isset($value->$val) and isset($value->$text))
$html .= '<option value="' . $value->$val . '" ' . ($value->$val == $selected ? " selected " : "") . '>' . $value->$text . '</option>';
}
$html .= "</select>";
echo $html;
} | php | static function select($name, array $values, $val, $text, $selected, $padrao = null, $attr = array())
{
$html = '<select ';
$attr = array_merge(array("name" => $name), $attr);
$html .= self::getAttributes($attr);
$html .= ">";
if ($padrao != null)
$html .= '<option value="">' . $padrao . '</option>';
foreach ($values as $value) {
if (isset($value->$val) and isset($value->$text))
$html .= '<option value="' . $value->$val . '" ' . ($value->$val == $selected ? " selected " : "") . '>' . $value->$text . '</option>';
}
$html .= "</select>";
echo $html;
} | [
"static",
"function",
"select",
"(",
"$",
"name",
",",
"array",
"$",
"values",
",",
"$",
"val",
",",
"$",
"text",
",",
"$",
"selected",
",",
"$",
"padrao",
"=",
"null",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"'<select '",
";",
"$",
"attr",
"=",
"array_merge",
"(",
"array",
"(",
"\"name\"",
"=>",
"$",
"name",
")",
",",
"$",
"attr",
")",
";",
"$",
"html",
".=",
"self",
"::",
"getAttributes",
"(",
"$",
"attr",
")",
";",
"$",
"html",
".=",
"\">\"",
";",
"if",
"(",
"$",
"padrao",
"!=",
"null",
")",
"$",
"html",
".=",
"'<option value=\"\">'",
".",
"$",
"padrao",
".",
"'</option>'",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"->",
"$",
"val",
")",
"and",
"isset",
"(",
"$",
"value",
"->",
"$",
"text",
")",
")",
"$",
"html",
".=",
"'<option value=\"'",
".",
"$",
"value",
"->",
"$",
"val",
".",
"'\" '",
".",
"(",
"$",
"value",
"->",
"$",
"val",
"==",
"$",
"selected",
"?",
"\" selected \"",
":",
"\"\"",
")",
".",
"'>'",
".",
"$",
"value",
"->",
"$",
"text",
".",
"'</option>'",
";",
"}",
"$",
"html",
".=",
"\"</select>\"",
";",
"echo",
"$",
"html",
";",
"}"
] | Cria um select Html
@param $name - Nome do campo
@param array $values - array com os objetos com os valores
@param $val - campo do objeto que contem o dado que deve ser o value do option
@param $text - campo do objeto que contem o dado que deve ser o texto do option
@param $selected - valor que deve vim selecionado
@param null $padrao - Texto que deve ser inserido antes de todos os itens
@param array $attr - atributos para adicionar na tag select | [
"Cria",
"um",
"select",
"Html"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Html.php#L55-L73 |
9,597 | cmdweb/kernel | Kernel/Html.php | Html.ValidateSummary | static function ValidateSummary()
{
$erros = ModelState::getErrors();
if (count($erros) > 0):
$html = '<ul class="validate-summary">';
foreach ($erros as $erro) {
$html .= '<li>' . $erro . '</li>';
}
$html .= '</ul>';
echo $html;
endif;
} | php | static function ValidateSummary()
{
$erros = ModelState::getErrors();
if (count($erros) > 0):
$html = '<ul class="validate-summary">';
foreach ($erros as $erro) {
$html .= '<li>' . $erro . '</li>';
}
$html .= '</ul>';
echo $html;
endif;
} | [
"static",
"function",
"ValidateSummary",
"(",
")",
"{",
"$",
"erros",
"=",
"ModelState",
"::",
"getErrors",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"erros",
")",
">",
"0",
")",
":",
"$",
"html",
"=",
"'<ul class=\"validate-summary\">'",
";",
"foreach",
"(",
"$",
"erros",
"as",
"$",
"erro",
")",
"{",
"$",
"html",
".=",
"'<li>'",
".",
"$",
"erro",
".",
"'</li>'",
";",
"}",
"$",
"html",
".=",
"'</ul>'",
";",
"echo",
"$",
"html",
";",
"endif",
";",
"}"
] | ValidateSumary - Exibe os erros do modelstate na tela | [
"ValidateSumary",
"-",
"Exibe",
"os",
"erros",
"do",
"modelstate",
"na",
"tela"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Html.php#L78-L92 |
9,598 | cmdweb/kernel | Kernel/Html.php | Html.getAttributes | private static function getAttributes($attr)
{
$html = "";
foreach ($attr as $key => $value) {
$html .= $key . '="' . $value . '" ';
}
return $html;
} | php | private static function getAttributes($attr)
{
$html = "";
foreach ($attr as $key => $value) {
$html .= $key . '="' . $value . '" ';
}
return $html;
} | [
"private",
"static",
"function",
"getAttributes",
"(",
"$",
"attr",
")",
"{",
"$",
"html",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"html",
".=",
"$",
"key",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\" '",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Pega os atributos | [
"Pega",
"os",
"atributos"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Html.php#L191-L199 |
9,599 | cmdweb/kernel | Kernel/Html.php | Html.input | private static function input($name, $value, $attr = array())
{
$html = '<input ';
$attr = array_merge(array("value" => $value, "name" => $name), $attr);
$html .= self::getAttributes($attr);
$html .= " />";
echo $html;
} | php | private static function input($name, $value, $attr = array())
{
$html = '<input ';
$attr = array_merge(array("value" => $value, "name" => $name), $attr);
$html .= self::getAttributes($attr);
$html .= " />";
echo $html;
} | [
"private",
"static",
"function",
"input",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"'<input '",
";",
"$",
"attr",
"=",
"array_merge",
"(",
"array",
"(",
"\"value\"",
"=>",
"$",
"value",
",",
"\"name\"",
"=>",
"$",
"name",
")",
",",
"$",
"attr",
")",
";",
"$",
"html",
".=",
"self",
"::",
"getAttributes",
"(",
"$",
"attr",
")",
";",
"$",
"html",
".=",
"\" />\"",
";",
"echo",
"$",
"html",
";",
"}"
] | Cria os inputs | [
"Cria",
"os",
"inputs"
] | 01dfc802c582adac1a739bcb34e4c31d86cde268 | https://github.com/cmdweb/kernel/blob/01dfc802c582adac1a739bcb34e4c31d86cde268/Kernel/Html.php#L204-L211 |
Subsets and Splits