repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
austinkregel/Warden | src/Warden/Http/Controllers/ModelController.php | ModelController.getNewModel | protected function getNewModel($model_name, FormModel $form)
{
/*
* We need to grab the model from the config and select one entry for
* that model from within the database.
*/
$model = $this->findModel($model_name);
/*
* Here we generate the form to update the model using the kregel/formmodel
* package
*/
$form_info = $form->using(config('kregel.formmodel.using.framework'))
->withModel($model)
->submitTo(route('warden::api.create-model', $model_name))
->form([
'method' => 'post',
'enctype' => 'multipart/form-data',
]);
return view('warden::view-model')
->with('form', $form_info)
->with('model_name', $model_name);
} | php | protected function getNewModel($model_name, FormModel $form)
{
/*
* We need to grab the model from the config and select one entry for
* that model from within the database.
*/
$model = $this->findModel($model_name);
/*
* Here we generate the form to update the model using the kregel/formmodel
* package
*/
$form_info = $form->using(config('kregel.formmodel.using.framework'))
->withModel($model)
->submitTo(route('warden::api.create-model', $model_name))
->form([
'method' => 'post',
'enctype' => 'multipart/form-data',
]);
return view('warden::view-model')
->with('form', $form_info)
->with('model_name', $model_name);
} | [
"protected",
"function",
"getNewModel",
"(",
"$",
"model_name",
",",
"FormModel",
"$",
"form",
")",
"{",
"/*\n * We need to grab the model from the config and select one entry for\n * that model from within the database.\n */",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"model_name",
")",
";",
"/*\n * Here we generate the form to update the model using the kregel/formmodel\n * package\n */",
"$",
"form_info",
"=",
"$",
"form",
"->",
"using",
"(",
"config",
"(",
"'kregel.formmodel.using.framework'",
")",
")",
"->",
"withModel",
"(",
"$",
"model",
")",
"->",
"submitTo",
"(",
"route",
"(",
"'warden::api.create-model'",
",",
"$",
"model_name",
")",
")",
"->",
"form",
"(",
"[",
"'method'",
"=>",
"'post'",
",",
"'enctype'",
"=>",
"'multipart/form-data'",
",",
"]",
")",
";",
"return",
"view",
"(",
"'warden::view-model'",
")",
"->",
"with",
"(",
"'form'",
",",
"$",
"form_info",
")",
"->",
"with",
"(",
"'model_name'",
",",
"$",
"model_name",
")",
";",
"}"
] | @param string $model_name A key in the warden.models configuration
@param FormModel $form An injected model
@return mixed | [
"@param",
"string",
"$model_name",
"A",
"key",
"in",
"the",
"warden",
".",
"models",
"configuration",
"@param",
"FormModel",
"$form",
"An",
"injected",
"model"
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ModelController.php#L105-L128 |
austinkregel/Warden | src/Warden/Http/Controllers/ModelController.php | ModelController.deleteModel | protected function deleteModel($model_name, $id)
{
/*
* Retrieve the desired model
*/
$response = $this->delete('warden::api.delete-model', [$model_name, $id]);
Session::flash('message', 'Hooray! It worked! The model was deleted!');
return redirect(route('warden::models', $model_name));
} | php | protected function deleteModel($model_name, $id)
{
/*
* Retrieve the desired model
*/
$response = $this->delete('warden::api.delete-model', [$model_name, $id]);
Session::flash('message', 'Hooray! It worked! The model was deleted!');
return redirect(route('warden::models', $model_name));
} | [
"protected",
"function",
"deleteModel",
"(",
"$",
"model_name",
",",
"$",
"id",
")",
"{",
"/*\n * Retrieve the desired model\n */",
"$",
"response",
"=",
"$",
"this",
"->",
"delete",
"(",
"'warden::api.delete-model'",
",",
"[",
"$",
"model_name",
",",
"$",
"id",
"]",
")",
";",
"Session",
"::",
"flash",
"(",
"'message'",
",",
"'Hooray! It worked! The model was deleted!'",
")",
";",
"return",
"redirect",
"(",
"route",
"(",
"'warden::models'",
",",
"$",
"model_name",
")",
")",
";",
"}"
] | @depreciated Please use ajax to delete the element.
@param string $model_name A key in the warden.models configuration
@param int $id The id of the model
@return Route | [
"@depreciated",
"Please",
"use",
"ajax",
"to",
"delete",
"the",
"element",
"."
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ModelController.php#L138-L148 |
austinkregel/Warden | src/Warden/Http/Controllers/ModelController.php | ModelController.createModel | protected function createModel($model_name)
{
$this->post('warden::api.create-model', [$model_name]);
return redirect(route('warden::model', [$model_name, $model->id]));
} | php | protected function createModel($model_name)
{
$this->post('warden::api.create-model', [$model_name]);
return redirect(route('warden::model', [$model_name, $model->id]));
} | [
"protected",
"function",
"createModel",
"(",
"$",
"model_name",
")",
"{",
"$",
"this",
"->",
"post",
"(",
"'warden::api.create-model'",
",",
"[",
"$",
"model_name",
"]",
")",
";",
"return",
"redirect",
"(",
"route",
"(",
"'warden::model'",
",",
"[",
"$",
"model_name",
",",
"$",
"model",
"->",
"id",
"]",
")",
")",
";",
"}"
] | @param string $model_name A key in the warden.models configuration
@return Route | [
"@param",
"string",
"$model_name",
"A",
"key",
"in",
"the",
"warden",
".",
"models",
"configuration"
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ModelController.php#L155-L160 |
austinkregel/Warden | src/Warden/Http/Controllers/ModelController.php | ModelController.sortInputAndApply | private function sortInputAndApply(Model &$model, $update = false)
{
// Loop through all input
if ($update) {
foreach (Input::all() as $key => $value) {
// Check to see if there is any available value for the desired model.
if (!empty($model->$key)) {
// If the value is not equal to the desired value
if ($model->$key !== $value) {
// Remove any extra spaces
$model->$key = $this->manageInput($key, $value);
}
} elseif (Input::has('_relations')) {
// Explode any potential relations.
$relations = explode(',', Input::get('_relations'));
foreach ($relations as $relation) {
// If the relation has the key, update the value.
if (!empty($model->$relation->$key)) {
if ($model->$relations->$key !== $value) {
$model->$relations->$key = $this->manageInput($key, $value);
}
}
}
}
}
} else {
foreach ($model->getFillable() as $key) {
foreach (Input::all() as $field => $value) {
// If the fillable key doesn't match the input
// field keep going,Otherwise, set the values.
if ($key === $field) {
$model->$key = $this->manageInput($key, $value);
}
}
}
}
// Unconventional return?
return $model;
} | php | private function sortInputAndApply(Model &$model, $update = false)
{
// Loop through all input
if ($update) {
foreach (Input::all() as $key => $value) {
// Check to see if there is any available value for the desired model.
if (!empty($model->$key)) {
// If the value is not equal to the desired value
if ($model->$key !== $value) {
// Remove any extra spaces
$model->$key = $this->manageInput($key, $value);
}
} elseif (Input::has('_relations')) {
// Explode any potential relations.
$relations = explode(',', Input::get('_relations'));
foreach ($relations as $relation) {
// If the relation has the key, update the value.
if (!empty($model->$relation->$key)) {
if ($model->$relations->$key !== $value) {
$model->$relations->$key = $this->manageInput($key, $value);
}
}
}
}
}
} else {
foreach ($model->getFillable() as $key) {
foreach (Input::all() as $field => $value) {
// If the fillable key doesn't match the input
// field keep going,Otherwise, set the values.
if ($key === $field) {
$model->$key = $this->manageInput($key, $value);
}
}
}
}
// Unconventional return?
return $model;
} | [
"private",
"function",
"sortInputAndApply",
"(",
"Model",
"&",
"$",
"model",
",",
"$",
"update",
"=",
"false",
")",
"{",
"// Loop through all input",
"if",
"(",
"$",
"update",
")",
"{",
"foreach",
"(",
"Input",
"::",
"all",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Check to see if there is any available value for the desired model.",
"if",
"(",
"!",
"empty",
"(",
"$",
"model",
"->",
"$",
"key",
")",
")",
"{",
"// If the value is not equal to the desired value",
"if",
"(",
"$",
"model",
"->",
"$",
"key",
"!==",
"$",
"value",
")",
"{",
"// Remove any extra spaces",
"$",
"model",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"manageInput",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"Input",
"::",
"has",
"(",
"'_relations'",
")",
")",
"{",
"// Explode any potential relations.",
"$",
"relations",
"=",
"explode",
"(",
"','",
",",
"Input",
"::",
"get",
"(",
"'_relations'",
")",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"// If the relation has the key, update the value.",
"if",
"(",
"!",
"empty",
"(",
"$",
"model",
"->",
"$",
"relation",
"->",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"$",
"relations",
"->",
"$",
"key",
"!==",
"$",
"value",
")",
"{",
"$",
"model",
"->",
"$",
"relations",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"manageInput",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"model",
"->",
"getFillable",
"(",
")",
"as",
"$",
"key",
")",
"{",
"foreach",
"(",
"Input",
"::",
"all",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"// If the fillable key doesn't match the input",
"// field keep going,Otherwise, set the values.",
"if",
"(",
"$",
"key",
"===",
"$",
"field",
")",
"{",
"$",
"model",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"manageInput",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"// Unconventional return?",
"return",
"$",
"model",
";",
"}"
] | @param Model $model This should be an eloquent based thing...
@return Model A newed up model | [
"@param",
"Model",
"$model",
"This",
"should",
"be",
"an",
"eloquent",
"based",
"thing",
"..."
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ModelController.php#L167-L205 |
austinkregel/Warden | src/Warden/Http/Controllers/ModelController.php | ModelController.manageInput | private function manageInput($input_type, $input)
{
switch (true) {
case stripos($input_type, 'password') !== false:
// Encrypt the password fields
// The password field will not be shortend due to poor naming of
// Other potential naming conflicts. ie. using pass will effect something 'compass'
return bcrypt($input);
// Don't know what other input will need pre-processing...
default:
// Remove any extra starting or trailing spaces.
return trim($input);
}
} | php | private function manageInput($input_type, $input)
{
switch (true) {
case stripos($input_type, 'password') !== false:
// Encrypt the password fields
// The password field will not be shortend due to poor naming of
// Other potential naming conflicts. ie. using pass will effect something 'compass'
return bcrypt($input);
// Don't know what other input will need pre-processing...
default:
// Remove any extra starting or trailing spaces.
return trim($input);
}
} | [
"private",
"function",
"manageInput",
"(",
"$",
"input_type",
",",
"$",
"input",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"stripos",
"(",
"$",
"input_type",
",",
"'password'",
")",
"!==",
"false",
":",
"// Encrypt the password fields",
"// The password field will not be shortend due to poor naming of",
"// Other potential naming conflicts. ie. using pass will effect something 'compass'",
"return",
"bcrypt",
"(",
"$",
"input",
")",
";",
"// Don't know what other input will need pre-processing...",
"default",
":",
"// Remove any extra starting or trailing spaces.",
"return",
"trim",
"(",
"$",
"input",
")",
";",
"}",
"}"
] | @param $input_type
@param $input
@return string | [
"@param",
"$input_type",
"@param",
"$input"
] | train | https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/ModelController.php#L213-L226 |
mihai-stancu/serializer | Serializer/Normalizer/RecursiveNormalizer.php | RecursiveNormalizer.instantiateObject | protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
if (
isset($context['object_to_populate']) &&
is_object($context['object_to_populate']) &&
$class === get_class($context['object_to_populate'])
) {
return $context['object_to_populate'];
}
$format = null;
if (isset($context['format'])) {
$format = $context['format'];
}
$constructor = $reflectionClass->getConstructor();
if (!$constructor) {
return new $class();
}
$constructorParameters = $constructor->getParameters();
$params = array();
foreach ($constructorParameters as $constructorParameter) {
$paramName = $constructorParameter->name;
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;
$allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
$ignored = in_array($paramName, $this->ignoredAttributes);
if (!$allowed || $ignored) {
continue;
}
$missing = !isset($data[$key]) && !array_key_exists($key, $data);
$variadic = method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic();
if ($variadic && !$missing && !is_array($data[$paramName])) {
$message = 'Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.';
throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
}
if ($variadic && !$missing) {
$params = array_merge($params, $data[$paramName]);
continue;
}
if ($missing && !$variadic && !$constructorParameter->isDefaultValueAvailable()) {
$message = 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.';
throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
}
if ($missing && $constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
continue;
}
if (!$missing) {
$params[] = $this->denormalizeProperty($data[$key], $class, $key, $format, $context);
unset($data[$key]);
}
}
return $reflectionClass->newInstanceArgs($params);
} | php | protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
{
if (
isset($context['object_to_populate']) &&
is_object($context['object_to_populate']) &&
$class === get_class($context['object_to_populate'])
) {
return $context['object_to_populate'];
}
$format = null;
if (isset($context['format'])) {
$format = $context['format'];
}
$constructor = $reflectionClass->getConstructor();
if (!$constructor) {
return new $class();
}
$constructorParameters = $constructor->getParameters();
$params = array();
foreach ($constructorParameters as $constructorParameter) {
$paramName = $constructorParameter->name;
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName) : $paramName;
$allowed = $allowedAttributes === false || in_array($paramName, $allowedAttributes);
$ignored = in_array($paramName, $this->ignoredAttributes);
if (!$allowed || $ignored) {
continue;
}
$missing = !isset($data[$key]) && !array_key_exists($key, $data);
$variadic = method_exists($constructorParameter, 'isVariadic') && $constructorParameter->isVariadic();
if ($variadic && !$missing && !is_array($data[$paramName])) {
$message = 'Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.';
throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
}
if ($variadic && !$missing) {
$params = array_merge($params, $data[$paramName]);
continue;
}
if ($missing && !$variadic && !$constructorParameter->isDefaultValueAvailable()) {
$message = 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.';
throw new RuntimeException(sprintf($message, $class, $constructorParameter->name));
}
if ($missing && $constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
continue;
}
if (!$missing) {
$params[] = $this->denormalizeProperty($data[$key], $class, $key, $format, $context);
unset($data[$key]);
}
}
return $reflectionClass->newInstanceArgs($params);
} | [
"protected",
"function",
"instantiateObject",
"(",
"array",
"&",
"$",
"data",
",",
"$",
"class",
",",
"array",
"&",
"$",
"context",
",",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
",",
"$",
"allowedAttributes",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'object_to_populate'",
"]",
")",
"&&",
"is_object",
"(",
"$",
"context",
"[",
"'object_to_populate'",
"]",
")",
"&&",
"$",
"class",
"===",
"get_class",
"(",
"$",
"context",
"[",
"'object_to_populate'",
"]",
")",
")",
"{",
"return",
"$",
"context",
"[",
"'object_to_populate'",
"]",
";",
"}",
"$",
"format",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"format",
"=",
"$",
"context",
"[",
"'format'",
"]",
";",
"}",
"$",
"constructor",
"=",
"$",
"reflectionClass",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"!",
"$",
"constructor",
")",
"{",
"return",
"new",
"$",
"class",
"(",
")",
";",
"}",
"$",
"constructorParameters",
"=",
"$",
"constructor",
"->",
"getParameters",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"constructorParameters",
"as",
"$",
"constructorParameter",
")",
"{",
"$",
"paramName",
"=",
"$",
"constructorParameter",
"->",
"name",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"nameConverter",
"?",
"$",
"this",
"->",
"nameConverter",
"->",
"normalize",
"(",
"$",
"paramName",
")",
":",
"$",
"paramName",
";",
"$",
"allowed",
"=",
"$",
"allowedAttributes",
"===",
"false",
"||",
"in_array",
"(",
"$",
"paramName",
",",
"$",
"allowedAttributes",
")",
";",
"$",
"ignored",
"=",
"in_array",
"(",
"$",
"paramName",
",",
"$",
"this",
"->",
"ignoredAttributes",
")",
";",
"if",
"(",
"!",
"$",
"allowed",
"||",
"$",
"ignored",
")",
"{",
"continue",
";",
"}",
"$",
"missing",
"=",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"$",
"variadic",
"=",
"method_exists",
"(",
"$",
"constructorParameter",
",",
"'isVariadic'",
")",
"&&",
"$",
"constructorParameter",
"->",
"isVariadic",
"(",
")",
";",
"if",
"(",
"$",
"variadic",
"&&",
"!",
"$",
"missing",
"&&",
"!",
"is_array",
"(",
"$",
"data",
"[",
"$",
"paramName",
"]",
")",
")",
"{",
"$",
"message",
"=",
"'Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.'",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"class",
",",
"$",
"constructorParameter",
"->",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"variadic",
"&&",
"!",
"$",
"missing",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"params",
",",
"$",
"data",
"[",
"$",
"paramName",
"]",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"missing",
"&&",
"!",
"$",
"variadic",
"&&",
"!",
"$",
"constructorParameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"message",
"=",
"'Cannot create an instance of %s from serialized data because its constructor requires parameter \"%s\" to be present.'",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"class",
",",
"$",
"constructorParameter",
"->",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"missing",
"&&",
"$",
"constructorParameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"constructorParameter",
"->",
"getDefaultValue",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"missing",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"this",
"->",
"denormalizeProperty",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
",",
"$",
"class",
",",
"$",
"key",
",",
"$",
"format",
",",
"$",
"context",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"reflectionClass",
"->",
"newInstanceArgs",
"(",
"$",
"params",
")",
";",
"}"
] | @param array $data
@param string $class
@param array $context
@param \ReflectionClass $reflectionClass
@param array|bool $allowedAttributes
@throws RuntimeException
@return object | [
"@param",
"array",
"$data",
"@param",
"string",
"$class",
"@param",
"array",
"$context",
"@param",
"\\",
"ReflectionClass",
"$reflectionClass",
"@param",
"array|bool",
"$allowedAttributes"
] | train | https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/RecursiveNormalizer.php#L53-L120 |
mihai-stancu/serializer | Serializer/Normalizer/RecursiveNormalizer.php | RecursiveNormalizer.denormalizeProperty | protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
{
if (!$this->propertyInfoExtractor) {
return $data;
}
/** @var Type[] $types */
$types = (array) $this->propertyInfoExtractor->getTypes($class, $name);
$_class = null;
$_class = array_reduce(
$types,
function($class, Type $type) {
return $class ?: $type->getClassName();
},
$_class
);
if ($data === null and $_class === null) {
return $data;
}
if (!$this->serializer instanceof DenormalizerInterface) {
$message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
throw new RuntimeException(sprintf($message, $name));
}
if ($_class === null
or !$this->serializer->supportsDenormalization($data, $_class, $format, $context)) {
return $data;
}
return $this->serializer->denormalize($data, $_class, $format, $context);
} | php | protected function denormalizeProperty($data, $class, $name, $format = null, array $context = array())
{
if (!$this->propertyInfoExtractor) {
return $data;
}
/** @var Type[] $types */
$types = (array) $this->propertyInfoExtractor->getTypes($class, $name);
$_class = null;
$_class = array_reduce(
$types,
function($class, Type $type) {
return $class ?: $type->getClassName();
},
$_class
);
if ($data === null and $_class === null) {
return $data;
}
if (!$this->serializer instanceof DenormalizerInterface) {
$message = 'Cannot denormalize attribute "%s" because injected serializer is not a denormalizer';
throw new RuntimeException(sprintf($message, $name));
}
if ($_class === null
or !$this->serializer->supportsDenormalization($data, $_class, $format, $context)) {
return $data;
}
return $this->serializer->denormalize($data, $_class, $format, $context);
} | [
"protected",
"function",
"denormalizeProperty",
"(",
"$",
"data",
",",
"$",
"class",
",",
"$",
"name",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"propertyInfoExtractor",
")",
"{",
"return",
"$",
"data",
";",
"}",
"/** @var Type[] $types */",
"$",
"types",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"propertyInfoExtractor",
"->",
"getTypes",
"(",
"$",
"class",
",",
"$",
"name",
")",
";",
"$",
"_class",
"=",
"null",
";",
"$",
"_class",
"=",
"array_reduce",
"(",
"$",
"types",
",",
"function",
"(",
"$",
"class",
",",
"Type",
"$",
"type",
")",
"{",
"return",
"$",
"class",
"?",
":",
"$",
"type",
"->",
"getClassName",
"(",
")",
";",
"}",
",",
"$",
"_class",
")",
";",
"if",
"(",
"$",
"data",
"===",
"null",
"and",
"$",
"_class",
"===",
"null",
")",
"{",
"return",
"$",
"data",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"serializer",
"instanceof",
"DenormalizerInterface",
")",
"{",
"$",
"message",
"=",
"'Cannot denormalize attribute \"%s\" because injected serializer is not a denormalizer'",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"_class",
"===",
"null",
"or",
"!",
"$",
"this",
"->",
"serializer",
"->",
"supportsDenormalization",
"(",
"$",
"data",
",",
"$",
"_class",
",",
"$",
"format",
",",
"$",
"context",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"serializer",
"->",
"denormalize",
"(",
"$",
"data",
",",
"$",
"_class",
",",
"$",
"format",
",",
"$",
"context",
")",
";",
"}"
] | @param mixed $data
@param string $class
@param string $name
@param string $format
@param array $context
@throws RuntimeException
@return mixed|object | [
"@param",
"mixed",
"$data",
"@param",
"string",
"$class",
"@param",
"string",
"$name",
"@param",
"string",
"$format",
"@param",
"array",
"$context"
] | train | https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/RecursiveNormalizer.php#L133-L165 |
mihai-stancu/serializer | Serializer/Normalizer/RecursiveNormalizer.php | RecursiveNormalizer.denormalize | public function denormalize($data, $class, $format = null, array $context = array())
{
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
$normalizedData = $this->prepareForDenormalization($data);
$reflectionClass = new \ReflectionClass($class);
$subcontext = array_merge($context, array('format' => $format));
$object = $this->instantiateObject($normalizedData, $class, $subcontext, $reflectionClass, $allowedAttributes);
$classMethods = get_class_methods($object);
foreach ($normalizedData as $attribute => $value) {
if ($this->nameConverter) {
$attribute = $this->nameConverter->denormalize($attribute);
}
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
$ignored = in_array($attribute, $this->ignoredAttributes);
if (!$allowed || $ignored) {
continue;
}
$setter = 'set'.ucfirst($attribute);
if (!in_array($setter, $classMethods)) {
continue;
}
$value = $this->denormalizeProperty($value, $class, $attribute, $format, $context);
$object->$setter($value);
}
return $object;
} | php | public function denormalize($data, $class, $format = null, array $context = array())
{
$allowedAttributes = $this->getAllowedAttributes($class, $context, true);
$normalizedData = $this->prepareForDenormalization($data);
$reflectionClass = new \ReflectionClass($class);
$subcontext = array_merge($context, array('format' => $format));
$object = $this->instantiateObject($normalizedData, $class, $subcontext, $reflectionClass, $allowedAttributes);
$classMethods = get_class_methods($object);
foreach ($normalizedData as $attribute => $value) {
if ($this->nameConverter) {
$attribute = $this->nameConverter->denormalize($attribute);
}
$allowed = $allowedAttributes === false || in_array($attribute, $allowedAttributes);
$ignored = in_array($attribute, $this->ignoredAttributes);
if (!$allowed || $ignored) {
continue;
}
$setter = 'set'.ucfirst($attribute);
if (!in_array($setter, $classMethods)) {
continue;
}
$value = $this->denormalizeProperty($value, $class, $attribute, $format, $context);
$object->$setter($value);
}
return $object;
} | [
"public",
"function",
"denormalize",
"(",
"$",
"data",
",",
"$",
"class",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"$",
"allowedAttributes",
"=",
"$",
"this",
"->",
"getAllowedAttributes",
"(",
"$",
"class",
",",
"$",
"context",
",",
"true",
")",
";",
"$",
"normalizedData",
"=",
"$",
"this",
"->",
"prepareForDenormalization",
"(",
"$",
"data",
")",
";",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"subcontext",
"=",
"array_merge",
"(",
"$",
"context",
",",
"array",
"(",
"'format'",
"=>",
"$",
"format",
")",
")",
";",
"$",
"object",
"=",
"$",
"this",
"->",
"instantiateObject",
"(",
"$",
"normalizedData",
",",
"$",
"class",
",",
"$",
"subcontext",
",",
"$",
"reflectionClass",
",",
"$",
"allowedAttributes",
")",
";",
"$",
"classMethods",
"=",
"get_class_methods",
"(",
"$",
"object",
")",
";",
"foreach",
"(",
"$",
"normalizedData",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nameConverter",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"nameConverter",
"->",
"denormalize",
"(",
"$",
"attribute",
")",
";",
"}",
"$",
"allowed",
"=",
"$",
"allowedAttributes",
"===",
"false",
"||",
"in_array",
"(",
"$",
"attribute",
",",
"$",
"allowedAttributes",
")",
";",
"$",
"ignored",
"=",
"in_array",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"ignoredAttributes",
")",
";",
"if",
"(",
"!",
"$",
"allowed",
"||",
"$",
"ignored",
")",
"{",
"continue",
";",
"}",
"$",
"setter",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"setter",
",",
"$",
"classMethods",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"denormalizeProperty",
"(",
"$",
"value",
",",
"$",
"class",
",",
"$",
"attribute",
",",
"$",
"format",
",",
"$",
"context",
")",
";",
"$",
"object",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | @param mixed $data
@param string $class
@param null $format
@param array $context
@return object | [
"@param",
"mixed",
"$data",
"@param",
"string",
"$class",
"@param",
"null",
"$format",
"@param",
"array",
"$context"
] | train | https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Normalizer/RecursiveNormalizer.php#L175-L209 |
ClanCats/Core | src/classes/CCAsset.php | CCAsset.macro_og | protected static function macro_og( $tags, $content = null )
{
if ( !is_array( $tags ) )
{
$tags = array( $tags => $content );
}
$buffer = "";
foreach( $tags as $key => $content )
{
$buffer .= '<meta property="og:'.$key.'" content="'.$content.'" />';
}
return $buffer;
} | php | protected static function macro_og( $tags, $content = null )
{
if ( !is_array( $tags ) )
{
$tags = array( $tags => $content );
}
$buffer = "";
foreach( $tags as $key => $content )
{
$buffer .= '<meta property="og:'.$key.'" content="'.$content.'" />';
}
return $buffer;
} | [
"protected",
"static",
"function",
"macro_og",
"(",
"$",
"tags",
",",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tags",
")",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
"$",
"tags",
"=>",
"$",
"content",
")",
";",
"}",
"$",
"buffer",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"key",
"=>",
"$",
"content",
")",
"{",
"$",
"buffer",
".=",
"'<meta property=\"og:'",
".",
"$",
"key",
".",
"'\" content=\"'",
".",
"$",
"content",
".",
"'\" />'",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
] | OG Macro - Generates open grapth tags
// <meta property="og:type" content="video" />
CCAsset::og( 'type', 'video' );
// <meta property="og:type" content="video" />
// <meta property="og:res" content="1080p" />
CCAsset::og( array( 'type' => 'video', 'res' => '1080p' ));
@param array|string $tags
@param string $content
@return string | [
"OG",
"Macro",
"-",
"Generates",
"open",
"grapth",
"tags"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L109-L124 |
ClanCats/Core | src/classes/CCAsset.php | CCAsset.uri | public static function uri( $uri, $name = null )
{
// when the uri conains a protocol we just return
// the given uri.
if ( strpos( $uri, '://' ) === false )
{
// If the path is relative and not absolute
// we prefix the holder path.
if ( substr( $uri, 0, 1 ) != '/' )
{
$uri = CCUrl::to( static::holder( $name )->path.$uri );
}
// When the given uri is absolute we remove the first
// slash and let CCUrl do the job.
else
{
$uri = CCUrl::to( substr( $uri, 1 ) );
}
}
return $uri;
} | php | public static function uri( $uri, $name = null )
{
// when the uri conains a protocol we just return
// the given uri.
if ( strpos( $uri, '://' ) === false )
{
// If the path is relative and not absolute
// we prefix the holder path.
if ( substr( $uri, 0, 1 ) != '/' )
{
$uri = CCUrl::to( static::holder( $name )->path.$uri );
}
// When the given uri is absolute we remove the first
// slash and let CCUrl do the job.
else
{
$uri = CCUrl::to( substr( $uri, 1 ) );
}
}
return $uri;
} | [
"public",
"static",
"function",
"uri",
"(",
"$",
"uri",
",",
"$",
"name",
"=",
"null",
")",
"{",
"// when the uri conains a protocol we just return ",
"// the given uri.",
"if",
"(",
"strpos",
"(",
"$",
"uri",
",",
"'://'",
")",
"===",
"false",
")",
"{",
"// If the path is relative and not absolute",
"// we prefix the holder path.",
"if",
"(",
"substr",
"(",
"$",
"uri",
",",
"0",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"uri",
"=",
"CCUrl",
"::",
"to",
"(",
"static",
"::",
"holder",
"(",
"$",
"name",
")",
"->",
"path",
".",
"$",
"uri",
")",
";",
"}",
"// When the given uri is absolute we remove the first",
"// slash and let CCUrl do the job.",
"else",
"{",
"$",
"uri",
"=",
"CCUrl",
"::",
"to",
"(",
"substr",
"(",
"$",
"uri",
",",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"uri",
";",
"}"
] | Get the uri to an asset
// /assets/images/something.jpg
CCAsset::uri( 'images/something.jpg' );
// /assets/MyTheme/images/something.jpg
CCAsset::uri( 'images/logo.png', 'theme' );
// will not modify the given url
CCAsset::uri( 'http://example.com/images/logo.jpg' );
@param string $uri
@param string $name
@return string | [
"Get",
"the",
"uri",
"to",
"an",
"asset"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L188-L209 |
ClanCats/Core | src/classes/CCAsset.php | CCAsset.holder | public static function holder( $name = null )
{
if ( !isset( $name ) )
{
$name = static::$_default;
}
if ( !isset( static::$instances[$name] ) )
{
static::$instances[$name] = new CCAsset_Holder();
}
return static::$instances[$name];
} | php | public static function holder( $name = null )
{
if ( !isset( $name ) )
{
$name = static::$_default;
}
if ( !isset( static::$instances[$name] ) )
{
static::$instances[$name] = new CCAsset_Holder();
}
return static::$instances[$name];
} | [
"public",
"static",
"function",
"holder",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"$",
"_default",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"CCAsset_Holder",
"(",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
] | Get an asset holder instance.
$holder = CCAsset::holder();
$holder = CCAsset::holder( 'footer' );
@param string $name
@return CCAsset | [
"Get",
"an",
"asset",
"holder",
"instance",
"."
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L220-L233 |
ClanCats/Core | src/classes/CCAsset.php | CCAsset.code | public static function code( $type, $name = null )
{
$buffer = "";
foreach( static::holder( $name )->get( $type ) as $item )
{
$buffer .= call_user_func( array( '\\CCAsset', $type ), $item, $name );
}
return $buffer;
} | php | public static function code( $type, $name = null )
{
$buffer = "";
foreach( static::holder( $name )->get( $type ) as $item )
{
$buffer .= call_user_func( array( '\\CCAsset', $type ), $item, $name );
}
return $buffer;
} | [
"public",
"static",
"function",
"code",
"(",
"$",
"type",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"buffer",
"=",
"\"\"",
";",
"foreach",
"(",
"static",
"::",
"holder",
"(",
"$",
"name",
")",
"->",
"get",
"(",
"$",
"type",
")",
"as",
"$",
"item",
")",
"{",
"$",
"buffer",
".=",
"call_user_func",
"(",
"array",
"(",
"'\\\\CCAsset'",
",",
"$",
"type",
")",
",",
"$",
"item",
",",
"$",
"name",
")",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
] | Get all assets of a specific type in a holder and run them
trough the maching macros.
CCAsset::code( 'css' );
CCAsset::code( 'js', 'footer' );
@param string $type
@param string $name | [
"Get",
"all",
"assets",
"of",
"a",
"specific",
"type",
"in",
"a",
"holder",
"and",
"run",
"them",
"trough",
"the",
"maching",
"macros",
"."
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L245-L255 |
arsengoian/viper-framework | src/Viper/Daemon/QueueRouter.php | QueueRouter.add | public function add(Task $task) : void
{
$this->index++;
Util::put($this -> storage().$this->index.'.queue', serialize($task));
$this -> updateIterator();
Util::put($this -> storage().'_index', $this -> index);
} | php | public function add(Task $task) : void
{
$this->index++;
Util::put($this -> storage().$this->index.'.queue', serialize($task));
$this -> updateIterator();
Util::put($this -> storage().'_index', $this -> index);
} | [
"public",
"function",
"add",
"(",
"Task",
"$",
"task",
")",
":",
"void",
"{",
"$",
"this",
"->",
"index",
"++",
";",
"Util",
"::",
"put",
"(",
"$",
"this",
"->",
"storage",
"(",
")",
".",
"$",
"this",
"->",
"index",
".",
"'.queue'",
",",
"serialize",
"(",
"$",
"task",
")",
")",
";",
"$",
"this",
"->",
"updateIterator",
"(",
")",
";",
"Util",
"::",
"put",
"(",
"$",
"this",
"->",
"storage",
"(",
")",
".",
"'_index'",
",",
"$",
"this",
"->",
"index",
")",
";",
"}"
] | Add new task to queue top
@param Task $task | [
"Add",
"new",
"task",
"to",
"queue",
"top"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/QueueRouter.php#L52-L58 |
arsengoian/viper-framework | src/Viper/Daemon/QueueRouter.php | QueueRouter.pop | public function pop(int $num) : Collection
{
$ret = new Collection();
foreach ($this -> iterator as $item) {
if (!$num--)
return $ret;
$ret[] = unserialize(file_get_contents($item));
unlink($item);
}
$this -> updateIterator();
return $ret;
} | php | public function pop(int $num) : Collection
{
$ret = new Collection();
foreach ($this -> iterator as $item) {
if (!$num--)
return $ret;
$ret[] = unserialize(file_get_contents($item));
unlink($item);
}
$this -> updateIterator();
return $ret;
} | [
"public",
"function",
"pop",
"(",
"int",
"$",
"num",
")",
":",
"Collection",
"{",
"$",
"ret",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"iterator",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"num",
"--",
")",
"return",
"$",
"ret",
";",
"$",
"ret",
"[",
"]",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"item",
")",
")",
";",
"unlink",
"(",
"$",
"item",
")",
";",
"}",
"$",
"this",
"->",
"updateIterator",
"(",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | Get the oldest items from the queue
@param int $num the number of items to pop
@return Collection
TODO fix situation when crash is immediately after pop; | [
"Get",
"the",
"oldest",
"items",
"from",
"the",
"queue"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/QueueRouter.php#L66-L77 |
PortaText/php-sdk | src/PortaText/Command/Api/Templates.php | Templates.getEndpoint | protected function getEndpoint($method)
{
$endpoint = "templates";
$templateId = $this->getArgument("id");
if (!is_null($templateId)) {
$endpoint .= "/$templateId";
$this->delArgument("id");
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$endpoint = "templates";
$templateId = $this->getArgument("id");
if (!is_null($templateId)) {
$endpoint .= "/$templateId";
$this->delArgument("id");
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"endpoint",
"=",
"\"templates\"",
";",
"$",
"templateId",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"id\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"templateId",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$templateId\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"id\"",
")",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
] | Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Templates.php#L75-L84 |
claroline/ForumBundle | Event/Log/CreateMessageEvent.php | CreateMessageEvent.getNotificationDetails | public function getNotificationDetails()
{
$details = $this->details;
$details['forum']['name'] = $this->message->getSubject()->getCategory()->getForum()->getResourceNode()->getName();
return $details;
} | php | public function getNotificationDetails()
{
$details = $this->details;
$details['forum']['name'] = $this->message->getSubject()->getCategory()->getForum()->getResourceNode()->getName();
return $details;
} | [
"public",
"function",
"getNotificationDetails",
"(",
")",
"{",
"$",
"details",
"=",
"$",
"this",
"->",
"details",
";",
"$",
"details",
"[",
"'forum'",
"]",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"message",
"->",
"getSubject",
"(",
")",
"->",
"getCategory",
"(",
")",
"->",
"getForum",
"(",
")",
"->",
"getResourceNode",
"(",
")",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"details",
";",
"}"
] | Get details
@return array | [
"Get",
"details"
] | train | https://github.com/claroline/ForumBundle/blob/bd85dfd870cacee541ea94fec8e59744bf90eaf4/Event/Log/CreateMessageEvent.php#L114-L120 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getFieldNames | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, RemoteAppPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return RemoteAppPeer::$fieldNames[$type];
} | php | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, RemoteAppPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return RemoteAppPeer::$fieldNames[$type];
} | [
"public",
"static",
"function",
"getFieldNames",
"(",
"$",
"type",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"RemoteAppPeer",
"::",
"$",
"fieldNames",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. '",
".",
"$",
"type",
".",
"' was given.'",
")",
";",
"}",
"return",
"RemoteAppPeer",
"::",
"$",
"fieldNames",
"[",
"$",
"type",
"]",
";",
"}"
] | Returns an array of field names.
@param string $type The type of fieldnames to return:
One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
@return array A list of field names
@throws PropelException - if the type is not valid. | [
"Returns",
"an",
"array",
"of",
"field",
"names",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L212-L219 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getValueSet | public static function getValueSet($colname)
{
$valueSets = RemoteAppPeer::getValueSets();
if (!isset($valueSets[$colname])) {
throw new PropelException(sprintf('Column "%s" has no ValueSet.', $colname));
}
return $valueSets[$colname];
} | php | public static function getValueSet($colname)
{
$valueSets = RemoteAppPeer::getValueSets();
if (!isset($valueSets[$colname])) {
throw new PropelException(sprintf('Column "%s" has no ValueSet.', $colname));
}
return $valueSets[$colname];
} | [
"public",
"static",
"function",
"getValueSet",
"(",
"$",
"colname",
")",
"{",
"$",
"valueSets",
"=",
"RemoteAppPeer",
"::",
"getValueSets",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"valueSets",
"[",
"$",
"colname",
"]",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Column \"%s\" has no ValueSet.'",
",",
"$",
"colname",
")",
")",
";",
"}",
"return",
"$",
"valueSets",
"[",
"$",
"colname",
"]",
";",
"}"
] | Gets the list of values for an ENUM column
@param string $colname The ENUM column name.
@return array list of possible values for the column | [
"Gets",
"the",
"list",
"of",
"values",
"for",
"an",
"ENUM",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L237-L246 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getSqlValueForEnum | public static function getSqlValueForEnum($colname, $enumVal)
{
$values = RemoteAppPeer::getValueSet($colname);
if (!in_array($enumVal, $values)) {
throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $colname));
}
return array_search($enumVal, $values);
} | php | public static function getSqlValueForEnum($colname, $enumVal)
{
$values = RemoteAppPeer::getValueSet($colname);
if (!in_array($enumVal, $values)) {
throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $colname));
}
return array_search($enumVal, $values);
} | [
"public",
"static",
"function",
"getSqlValueForEnum",
"(",
"$",
"colname",
",",
"$",
"enumVal",
")",
"{",
"$",
"values",
"=",
"RemoteAppPeer",
"::",
"getValueSet",
"(",
"$",
"colname",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"enumVal",
",",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Value \"%s\" is not accepted in this enumerated column'",
",",
"$",
"colname",
")",
")",
";",
"}",
"return",
"array_search",
"(",
"$",
"enumVal",
",",
"$",
"values",
")",
";",
"}"
] | Gets the SQL value for the ENUM column value
@param string $colname ENUM column name.
@param string $enumVal ENUM value.
@return int SQL value | [
"Gets",
"the",
"SQL",
"value",
"for",
"the",
"ENUM",
"column",
"value"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L256-L264 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.addSelectColumns | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(RemoteAppPeer::ID);
$criteria->addSelectColumn(RemoteAppPeer::TYPE);
$criteria->addSelectColumn(RemoteAppPeer::NAME);
$criteria->addSelectColumn(RemoteAppPeer::DOMAIN);
$criteria->addSelectColumn(RemoteAppPeer::API_URL);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_HTTP_USER);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_HTTP_PASSWORD);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_TYPE);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_USER);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_PASSWORD);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_TOKEN);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_URL_USER_KEY);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_URL_PW_KEY);
$criteria->addSelectColumn(RemoteAppPeer::CRON);
$criteria->addSelectColumn(RemoteAppPeer::CUSTOMER_ID);
$criteria->addSelectColumn(RemoteAppPeer::ACTIVATED);
$criteria->addSelectColumn(RemoteAppPeer::NOTES);
$criteria->addSelectColumn(RemoteAppPeer::LAST_RUN);
$criteria->addSelectColumn(RemoteAppPeer::INCLUDELOG);
$criteria->addSelectColumn(RemoteAppPeer::PUBLIC_KEY);
$criteria->addSelectColumn(RemoteAppPeer::WEBSITE_HASH);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_RECIPIENT);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_SENDER);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_CHANGE);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_ERROR);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.type');
$criteria->addSelectColumn($alias . '.name');
$criteria->addSelectColumn($alias . '.domain');
$criteria->addSelectColumn($alias . '.api_url');
$criteria->addSelectColumn($alias . '.api_auth_http_user');
$criteria->addSelectColumn($alias . '.api_auth_http_password');
$criteria->addSelectColumn($alias . '.api_auth_type');
$criteria->addSelectColumn($alias . '.api_auth_user');
$criteria->addSelectColumn($alias . '.api_auth_password');
$criteria->addSelectColumn($alias . '.api_auth_token');
$criteria->addSelectColumn($alias . '.api_auth_url_user_key');
$criteria->addSelectColumn($alias . '.api_auth_url_pw_key');
$criteria->addSelectColumn($alias . '.cron');
$criteria->addSelectColumn($alias . '.customer_id');
$criteria->addSelectColumn($alias . '.activated');
$criteria->addSelectColumn($alias . '.notes');
$criteria->addSelectColumn($alias . '.last_run');
$criteria->addSelectColumn($alias . '.includeLog');
$criteria->addSelectColumn($alias . '.public_key');
$criteria->addSelectColumn($alias . '.website_hash');
$criteria->addSelectColumn($alias . '.notification_recipient');
$criteria->addSelectColumn($alias . '.notification_sender');
$criteria->addSelectColumn($alias . '.notification_change');
$criteria->addSelectColumn($alias . '.notification_error');
}
} | php | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(RemoteAppPeer::ID);
$criteria->addSelectColumn(RemoteAppPeer::TYPE);
$criteria->addSelectColumn(RemoteAppPeer::NAME);
$criteria->addSelectColumn(RemoteAppPeer::DOMAIN);
$criteria->addSelectColumn(RemoteAppPeer::API_URL);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_HTTP_USER);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_HTTP_PASSWORD);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_TYPE);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_USER);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_PASSWORD);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_TOKEN);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_URL_USER_KEY);
$criteria->addSelectColumn(RemoteAppPeer::API_AUTH_URL_PW_KEY);
$criteria->addSelectColumn(RemoteAppPeer::CRON);
$criteria->addSelectColumn(RemoteAppPeer::CUSTOMER_ID);
$criteria->addSelectColumn(RemoteAppPeer::ACTIVATED);
$criteria->addSelectColumn(RemoteAppPeer::NOTES);
$criteria->addSelectColumn(RemoteAppPeer::LAST_RUN);
$criteria->addSelectColumn(RemoteAppPeer::INCLUDELOG);
$criteria->addSelectColumn(RemoteAppPeer::PUBLIC_KEY);
$criteria->addSelectColumn(RemoteAppPeer::WEBSITE_HASH);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_RECIPIENT);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_SENDER);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_CHANGE);
$criteria->addSelectColumn(RemoteAppPeer::NOTIFICATION_ERROR);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.type');
$criteria->addSelectColumn($alias . '.name');
$criteria->addSelectColumn($alias . '.domain');
$criteria->addSelectColumn($alias . '.api_url');
$criteria->addSelectColumn($alias . '.api_auth_http_user');
$criteria->addSelectColumn($alias . '.api_auth_http_password');
$criteria->addSelectColumn($alias . '.api_auth_type');
$criteria->addSelectColumn($alias . '.api_auth_user');
$criteria->addSelectColumn($alias . '.api_auth_password');
$criteria->addSelectColumn($alias . '.api_auth_token');
$criteria->addSelectColumn($alias . '.api_auth_url_user_key');
$criteria->addSelectColumn($alias . '.api_auth_url_pw_key');
$criteria->addSelectColumn($alias . '.cron');
$criteria->addSelectColumn($alias . '.customer_id');
$criteria->addSelectColumn($alias . '.activated');
$criteria->addSelectColumn($alias . '.notes');
$criteria->addSelectColumn($alias . '.last_run');
$criteria->addSelectColumn($alias . '.includeLog');
$criteria->addSelectColumn($alias . '.public_key');
$criteria->addSelectColumn($alias . '.website_hash');
$criteria->addSelectColumn($alias . '.notification_recipient');
$criteria->addSelectColumn($alias . '.notification_sender');
$criteria->addSelectColumn($alias . '.notification_change');
$criteria->addSelectColumn($alias . '.notification_error');
}
} | [
"public",
"static",
"function",
"addSelectColumns",
"(",
"Criteria",
"$",
"criteria",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"alias",
")",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"ID",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"TYPE",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NAME",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"DOMAIN",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_URL",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_HTTP_USER",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_HTTP_PASSWORD",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_TYPE",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_USER",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_PASSWORD",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_TOKEN",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_URL_USER_KEY",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_URL_PW_KEY",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"CRON",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"CUSTOMER_ID",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"ACTIVATED",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NOTES",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"LAST_RUN",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"INCLUDELOG",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"PUBLIC_KEY",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"WEBSITE_HASH",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NOTIFICATION_RECIPIENT",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NOTIFICATION_SENDER",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NOTIFICATION_CHANGE",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"RemoteAppPeer",
"::",
"NOTIFICATION_ERROR",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.id'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.type'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.name'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.domain'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_url'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_http_user'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_http_password'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_type'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_user'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_password'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_token'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_url_user_key'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.api_auth_url_pw_key'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.cron'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.customer_id'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.activated'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.notes'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.last_run'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.includeLog'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.public_key'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.website_hash'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.notification_recipient'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.notification_sender'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.notification_change'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.notification_error'",
")",
";",
"}",
"}"
] | Add all the columns needed to create a new object.
Note: any columns that were marked with lazyLoad="true" in the
XML schema will not be added to the select list and only loaded
on demand.
@param Criteria $criteria object containing the columns to add.
@param string $alias optional table alias
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Add",
"all",
"the",
"columns",
"needed",
"to",
"create",
"a",
"new",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L295-L350 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getInstanceFromPool | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(RemoteAppPeer::$instances[$key])) {
return RemoteAppPeer::$instances[$key];
}
}
return null; // just to be explicit
} | php | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(RemoteAppPeer::$instances[$key])) {
return RemoteAppPeer::$instances[$key];
}
}
return null; // just to be explicit
} | [
"public",
"static",
"function",
"getInstanceFromPool",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Propel",
"::",
"isInstancePoolingEnabled",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"RemoteAppPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"RemoteAppPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
] | Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
For tables with a single-column primary key, that simple pkey value will be returned. For tables with
a multi-column primary key, a serialize()d version of the primary key will be returned.
@param string $key The key (@see getPrimaryKeyHash()) for this instance.
@return RemoteApp Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
@see getPrimaryKeyHash() | [
"Retrieves",
"a",
"string",
"version",
"of",
"the",
"primary",
"key",
"from",
"the",
"DB",
"resultset",
"row",
"that",
"can",
"be",
"used",
"to",
"uniquely",
"identify",
"a",
"row",
"in",
"this",
"table",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L521-L530 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.clearInstancePool | public static function clearInstancePool($and_clear_all_references = false)
{
if ($and_clear_all_references) {
foreach (RemoteAppPeer::$instances as $instance) {
$instance->clearAllReferences(true);
}
}
RemoteAppPeer::$instances = array();
} | php | public static function clearInstancePool($and_clear_all_references = false)
{
if ($and_clear_all_references) {
foreach (RemoteAppPeer::$instances as $instance) {
$instance->clearAllReferences(true);
}
}
RemoteAppPeer::$instances = array();
} | [
"public",
"static",
"function",
"clearInstancePool",
"(",
"$",
"and_clear_all_references",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"and_clear_all_references",
")",
"{",
"foreach",
"(",
"RemoteAppPeer",
"::",
"$",
"instances",
"as",
"$",
"instance",
")",
"{",
"$",
"instance",
"->",
"clearAllReferences",
"(",
"true",
")",
";",
"}",
"}",
"RemoteAppPeer",
"::",
"$",
"instances",
"=",
"array",
"(",
")",
";",
"}"
] | Clear the instance pool.
@return void | [
"Clear",
"the",
"instance",
"pool",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L537-L545 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.buildTableMap | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseRemoteAppPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseRemoteAppPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\RemoteAppTableMap());
}
} | php | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseRemoteAppPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseRemoteAppPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\AppBundle\Model\map\RemoteAppTableMap());
}
} | [
"public",
"static",
"function",
"buildTableMap",
"(",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"BaseRemoteAppPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"!",
"$",
"dbMap",
"->",
"hasTable",
"(",
"BaseRemoteAppPeer",
"::",
"TABLE_NAME",
")",
")",
"{",
"$",
"dbMap",
"->",
"addTableObject",
"(",
"new",
"\\",
"Slashworks",
"\\",
"AppBundle",
"\\",
"Model",
"\\",
"map",
"\\",
"RemoteAppTableMap",
"(",
")",
")",
";",
"}",
"}"
] | Add a TableMap instance to the database for this peer class. | [
"Add",
"a",
"TableMap",
"instance",
"to",
"the",
"database",
"for",
"this",
"peer",
"class",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L908-L914 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.doOnDeleteCascade | protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
{
// initialize var to track total num of affected rows
$affectedRows = 0;
// first find the objects that are implicated by the $criteria
$objects = RemoteAppPeer::doSelect($criteria, $con);
foreach ($objects as $obj) {
// delete related ApiLog objects
$criteria = new Criteria(ApiLogPeer::DATABASE_NAME);
$criteria->add(ApiLogPeer::REMOTE_APP_ID, $obj->getId());
$affectedRows += ApiLogPeer::doDelete($criteria, $con);
// delete related RemoteHistoryContao objects
$criteria = new Criteria(RemoteHistoryContaoPeer::DATABASE_NAME);
$criteria->add(RemoteHistoryContaoPeer::REMOTE_APP_ID, $obj->getId());
$affectedRows += RemoteHistoryContaoPeer::doDelete($criteria, $con);
}
return $affectedRows;
} | php | protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
{
// initialize var to track total num of affected rows
$affectedRows = 0;
// first find the objects that are implicated by the $criteria
$objects = RemoteAppPeer::doSelect($criteria, $con);
foreach ($objects as $obj) {
// delete related ApiLog objects
$criteria = new Criteria(ApiLogPeer::DATABASE_NAME);
$criteria->add(ApiLogPeer::REMOTE_APP_ID, $obj->getId());
$affectedRows += ApiLogPeer::doDelete($criteria, $con);
// delete related RemoteHistoryContao objects
$criteria = new Criteria(RemoteHistoryContaoPeer::DATABASE_NAME);
$criteria->add(RemoteHistoryContaoPeer::REMOTE_APP_ID, $obj->getId());
$affectedRows += RemoteHistoryContaoPeer::doDelete($criteria, $con);
}
return $affectedRows;
} | [
"protected",
"static",
"function",
"doOnDeleteCascade",
"(",
"Criteria",
"$",
"criteria",
",",
"PropelPDO",
"$",
"con",
")",
"{",
"// initialize var to track total num of affected rows",
"$",
"affectedRows",
"=",
"0",
";",
"// first find the objects that are implicated by the $criteria",
"$",
"objects",
"=",
"RemoteAppPeer",
"::",
"doSelect",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"obj",
")",
"{",
"// delete related ApiLog objects",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"ApiLogPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"ApiLogPeer",
"::",
"REMOTE_APP_ID",
",",
"$",
"obj",
"->",
"getId",
"(",
")",
")",
";",
"$",
"affectedRows",
"+=",
"ApiLogPeer",
"::",
"doDelete",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"// delete related RemoteHistoryContao objects",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"RemoteHistoryContaoPeer",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"RemoteHistoryContaoPeer",
"::",
"REMOTE_APP_ID",
",",
"$",
"obj",
"->",
"getId",
"(",
")",
")",
";",
"$",
"affectedRows",
"+=",
"RemoteHistoryContaoPeer",
"::",
"doDelete",
"(",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
] | This is a method for emulating ON DELETE CASCADE for DBs that don't support this
feature (like MySQL or SQLite).
This method is not very speedy because it must perform a query first to get
the implicated records and then perform the deletes by calling those Peer classes.
This method should be used within a transaction if possible.
@param Criteria $criteria
@param PropelPDO $con
@return int The number of affected rows (if supported by underlying database driver). | [
"This",
"is",
"a",
"method",
"for",
"emulating",
"ON",
"DELETE",
"CASCADE",
"for",
"DBs",
"that",
"don",
"t",
"support",
"this",
"feature",
"(",
"like",
"MySQL",
"or",
"SQLite",
")",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L1121-L1145 |
fyuze/framework | src/Fyuze/Http/Message/Upload.php | Upload.getStream | public function getStream()
{
if ($this->moved === true) {
throw new \RuntimeException('File has already been moved to disk.');
}
if ($this->stream instanceof StreamInterface) {
return $this->stream;
}
return $this->stream = new Stream($this->stream);
} | php | public function getStream()
{
if ($this->moved === true) {
throw new \RuntimeException('File has already been moved to disk.');
}
if ($this->stream instanceof StreamInterface) {
return $this->stream;
}
return $this->stream = new Stream($this->stream);
} | [
"public",
"function",
"getStream",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'File has already been moved to disk.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"stream",
"instanceof",
"StreamInterface",
")",
"{",
"return",
"$",
"this",
"->",
"stream",
";",
"}",
"return",
"$",
"this",
"->",
"stream",
"=",
"new",
"Stream",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"}"
] | {@inheritdoc}
@return StreamInterface Stream representation of the uploaded file.
@throws \RuntimeException in cases when no stream is available or can be
created. | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Message/Upload.php#L79-L90 |
fyuze/framework | src/Fyuze/Http/Message/Upload.php | Upload.moveTo | public function moveTo($targetPath)
{
if ($this->moved === true) {
throw new RuntimeException('This file has already been moved.');
}
if (is_writable($targetPath) === false) {
throw new InvalidArgumentException(
'Unable to write to target path'
);
}
if (strpos(PHP_SAPI, 'cli') === 0) {
$stream = new Stream($targetPath, 'wb+');
$this->getStream()->rewind();
$stream->write($this->stream->getContents());
} else {
// @codeCoverageIgnoreStart
if (move_uploaded_file($this->stream, $targetPath) === false) {
throw new RuntimeException('There was a problem moving your uploaded file.');
}
// @codeCoverageIgnoreEnd
}
$this->moved = true;
} | php | public function moveTo($targetPath)
{
if ($this->moved === true) {
throw new RuntimeException('This file has already been moved.');
}
if (is_writable($targetPath) === false) {
throw new InvalidArgumentException(
'Unable to write to target path'
);
}
if (strpos(PHP_SAPI, 'cli') === 0) {
$stream = new Stream($targetPath, 'wb+');
$this->getStream()->rewind();
$stream->write($this->stream->getContents());
} else {
// @codeCoverageIgnoreStart
if (move_uploaded_file($this->stream, $targetPath) === false) {
throw new RuntimeException('There was a problem moving your uploaded file.');
}
// @codeCoverageIgnoreEnd
}
$this->moved = true;
} | [
"public",
"function",
"moveTo",
"(",
"$",
"targetPath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
"===",
"true",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'This file has already been moved.'",
")",
";",
"}",
"if",
"(",
"is_writable",
"(",
"$",
"targetPath",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unable to write to target path'",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"PHP_SAPI",
",",
"'cli'",
")",
"===",
"0",
")",
"{",
"$",
"stream",
"=",
"new",
"Stream",
"(",
"$",
"targetPath",
",",
"'wb+'",
")",
";",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"$",
"stream",
"->",
"write",
"(",
"$",
"this",
"->",
"stream",
"->",
"getContents",
"(",
")",
")",
";",
"}",
"else",
"{",
"// @codeCoverageIgnoreStart",
"if",
"(",
"move_uploaded_file",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"targetPath",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'There was a problem moving your uploaded file.'",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"}",
"$",
"this",
"->",
"moved",
"=",
"true",
";",
"}"
] | {@inheritdoc}
@see http://php.net/is_uploaded_file
@see http://php.net/move_uploaded_file
@param string $targetPath Path to which to move the uploaded file.
@throws \InvalidArgumentException if the $path specified is invalid.
@throws \RuntimeException on any error during the move operation, or on
the second or subsequent call to the method. | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Message/Upload.php#L102-L129 |
freyo/flysystem-qcloud-cos-v3 | src/Adapter.php | Adapter.rename | public function rename($path, $newpath)
{
return (bool)$this->normalizeResponse(
Cosapi::move($this->getBucket(), $path, $newpath, 1)
);
} | php | public function rename($path, $newpath)
{
return (bool)$this->normalizeResponse(
Cosapi::move($this->getBucket(), $path, $newpath, 1)
);
} | [
"public",
"function",
"rename",
"(",
"$",
"path",
",",
"$",
"newpath",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"normalizeResponse",
"(",
"Cosapi",
"::",
"move",
"(",
"$",
"this",
"->",
"getBucket",
"(",
")",
",",
"$",
"path",
",",
"$",
"newpath",
",",
"1",
")",
")",
";",
"}"
] | @param string $path
@param string $newpath
@return bool | [
"@param",
"string",
"$path",
"@param",
"string",
"$newpath"
] | train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Adapter.php#L171-L176 |
freyo/flysystem-qcloud-cos-v3 | src/Adapter.php | Adapter.copy | public function copy($path, $newpath)
{
$resource = $this->read($path);
return isset($resource['contents'])
? (bool)$this->update($newpath, $resource['contents'], new Config()) : false;
} | php | public function copy($path, $newpath)
{
$resource = $this->read($path);
return isset($resource['contents'])
? (bool)$this->update($newpath, $resource['contents'], new Config()) : false;
} | [
"public",
"function",
"copy",
"(",
"$",
"path",
",",
"$",
"newpath",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"path",
")",
";",
"return",
"isset",
"(",
"$",
"resource",
"[",
"'contents'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"this",
"->",
"update",
"(",
"$",
"newpath",
",",
"$",
"resource",
"[",
"'contents'",
"]",
",",
"new",
"Config",
"(",
")",
")",
":",
"false",
";",
"}"
] | @param string $path
@param string $newpath
@return bool | [
"@param",
"string",
"$path",
"@param",
"string",
"$newpath"
] | train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Adapter.php#L184-L190 |
freyo/flysystem-qcloud-cos-v3 | src/Adapter.php | Adapter.delete | public function delete($path)
{
return (bool)$this->normalizeResponse(
Cosapi::delFile($this->getBucket(), $path)
);
} | php | public function delete($path)
{
return (bool)$this->normalizeResponse(
Cosapi::delFile($this->getBucket(), $path)
);
} | [
"public",
"function",
"delete",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"normalizeResponse",
"(",
"Cosapi",
"::",
"delFile",
"(",
"$",
"this",
"->",
"getBucket",
"(",
")",
",",
"$",
"path",
")",
")",
";",
"}"
] | @param string $path
@return bool | [
"@param",
"string",
"$path"
] | train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Adapter.php#L197-L202 |
freyo/flysystem-qcloud-cos-v3 | src/Adapter.php | Adapter.deleteDir | public function deleteDir($dirname)
{
return (bool)$this->normalizeResponse(
Cosapi::delFolder($this->getBucket(), $dirname)
);
} | php | public function deleteDir($dirname)
{
return (bool)$this->normalizeResponse(
Cosapi::delFolder($this->getBucket(), $dirname)
);
} | [
"public",
"function",
"deleteDir",
"(",
"$",
"dirname",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"normalizeResponse",
"(",
"Cosapi",
"::",
"delFolder",
"(",
"$",
"this",
"->",
"getBucket",
"(",
")",
",",
"$",
"dirname",
")",
")",
";",
"}"
] | @param string $dirname
@return bool | [
"@param",
"string",
"$dirname"
] | train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Adapter.php#L209-L214 |
freyo/flysystem-qcloud-cos-v3 | src/Adapter.php | Adapter.listContents | public function listContents($directory = '', $recursive = false)
{
return $this->normalizeResponse(
Cosapi::listFolder($this->getBucket(), $directory)
);
} | php | public function listContents($directory = '', $recursive = false)
{
return $this->normalizeResponse(
Cosapi::listFolder($this->getBucket(), $directory)
);
} | [
"public",
"function",
"listContents",
"(",
"$",
"directory",
"=",
"''",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"normalizeResponse",
"(",
"Cosapi",
"::",
"listFolder",
"(",
"$",
"this",
"->",
"getBucket",
"(",
")",
",",
"$",
"directory",
")",
")",
";",
"}"
] | @param string $directory
@param bool $recursive
@return bool | [
"@param",
"string",
"$directory",
"@param",
"bool",
"$recursive"
] | train | https://github.com/freyo/flysystem-qcloud-cos-v3/blob/6bddbc22396aa1228942ec4c0ce46935d415f3b4/src/Adapter.php#L289-L294 |
windwork/wf-mailer | lib/Helper.php | Helper.emailEncode | public static function emailEncode($emails, $encode = 'utf-8')
{
$emails = str_replace(['"', "\r", "\n", "\t"], '', $emails);
$emailArr = explode(',', $emails);
foreach ($emailArr as $k => $mail) {
$mail = trim($mail);
if (preg_match('/^(.+?)<(.+?)>$/', $mail, $match)) {
$mail = static::encode(trim($match[1])) . " <{$match[2]}>";
}
$emailArr[$k] = $mail;
}
return implode(', ', $emailArr);
} | php | public static function emailEncode($emails, $encode = 'utf-8')
{
$emails = str_replace(['"', "\r", "\n", "\t"], '', $emails);
$emailArr = explode(',', $emails);
foreach ($emailArr as $k => $mail) {
$mail = trim($mail);
if (preg_match('/^(.+?)<(.+?)>$/', $mail, $match)) {
$mail = static::encode(trim($match[1])) . " <{$match[2]}>";
}
$emailArr[$k] = $mail;
}
return implode(', ', $emailArr);
} | [
"public",
"static",
"function",
"emailEncode",
"(",
"$",
"emails",
",",
"$",
"encode",
"=",
"'utf-8'",
")",
"{",
"$",
"emails",
"=",
"str_replace",
"(",
"[",
"'\"'",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
"]",
",",
"''",
",",
"$",
"emails",
")",
";",
"$",
"emailArr",
"=",
"explode",
"(",
"','",
",",
"$",
"emails",
")",
";",
"foreach",
"(",
"$",
"emailArr",
"as",
"$",
"k",
"=>",
"$",
"mail",
")",
"{",
"$",
"mail",
"=",
"trim",
"(",
"$",
"mail",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^(.+?)<(.+?)>$/'",
",",
"$",
"mail",
",",
"$",
"match",
")",
")",
"{",
"$",
"mail",
"=",
"static",
"::",
"encode",
"(",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
".",
"\" <{$match[2]}>\"",
";",
"}",
"$",
"emailArr",
"[",
"$",
"k",
"]",
"=",
"$",
"mail",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"emailArr",
")",
";",
"}"
] | 邮箱(收件人、发件人、抄送、密送)编码
@param string $emails 格式:昵称<[email protected]>,孟春<[email protected]> 多个账号用半角逗号隔开 | [
"邮箱(收件人、发件人、抄送、密送)编码"
] | train | https://github.com/windwork/wf-mailer/blob/71fbdb3bcb5bdc0a53fa8b4433c446828e205d22/lib/Helper.php#L25-L41 |
jpcercal/resource-query-language | src/Processor/DoctrineOrmProcessor.php | DoctrineOrmProcessor.setWhereOperationMode | protected function setWhereOperationMode($whereOperationMode)
{
if (!in_array($whereOperationMode, [self::WHERE_OPERATION_MODE_AND, self::WHERE_OPERATION_MODE_OR])) {
throw new ProcessorException(sprintf(
'The where operation mode "%s" is not allowed or not exists.',
$whereOperationMode
));
}
$this->whereOperationMode = $whereOperationMode;
return $this;
} | php | protected function setWhereOperationMode($whereOperationMode)
{
if (!in_array($whereOperationMode, [self::WHERE_OPERATION_MODE_AND, self::WHERE_OPERATION_MODE_OR])) {
throw new ProcessorException(sprintf(
'The where operation mode "%s" is not allowed or not exists.',
$whereOperationMode
));
}
$this->whereOperationMode = $whereOperationMode;
return $this;
} | [
"protected",
"function",
"setWhereOperationMode",
"(",
"$",
"whereOperationMode",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"whereOperationMode",
",",
"[",
"self",
"::",
"WHERE_OPERATION_MODE_AND",
",",
"self",
"::",
"WHERE_OPERATION_MODE_OR",
"]",
")",
")",
"{",
"throw",
"new",
"ProcessorException",
"(",
"sprintf",
"(",
"'The where operation mode \"%s\" is not allowed or not exists.'",
",",
"$",
"whereOperationMode",
")",
")",
";",
"}",
"$",
"this",
"->",
"whereOperationMode",
"=",
"$",
"whereOperationMode",
";",
"return",
"$",
"this",
";",
"}"
] | @param string $whereOperationMode
@return DoctrineOrmProcessor
@throws ProcessorException | [
"@param",
"string",
"$whereOperationMode"
] | train | https://github.com/jpcercal/resource-query-language/blob/2a1520198c717a8199cd8d3d85ca2557e24cb7f5/src/Processor/DoctrineOrmProcessor.php#L62-L74 |
jpcercal/resource-query-language | src/Processor/DoctrineOrmProcessor.php | DoctrineOrmProcessor.getParamKeyByExpr | protected function getParamKeyByExpr(ExprInterface $expr)
{
return str_replace('.', '', $expr->getField()) . ucfirst($expr->getExpression()) . uniqid();
} | php | protected function getParamKeyByExpr(ExprInterface $expr)
{
return str_replace('.', '', $expr->getField()) . ucfirst($expr->getExpression()) . uniqid();
} | [
"protected",
"function",
"getParamKeyByExpr",
"(",
"ExprInterface",
"$",
"expr",
")",
"{",
"return",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"$",
"expr",
"->",
"getField",
"(",
")",
")",
".",
"ucfirst",
"(",
"$",
"expr",
"->",
"getExpression",
"(",
")",
")",
".",
"uniqid",
"(",
")",
";",
"}"
] | Get the parameter key that is used by doctrine to put the query parameter identifier.
@param ExprInterface $expr
@return string | [
"Get",
"the",
"parameter",
"key",
"that",
"is",
"used",
"by",
"doctrine",
"to",
"put",
"the",
"query",
"parameter",
"identifier",
"."
] | train | https://github.com/jpcercal/resource-query-language/blob/2a1520198c717a8199cd8d3d85ca2557e24cb7f5/src/Processor/DoctrineOrmProcessor.php#L113-L116 |
steeffeen/FancyManiaLinks | FML/Script/Features/Preload.php | Preload.addImageUrl | public function addImageUrl($imageUrl)
{
if (!in_array($imageUrl, $this->imageUrls)) {
array_push($this->imageUrls, $imageUrl);
}
return $this;
} | php | public function addImageUrl($imageUrl)
{
if (!in_array($imageUrl, $this->imageUrls)) {
array_push($this->imageUrls, $imageUrl);
}
return $this;
} | [
"public",
"function",
"addImageUrl",
"(",
"$",
"imageUrl",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"imageUrl",
",",
"$",
"this",
"->",
"imageUrls",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"imageUrls",
",",
"$",
"imageUrl",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add an Image Url to preload
@api
@param string $imageUrl Image Url
@return static | [
"Add",
"an",
"Image",
"Url",
"to",
"preload"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Preload.php#L55-L61 |
steeffeen/FancyManiaLinks | FML/Script/Features/Preload.php | Preload.getScriptText | protected function getScriptText()
{
$scriptText = "";
foreach ($this->imageUrls as $imageUrl) {
$escapedImageUrl = Builder::escapeText($imageUrl);
$scriptText .= "
PreloadImage({$escapedImageUrl});";
}
return $scriptText;
} | php | protected function getScriptText()
{
$scriptText = "";
foreach ($this->imageUrls as $imageUrl) {
$escapedImageUrl = Builder::escapeText($imageUrl);
$scriptText .= "
PreloadImage({$escapedImageUrl});";
}
return $scriptText;
} | [
"protected",
"function",
"getScriptText",
"(",
")",
"{",
"$",
"scriptText",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"imageUrls",
"as",
"$",
"imageUrl",
")",
"{",
"$",
"escapedImageUrl",
"=",
"Builder",
"::",
"escapeText",
"(",
"$",
"imageUrl",
")",
";",
"$",
"scriptText",
".=",
"\"\nPreloadImage({$escapedImageUrl});\"",
";",
"}",
"return",
"$",
"scriptText",
";",
"}"
] | Get the script text
@return string | [
"Get",
"the",
"script",
"text"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Preload.php#L102-L111 |
TypistTech/wp-kses-view | src/View.php | View.toHtml | public function toHtml($context = null): string
{
return wp_kses(
$this->unsafeRender($context),
$this->allowedHtml
);
} | php | public function toHtml($context = null): string
{
return wp_kses(
$this->unsafeRender($context),
$this->allowedHtml
);
} | [
"public",
"function",
"toHtml",
"(",
"$",
"context",
"=",
"null",
")",
":",
"string",
"{",
"return",
"wp_kses",
"(",
"$",
"this",
"->",
"unsafeRender",
"(",
"$",
"context",
")",
",",
"$",
"this",
"->",
"allowedHtml",
")",
";",
"}"
] | Convert the view to safe HTML.
@param mixed $context Optional. Context object for which to render the view.
@return string | [
"Convert",
"the",
"view",
"to",
"safe",
"HTML",
"."
] | train | https://github.com/TypistTech/wp-kses-view/blob/6a5e5a34b81c6387d1c5356c9e42166daec9225f/src/View.php#L80-L86 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php | GenerateDoctrineCrudCommand.generateDatatable | protected function generateDatatable($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getDatatableGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | php | protected function generateDatatable($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getDatatableGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | [
"protected",
"function",
"generateDatatable",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
",",
"$",
"forceOverwrite",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getDatatableGenerator",
"(",
"$",
"bundle",
")",
"->",
"generate",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
"[",
"0",
"]",
",",
"$",
"forceOverwrite",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"// form already exists",
"}",
"}"
] | Tries to generate forms if they don't exist yet and if we need write operations on entities. | [
"Tries",
"to",
"generate",
"forms",
"if",
"they",
"don",
"t",
"exist",
"yet",
"and",
"if",
"we",
"need",
"write",
"operations",
"on",
"entities",
"."
] | train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php#L230-L237 |
Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php | GenerateDoctrineCrudCommand.generateTranslations | protected function generateTranslations($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getTranslationsGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | php | protected function generateTranslations($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getTranslationsGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | [
"protected",
"function",
"generateTranslations",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
",",
"$",
"forceOverwrite",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getTranslationsGenerator",
"(",
"$",
"bundle",
")",
"->",
"generate",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
"[",
"0",
"]",
",",
"$",
"forceOverwrite",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"// form already exists",
"}",
"}"
] | Tries to generate translations if they don't exist yet and if we need write operations on entities. | [
"Tries",
"to",
"generate",
"translations",
"if",
"they",
"don",
"t",
"exist",
"yet",
"and",
"if",
"we",
"need",
"write",
"operations",
"on",
"entities",
"."
] | train | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php#L242-L249 |
ruvents/ruwork-upload-bundle | Source/Handler/UploadedFileHandler.php | UploadedFileHandler.write | public function write($source, string $target): void
{
$source->move(\dirname($target), basename($target));
} | php | public function write($source, string $target): void
{
$source->move(\dirname($target), basename($target));
} | [
"public",
"function",
"write",
"(",
"$",
"source",
",",
"string",
"$",
"target",
")",
":",
"void",
"{",
"$",
"source",
"->",
"move",
"(",
"\\",
"dirname",
"(",
"$",
"target",
")",
",",
"basename",
"(",
"$",
"target",
")",
")",
";",
"}"
] | {@inheritdoc}
@param UploadedFile $source | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Source/Handler/UploadedFileHandler.php#L26-L29 |
ruvents/ruwork-upload-bundle | Source/Handler/UploadedFileHandler.php | UploadedFileHandler.getAttributes | public function getAttributes($source): array
{
return [
self::CLIENT_MIME_TYPE => $source->getClientMimeType(),
self::CLIENT_NAME => $source->getClientOriginalName(),
self::TMP_PATH => $source->getPathname(),
];
} | php | public function getAttributes($source): array
{
return [
self::CLIENT_MIME_TYPE => $source->getClientMimeType(),
self::CLIENT_NAME => $source->getClientOriginalName(),
self::TMP_PATH => $source->getPathname(),
];
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"source",
")",
":",
"array",
"{",
"return",
"[",
"self",
"::",
"CLIENT_MIME_TYPE",
"=>",
"$",
"source",
"->",
"getClientMimeType",
"(",
")",
",",
"self",
"::",
"CLIENT_NAME",
"=>",
"$",
"source",
"->",
"getClientOriginalName",
"(",
")",
",",
"self",
"::",
"TMP_PATH",
"=>",
"$",
"source",
"->",
"getPathname",
"(",
")",
",",
"]",
";",
"}"
] | {@inheritdoc}
@param UploadedFile $source | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Source/Handler/UploadedFileHandler.php#L36-L43 |
webforge-labs/psc-cms | lib/Psc/Code/Generate/ClassBuilder.php | ClassBuilder.createMethod | public function createMethod($name, $params = array(), $body = NULL, $modifiers = 256) {
$method = $this->class->createMethod($name, $params, $body, $modifiers);
$method->setClassBuilder($this);
return $method;
} | php | public function createMethod($name, $params = array(), $body = NULL, $modifiers = 256) {
$method = $this->class->createMethod($name, $params, $body, $modifiers);
$method->setClassBuilder($this);
return $method;
} | [
"public",
"function",
"createMethod",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"body",
"=",
"NULL",
",",
"$",
"modifiers",
"=",
"256",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"class",
"->",
"createMethod",
"(",
"$",
"name",
",",
"$",
"params",
",",
"$",
"body",
",",
"$",
"modifiers",
")",
";",
"$",
"method",
"->",
"setClassBuilder",
"(",
"$",
"this",
")",
";",
"return",
"$",
"method",
";",
"}"
] | Erstellt eine neue Methode
@return GMethod | [
"Erstellt",
"eine",
"neue",
"Methode"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/ClassBuilder.php#L109-L113 |
webforge-labs/psc-cms | lib/Psc/Code/Generate/ClassBuilder.php | ClassBuilder.generateSetter | public function generateSetter(ClassBuilderProperty $property, $setter = NULL, $flags = 0) {
$setter = $setter ?: $property->getSetterName();
// wenn die klasse die Methode wirklich selbst hat, überschreiben wir diesen nicht
if ($this->class->hasOwnMethod($setter)) {
return $this;
}
// die methode gibt es auch nicht in der hierarchy, dann erstelleln wir sie ganz normal
if (!$this->class->hasMethod($setter)) {
$gMethod = $this->class->createMethod(
$setter,
array(
new GParameter(
$property->getName(),
$property->getPHPHint(),
($property->isNullable() && $property->getPHPHint() != NULL) ? NULL : GParameter::UNDEFINED
)
),
$this->createCode('setter', array(
'property'=>$property->getName()
)),
GMethod::MODIFIER_PUBLIC
);
$gMethod->createDocBlock()->addSimpleAnnotation('param '.($property->getDocType() ?: 'undefined').' $'.$property->getName());
} elseif (($flags & self::INHERIT)) {
// wir wollen die methode in dieser klasse haben (das besagt das flag), allerdings müssen wird ie methode ableiten
$method = clone $this->class->getMethod($setter);
if ($method->isAbstract()) {
$method->setAbstract(FALSE);
}
// check ob das property->getName() richtig ist?
if (count($method->getParameters()) === 0) {
$method->addParameter(
new GParameter(
$property->getName(),
$property->getPHPHint()
)
);
} elseif (count($method->getParameters()) > 0) {
$method->getParameterByIndex(0)->setName($property->getName());
}
$method->setBodyCode(
$this->createCode('setter', array(
'property'=>$property->getName()
))
);
$this->addMethod($method);
}
return $this;
} | php | public function generateSetter(ClassBuilderProperty $property, $setter = NULL, $flags = 0) {
$setter = $setter ?: $property->getSetterName();
// wenn die klasse die Methode wirklich selbst hat, überschreiben wir diesen nicht
if ($this->class->hasOwnMethod($setter)) {
return $this;
}
// die methode gibt es auch nicht in der hierarchy, dann erstelleln wir sie ganz normal
if (!$this->class->hasMethod($setter)) {
$gMethod = $this->class->createMethod(
$setter,
array(
new GParameter(
$property->getName(),
$property->getPHPHint(),
($property->isNullable() && $property->getPHPHint() != NULL) ? NULL : GParameter::UNDEFINED
)
),
$this->createCode('setter', array(
'property'=>$property->getName()
)),
GMethod::MODIFIER_PUBLIC
);
$gMethod->createDocBlock()->addSimpleAnnotation('param '.($property->getDocType() ?: 'undefined').' $'.$property->getName());
} elseif (($flags & self::INHERIT)) {
// wir wollen die methode in dieser klasse haben (das besagt das flag), allerdings müssen wird ie methode ableiten
$method = clone $this->class->getMethod($setter);
if ($method->isAbstract()) {
$method->setAbstract(FALSE);
}
// check ob das property->getName() richtig ist?
if (count($method->getParameters()) === 0) {
$method->addParameter(
new GParameter(
$property->getName(),
$property->getPHPHint()
)
);
} elseif (count($method->getParameters()) > 0) {
$method->getParameterByIndex(0)->setName($property->getName());
}
$method->setBodyCode(
$this->createCode('setter', array(
'property'=>$property->getName()
))
);
$this->addMethod($method);
}
return $this;
} | [
"public",
"function",
"generateSetter",
"(",
"ClassBuilderProperty",
"$",
"property",
",",
"$",
"setter",
"=",
"NULL",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"$",
"setter",
"=",
"$",
"setter",
"?",
":",
"$",
"property",
"->",
"getSetterName",
"(",
")",
";",
"// wenn die klasse die Methode wirklich selbst hat, überschreiben wir diesen nicht",
"if",
"(",
"$",
"this",
"->",
"class",
"->",
"hasOwnMethod",
"(",
"$",
"setter",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// die methode gibt es auch nicht in der hierarchy, dann erstelleln wir sie ganz normal",
"if",
"(",
"!",
"$",
"this",
"->",
"class",
"->",
"hasMethod",
"(",
"$",
"setter",
")",
")",
"{",
"$",
"gMethod",
"=",
"$",
"this",
"->",
"class",
"->",
"createMethod",
"(",
"$",
"setter",
",",
"array",
"(",
"new",
"GParameter",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"property",
"->",
"getPHPHint",
"(",
")",
",",
"(",
"$",
"property",
"->",
"isNullable",
"(",
")",
"&&",
"$",
"property",
"->",
"getPHPHint",
"(",
")",
"!=",
"NULL",
")",
"?",
"NULL",
":",
"GParameter",
"::",
"UNDEFINED",
")",
")",
",",
"$",
"this",
"->",
"createCode",
"(",
"'setter'",
",",
"array",
"(",
"'property'",
"=>",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
",",
"GMethod",
"::",
"MODIFIER_PUBLIC",
")",
";",
"$",
"gMethod",
"->",
"createDocBlock",
"(",
")",
"->",
"addSimpleAnnotation",
"(",
"'param '",
".",
"(",
"$",
"property",
"->",
"getDocType",
"(",
")",
"?",
":",
"'undefined'",
")",
".",
"' $'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"flags",
"&",
"self",
"::",
"INHERIT",
")",
")",
"{",
"// wir wollen die methode in dieser klasse haben (das besagt das flag), allerdings müssen wird ie methode ableiten",
"$",
"method",
"=",
"clone",
"$",
"this",
"->",
"class",
"->",
"getMethod",
"(",
"$",
"setter",
")",
";",
"if",
"(",
"$",
"method",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"method",
"->",
"setAbstract",
"(",
"FALSE",
")",
";",
"}",
"// check ob das property->getName() richtig ist?",
"if",
"(",
"count",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"method",
"->",
"addParameter",
"(",
"new",
"GParameter",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"property",
"->",
"getPHPHint",
"(",
")",
")",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"method",
"->",
"getParameterByIndex",
"(",
"0",
")",
"->",
"setName",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"}",
"$",
"method",
"->",
"setBodyCode",
"(",
"$",
"this",
"->",
"createCode",
"(",
"'setter'",
",",
"array",
"(",
"'property'",
"=>",
"$",
"property",
"->",
"getName",
"(",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"addMethod",
"(",
"$",
"method",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | @param string der volle Name des Setters
@param $flags wenn dies z.B: INHERIT ist wird immer eine eigene Methode für den Setter erstellt (auch wenn es die Methode schon in der Hierarchy gibt) | [
"@param",
"string",
"der",
"volle",
"Name",
"des",
"Setters"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/ClassBuilder.php#L217-L271 |
webforge-labs/psc-cms | lib/Psc/Code/Generate/ClassBuilder.php | ClassBuilder.setParentClass | public function setParentClass(GClass $gClass) {
$this->class->setParentClass($gClass);
if ($gClass->exists()) {
try {
// damit die gclass vernünftig initialisiert wird
$this->class->elevateParent();
} catch (\Psc\Code\Generate\ReflectionException $e) {
throw new \Psc\Exception(
'Die Parent-Klasse: '.$gClass->getFQN().' kann nicht elevated werden. Das ist schlecht, denn so können nicht alle methoden korrekt vererbt werden oder properties erstellt werden.'.
'Die SyntaxFehler der Klasse müssen zuerst behoben werden',
0,
$e
);
}
}
return $this;
} | php | public function setParentClass(GClass $gClass) {
$this->class->setParentClass($gClass);
if ($gClass->exists()) {
try {
// damit die gclass vernünftig initialisiert wird
$this->class->elevateParent();
} catch (\Psc\Code\Generate\ReflectionException $e) {
throw new \Psc\Exception(
'Die Parent-Klasse: '.$gClass->getFQN().' kann nicht elevated werden. Das ist schlecht, denn so können nicht alle methoden korrekt vererbt werden oder properties erstellt werden.'.
'Die SyntaxFehler der Klasse müssen zuerst behoben werden',
0,
$e
);
}
}
return $this;
} | [
"public",
"function",
"setParentClass",
"(",
"GClass",
"$",
"gClass",
")",
"{",
"$",
"this",
"->",
"class",
"->",
"setParentClass",
"(",
"$",
"gClass",
")",
";",
"if",
"(",
"$",
"gClass",
"->",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"// damit die gclass vernünftig initialisiert wird",
"$",
"this",
"->",
"class",
"->",
"elevateParent",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Psc",
"\\",
"Code",
"\\",
"Generate",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Psc",
"\\",
"Exception",
"(",
"'Die Parent-Klasse: '",
".",
"$",
"gClass",
"->",
"getFQN",
"(",
")",
".",
"' kann nicht elevated werden. Das ist schlecht, denn so können nicht alle methoden korrekt vererbt werden oder properties erstellt werden.'.",
"",
"'Die SyntaxFehler der Klasse müssen zuerst behoben werden',",
"",
"0",
",",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Elevated die ParentClass um properties der Hierarchy laden zu können | [
"Elevated",
"die",
"ParentClass",
"um",
"properties",
"der",
"Hierarchy",
"laden",
"zu",
"können"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/ClassBuilder.php#L421-L439 |
terion-name/package-installer | src/Terion/PackageInstaller/PackageProcessCommand.php | PackageProcessCommand.fire | public function fire()
{
$packageName = $this->argument('packageName');
$version = $this->argument('version');
$version = unserialize(base64_decode($version));
$this->postProcess($packageName, $version);
} | php | public function fire()
{
$packageName = $this->argument('packageName');
$version = $this->argument('version');
$version = unserialize(base64_decode($version));
$this->postProcess($packageName, $version);
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"packageName",
"=",
"$",
"this",
"->",
"argument",
"(",
"'packageName'",
")",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"argument",
"(",
"'version'",
")",
";",
"$",
"version",
"=",
"unserialize",
"(",
"base64_decode",
"(",
"$",
"version",
")",
")",
";",
"$",
"this",
"->",
"postProcess",
"(",
"$",
"packageName",
",",
"$",
"version",
")",
";",
"}"
] | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageProcessCommand.php#L67-L73 |
terion-name/package-installer | src/Terion/PackageInstaller/PackageProcessCommand.php | PackageProcessCommand.postProcess | protected function postProcess($packageName, Version $version)
{
$this->comment('Processing package...');
$specials = $this->resolver->specials($packageName, $version);
if ($specials === false) {
$this->info("No Service Providers and Facades found. Assuming that package is not designed for Laravel");
$this->info('Finishing');
exit;
}
if ($this->resolver->isProvidesJsonDetected()) {
$this->comment('provides.json detected');
}
if (count($specials['providers'])) {
$this->comment('Found ' . count($specials['providers']) . ' service providers:');
foreach ($specials['providers'] as $i => $p) {
$this->info("[" . ($i + 1) . "] {$p}");
$this->config->addProvider($p);
}
}
if (count($specials['aliases'])) {
$this->comment('Found ' . count($specials['aliases']) . ' aliases:');
foreach ($specials['aliases'] as $i => $alias) {
$this->info("[" . ($i + 1) . "] {$alias['facade']} [{$alias['alias']}]");
$this->config->addAlias($alias['alias'], $alias['facade']);
}
}
// publish configs and assets
try {
$this->call('config:publish', array('package' => $packageName));
} catch (Exception $e) {
$this->comment($e->getMessage());
}
try {
$this->call('asset:publish', array('package' => $packageName));
} catch (Exception $e) {
$this->comment($e->getMessage());
}
} | php | protected function postProcess($packageName, Version $version)
{
$this->comment('Processing package...');
$specials = $this->resolver->specials($packageName, $version);
if ($specials === false) {
$this->info("No Service Providers and Facades found. Assuming that package is not designed for Laravel");
$this->info('Finishing');
exit;
}
if ($this->resolver->isProvidesJsonDetected()) {
$this->comment('provides.json detected');
}
if (count($specials['providers'])) {
$this->comment('Found ' . count($specials['providers']) . ' service providers:');
foreach ($specials['providers'] as $i => $p) {
$this->info("[" . ($i + 1) . "] {$p}");
$this->config->addProvider($p);
}
}
if (count($specials['aliases'])) {
$this->comment('Found ' . count($specials['aliases']) . ' aliases:');
foreach ($specials['aliases'] as $i => $alias) {
$this->info("[" . ($i + 1) . "] {$alias['facade']} [{$alias['alias']}]");
$this->config->addAlias($alias['alias'], $alias['facade']);
}
}
// publish configs and assets
try {
$this->call('config:publish', array('package' => $packageName));
} catch (Exception $e) {
$this->comment($e->getMessage());
}
try {
$this->call('asset:publish', array('package' => $packageName));
} catch (Exception $e) {
$this->comment($e->getMessage());
}
} | [
"protected",
"function",
"postProcess",
"(",
"$",
"packageName",
",",
"Version",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"'Processing package...'",
")",
";",
"$",
"specials",
"=",
"$",
"this",
"->",
"resolver",
"->",
"specials",
"(",
"$",
"packageName",
",",
"$",
"version",
")",
";",
"if",
"(",
"$",
"specials",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"No Service Providers and Facades found. Assuming that package is not designed for Laravel\"",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Finishing'",
")",
";",
"exit",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resolver",
"->",
"isProvidesJsonDetected",
"(",
")",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"'provides.json detected'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"specials",
"[",
"'providers'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"'Found '",
".",
"count",
"(",
"$",
"specials",
"[",
"'providers'",
"]",
")",
".",
"' service providers:'",
")",
";",
"foreach",
"(",
"$",
"specials",
"[",
"'providers'",
"]",
"as",
"$",
"i",
"=>",
"$",
"p",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"[\"",
".",
"(",
"$",
"i",
"+",
"1",
")",
".",
"\"] {$p}\"",
")",
";",
"$",
"this",
"->",
"config",
"->",
"addProvider",
"(",
"$",
"p",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"specials",
"[",
"'aliases'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"'Found '",
".",
"count",
"(",
"$",
"specials",
"[",
"'aliases'",
"]",
")",
".",
"' aliases:'",
")",
";",
"foreach",
"(",
"$",
"specials",
"[",
"'aliases'",
"]",
"as",
"$",
"i",
"=>",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"[\"",
".",
"(",
"$",
"i",
"+",
"1",
")",
".",
"\"] {$alias['facade']} [{$alias['alias']}]\"",
")",
";",
"$",
"this",
"->",
"config",
"->",
"addAlias",
"(",
"$",
"alias",
"[",
"'alias'",
"]",
",",
"$",
"alias",
"[",
"'facade'",
"]",
")",
";",
"}",
"}",
"// publish configs and assets",
"try",
"{",
"$",
"this",
"->",
"call",
"(",
"'config:publish'",
",",
"array",
"(",
"'package'",
"=>",
"$",
"packageName",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"call",
"(",
"'asset:publish'",
",",
"array",
"(",
"'package'",
"=>",
"$",
"packageName",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"comment",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Process package after install
e.g. search and register ServiceProviders and Facades.
@param $packageName
@param Version $version | [
"Process",
"package",
"after",
"install",
"e",
".",
"g",
".",
"search",
"and",
"register",
"ServiceProviders",
"and",
"Facades",
"."
] | train | https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageProcessCommand.php#L82-L125 |
bdunogier/iftttbundle | IFTTT/RequestParser.php | RequestParser.getRequest | public function getRequest( array $requestPostData )
{
$requestProperties = array(
'username' => $requestPostData[1],
'password' => $requestPostData[2],
'title' => $requestPostData[3]['title'],
'description' => $requestPostData[3]['description'],
'keywords' => $requestPostData[3]['mt_keywords'],
'status' => $requestPostData[3]['post_status'],
);
return new Request( $requestProperties );
} | php | public function getRequest( array $requestPostData )
{
$requestProperties = array(
'username' => $requestPostData[1],
'password' => $requestPostData[2],
'title' => $requestPostData[3]['title'],
'description' => $requestPostData[3]['description'],
'keywords' => $requestPostData[3]['mt_keywords'],
'status' => $requestPostData[3]['post_status'],
);
return new Request( $requestProperties );
} | [
"public",
"function",
"getRequest",
"(",
"array",
"$",
"requestPostData",
")",
"{",
"$",
"requestProperties",
"=",
"array",
"(",
"'username'",
"=>",
"$",
"requestPostData",
"[",
"1",
"]",
",",
"'password'",
"=>",
"$",
"requestPostData",
"[",
"2",
"]",
",",
"'title'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'title'",
"]",
",",
"'description'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'description'",
"]",
",",
"'keywords'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'mt_keywords'",
"]",
",",
"'status'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'post_status'",
"]",
",",
")",
";",
"return",
"new",
"Request",
"(",
"$",
"requestProperties",
")",
";",
"}"
] | Creates an IFTTT Request from XML RPC post data
@param array $requestPostData
@return \BD\Bundle\IFTTTBundle\IFTTT\Request | [
"Creates",
"an",
"IFTTT",
"Request",
"from",
"XML",
"RPC",
"post",
"data"
] | train | https://github.com/bdunogier/iftttbundle/blob/b3232a9f49cc6cc8bfc86e92eaf961d8c59021fa/IFTTT/RequestParser.php#L21-L33 |
webforge-labs/psc-cms | lib/Psc/Code/ExceptionBuilder.php | ExceptionBuilder.end | public function end() {
$c = $this->fqn;
$this->exception = new $c($this->msg, $this->code, $this->previous);
foreach ($this->vars as $var => $value) {
$this->exception->$var = $value;
}
return $this->exception;
} | php | public function end() {
$c = $this->fqn;
$this->exception = new $c($this->msg, $this->code, $this->previous);
foreach ($this->vars as $var => $value) {
$this->exception->$var = $value;
}
return $this->exception;
} | [
"public",
"function",
"end",
"(",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"fqn",
";",
"$",
"this",
"->",
"exception",
"=",
"new",
"$",
"c",
"(",
"$",
"this",
"->",
"msg",
",",
"$",
"this",
"->",
"code",
",",
"$",
"this",
"->",
"previous",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"vars",
"as",
"$",
"var",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"exception",
"->",
"$",
"var",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"exception",
";",
"}"
] | Gibt die fertige Exception zurück
Nachdem end() aufgerufen wurde, haben die anderen Funktionen keinen Effekt mehr. Der Builder ist dann nutzlos
@return Exception | [
"Gibt",
"die",
"fertige",
"Exception",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/ExceptionBuilder.php#L34-L42 |
steeffeen/FancyManiaLinks | FML/Form/Parameters.php | Parameters.getValue | public static function getValue($name)
{
if (array_key_exists($name, $_GET)) {
return $_GET[$name];
}
if (array_key_exists($name, $_POST)) {
return $_POST[$name];
}
return null;
} | php | public static function getValue($name)
{
if (array_key_exists($name, $_GET)) {
return $_GET[$name];
}
if (array_key_exists($name, $_POST)) {
return $_POST[$name];
}
return null;
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_GET",
")",
")",
"{",
"return",
"$",
"_GET",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_POST",
")",
")",
"{",
"return",
"$",
"_POST",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get the submitted form value
@param string $name Value name
@return string | [
"Get",
"the",
"submitted",
"form",
"value"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Form/Parameters.php#L21-L30 |
webforge-labs/psc-cms | lib/Psc/FE/Errors.php | Errors.hasErrors | public function hasErrors() {
foreach ($this->jsonArray as $error) {
if ($error['type'] != self::OK)
return TRUE;
}
return FALSE;
} | php | public function hasErrors() {
foreach ($this->jsonArray as $error) {
if ($error['type'] != self::OK)
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"hasErrors",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"jsonArray",
"as",
"$",
"error",
")",
"{",
"if",
"(",
"$",
"error",
"[",
"'type'",
"]",
"!=",
"self",
"::",
"OK",
")",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Gibt nur dann Errors zurück, wenn diese ungleich self::OK sind
@return bool | [
"Gibt",
"nur",
"dann",
"Errors",
"zurück",
"wenn",
"diese",
"ungleich",
"self",
"::",
"OK",
"sind"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/FE/Errors.php#L69-L75 |
webforge-labs/psc-cms | lib/Psc/FE/Errors.php | Errors.addEx | public function addEx(\Psc\Exception $e) {
if (isset($e->errorMessage)) {
$msg = $e->errorMessage;
} else {
$msg = $e->getMessage();
}
if (isset($e->errorStatus)) {
$errorStatus = $e->errorStatus;
} else {
$errorStatus = self::ERROR;
}
$devInfo = NULL;
if (PSC::getProject()->isDevelopment()) {
$devInfo = \Psc\Exception::getExceptionText($e, 'html');
}
return $this->add($msg, $errorStatus, $devInfo);
} | php | public function addEx(\Psc\Exception $e) {
if (isset($e->errorMessage)) {
$msg = $e->errorMessage;
} else {
$msg = $e->getMessage();
}
if (isset($e->errorStatus)) {
$errorStatus = $e->errorStatus;
} else {
$errorStatus = self::ERROR;
}
$devInfo = NULL;
if (PSC::getProject()->isDevelopment()) {
$devInfo = \Psc\Exception::getExceptionText($e, 'html');
}
return $this->add($msg, $errorStatus, $devInfo);
} | [
"public",
"function",
"addEx",
"(",
"\\",
"Psc",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"e",
"->",
"errorMessage",
")",
")",
"{",
"$",
"msg",
"=",
"$",
"e",
"->",
"errorMessage",
";",
"}",
"else",
"{",
"$",
"msg",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"e",
"->",
"errorStatus",
")",
")",
"{",
"$",
"errorStatus",
"=",
"$",
"e",
"->",
"errorStatus",
";",
"}",
"else",
"{",
"$",
"errorStatus",
"=",
"self",
"::",
"ERROR",
";",
"}",
"$",
"devInfo",
"=",
"NULL",
";",
"if",
"(",
"PSC",
"::",
"getProject",
"(",
")",
"->",
"isDevelopment",
"(",
")",
")",
"{",
"$",
"devInfo",
"=",
"\\",
"Psc",
"\\",
"Exception",
"::",
"getExceptionText",
"(",
"$",
"e",
",",
"'html'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"add",
"(",
"$",
"msg",
",",
"$",
"errorStatus",
",",
"$",
"devInfo",
")",
";",
"}"
] | Fügt eine schöne Exception als Fehler hinzu | [
"Fügt",
"eine",
"schöne",
"Exception",
"als",
"Fehler",
"hinzu"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/FE/Errors.php#L108-L127 |
webforge-labs/psc-cms | lib/Psc/FE/Errors.php | Errors.html | public function html() {
$html = NULL;
if (count($this->jsonArray) > 0) {
$content = json_encode($this->jsonArray,
JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP
);
$html = HTML::tag('div',$content,array('id'=>$this->getJsonId()))->setStyle('display','none');
}
return $html;
} | php | public function html() {
$html = NULL;
if (count($this->jsonArray) > 0) {
$content = json_encode($this->jsonArray,
JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP
);
$html = HTML::tag('div',$content,array('id'=>$this->getJsonId()))->setStyle('display','none');
}
return $html;
} | [
"public",
"function",
"html",
"(",
")",
"{",
"$",
"html",
"=",
"NULL",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"jsonArray",
")",
">",
"0",
")",
"{",
"$",
"content",
"=",
"json_encode",
"(",
"$",
"this",
"->",
"jsonArray",
",",
"JSON_HEX_TAG",
"|",
"JSON_HEX_APOS",
"|",
"JSON_HEX_QUOT",
"|",
"JSON_HEX_AMP",
")",
";",
"$",
"html",
"=",
"HTML",
"::",
"tag",
"(",
"'div'",
",",
"$",
"content",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"getJsonId",
"(",
")",
")",
")",
"->",
"setStyle",
"(",
"'display'",
",",
"'none'",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Gibt Informationen für die Fehler die angezeigt werden sollen, für das JavaScript zurück
@return HTMLTag|NULL | [
"Gibt",
"Informationen",
"für",
"die",
"Fehler",
"die",
"angezeigt",
"werden",
"sollen",
"für",
"das",
"JavaScript",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/FE/Errors.php#L160-L171 |
inpsyde/inpsyde-filter | src/WordPress/SpecialChars.php | SpecialChars.filter | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
$quote_style = $this->options[ 'quote_style' ];
$charset = (string) $this->options[ 'charset' ];
$double_quotes = (bool) $this->options[ 'double_encode' ];
return _wp_specialchars( $value, $quote_style, $charset, $double_quotes );
} | php | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
$quote_style = $this->options[ 'quote_style' ];
$charset = (string) $this->options[ 'charset' ];
$double_quotes = (bool) $this->options[ 'double_encode' ];
return _wp_specialchars( $value, $quote_style, $charset, $double_quotes );
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"do_action",
"(",
"'inpsyde.filter.error'",
",",
"'The given value is not string or empty.'",
",",
"[",
"'method'",
"=>",
"__METHOD__",
",",
"'value'",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"value",
";",
"}",
"$",
"quote_style",
"=",
"$",
"this",
"->",
"options",
"[",
"'quote_style'",
"]",
";",
"$",
"charset",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"options",
"[",
"'charset'",
"]",
";",
"$",
"double_quotes",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"options",
"[",
"'double_encode'",
"]",
";",
"return",
"_wp_specialchars",
"(",
"$",
"value",
",",
"$",
"quote_style",
",",
"$",
"charset",
",",
"$",
"double_quotes",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/SpecialChars.php#L26-L39 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toNanos | public function toNanos($d)
{
$v = $this->getValue();
return $this->x($d, $this->{'c'.$v}/$this->c0, PHP_INT_MAX/($this->{'c'.$v}/$this->c0));
} | php | public function toNanos($d)
{
$v = $this->getValue();
return $this->x($d, $this->{'c'.$v}/$this->c0, PHP_INT_MAX/($this->{'c'.$v}/$this->c0));
} | [
"public",
"function",
"toNanos",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c0",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c0",
")",
")",
";",
"}"
] | Convert to nanos
@param int $d
@return int | [
"Convert",
"to",
"nanos"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L52-L56 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMicros | public function toMicros($d)
{
$v = $this->getValue();
if ($v < self::MICROSECONDS) {
return $d/($this->c1/$this->c0);
} else {
return $this->x($d, $this->{'c'.$v}/$this->c1, PHP_INT_MAX/($this->{'c'.$v})/$this->c1);
}
} | php | public function toMicros($d)
{
$v = $this->getValue();
if ($v < self::MICROSECONDS) {
return $d/($this->c1/$this->c0);
} else {
return $this->x($d, $this->{'c'.$v}/$this->c1, PHP_INT_MAX/($this->{'c'.$v})/$this->c1);
}
} | [
"public",
"function",
"toMicros",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MICROSECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c1",
"/",
"$",
"this",
"->",
"c0",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c1",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
"/",
"$",
"this",
"->",
"c1",
")",
";",
"}",
"}"
] | Convert to micros
@param int $d
@return float|int | [
"Convert",
"to",
"micros"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L64-L72 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMillis | public function toMillis($d)
{
$v = $this->getValue();
if ($v < self::MILLISECONDS) {
return $d/($this->c2/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c2, PHP_INT_MAX/($this->{'c'.$v}/$this->c2));
}
} | php | public function toMillis($d)
{
$v = $this->getValue();
if ($v < self::MILLISECONDS) {
return $d/($this->c2/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c2, PHP_INT_MAX/($this->{'c'.$v}/$this->c2));
}
} | [
"public",
"function",
"toMillis",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MILLISECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c2",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c2",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c2",
")",
")",
";",
"}",
"}"
] | Convert to millies
@param int $d
@return float|int | [
"Convert",
"to",
"millies"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L80-L88 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toSeconds | public function toSeconds($d)
{
$v = $this->getValue();
if ($v < self::SECONDS) {
return $d/($this->c3/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c3, PHP_INT_MAX/($this->{'c'.$v}/$this->c3));
}
} | php | public function toSeconds($d)
{
$v = $this->getValue();
if ($v < self::SECONDS) {
return $d/($this->c3/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c3, PHP_INT_MAX/($this->{'c'.$v}/$this->c3));
}
} | [
"public",
"function",
"toSeconds",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"SECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c3",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c3",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c3",
")",
")",
";",
"}",
"}"
] | Convert to seconds
@param int $d
@return float|int | [
"Convert",
"to",
"seconds"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L96-L104 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMinutes | public function toMinutes($d)
{
$v = $this->getValue();
if ($v < self::MINUTES) {
return $d/($this->c4/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c4, PHP_INT_MAX/($this->{'c'.$v}/$this->c4));
}
} | php | public function toMinutes($d)
{
$v = $this->getValue();
if ($v < self::MINUTES) {
return $d/($this->c4/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c4, PHP_INT_MAX/($this->{'c'.$v}/$this->c4));
}
} | [
"public",
"function",
"toMinutes",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MINUTES",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c4",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c4",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c4",
")",
")",
";",
"}",
"}"
] | Convert to minutes
@param int $d
@return float|int | [
"Convert",
"to",
"minutes"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L112-L120 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toHours | public function toHours($d)
{
$v = $this->getValue();
if ($v < self::HOURS) {
return $d/($this->c5/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c5, PHP_INT_MAX/($this->{'c'.$v}/$this->c5));
}
} | php | public function toHours($d)
{
$v = $this->getValue();
if ($v < self::HOURS) {
return $d/($this->c5/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c5, PHP_INT_MAX/($this->{'c'.$v}/$this->c5));
}
} | [
"public",
"function",
"toHours",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"HOURS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c5",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c5",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c5",
")",
")",
";",
"}",
"}"
] | Convert to hours
@param int $d
@return float|int | [
"Convert",
"to",
"hours"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L128-L136 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toDays | public function toDays($d)
{
$v = $this->getValue();
return $d/($this->c6/$this->{'c'.$v});
} | php | public function toDays($d)
{
$v = $this->getValue();
return $d/($this->c6/$this->{'c'.$v});
} | [
"public",
"function",
"toDays",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c6",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}"
] | Convert to days
@param int $d
@return float | [
"Convert",
"to",
"days"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L144-L148 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.convert | public function convert($sourceDuration, TimeUnit $sourceUnit)
{
switch ($this->getValue()) {
case self::NANOSECONDS:
return $sourceUnit->toNanos($sourceDuration);
case self::MICROSECONDS:
return $sourceUnit->toMicros($sourceDuration);
case self::MILLISECONDS:
return $sourceUnit->toMillis($sourceDuration);
case self::SECONDS:
return $sourceUnit->toSeconds($sourceDuration);
case self::MINUTES;
return $sourceUnit->toMinutes($sourceDuration);
case self::HOURS;
return $sourceUnit->toHours($sourceDuration);
case self::DAYS:
return $sourceUnit->toDays($sourceDuration);
}
} | php | public function convert($sourceDuration, TimeUnit $sourceUnit)
{
switch ($this->getValue()) {
case self::NANOSECONDS:
return $sourceUnit->toNanos($sourceDuration);
case self::MICROSECONDS:
return $sourceUnit->toMicros($sourceDuration);
case self::MILLISECONDS:
return $sourceUnit->toMillis($sourceDuration);
case self::SECONDS:
return $sourceUnit->toSeconds($sourceDuration);
case self::MINUTES;
return $sourceUnit->toMinutes($sourceDuration);
case self::HOURS;
return $sourceUnit->toHours($sourceDuration);
case self::DAYS:
return $sourceUnit->toDays($sourceDuration);
}
} | [
"public",
"function",
"convert",
"(",
"$",
"sourceDuration",
",",
"TimeUnit",
"$",
"sourceUnit",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
"{",
"case",
"self",
"::",
"NANOSECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toNanos",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MICROSECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toMicros",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MILLISECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toMillis",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"SECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toSeconds",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MINUTES",
";",
"return",
"$",
"sourceUnit",
"->",
"toMinutes",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"HOURS",
";",
"return",
"$",
"sourceUnit",
"->",
"toHours",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"DAYS",
":",
"return",
"$",
"sourceUnit",
"->",
"toDays",
"(",
"$",
"sourceDuration",
")",
";",
"}",
"}"
] | Convert the given time duration in the given unit to this
unit. Conversions from finer to coarser granularities
truncate, so lose precision. For example converting
999 milliseconds to seconds results in
0. Conversions from coarser to finer granularities
with arguments that would numerically overflow saturate to
"-PHP_INT_MAX -1" if negative or "PHP_INT_MAX"
if positive.
For example, to convert 10 minutes to milliseconds, use:
TimeUnit::MILLISECONDS()->convert(10, TimeUnit::MINUTES);
@param int $sourceDuration the time duration in the given source unit
@param TimeUnit $sourceUnit the unit of the source duration argument
@return float|int | [
"Convert",
"the",
"given",
"time",
"duration",
"in",
"the",
"given",
"unit",
"to",
"this",
"unit",
".",
"Conversions",
"from",
"finer",
"to",
"coarser",
"granularities",
"truncate",
"so",
"lose",
"precision",
".",
"For",
"example",
"converting",
"999",
"milliseconds",
"to",
"seconds",
"results",
"in",
"0",
".",
"Conversions",
"from",
"coarser",
"to",
"finer",
"granularities",
"with",
"arguments",
"that",
"would",
"numerically",
"overflow",
"saturate",
"to",
"-",
"PHP_INT_MAX",
"-",
"1",
"if",
"negative",
"or",
"PHP_INT_MAX",
"if",
"positive",
"."
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L167-L185 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.x | private function x($d, $m, $over)
{
if ($d > $over) {
return PHP_INT_MAX;
}
if ($d < -$over) {
return -PHP_INT_MAX -1;
}
return $d * $m;
} | php | private function x($d, $m, $over)
{
if ($d > $over) {
return PHP_INT_MAX;
}
if ($d < -$over) {
return -PHP_INT_MAX -1;
}
return $d * $m;
} | [
"private",
"function",
"x",
"(",
"$",
"d",
",",
"$",
"m",
",",
"$",
"over",
")",
"{",
"if",
"(",
"$",
"d",
">",
"$",
"over",
")",
"{",
"return",
"PHP_INT_MAX",
";",
"}",
"if",
"(",
"$",
"d",
"<",
"-",
"$",
"over",
")",
"{",
"return",
"-",
"PHP_INT_MAX",
"-",
"1",
";",
"}",
"return",
"$",
"d",
"*",
"$",
"m",
";",
"}"
] | Scale d by m, checking for overflow.
This has a short name to make code more readable.
@param int $d
@param int $m
@param int $over
@return int | [
"Scale",
"d",
"by",
"m",
"checking",
"for",
"overflow",
".",
"This",
"has",
"a",
"short",
"name",
"to",
"make",
"code",
"more",
"readable",
"."
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L196-L205 |
webtorque7/link-field | code/WTLink.php | WTLink.Link | public function Link()
{
$link = '';
switch ($this->type) {
case 'Internal' :
if ($this->internal && ($page = SiteTree::get()->byID($this->internal))) {
$link = $page->Link();
}
break;
case 'External' :
$link = $this->external;
break;
case 'Email' :
$link = $this->email ? 'mailto:' . $this->email : '';
break;
case 'File' :
if ($this->file) {
$link = File::get()->byID($this->file)->Filename;
}
break;
case 'DataObject':
if ($do = $this->getDO()) {
$link = $do->Link();
}
break;
}
if ($this->extra) {
//added a query string, but no ? to start it
if (strpos($this->extra, '=' !== false && strpos($this->extra, '?' === false))) {
$link .= '?';
}
$link .= $this->extra;
}
if ($this->anchor) {
$link .= '#' . $this->anchor;
}
return $link;
} | php | public function Link()
{
$link = '';
switch ($this->type) {
case 'Internal' :
if ($this->internal && ($page = SiteTree::get()->byID($this->internal))) {
$link = $page->Link();
}
break;
case 'External' :
$link = $this->external;
break;
case 'Email' :
$link = $this->email ? 'mailto:' . $this->email : '';
break;
case 'File' :
if ($this->file) {
$link = File::get()->byID($this->file)->Filename;
}
break;
case 'DataObject':
if ($do = $this->getDO()) {
$link = $do->Link();
}
break;
}
if ($this->extra) {
//added a query string, but no ? to start it
if (strpos($this->extra, '=' !== false && strpos($this->extra, '?' === false))) {
$link .= '?';
}
$link .= $this->extra;
}
if ($this->anchor) {
$link .= '#' . $this->anchor;
}
return $link;
} | [
"public",
"function",
"Link",
"(",
")",
"{",
"$",
"link",
"=",
"''",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"'Internal'",
":",
"if",
"(",
"$",
"this",
"->",
"internal",
"&&",
"(",
"$",
"page",
"=",
"SiteTree",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"internal",
")",
")",
")",
"{",
"$",
"link",
"=",
"$",
"page",
"->",
"Link",
"(",
")",
";",
"}",
"break",
";",
"case",
"'External'",
":",
"$",
"link",
"=",
"$",
"this",
"->",
"external",
";",
"break",
";",
"case",
"'Email'",
":",
"$",
"link",
"=",
"$",
"this",
"->",
"email",
"?",
"'mailto:'",
".",
"$",
"this",
"->",
"email",
":",
"''",
";",
"break",
";",
"case",
"'File'",
":",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"{",
"$",
"link",
"=",
"File",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"file",
")",
"->",
"Filename",
";",
"}",
"break",
";",
"case",
"'DataObject'",
":",
"if",
"(",
"$",
"do",
"=",
"$",
"this",
"->",
"getDO",
"(",
")",
")",
"{",
"$",
"link",
"=",
"$",
"do",
"->",
"Link",
"(",
")",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"extra",
")",
"{",
"//added a query string, but no ? to start it",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"extra",
",",
"'='",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"extra",
",",
"'?'",
"===",
"false",
")",
")",
")",
"{",
"$",
"link",
".=",
"'?'",
";",
"}",
"$",
"link",
".=",
"$",
"this",
"->",
"extra",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"anchor",
")",
"{",
"$",
"link",
".=",
"'#'",
".",
"$",
"this",
"->",
"anchor",
";",
"}",
"return",
"$",
"link",
";",
"}"
] | Determines the link by the type and what is set
@return mixed|string | [
"Determines",
"the",
"link",
"by",
"the",
"type",
"and",
"what",
"is",
"set"
] | train | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTLink.php#L389-L430 |
webtorque7/link-field | code/WTLink.php | WTLink.Tag | public function Tag($text = null)
{
$link = $this->Link();
if ($link) {
$target = !empty($this->targetBlank) ? 'target="_blank"' : '';
return $text ? "<a href=\"{$link}\" {$target}>" . Convert::raw2xml(
$text
) . '</a>' : "<a href=\"{$link}\" {$target}>";
}
return '';
} | php | public function Tag($text = null)
{
$link = $this->Link();
if ($link) {
$target = !empty($this->targetBlank) ? 'target="_blank"' : '';
return $text ? "<a href=\"{$link}\" {$target}>" . Convert::raw2xml(
$text
) . '</a>' : "<a href=\"{$link}\" {$target}>";
}
return '';
} | [
"public",
"function",
"Tag",
"(",
"$",
"text",
"=",
"null",
")",
"{",
"$",
"link",
"=",
"$",
"this",
"->",
"Link",
"(",
")",
";",
"if",
"(",
"$",
"link",
")",
"{",
"$",
"target",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"targetBlank",
")",
"?",
"'target=\"_blank\"'",
":",
"''",
";",
"return",
"$",
"text",
"?",
"\"<a href=\\\"{$link}\\\" {$target}>\"",
".",
"Convert",
"::",
"raw2xml",
"(",
"$",
"text",
")",
".",
"'</a>'",
":",
"\"<a href=\\\"{$link}\\\" {$target}>\"",
";",
"}",
"return",
"''",
";",
"}"
] | Creates the anchor tag, if $text is it is put inside the anchor tag, otherwise it only returns
the opening of the ancor tag
@param string|null $text
@return string | [
"Creates",
"the",
"anchor",
"tag",
"if",
"$text",
"is",
"it",
"is",
"put",
"inside",
"the",
"anchor",
"tag",
"otherwise",
"it",
"only",
"returns",
"the",
"opening",
"of",
"the",
"ancor",
"tag"
] | train | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTLink.php#L439-L452 |
webtorque7/link-field | code/WTLink.php | WTLink.getDO | public function getDO()
{
if (!empty($this->dataObject)) {
list($className, $ID) = explode('-', $this->dataObject);
return DataList::create($className)->byID($ID);
}
return null;
} | php | public function getDO()
{
if (!empty($this->dataObject)) {
list($className, $ID) = explode('-', $this->dataObject);
return DataList::create($className)->byID($ID);
}
return null;
} | [
"public",
"function",
"getDO",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"dataObject",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"ID",
")",
"=",
"explode",
"(",
"'-'",
",",
"$",
"this",
"->",
"dataObject",
")",
";",
"return",
"DataList",
"::",
"create",
"(",
"$",
"className",
")",
"->",
"byID",
"(",
"$",
"ID",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the DataObject instance
@return DataObject|null | [
"Get",
"the",
"DataObject",
"instance"
] | train | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTLink.php#L459-L468 |
CakeCMS/Core | src/Toolbar/ToolbarItemLink.php | ToolbarItemLink.fetchItem | public function fetchItem()
{
list ($source, $title, $url, $options) = func_get_args();
$url = Router::url($url);
return $this->_view->Html->link($title, $url, $options);
} | php | public function fetchItem()
{
list ($source, $title, $url, $options) = func_get_args();
$url = Router::url($url);
return $this->_view->Html->link($title, $url, $options);
} | [
"public",
"function",
"fetchItem",
"(",
")",
"{",
"list",
"(",
"$",
"source",
",",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
")",
"=",
"func_get_args",
"(",
")",
";",
"$",
"url",
"=",
"Router",
"::",
"url",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"_view",
"->",
"Html",
"->",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"}"
] | Fetch button id.
@return string
@SuppressWarnings("unused") | [
"Fetch",
"button",
"id",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Toolbar/ToolbarItemLink.php#L34-L40 |
sparwelt/imgix-lib | src/Components/ImgixUrlGenerator.php | ImgixUrlGenerator.generateUrl | public function generateUrl($originalUrl, array $filterParams = [])
{
if (empty($originalUrl)) {
throw new ResolutionException('Empty url');
}
$cdn = $this->cdnSelector->getCdnForImage($originalUrl);
$queryParams = $cdn->isGenerateFilterParams() ? array_merge($cdn->getDefaultQueryParams(), $filterParams) : [];
if (Utils::isMatrix($queryParams)) {
throw new ConfigurationException(
sprintf('Monodimensional array expected, matrix given as query parameters: %s', serialize($queryParams))
);
}
$cdnId = spl_object_hash($cdn);
$shardStrategy = $this->translateShardStrategy($cdn->getShardStrategy());
if (!isset($this->builders[$cdnId])) {
try {
$this->builders[$cdnId] = new UrlBuilder(
$cdn->getCdnDomains(),
$cdn->isUseSsl(),
$cdn->getSignKey(),
$shardStrategy,
false
);
} catch (\InvalidArgumentException $e) {
throw new ResolutionException($e->getMessage());
}
}
$imagePath = parse_url($originalUrl, PHP_URL_PATH);
if (false === $imagePath) {
throw new ResolutionException(sprintf('Malformed image url %s', $originalUrl));
}
return $this->builders[$cdnId]->createURL(parse_url($originalUrl, PHP_URL_PATH), $queryParams);
} | php | public function generateUrl($originalUrl, array $filterParams = [])
{
if (empty($originalUrl)) {
throw new ResolutionException('Empty url');
}
$cdn = $this->cdnSelector->getCdnForImage($originalUrl);
$queryParams = $cdn->isGenerateFilterParams() ? array_merge($cdn->getDefaultQueryParams(), $filterParams) : [];
if (Utils::isMatrix($queryParams)) {
throw new ConfigurationException(
sprintf('Monodimensional array expected, matrix given as query parameters: %s', serialize($queryParams))
);
}
$cdnId = spl_object_hash($cdn);
$shardStrategy = $this->translateShardStrategy($cdn->getShardStrategy());
if (!isset($this->builders[$cdnId])) {
try {
$this->builders[$cdnId] = new UrlBuilder(
$cdn->getCdnDomains(),
$cdn->isUseSsl(),
$cdn->getSignKey(),
$shardStrategy,
false
);
} catch (\InvalidArgumentException $e) {
throw new ResolutionException($e->getMessage());
}
}
$imagePath = parse_url($originalUrl, PHP_URL_PATH);
if (false === $imagePath) {
throw new ResolutionException(sprintf('Malformed image url %s', $originalUrl));
}
return $this->builders[$cdnId]->createURL(parse_url($originalUrl, PHP_URL_PATH), $queryParams);
} | [
"public",
"function",
"generateUrl",
"(",
"$",
"originalUrl",
",",
"array",
"$",
"filterParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"originalUrl",
")",
")",
"{",
"throw",
"new",
"ResolutionException",
"(",
"'Empty url'",
")",
";",
"}",
"$",
"cdn",
"=",
"$",
"this",
"->",
"cdnSelector",
"->",
"getCdnForImage",
"(",
"$",
"originalUrl",
")",
";",
"$",
"queryParams",
"=",
"$",
"cdn",
"->",
"isGenerateFilterParams",
"(",
")",
"?",
"array_merge",
"(",
"$",
"cdn",
"->",
"getDefaultQueryParams",
"(",
")",
",",
"$",
"filterParams",
")",
":",
"[",
"]",
";",
"if",
"(",
"Utils",
"::",
"isMatrix",
"(",
"$",
"queryParams",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Monodimensional array expected, matrix given as query parameters: %s'",
",",
"serialize",
"(",
"$",
"queryParams",
")",
")",
")",
";",
"}",
"$",
"cdnId",
"=",
"spl_object_hash",
"(",
"$",
"cdn",
")",
";",
"$",
"shardStrategy",
"=",
"$",
"this",
"->",
"translateShardStrategy",
"(",
"$",
"cdn",
"->",
"getShardStrategy",
"(",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"builders",
"[",
"$",
"cdnId",
"]",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"builders",
"[",
"$",
"cdnId",
"]",
"=",
"new",
"UrlBuilder",
"(",
"$",
"cdn",
"->",
"getCdnDomains",
"(",
")",
",",
"$",
"cdn",
"->",
"isUseSsl",
"(",
")",
",",
"$",
"cdn",
"->",
"getSignKey",
"(",
")",
",",
"$",
"shardStrategy",
",",
"false",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"ResolutionException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"$",
"imagePath",
"=",
"parse_url",
"(",
"$",
"originalUrl",
",",
"PHP_URL_PATH",
")",
";",
"if",
"(",
"false",
"===",
"$",
"imagePath",
")",
"{",
"throw",
"new",
"ResolutionException",
"(",
"sprintf",
"(",
"'Malformed image url %s'",
",",
"$",
"originalUrl",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"builders",
"[",
"$",
"cdnId",
"]",
"->",
"createURL",
"(",
"parse_url",
"(",
"$",
"originalUrl",
",",
"PHP_URL_PATH",
")",
",",
"$",
"queryParams",
")",
";",
"}"
] | @param string $originalUrl
@param array $filterParams
@return string
@throws \Sparwelt\ImgixLib\Exception\ResolutionException
@throws \Sparwelt\ImgixLib\Exception\ConfigurationException
@throws \InvalidArgumentException | [
"@param",
"string",
"$originalUrl",
"@param",
"array",
"$filterParams"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/ImgixUrlGenerator.php#L46-L86 |
sparwelt/imgix-lib | src/Components/ImgixUrlGenerator.php | ImgixUrlGenerator.translateShardStrategy | private function translateShardStrategy($shardStrategy)
{
switch ($shardStrategy) {
case 'crc':
return ShardStrategy::CRC;
case 'cycle':
return ShardStrategy::CYCLE;
default:
throw new ConfigurationException(
sprintf('Unrecognized shard strategy %s. Possible values: "crc", "cycle', $shardStrategy)
);
}
} | php | private function translateShardStrategy($shardStrategy)
{
switch ($shardStrategy) {
case 'crc':
return ShardStrategy::CRC;
case 'cycle':
return ShardStrategy::CYCLE;
default:
throw new ConfigurationException(
sprintf('Unrecognized shard strategy %s. Possible values: "crc", "cycle', $shardStrategy)
);
}
} | [
"private",
"function",
"translateShardStrategy",
"(",
"$",
"shardStrategy",
")",
"{",
"switch",
"(",
"$",
"shardStrategy",
")",
"{",
"case",
"'crc'",
":",
"return",
"ShardStrategy",
"::",
"CRC",
";",
"case",
"'cycle'",
":",
"return",
"ShardStrategy",
"::",
"CYCLE",
";",
"default",
":",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Unrecognized shard strategy %s. Possible values: \"crc\", \"cycle'",
",",
"$",
"shardStrategy",
")",
")",
";",
"}",
"}"
] | @param string $shardStrategy
@return int
@throws \Sparwelt\ImgixLib\Exception\ConfigurationException | [
"@param",
"string",
"$shardStrategy"
] | train | https://github.com/sparwelt/imgix-lib/blob/330e1db2bed71bc283e5a2da6246528f240939ec/src/Components/ImgixUrlGenerator.php#L95-L107 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Values/ContentObject.php | ContentObject.setParentLocations | public function setParentLocations(array $parentLocations)
{
$this->properties['parent_locations'] = [];
foreach ($parentLocations as $location) {
$this->addParentLocation($location);
}
} | php | public function setParentLocations(array $parentLocations)
{
$this->properties['parent_locations'] = [];
foreach ($parentLocations as $location) {
$this->addParentLocation($location);
}
} | [
"public",
"function",
"setParentLocations",
"(",
"array",
"$",
"parentLocations",
")",
"{",
"$",
"this",
"->",
"properties",
"[",
"'parent_locations'",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parentLocations",
"as",
"$",
"location",
")",
"{",
"$",
"this",
"->",
"addParentLocation",
"(",
"$",
"location",
")",
";",
"}",
"}"
] | Values in array must be of type Location, LocationObject or int.
@param array $parentLocations | [
"Values",
"in",
"array",
"must",
"be",
"of",
"type",
"Location",
"LocationObject",
"or",
"int",
"."
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentObject.php#L81-L87 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Values/ContentObject.php | ContentObject.addParentLocation | public function addParentLocation($parentLocation)
{
$locationObject = $this->convertToLocationObject($parentLocation);
if (!isset($locationObject->data['parent_location_id']) || (int) $locationObject->data['parent_location_id'] < 1) {
throw new InvalidDataStructureException('Parent location id must be an integer of 2 or above.');
}
if (!isset($locationObject->data['content_id'])) {
if ($this->getProperty('id')) {
$locationObject->data['content_id'] = $this->getProperty('id');
}
}
$this->properties['parent_locations'][$locationObject->data['parent_location_id']] = $locationObject;
} | php | public function addParentLocation($parentLocation)
{
$locationObject = $this->convertToLocationObject($parentLocation);
if (!isset($locationObject->data['parent_location_id']) || (int) $locationObject->data['parent_location_id'] < 1) {
throw new InvalidDataStructureException('Parent location id must be an integer of 2 or above.');
}
if (!isset($locationObject->data['content_id'])) {
if ($this->getProperty('id')) {
$locationObject->data['content_id'] = $this->getProperty('id');
}
}
$this->properties['parent_locations'][$locationObject->data['parent_location_id']] = $locationObject;
} | [
"public",
"function",
"addParentLocation",
"(",
"$",
"parentLocation",
")",
"{",
"$",
"locationObject",
"=",
"$",
"this",
"->",
"convertToLocationObject",
"(",
"$",
"parentLocation",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
")",
"||",
"(",
"int",
")",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidDataStructureException",
"(",
"'Parent location id must be an integer of 2 or above.'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"locationObject",
"->",
"data",
"[",
"'content_id'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"'id'",
")",
")",
"{",
"$",
"locationObject",
"->",
"data",
"[",
"'content_id'",
"]",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"'id'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"properties",
"[",
"'parent_locations'",
"]",
"[",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
"]",
"=",
"$",
"locationObject",
";",
"}"
] | Convert parameters to LocationCreateStruct and stores it on the ContentObject.
@param Location|LocationObject|int $parentLocation
@throws InvalidDataStructureException | [
"Convert",
"parameters",
"to",
"LocationCreateStruct",
"and",
"stores",
"it",
"on",
"the",
"ContentObject",
"."
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentObject.php#L96-L111 |
transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Values/ContentObject.php | ContentObject.convertToLocationObject | private function convertToLocationObject($parentLocation)
{
$locationObject = new LocationObject(array());
switch (true) {
case $parentLocation instanceof Location:
$locationObject->getMapper()->locationToObject($parentLocation);
break;
case is_int($parentLocation):
$locationObject->data['parent_location_id'] = $parentLocation;
break;
case $parentLocation instanceof LocationObject:
default:
$locationObject = $parentLocation;
}
return $locationObject;
} | php | private function convertToLocationObject($parentLocation)
{
$locationObject = new LocationObject(array());
switch (true) {
case $parentLocation instanceof Location:
$locationObject->getMapper()->locationToObject($parentLocation);
break;
case is_int($parentLocation):
$locationObject->data['parent_location_id'] = $parentLocation;
break;
case $parentLocation instanceof LocationObject:
default:
$locationObject = $parentLocation;
}
return $locationObject;
} | [
"private",
"function",
"convertToLocationObject",
"(",
"$",
"parentLocation",
")",
"{",
"$",
"locationObject",
"=",
"new",
"LocationObject",
"(",
"array",
"(",
")",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"parentLocation",
"instanceof",
"Location",
":",
"$",
"locationObject",
"->",
"getMapper",
"(",
")",
"->",
"locationToObject",
"(",
"$",
"parentLocation",
")",
";",
"break",
";",
"case",
"is_int",
"(",
"$",
"parentLocation",
")",
":",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
"=",
"$",
"parentLocation",
";",
"break",
";",
"case",
"$",
"parentLocation",
"instanceof",
"LocationObject",
":",
"default",
":",
"$",
"locationObject",
"=",
"$",
"parentLocation",
";",
"}",
"return",
"$",
"locationObject",
";",
"}"
] | @param int|Location|LocationObject $parentLocation
@return LocationObject | [
"@param",
"int|Location|LocationObject",
"$parentLocation"
] | train | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentObject.php#L118-L135 |
zircote/AMQP | library/AMQP/Wire/GenericContent.php | GenericContent.load_properties | public function load_properties($rawBytes)
{
$reader = new Reader($rawBytes);
$flagBits = false;
// Read 16-bit shorts until we get one with a low bit set to zero
$flags = array();
while (true) {
$flagBits = $reader->readShort();
$flags[] = $flagBits;
if (($flagBits & 1) == 0) {
break;
}
}
$shift = 0;
$data = array();
foreach ($this->propertyTypes as $key => $proptype) {
if ($shift == 0) {
if (!$flags) {
break;
}
$flagBits = array_shift($flags);
$shift = 15;
}
if ($flagBits & (1 << $shift)) {
$proptype = ucfirst($proptype);
$data[$key] = $reader->{'read' . $proptype}();
}
$shift -= 1;
}
$this->properties = $data;
} | php | public function load_properties($rawBytes)
{
$reader = new Reader($rawBytes);
$flagBits = false;
// Read 16-bit shorts until we get one with a low bit set to zero
$flags = array();
while (true) {
$flagBits = $reader->readShort();
$flags[] = $flagBits;
if (($flagBits & 1) == 0) {
break;
}
}
$shift = 0;
$data = array();
foreach ($this->propertyTypes as $key => $proptype) {
if ($shift == 0) {
if (!$flags) {
break;
}
$flagBits = array_shift($flags);
$shift = 15;
}
if ($flagBits & (1 << $shift)) {
$proptype = ucfirst($proptype);
$data[$key] = $reader->{'read' . $proptype}();
}
$shift -= 1;
}
$this->properties = $data;
} | [
"public",
"function",
"load_properties",
"(",
"$",
"rawBytes",
")",
"{",
"$",
"reader",
"=",
"new",
"Reader",
"(",
"$",
"rawBytes",
")",
";",
"$",
"flagBits",
"=",
"false",
";",
"// Read 16-bit shorts until we get one with a low bit set to zero",
"$",
"flags",
"=",
"array",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"$",
"flagBits",
"=",
"$",
"reader",
"->",
"readShort",
"(",
")",
";",
"$",
"flags",
"[",
"]",
"=",
"$",
"flagBits",
";",
"if",
"(",
"(",
"$",
"flagBits",
"&",
"1",
")",
"==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"$",
"shift",
"=",
"0",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"propertyTypes",
"as",
"$",
"key",
"=>",
"$",
"proptype",
")",
"{",
"if",
"(",
"$",
"shift",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"flags",
")",
"{",
"break",
";",
"}",
"$",
"flagBits",
"=",
"array_shift",
"(",
"$",
"flags",
")",
";",
"$",
"shift",
"=",
"15",
";",
"}",
"if",
"(",
"$",
"flagBits",
"&",
"(",
"1",
"<<",
"$",
"shift",
")",
")",
"{",
"$",
"proptype",
"=",
"ucfirst",
"(",
"$",
"proptype",
")",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"reader",
"->",
"{",
"'read'",
".",
"$",
"proptype",
"}",
"(",
")",
";",
"}",
"$",
"shift",
"-=",
"1",
";",
"}",
"$",
"this",
"->",
"properties",
"=",
"$",
"data",
";",
"}"
] | Given the raw bytes containing the property-flags and
property-list from a content-frame-header, parse and insert
into a dictionary stored in this object as an attribute named
'properties'. | [
"Given",
"the",
"raw",
"bytes",
"containing",
"the",
"property",
"-",
"flags",
"and",
"property",
"-",
"list",
"from",
"a",
"content",
"-",
"frame",
"-",
"header",
"parse",
"and",
"insert",
"into",
"a",
"dictionary",
"stored",
"in",
"this",
"object",
"as",
"an",
"attribute",
"named",
"properties",
"."
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/GenericContent.php#L88-L120 |
zircote/AMQP | library/AMQP/Wire/GenericContent.php | GenericContent.serializeProperties | public function serializeProperties()
{
$shift = 15;
$flagBits = 0;
$flags = array();
$rawBytes = new Writer();
foreach ($this->propertyTypes as $key => $proptype) {
if (isset($this->properties[$key])) {
$value = $this->properties[$key];
} else {
$value = null;
}
if ($value != null) {
if ($shift == 0) {
$flags[] = $flagBits;
$flagBits = 0;
$shift = 15;
}
$flagBits |= (1 << $shift);
if ($proptype != 'bit') {
$proptype = ucfirst($proptype);
$rawBytes->{'write' . $proptype}($value);
}
}
$shift -= 1;
}
$flags[] = $flagBits;
$result = new Writer();
foreach ($flags as $flagBits) {
$result->writeShort($flagBits);
}
$result->write($rawBytes->getvalue());
return $result->getvalue();
} | php | public function serializeProperties()
{
$shift = 15;
$flagBits = 0;
$flags = array();
$rawBytes = new Writer();
foreach ($this->propertyTypes as $key => $proptype) {
if (isset($this->properties[$key])) {
$value = $this->properties[$key];
} else {
$value = null;
}
if ($value != null) {
if ($shift == 0) {
$flags[] = $flagBits;
$flagBits = 0;
$shift = 15;
}
$flagBits |= (1 << $shift);
if ($proptype != 'bit') {
$proptype = ucfirst($proptype);
$rawBytes->{'write' . $proptype}($value);
}
}
$shift -= 1;
}
$flags[] = $flagBits;
$result = new Writer();
foreach ($flags as $flagBits) {
$result->writeShort($flagBits);
}
$result->write($rawBytes->getvalue());
return $result->getvalue();
} | [
"public",
"function",
"serializeProperties",
"(",
")",
"{",
"$",
"shift",
"=",
"15",
";",
"$",
"flagBits",
"=",
"0",
";",
"$",
"flags",
"=",
"array",
"(",
")",
";",
"$",
"rawBytes",
"=",
"new",
"Writer",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"propertyTypes",
"as",
"$",
"key",
"=>",
"$",
"proptype",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"properties",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"$",
"shift",
"==",
"0",
")",
"{",
"$",
"flags",
"[",
"]",
"=",
"$",
"flagBits",
";",
"$",
"flagBits",
"=",
"0",
";",
"$",
"shift",
"=",
"15",
";",
"}",
"$",
"flagBits",
"|=",
"(",
"1",
"<<",
"$",
"shift",
")",
";",
"if",
"(",
"$",
"proptype",
"!=",
"'bit'",
")",
"{",
"$",
"proptype",
"=",
"ucfirst",
"(",
"$",
"proptype",
")",
";",
"$",
"rawBytes",
"->",
"{",
"'write'",
".",
"$",
"proptype",
"}",
"(",
"$",
"value",
")",
";",
"}",
"}",
"$",
"shift",
"-=",
"1",
";",
"}",
"$",
"flags",
"[",
"]",
"=",
"$",
"flagBits",
";",
"$",
"result",
"=",
"new",
"Writer",
"(",
")",
";",
"foreach",
"(",
"$",
"flags",
"as",
"$",
"flagBits",
")",
"{",
"$",
"result",
"->",
"writeShort",
"(",
"$",
"flagBits",
")",
";",
"}",
"$",
"result",
"->",
"write",
"(",
"$",
"rawBytes",
"->",
"getvalue",
"(",
")",
")",
";",
"return",
"$",
"result",
"->",
"getvalue",
"(",
")",
";",
"}"
] | serialize the 'properties' attribute (a dictionary) into the
raw bytes making up a set of property flags and a property
list, suitable for putting into a content frame header. | [
"serialize",
"the",
"properties",
"attribute",
"(",
"a",
"dictionary",
")",
"into",
"the",
"raw",
"bytes",
"making",
"up",
"a",
"set",
"of",
"property",
"flags",
"and",
"a",
"property",
"list",
"suitable",
"for",
"putting",
"into",
"a",
"content",
"frame",
"header",
"."
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Wire/GenericContent.php#L140-L180 |
steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.renderStandalone | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $this->render($domDocument);
$domDocument->appendChild($domElement);
return $domDocument;
} | php | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $this->render($domDocument);
$domDocument->appendChild($domElement);
return $domDocument;
} | [
"public",
"function",
"renderStandalone",
"(",
")",
"{",
"$",
"domDocument",
"=",
"new",
"\\",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
";",
"$",
"domDocument",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"domElement",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"domDocument",
"->",
"appendChild",
"(",
"$",
"domElement",
")",
";",
"return",
"$",
"domDocument",
";",
"}"
] | Render the Custom UI standalone
@return \DOMDocument | [
"Render",
"the",
"Custom",
"UI",
"standalone"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L263-L272 |
steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.render | public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("custom_ui");
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) {
continue;
}
$settingDomElement = $domDocument->createElement($setting);
$settingDomElement->setAttribute("visible", ($value ? 1 : 0));
$domElement->appendChild($settingDomElement);
}
return $domElement;
} | php | public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("custom_ui");
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) {
continue;
}
$settingDomElement = $domDocument->createElement($setting);
$settingDomElement->setAttribute("visible", ($value ? 1 : 0));
$domElement->appendChild($settingDomElement);
}
return $domElement;
} | [
"public",
"function",
"render",
"(",
"\\",
"DOMDocument",
"$",
"domDocument",
")",
"{",
"$",
"domElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"custom_ui\"",
")",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"settingDomElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"$",
"setting",
")",
";",
"$",
"settingDomElement",
"->",
"setAttribute",
"(",
"\"visible\"",
",",
"(",
"$",
"value",
"?",
"1",
":",
"0",
")",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"settingDomElement",
")",
";",
"}",
"return",
"$",
"domElement",
";",
"}"
] | Render the Custom UI
@param \DOMDocument $domDocument DOMDocument for which the Custom UI should be rendered
@return \DOMElement | [
"Render",
"the",
"Custom",
"UI"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L280-L296 |
steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.getSettings | protected function getSettings()
{
return array(
"global" => $this->globalVisible,
"challenge_info" => $this->challengeInfoVisible,
"chat" => $this->chatVisible,
"checkpoint_list" => $this->checkpointListVisible,
"net_infos" => $this->netInfosVisible,
"notice" => $this->noticeVisible,
"round_scores" => $this->roundScoresVisible,
"scoretable" => $this->scoretableVisible
);
} | php | protected function getSettings()
{
return array(
"global" => $this->globalVisible,
"challenge_info" => $this->challengeInfoVisible,
"chat" => $this->chatVisible,
"checkpoint_list" => $this->checkpointListVisible,
"net_infos" => $this->netInfosVisible,
"notice" => $this->noticeVisible,
"round_scores" => $this->roundScoresVisible,
"scoretable" => $this->scoretableVisible
);
} | [
"protected",
"function",
"getSettings",
"(",
")",
"{",
"return",
"array",
"(",
"\"global\"",
"=>",
"$",
"this",
"->",
"globalVisible",
",",
"\"challenge_info\"",
"=>",
"$",
"this",
"->",
"challengeInfoVisible",
",",
"\"chat\"",
"=>",
"$",
"this",
"->",
"chatVisible",
",",
"\"checkpoint_list\"",
"=>",
"$",
"this",
"->",
"checkpointListVisible",
",",
"\"net_infos\"",
"=>",
"$",
"this",
"->",
"netInfosVisible",
",",
"\"notice\"",
"=>",
"$",
"this",
"->",
"noticeVisible",
",",
"\"round_scores\"",
"=>",
"$",
"this",
"->",
"roundScoresVisible",
",",
"\"scoretable\"",
"=>",
"$",
"this",
"->",
"scoretableVisible",
")",
";",
"}"
] | Get associative array of all Custom UI settings
@return array | [
"Get",
"associative",
"array",
"of",
"all",
"Custom",
"UI",
"settings"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L314-L326 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.getUrl | public function getUrl($path) {
if (strpos($path, '://') !== false) {
return $path;
}
$url = 'https://api.mch.weixin.qq.com/';
if ($this->get('debug_mode') === true) {
$url .= 'sandboxnew/';
}
return $url. trim($path, '/');
} | php | public function getUrl($path) {
if (strpos($path, '://') !== false) {
return $path;
}
$url = 'https://api.mch.weixin.qq.com/';
if ($this->get('debug_mode') === true) {
$url .= 'sandboxnew/';
}
return $url. trim($path, '/');
} | [
"public",
"function",
"getUrl",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'://'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"url",
"=",
"'https://api.mch.weixin.qq.com/'",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'debug_mode'",
")",
"===",
"true",
")",
"{",
"$",
"url",
".=",
"'sandboxnew/'",
";",
"}",
"return",
"$",
"url",
".",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"}"
] | 生成完整的网址
@param $path
@return string | [
"生成完整的网址"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L42-L51 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.order | public function order(array $args = array()) {
$args = $this->getOrder()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if ($args['result_code'] != 'SUCCESS') {
throw new Exception($args['err_code_des']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
$this->set($args);
return $args;
} | php | public function order(array $args = array()) {
$args = $this->getOrder()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if ($args['result_code'] != 'SUCCESS') {
throw new Exception($args['err_code_des']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
$this->set($args);
return $args;
} | [
"public",
"function",
"order",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getOrder",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"args",
"[",
"'result_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'err_code_des'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'数据验签失败!');",
"",
"",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"args",
")",
";",
"return",
"$",
"args",
";",
"}"
] | 生成预支付订单
[
'nonce_str' => '',
'body' => '',
'out_trade_no' => ',
'total_fee' => 1,
'spbill_create_ip' => '',
'time_start' => date('Ymdis')
]
@param array $args
@return array|bool|mixed|object
@throws \Exception | [
"生成预支付订单",
"[",
"nonce_str",
"=",
">",
"body",
"=",
">",
"out_trade_no",
"=",
">",
"total_fee",
"=",
">",
"1",
"spbill_create_ip",
"=",
">",
"time_start",
"=",
">",
"date",
"(",
"Ymdis",
")",
"]"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L499-L512 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.queryOrder | public function queryOrder(array $args = array()) {
$args = $this->getQuery()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | php | public function queryOrder(array $args = array()) {
$args = $this->getQuery()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | [
"public",
"function",
"queryOrder",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'数据验签失败!');",
"",
"",
"}",
"return",
"$",
"args",
";",
"}"
] | 查询订单
EXAMPLE:
[
'out_trade_no' =>
]
@param array $args
@return array|bool|mixed|object
@throws \Exception | [
"查询订单",
"EXAMPLE",
":",
"[",
"out_trade_no",
"=",
">",
"]"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L524-L533 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.closeOrder | public function closeOrder(array $args = array()) {
$args = $this->getClose()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | php | public function closeOrder(array $args = array()) {
$args = $this->getClose()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | [
"public",
"function",
"closeOrder",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getClose",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'数据验签失败!');",
"",
"",
"}",
"return",
"$",
"args",
";",
"}"
] | 关闭订单
@param array $args
@return array|bool|mixed|object
@throws \ErrorException
@throws \Exception | [
"关闭订单"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L542-L551 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.appPay | public function appPay(array $args = array()) {
if (!isset($args['timestamp'])) {
$args['timestamp'] = time();
}
return $this->set($args)->getAppPay();
} | php | public function appPay(array $args = array()) {
if (!isset($args['timestamp'])) {
$args['timestamp'] = time();
}
return $this->set($args)->getAppPay();
} | [
"public",
"function",
"appPay",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"'timestamp'",
"]",
")",
")",
"{",
"$",
"args",
"[",
"'timestamp'",
"]",
"=",
"time",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"args",
")",
"->",
"getAppPay",
"(",
")",
";",
"}"
] | APP支付参数 异步回调必须输出 appCallbackReturn()
@param array $args
@return string
@throws Exception | [
"APP支付参数",
"异步回调必须输出",
"appCallbackReturn",
"()"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L560-L565 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.downloadBill | public function downloadBill($file, array $args = array()) {
return $this->getBill()->parameters($this->merge($args))->save($file);
} | php | public function downloadBill($file, array $args = array()) {
return $this->getBill()->parameters($this->merge($args))->save($file);
} | [
"public",
"function",
"downloadBill",
"(",
"$",
"file",
",",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getBill",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"save",
"(",
"$",
"file",
")",
";",
"}"
] | 下载对账单
@param string|File $file
@param array $args
@return int
@throws \Exception | [
"下载对账单"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L582-L584 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.queryRefund | public function queryRefund(array $args = array()) {
$args = $this->getQueryRefund()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | php | public function queryRefund(array $args = array()) {
$args = $this->getQueryRefund()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | [
"public",
"function",
"queryRefund",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getQueryRefund",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'数据验签失败!');",
"",
"",
"}",
"return",
"$",
"args",
";",
"}"
] | 查询退款
@param array $args
@return array|bool|mixed|object
@throws \ErrorException
@throws \Exception | [
"查询退款"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L593-L602 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.refundOrder | public function refundOrder(array $args = array()) {
//第二种方式,两个文件合成一个.pem文件
$args = $this->setCert($this->getRefund())
->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if ($args['result_code'] != 'SUCCESS') {
throw new Exception($args['err_code_des']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | php | public function refundOrder(array $args = array()) {
//第二种方式,两个文件合成一个.pem文件
$args = $this->setCert($this->getRefund())
->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if ($args['result_code'] != 'SUCCESS') {
throw new Exception($args['err_code_des']);
}
if (!$this->verify($args)) {
throw new Exception('数据验签失败!');
}
return $args;
} | [
"public",
"function",
"refundOrder",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"//第二种方式,两个文件合成一个.pem文件",
"$",
"args",
"=",
"$",
"this",
"->",
"setCert",
"(",
"$",
"this",
"->",
"getRefund",
"(",
")",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"args",
"[",
"'result_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'err_code_des'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'数据验签失败!');",
"",
"",
"}",
"return",
"$",
"args",
";",
"}"
] | 退款
@param array $args
@return array|bool|mixed|object
@throws \Exception | [
"退款"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L610-L624 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.setCert | public function setCert(Http $http) {
//两个文件合成一个.pem文件
if (!empty($this->privateKeyFile)) {
return $http->setOption(CURLOPT_SSLCERT, (string)$this->privateKeyFile);
}
//cert 与 key 分别属于两个.pem文件
return $http->setOption([
CURLOPT_SSLCERTTYPE => 'PEM',
CURLOPT_SSLCERT => (string)$this->get('certFile'),
CURLOPT_SSLCERTPASSWD => $this->get('mch_id'),
CURLOPT_SSLKEYTYPE => 'PEM',
CURLOPT_SSLKEY => (string)$this->get('keyFile'),
CURLOPT_SSLKEYPASSWD => $this->get('mch_id'),
]);
} | php | public function setCert(Http $http) {
//两个文件合成一个.pem文件
if (!empty($this->privateKeyFile)) {
return $http->setOption(CURLOPT_SSLCERT, (string)$this->privateKeyFile);
}
//cert 与 key 分别属于两个.pem文件
return $http->setOption([
CURLOPT_SSLCERTTYPE => 'PEM',
CURLOPT_SSLCERT => (string)$this->get('certFile'),
CURLOPT_SSLCERTPASSWD => $this->get('mch_id'),
CURLOPT_SSLKEYTYPE => 'PEM',
CURLOPT_SSLKEY => (string)$this->get('keyFile'),
CURLOPT_SSLKEYPASSWD => $this->get('mch_id'),
]);
} | [
"public",
"function",
"setCert",
"(",
"Http",
"$",
"http",
")",
"{",
"//两个文件合成一个.pem文件",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"privateKeyFile",
")",
")",
"{",
"return",
"$",
"http",
"->",
"setOption",
"(",
"CURLOPT_SSLCERT",
",",
"(",
"string",
")",
"$",
"this",
"->",
"privateKeyFile",
")",
";",
"}",
"//cert 与 key 分别属于两个.pem文件",
"return",
"$",
"http",
"->",
"setOption",
"(",
"[",
"CURLOPT_SSLCERTTYPE",
"=>",
"'PEM'",
",",
"CURLOPT_SSLCERT",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"get",
"(",
"'certFile'",
")",
",",
"CURLOPT_SSLCERTPASSWD",
"=>",
"$",
"this",
"->",
"get",
"(",
"'mch_id'",
")",
",",
"CURLOPT_SSLKEYTYPE",
"=>",
"'PEM'",
",",
"CURLOPT_SSLKEY",
"=>",
"(",
"string",
")",
"$",
"this",
"->",
"get",
"(",
"'keyFile'",
")",
",",
"CURLOPT_SSLKEYPASSWD",
"=>",
"$",
"this",
"->",
"get",
"(",
"'mch_id'",
")",
",",
"]",
")",
";",
"}"
] | 添加证书
@param Http $http
@return Http | [
"添加证书"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L631-L645 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.sign | public function sign($args) {
if (empty($this->key)) {
throw new Exception('KEY IS NEED');
}
ksort($args);
reset($args);
$arg = '';
foreach ($args as $key => $item) {
if (Http::isEmpty($item) ||
in_array($key, $this->ignoreKeys)) {
continue;
}
$arg .= "{$key}={$item}&";
}
$signContent = $arg.'key='.$this->key;
if (!isset($args['sign_type']) || $args['sign_type'] == 'MD5') {
return strtoupper(md5($signContent));
}
return strtoupper(hash_hmac('sha256', $signContent, $this->key, false));
} | php | public function sign($args) {
if (empty($this->key)) {
throw new Exception('KEY IS NEED');
}
ksort($args);
reset($args);
$arg = '';
foreach ($args as $key => $item) {
if (Http::isEmpty($item) ||
in_array($key, $this->ignoreKeys)) {
continue;
}
$arg .= "{$key}={$item}&";
}
$signContent = $arg.'key='.$this->key;
if (!isset($args['sign_type']) || $args['sign_type'] == 'MD5') {
return strtoupper(md5($signContent));
}
return strtoupper(hash_hmac('sha256', $signContent, $this->key, false));
} | [
"public",
"function",
"sign",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"key",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'KEY IS NEED'",
")",
";",
"}",
"ksort",
"(",
"$",
"args",
")",
";",
"reset",
"(",
"$",
"args",
")",
";",
"$",
"arg",
"=",
"''",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"Http",
"::",
"isEmpty",
"(",
"$",
"item",
")",
"||",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"ignoreKeys",
")",
")",
"{",
"continue",
";",
"}",
"$",
"arg",
".=",
"\"{$key}={$item}&\"",
";",
"}",
"$",
"signContent",
"=",
"$",
"arg",
".",
"'key='",
".",
"$",
"this",
"->",
"key",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"'sign_type'",
"]",
")",
"||",
"$",
"args",
"[",
"'sign_type'",
"]",
"==",
"'MD5'",
")",
"{",
"return",
"strtoupper",
"(",
"md5",
"(",
"$",
"signContent",
")",
")",
";",
"}",
"return",
"strtoupper",
"(",
"hash_hmac",
"(",
"'sha256'",
",",
"$",
"signContent",
",",
"$",
"this",
"->",
"key",
",",
"false",
")",
")",
";",
"}"
] | 生成签名
@param array $args
@return string
@throws Exception | [
"生成签名"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L653-L672 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.verify | public function verify(array $args, $sign = null) {
if (is_null($sign)) {
$sign = $args[$this->signKey];
}
return $this->sign($args) === $sign;
} | php | public function verify(array $args, $sign = null) {
if (is_null($sign)) {
$sign = $args[$this->signKey];
}
return $this->sign($args) === $sign;
} | [
"public",
"function",
"verify",
"(",
"array",
"$",
"args",
",",
"$",
"sign",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sign",
")",
")",
"{",
"$",
"sign",
"=",
"$",
"args",
"[",
"$",
"this",
"->",
"signKey",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"sign",
"(",
"$",
"args",
")",
"===",
"$",
"sign",
";",
"}"
] | 验证
@param array $args
@param $sign
@return bool
@throws Exception | [
"验证"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L681-L686 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.callback | public function callback() {
$xml = app('request')->input();
if (empty($xml)) {
throw new Exception(
__('xml error')
);
}
/**
* 禁止引用外部xml实体
*/
$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
$args = Xml::specialDecode($xml);
libxml_disable_entity_loader($disableLibxmlEntityLoader);
Factory::log()
->info('WECHAT PAY CALLBACK: '.app('request')->input());
if (!is_array($args)) {
throw new Exception(
__('xml error')
);
}
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception(
__('verify sign error')
);
}
return $args;
} | php | public function callback() {
$xml = app('request')->input();
if (empty($xml)) {
throw new Exception(
__('xml error')
);
}
/**
* 禁止引用外部xml实体
*/
$disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
$args = Xml::specialDecode($xml);
libxml_disable_entity_loader($disableLibxmlEntityLoader);
Factory::log()
->info('WECHAT PAY CALLBACK: '.app('request')->input());
if (!is_array($args)) {
throw new Exception(
__('xml error')
);
}
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception(
__('verify sign error')
);
}
return $args;
} | [
"public",
"function",
"callback",
"(",
")",
"{",
"$",
"xml",
"=",
"app",
"(",
"'request'",
")",
"->",
"input",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"xml",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__",
"(",
"'xml error'",
")",
")",
";",
"}",
"/**\n * 禁止引用外部xml实体\n */",
"$",
"disableLibxmlEntityLoader",
"=",
"libxml_disable_entity_loader",
"(",
"true",
")",
";",
"$",
"args",
"=",
"Xml",
"::",
"specialDecode",
"(",
"$",
"xml",
")",
";",
"libxml_disable_entity_loader",
"(",
"$",
"disableLibxmlEntityLoader",
")",
";",
"Factory",
"::",
"log",
"(",
")",
"->",
"info",
"(",
"'WECHAT PAY CALLBACK: '",
".",
"app",
"(",
"'request'",
")",
"->",
"input",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__",
"(",
"'xml error'",
")",
")",
";",
"}",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__",
"(",
"'verify sign error'",
")",
")",
";",
"}",
"return",
"$",
"args",
";",
"}"
] | 交易完成回调
@return mixed
@throws Exception | [
"交易完成回调"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L693-L722 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.qrPay | public function qrPay(array $args = array()) {
$url = $this->getPayQr()->parameters($this->merge($args))->getUrl();
return (new QrCode())->create((string)$url);
} | php | public function qrPay(array $args = array()) {
$url = $this->getPayQr()->parameters($this->merge($args))->getUrl();
return (new QrCode())->create((string)$url);
} | [
"public",
"function",
"qrPay",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getPayQr",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"getUrl",
"(",
")",
";",
"return",
"(",
"new",
"QrCode",
"(",
")",
")",
"->",
"create",
"(",
"(",
"string",
")",
"$",
"url",
")",
";",
"}"
] | 微信二维码支付
@param array $args
@return Image
@throws Exception | [
"微信二维码支付"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L730-L733 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.orderQr | public function orderQr(array $args = array()) {
$data = $this->order($args);
if ($data === false) {
return false;
}
if (array_key_exists('code_url', $data)) {
return (new QrCode())->create($data['code_url']);
}
throw new Exception('unkown');
//return (new QrCode())->create($this->getUrl('orderQr', $data));
} | php | public function orderQr(array $args = array()) {
$data = $this->order($args);
if ($data === false) {
return false;
}
if (array_key_exists('code_url', $data)) {
return (new QrCode())->create($data['code_url']);
}
throw new Exception('unkown');
//return (new QrCode())->create($this->getUrl('orderQr', $data));
} | [
"public",
"function",
"orderQr",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"order",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'code_url'",
",",
"$",
"data",
")",
")",
"{",
"return",
"(",
"new",
"QrCode",
"(",
")",
")",
"->",
"create",
"(",
"$",
"data",
"[",
"'code_url'",
"]",
")",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'unkown'",
")",
";",
"//return (new QrCode())->create($this->getUrl('orderQr', $data));",
"}"
] | 商户后台系统先调用微信支付的统一下单接口,微信后台系统返回链接参数code_url,商户后台系统将code_url值生成二维码图片
@param array $args
@return bool|Image
@throws \Exception | [
"商户后台系统先调用微信支付的统一下单接口,微信后台系统返回链接参数code_url,商户后台系统将code_url值生成二维码图片"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L758-L768 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.h5Pay | public function h5Pay(array $args = [], $redirect_url = null) {
$args['trade_type'] = 'MWEB';
$data = $this->order($args);
if ($data === false) {
return false;
}
if (array_key_exists('mweb_url', $data)) {
return $data['mweb_url'].'&redirect_url='.urlencode((string)$redirect_url);
}
throw new Exception('unkown');
} | php | public function h5Pay(array $args = [], $redirect_url = null) {
$args['trade_type'] = 'MWEB';
$data = $this->order($args);
if ($data === false) {
return false;
}
if (array_key_exists('mweb_url', $data)) {
return $data['mweb_url'].'&redirect_url='.urlencode((string)$redirect_url);
}
throw new Exception('unkown');
} | [
"public",
"function",
"h5Pay",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"redirect_url",
"=",
"null",
")",
"{",
"$",
"args",
"[",
"'trade_type'",
"]",
"=",
"'MWEB'",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"order",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"data",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'mweb_url'",
",",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
"[",
"'mweb_url'",
"]",
".",
"'&redirect_url='",
".",
"urlencode",
"(",
"(",
"string",
")",
"$",
"redirect_url",
")",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'unkown'",
")",
";",
"}"
] | h5下单获取支付链接,并加上回调地址
@param array $args
@param string|Uri $redirect_url
@return string
@throws \Exception | [
"h5下单获取支付链接,并加上回调地址"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L777-L787 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.jsPay | public function jsPay(array $args = array()) {
$args['appId'] = $this->get('appid'); //防止微信返回appid
$args['nonceStr'] = Str::random(32);
$args['timeStamp'] = time();
$data = $this->set($args)->getJsApi();
$data['package'] = 'prepay_id='.$data['package']['prepay_id'];
$data['paySign'] = $this->sign($data);
return $data;
} | php | public function jsPay(array $args = array()) {
$args['appId'] = $this->get('appid'); //防止微信返回appid
$args['nonceStr'] = Str::random(32);
$args['timeStamp'] = time();
$data = $this->set($args)->getJsApi();
$data['package'] = 'prepay_id='.$data['package']['prepay_id'];
$data['paySign'] = $this->sign($data);
return $data;
} | [
"public",
"function",
"jsPay",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"[",
"'appId'",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"'appid'",
")",
";",
"//防止微信返回appid",
"$",
"args",
"[",
"'nonceStr'",
"]",
"=",
"Str",
"::",
"random",
"(",
"32",
")",
";",
"$",
"args",
"[",
"'timeStamp'",
"]",
"=",
"time",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"set",
"(",
"$",
"args",
")",
"->",
"getJsApi",
"(",
")",
";",
"$",
"data",
"[",
"'package'",
"]",
"=",
"'prepay_id='",
".",
"$",
"data",
"[",
"'package'",
"]",
"[",
"'prepay_id'",
"]",
";",
"$",
"data",
"[",
"'paySign'",
"]",
"=",
"$",
"this",
"->",
"sign",
"(",
"$",
"data",
")",
";",
"return",
"$",
"data",
";",
"}"
] | 公众号支付 在微信浏览器里面打开H5网页中执行JS调起支付。接口输入输出数据格式为JSON。
https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6
@param array $args
@return array
@throws Exception | [
"公众号支付",
"在微信浏览器里面打开H5网页中执行JS调起支付。接口输入输出数据格式为JSON。",
"https",
":",
"//",
"pay",
".",
"weixin",
".",
"qq",
".",
"com",
"/",
"wiki",
"/",
"doc",
"/",
"api",
"/",
"jsapi",
".",
"php?chapter",
"=",
"7_7&index",
"=",
"6"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L796-L804 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.declareOrder | public function declareOrder(array $args = array()) {
$args = $this->getDeclareOrder()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception(
__('verify sign error')
);
}
$this->set($args);
return $args;
} | php | public function declareOrder(array $args = array()) {
$args = $this->getDeclareOrder()->parameters($this->merge($args))->text();
if ($args['return_code'] != 'SUCCESS') {
throw new Exception($args['return_msg']);
}
if (!$this->verify($args)) {
throw new Exception(
__('verify sign error')
);
}
$this->set($args);
return $args;
} | [
"public",
"function",
"declareOrder",
"(",
"array",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"getDeclareOrder",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"args",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"verify",
"(",
"$",
"args",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__",
"(",
"'verify sign error'",
")",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"args",
")",
";",
"return",
"$",
"args",
";",
"}"
] | 报关
@param array $args
@return array|mixed
@throws Exception | [
"报关"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L812-L824 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.transfer | public function transfer(array $args) {
$data = $this->getTransfer()->parameters($this->merge($args))->text();
if (empty($data)) {
return false;
}
if ($data['return_code'] != 'SUCCESS') {
throw new Exception($data['return_msg']);
}
if ($data['result_code'] != 'SUCCESS') {
throw new Exception($data['err_code_des']);
}
return $data;
} | php | public function transfer(array $args) {
$data = $this->getTransfer()->parameters($this->merge($args))->text();
if (empty($data)) {
return false;
}
if ($data['return_code'] != 'SUCCESS') {
throw new Exception($data['return_msg']);
}
if ($data['result_code'] != 'SUCCESS') {
throw new Exception($data['err_code_des']);
}
return $data;
} | [
"public",
"function",
"transfer",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getTransfer",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"data",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"data",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"data",
"[",
"'result_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"data",
"[",
"'err_code_des'",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | 转账给个人
@param array $args
@return bool|array
@throws Exception | [
"转账给个人"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L832-L844 |
zodream/thirdparty | src/Pay/WeChat.php | WeChat.refund | public function refund(array $args) {
$data = $this->getRefund()->parameters($this->merge($args))->text();
if (empty($data)) {
return false;
}
if ($data['return_code'] != 'SUCCESS') {
throw new Exception($data['return_msg']);
}
if ($data['result_code'] != 'SUCCESS') {
throw new Exception($data['err_code_des']);
}
return $data;
} | php | public function refund(array $args) {
$data = $this->getRefund()->parameters($this->merge($args))->text();
if (empty($data)) {
return false;
}
if ($data['return_code'] != 'SUCCESS') {
throw new Exception($data['return_msg']);
}
if ($data['result_code'] != 'SUCCESS') {
throw new Exception($data['err_code_des']);
}
return $data;
} | [
"public",
"function",
"refund",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getRefund",
"(",
")",
"->",
"parameters",
"(",
"$",
"this",
"->",
"merge",
"(",
"$",
"args",
")",
")",
"->",
"text",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"data",
"[",
"'return_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"data",
"[",
"'return_msg'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"data",
"[",
"'result_code'",
"]",
"!=",
"'SUCCESS'",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"data",
"[",
"'err_code_des'",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | 退款
@param array $args
@return bool|mixed|null
@throws Exception | [
"退款"
] | train | https://github.com/zodream/thirdparty/blob/b9d39087913850f1c5c7c9165105fec22a128f8f/src/Pay/WeChat.php#L852-L864 |
accgit/single-web | src/Single/Latte.php | Latte.createLatteEngine | private function createLatteEngine()
{
$latte = new LatteEngine\Engine;
$latte->setTempDirectory($this->temp);
// Form macro.
$latte->onCompile[] = function($latte) {
Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
};
return $latte;
} | php | private function createLatteEngine()
{
$latte = new LatteEngine\Engine;
$latte->setTempDirectory($this->temp);
// Form macro.
$latte->onCompile[] = function($latte) {
Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
};
return $latte;
} | [
"private",
"function",
"createLatteEngine",
"(",
")",
"{",
"$",
"latte",
"=",
"new",
"LatteEngine",
"\\",
"Engine",
";",
"$",
"latte",
"->",
"setTempDirectory",
"(",
"$",
"this",
"->",
"temp",
")",
";",
"// Form macro.\r",
"$",
"latte",
"->",
"onCompile",
"[",
"]",
"=",
"function",
"(",
"$",
"latte",
")",
"{",
"Bridges",
"\\",
"FormsLatte",
"\\",
"FormMacros",
"::",
"install",
"(",
"$",
"latte",
"->",
"getCompiler",
"(",
")",
")",
";",
"}",
";",
"return",
"$",
"latte",
";",
"}"
] | Latte engine settings.
@return LatteEngine\Engine | [
"Latte",
"engine",
"settings",
"."
] | train | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L41-L51 |
accgit/single-web | src/Single/Latte.php | Latte.getBasePath | private function getBasePath()
{
$pathInfo = new Http\RequestFactory;
$basePath = rtrim($pathInfo->createHttpRequest()->url->basePath, '/');
return $basePath;
} | php | private function getBasePath()
{
$pathInfo = new Http\RequestFactory;
$basePath = rtrim($pathInfo->createHttpRequest()->url->basePath, '/');
return $basePath;
} | [
"private",
"function",
"getBasePath",
"(",
")",
"{",
"$",
"pathInfo",
"=",
"new",
"Http",
"\\",
"RequestFactory",
";",
"$",
"basePath",
"=",
"rtrim",
"(",
"$",
"pathInfo",
"->",
"createHttpRequest",
"(",
")",
"->",
"url",
"->",
"basePath",
",",
"'/'",
")",
";",
"return",
"$",
"basePath",
";",
"}"
] | Path to root.
@return string | [
"Path",
"to",
"root",
"."
] | train | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L57-L62 |
accgit/single-web | src/Single/Latte.php | Latte.render | public function render($name, array $params = [])
{
$latte = $this->createLatteEngine();
$basePath = ['basePath' => $this->getBasePath()] ;
$latte->render($name, $params + $basePath);
return $latte;
} | php | public function render($name, array $params = [])
{
$latte = $this->createLatteEngine();
$basePath = ['basePath' => $this->getBasePath()] ;
$latte->render($name, $params + $basePath);
return $latte;
} | [
"public",
"function",
"render",
"(",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"latte",
"=",
"$",
"this",
"->",
"createLatteEngine",
"(",
")",
";",
"$",
"basePath",
"=",
"[",
"'basePath'",
"=>",
"$",
"this",
"->",
"getBasePath",
"(",
")",
"]",
";",
"$",
"latte",
"->",
"render",
"(",
"$",
"name",
",",
"$",
"params",
"+",
"$",
"basePath",
")",
";",
"return",
"$",
"latte",
";",
"}"
] | Create a template and insert parameters.
@param string $name
@return self | [
"Create",
"a",
"template",
"and",
"insert",
"parameters",
"."
] | train | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L69-L75 |
yuncms/framework | src/caching/YacCache.php | YacCache.setValue | protected function setValue($key, $value, $duration)
{
return $this->yac->set($key, $value, $duration);
} | php | protected function setValue($key, $value, $duration)
{
return $this->yac->set($key, $value, $duration);
} | [
"protected",
"function",
"setValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
"{",
"return",
"$",
"this",
"->",
"yac",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
";",
"}"
] | Stores a value identified by a key in cache.
This is the implementation of the method declared in the parent class.
@param string $key the key identifying the value to be cached
@param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]],
it could be something else.
@param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
@return bool true if the value is successfully stored into cache, false otherwise | [
"Stores",
"a",
"value",
"identified",
"by",
"a",
"key",
"in",
"cache",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"method",
"declared",
"in",
"the",
"parent",
"class",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/caching/YacCache.php#L89-L92 |
yuncms/framework | src/caching/YacCache.php | YacCache.addValue | protected function addValue($key, $value, $duration)
{
return $this->yac->set($key, $value, $duration);
} | php | protected function addValue($key, $value, $duration)
{
return $this->yac->set($key, $value, $duration);
} | [
"protected",
"function",
"addValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
"{",
"return",
"$",
"this",
"->",
"yac",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"duration",
")",
";",
"}"
] | Stores a value identified by a key into cache if the cache does not contain this key.
This is the implementation of the method declared in the parent class.
@param string $key the key identifying the value to be cached
@param mixed $value the value to be cached. Most often it's a string. If you have disabled [[serializer]],
it could be something else.
@param int $duration the number of seconds in which the cached value will expire. 0 means never expire.
@return bool true if the value is successfully stored into cache, false otherwise | [
"Stores",
"a",
"value",
"identified",
"by",
"a",
"key",
"into",
"cache",
"if",
"the",
"cache",
"does",
"not",
"contain",
"this",
"key",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"method",
"declared",
"in",
"the",
"parent",
"class",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/caching/YacCache.php#L113-L116 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.