repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
atelierspierrot/templatengine | src/TemplateEngine/TemplateObject/CssFile.php | CssFile.addMerged | public function addMerged($file_path, $media = 'screen')
{
$_fp = $this->__template->findAsset($file_path);
if ($_fp || \AssetsManager\Loader::isUrl($file_path)) {
$this->registry->addEntry(array(
'file'=>$_fp, 'media'=>$media
), 'css_merged_files');
} else {
throw new \InvalidArgumentException(
sprintf('CSS merged file "%s" not found!', $file_path)
);
}
return $this;
} | php | public function addMerged($file_path, $media = 'screen')
{
$_fp = $this->__template->findAsset($file_path);
if ($_fp || \AssetsManager\Loader::isUrl($file_path)) {
$this->registry->addEntry(array(
'file'=>$_fp, 'media'=>$media
), 'css_merged_files');
} else {
throw new \InvalidArgumentException(
sprintf('CSS merged file "%s" not found!', $file_path)
);
}
return $this;
} | [
"public",
"function",
"addMerged",
"(",
"$",
"file_path",
",",
"$",
"media",
"=",
"'screen'",
")",
"{",
"$",
"_fp",
"=",
"$",
"this",
"->",
"__template",
"->",
"findAsset",
"(",
"$",
"file_path",
")",
";",
"if",
"(",
"$",
"_fp",
"||",
"\\",
"AssetsManager",
"\\",
"Loader",
"::",
"isUrl",
"(",
"$",
"file_path",
")",
")",
"{",
"$",
"this",
"->",
"registry",
"->",
"addEntry",
"(",
"array",
"(",
"'file'",
"=>",
"$",
"_fp",
",",
"'media'",
"=>",
"$",
"media",
")",
",",
"'css_merged_files'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'CSS merged file \"%s\" not found!'",
",",
"$",
"file_path",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add an merged file
@param string $file_path The new CSS path
@param string $media The media type for the CSS file (default is "screen")
@return self
@throws \InvalidArgumentException if the path doesn't exist | [
"Add",
"an",
"merged",
"file"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/TemplateEngine/TemplateObject/CssFile.php#L210-L223 | train |
atelierspierrot/templatengine | src/TemplateEngine/TemplateObject/CssFile.php | CssFile.writeMinified | public function writeMinified($mask = '%s')
{
$str='';
foreach ($this->cleanStack($this->getMinified(), 'file') as $entry) {
$tag_attrs = array(
'rel'=>'stylesheet',
'type'=>'text/css',
'href'=>$entry['file']
);
if (isset($entry['media']) && !empty($entry['media']) && $entry['media']!='screen') {
$tag_attrs['media'] = $entry['media'];
}
$str .= sprintf($mask, Html::writeHtmlTag('link', null, $tag_attrs, true));
}
return $str;
} | php | public function writeMinified($mask = '%s')
{
$str='';
foreach ($this->cleanStack($this->getMinified(), 'file') as $entry) {
$tag_attrs = array(
'rel'=>'stylesheet',
'type'=>'text/css',
'href'=>$entry['file']
);
if (isset($entry['media']) && !empty($entry['media']) && $entry['media']!='screen') {
$tag_attrs['media'] = $entry['media'];
}
$str .= sprintf($mask, Html::writeHtmlTag('link', null, $tag_attrs, true));
}
return $str;
} | [
"public",
"function",
"writeMinified",
"(",
"$",
"mask",
"=",
"'%s'",
")",
"{",
"$",
"str",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"cleanStack",
"(",
"$",
"this",
"->",
"getMinified",
"(",
")",
",",
"'file'",
")",
"as",
"$",
"entry",
")",
"{",
"$",
"tag_attrs",
"=",
"array",
"(",
"'rel'",
"=>",
"'stylesheet'",
",",
"'type'",
"=>",
"'text/css'",
",",
"'href'",
"=>",
"$",
"entry",
"[",
"'file'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"entry",
"[",
"'media'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"entry",
"[",
"'media'",
"]",
")",
"&&",
"$",
"entry",
"[",
"'media'",
"]",
"!=",
"'screen'",
")",
"{",
"$",
"tag_attrs",
"[",
"'media'",
"]",
"=",
"$",
"entry",
"[",
"'media'",
"]",
";",
"}",
"$",
"str",
".=",
"sprintf",
"(",
"$",
"mask",
",",
"Html",
"::",
"writeHtmlTag",
"(",
"'link'",
",",
"null",
",",
"$",
"tag_attrs",
",",
"true",
")",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Write minified versions of the files stack in the cache directory
@param string $mask A mask to write each line via "sprintf()"
@return string The string to display fot this template object | [
"Write",
"minified",
"versions",
"of",
"the",
"files",
"stack",
"in",
"the",
"cache",
"directory"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/TemplateEngine/TemplateObject/CssFile.php#L380-L395 | train |
antaresproject/sample_module | src/Processor/ModuleProcessor.php | ModuleProcessor.form | protected function form(Model $model)
{
$this->breadcrumb->onItem($model);
return app('antares.form')->of('awesone-module-form', function(FormGrid $form) use($model) {
$form->name('My Awesome Module Form');
$form->resourced('antares::sample_module/index', $model);
$form->fieldset(function (Fieldset $fieldset) use($model) {
$fieldset->legend('Fieldset');
if (!auth()->user()->hasRoles('member')) {
$fieldset->control('select', 'user')
->label(trans('antares/sample_module::form.user_select'))
->options(function() {
return User::members()
->select([DB::raw('concat(firstname," ",lastname) as name'), 'id'])
->orderBy('firstname', 'asc')
->orderBy('lastname', 'desc')
->get()
->map(function($option) {
return ['id' => $option->id, 'title' => '#' . $option->id . ' ' . $option->name];
})->pluck('title', 'id');
})
->attributes(['data-selectar--search' => true, 'data-placeholder' => 'testowanie'])
->wrapper(['class' => 'w300'])
->value($model->user_id);
}
$fieldset->control('input:text', 'name')
->label(trans('antares/sample_module::form.name'))
->wrapper(['class' => 'w300']);
$fieldset->control('select', 'field_1')
->label(trans('antares/sample_module::form.field_1'))
->options(self::getOptions())
->wrapper(['class' => 'w200']);
$fieldset->control('input:checkbox', 'field_2')
->label(trans('antares/sample_module::form.field_2'))
->value(1)
->checked($model->exists ? array_get($model->value, 'field_2', false) : false);
$fieldset->control('button', 'cancel')
->field(function() {
return app('html')->link(handles("antares::sample_module/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
});
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
->value(trans('antares/foundation::label.save_changes'));
});
$form->ajaxable()->rules(['name' => 'required']);
});
} | php | protected function form(Model $model)
{
$this->breadcrumb->onItem($model);
return app('antares.form')->of('awesone-module-form', function(FormGrid $form) use($model) {
$form->name('My Awesome Module Form');
$form->resourced('antares::sample_module/index', $model);
$form->fieldset(function (Fieldset $fieldset) use($model) {
$fieldset->legend('Fieldset');
if (!auth()->user()->hasRoles('member')) {
$fieldset->control('select', 'user')
->label(trans('antares/sample_module::form.user_select'))
->options(function() {
return User::members()
->select([DB::raw('concat(firstname," ",lastname) as name'), 'id'])
->orderBy('firstname', 'asc')
->orderBy('lastname', 'desc')
->get()
->map(function($option) {
return ['id' => $option->id, 'title' => '#' . $option->id . ' ' . $option->name];
})->pluck('title', 'id');
})
->attributes(['data-selectar--search' => true, 'data-placeholder' => 'testowanie'])
->wrapper(['class' => 'w300'])
->value($model->user_id);
}
$fieldset->control('input:text', 'name')
->label(trans('antares/sample_module::form.name'))
->wrapper(['class' => 'w300']);
$fieldset->control('select', 'field_1')
->label(trans('antares/sample_module::form.field_1'))
->options(self::getOptions())
->wrapper(['class' => 'w200']);
$fieldset->control('input:checkbox', 'field_2')
->label(trans('antares/sample_module::form.field_2'))
->value(1)
->checked($model->exists ? array_get($model->value, 'field_2', false) : false);
$fieldset->control('button', 'cancel')
->field(function() {
return app('html')->link(handles("antares::sample_module/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
});
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
->value(trans('antares/foundation::label.save_changes'));
});
$form->ajaxable()->rules(['name' => 'required']);
});
} | [
"protected",
"function",
"form",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"breadcrumb",
"->",
"onItem",
"(",
"$",
"model",
")",
";",
"return",
"app",
"(",
"'antares.form'",
")",
"->",
"of",
"(",
"'awesone-module-form'",
",",
"function",
"(",
"FormGrid",
"$",
"form",
")",
"use",
"(",
"$",
"model",
")",
"{",
"$",
"form",
"->",
"name",
"(",
"'My Awesome Module Form'",
")",
";",
"$",
"form",
"->",
"resourced",
"(",
"'antares::sample_module/index'",
",",
"$",
"model",
")",
";",
"$",
"form",
"->",
"fieldset",
"(",
"function",
"(",
"Fieldset",
"$",
"fieldset",
")",
"use",
"(",
"$",
"model",
")",
"{",
"$",
"fieldset",
"->",
"legend",
"(",
"'Fieldset'",
")",
";",
"if",
"(",
"!",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"hasRoles",
"(",
"'member'",
")",
")",
"{",
"$",
"fieldset",
"->",
"control",
"(",
"'select'",
",",
"'user'",
")",
"->",
"label",
"(",
"trans",
"(",
"'antares/sample_module::form.user_select'",
")",
")",
"->",
"options",
"(",
"function",
"(",
")",
"{",
"return",
"User",
"::",
"members",
"(",
")",
"->",
"select",
"(",
"[",
"DB",
"::",
"raw",
"(",
"'concat(firstname,\" \",lastname) as name'",
")",
",",
"'id'",
"]",
")",
"->",
"orderBy",
"(",
"'firstname'",
",",
"'asc'",
")",
"->",
"orderBy",
"(",
"'lastname'",
",",
"'desc'",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"option",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"option",
"->",
"id",
",",
"'title'",
"=>",
"'#'",
".",
"$",
"option",
"->",
"id",
".",
"' '",
".",
"$",
"option",
"->",
"name",
"]",
";",
"}",
")",
"->",
"pluck",
"(",
"'title'",
",",
"'id'",
")",
";",
"}",
")",
"->",
"attributes",
"(",
"[",
"'data-selectar--search'",
"=>",
"true",
",",
"'data-placeholder'",
"=>",
"'testowanie'",
"]",
")",
"->",
"wrapper",
"(",
"[",
"'class'",
"=>",
"'w300'",
"]",
")",
"->",
"value",
"(",
"$",
"model",
"->",
"user_id",
")",
";",
"}",
"$",
"fieldset",
"->",
"control",
"(",
"'input:text'",
",",
"'name'",
")",
"->",
"label",
"(",
"trans",
"(",
"'antares/sample_module::form.name'",
")",
")",
"->",
"wrapper",
"(",
"[",
"'class'",
"=>",
"'w300'",
"]",
")",
";",
"$",
"fieldset",
"->",
"control",
"(",
"'select'",
",",
"'field_1'",
")",
"->",
"label",
"(",
"trans",
"(",
"'antares/sample_module::form.field_1'",
")",
")",
"->",
"options",
"(",
"self",
"::",
"getOptions",
"(",
")",
")",
"->",
"wrapper",
"(",
"[",
"'class'",
"=>",
"'w200'",
"]",
")",
";",
"$",
"fieldset",
"->",
"control",
"(",
"'input:checkbox'",
",",
"'field_2'",
")",
"->",
"label",
"(",
"trans",
"(",
"'antares/sample_module::form.field_2'",
")",
")",
"->",
"value",
"(",
"1",
")",
"->",
"checked",
"(",
"$",
"model",
"->",
"exists",
"?",
"array_get",
"(",
"$",
"model",
"->",
"value",
",",
"'field_2'",
",",
"false",
")",
":",
"false",
")",
";",
"$",
"fieldset",
"->",
"control",
"(",
"'button'",
",",
"'cancel'",
")",
"->",
"field",
"(",
"function",
"(",
")",
"{",
"return",
"app",
"(",
"'html'",
")",
"->",
"link",
"(",
"handles",
"(",
"\"antares::sample_module/index\"",
")",
",",
"trans",
"(",
"'antares/foundation::label.cancel'",
")",
",",
"[",
"'class'",
"=>",
"'btn btn--md btn--default mdl-button mdl-js-button'",
"]",
")",
";",
"}",
")",
";",
"$",
"fieldset",
"->",
"control",
"(",
"'button'",
",",
"'button'",
")",
"->",
"attributes",
"(",
"[",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'btn btn-primary'",
"]",
")",
"->",
"value",
"(",
"trans",
"(",
"'antares/foundation::label.save_changes'",
")",
")",
";",
"}",
")",
";",
"$",
"form",
"->",
"ajaxable",
"(",
")",
"->",
"rules",
"(",
"[",
"'name'",
"=>",
"'required'",
"]",
")",
";",
"}",
")",
";",
"}"
] | Generowanie nowego obiektu formularza
@param Model $model
@return \Antares\Html\Form\FormBuilder | [
"Generowanie",
"nowego",
"obiektu",
"formularza"
] | aceab14f392c25e32729018518e9d6b4e6fe23db | https://github.com/antaresproject/sample_module/blob/aceab14f392c25e32729018518e9d6b4e6fe23db/src/Processor/ModuleProcessor.php#L101-L156 | train |
antaresproject/sample_module | src/Processor/ModuleProcessor.php | ModuleProcessor.store | public function store()
{
$input = Input::all();
$user = auth()->user();
$attributes = [
'user_id' => $user->hasRoles('member') ? $user->id : array_get($input, 'user'),
'name' => array_get($input, 'name'),
'value' => array_only($input, ['field_1', 'field_2'])
];
$model = new ModuleRow($attributes);
$form = $this->form($model);
if (!$form->isValid()) {
return redirect_with_errors(handles('antares::sample_module/index/create'), $form->getMessageBag());
}
if (!$model->save()) {
event('notifications.item_has_not_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_error'), 'error');
}
event('notifications.item_has_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_success'), 'success');
} | php | public function store()
{
$input = Input::all();
$user = auth()->user();
$attributes = [
'user_id' => $user->hasRoles('member') ? $user->id : array_get($input, 'user'),
'name' => array_get($input, 'name'),
'value' => array_only($input, ['field_1', 'field_2'])
];
$model = new ModuleRow($attributes);
$form = $this->form($model);
if (!$form->isValid()) {
return redirect_with_errors(handles('antares::sample_module/index/create'), $form->getMessageBag());
}
if (!$model->save()) {
event('notifications.item_has_not_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_error'), 'error');
}
event('notifications.item_has_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_success'), 'success');
} | [
"public",
"function",
"store",
"(",
")",
"{",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"attributes",
"=",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"hasRoles",
"(",
"'member'",
")",
"?",
"$",
"user",
"->",
"id",
":",
"array_get",
"(",
"$",
"input",
",",
"'user'",
")",
",",
"'name'",
"=>",
"array_get",
"(",
"$",
"input",
",",
"'name'",
")",
",",
"'value'",
"=>",
"array_only",
"(",
"$",
"input",
",",
"[",
"'field_1'",
",",
"'field_2'",
"]",
")",
"]",
";",
"$",
"model",
"=",
"new",
"ModuleRow",
"(",
"$",
"attributes",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"form",
"(",
"$",
"model",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"redirect_with_errors",
"(",
"handles",
"(",
"'antares::sample_module/index/create'",
")",
",",
"$",
"form",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"event",
"(",
"'notifications.item_has_not_been_created'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.save_error'",
")",
",",
"'error'",
")",
";",
"}",
"event",
"(",
"'notifications.item_has_been_created'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.save_success'",
")",
",",
"'success'",
")",
";",
"}"
] | When stores form fields in database
@return \Illuminate\Http\RedirectResponse | [
"When",
"stores",
"form",
"fields",
"in",
"database"
] | aceab14f392c25e32729018518e9d6b4e6fe23db | https://github.com/antaresproject/sample_module/blob/aceab14f392c25e32729018518e9d6b4e6fe23db/src/Processor/ModuleProcessor.php#L173-L194 | train |
antaresproject/sample_module | src/Processor/ModuleProcessor.php | ModuleProcessor.update | public function update($id)
{
$model = ModuleRow::withoutGlobalScopes()->findOrFail($id);
if (!request()->isMethod('put')) {
$form = $this->form($model);
} else {
$input = Input::all();
$user = auth()->user();
if (!$user->hasRoles('member')) {
$model->user_id = array_get($input, 'user');
}
$model->name = array_get($input, 'name');
$model->value = array_only($input, ['field_1', 'field_2']);
$form = $this->form($model);
if (!$form->isValid()) {
return redirect_with_errors(handles('antares::sample_module/index/' . $id . '/edit'), $form->getMessageBag());
}
if (!$model->save()) {
event('notifications.item_has_not_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_error'), 'error');
}
event('notifications.item_has_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_success'), 'success');
}
return view('antares/sample_module::admin.module.create', ['form' => $form]);
} | php | public function update($id)
{
$model = ModuleRow::withoutGlobalScopes()->findOrFail($id);
if (!request()->isMethod('put')) {
$form = $this->form($model);
} else {
$input = Input::all();
$user = auth()->user();
if (!$user->hasRoles('member')) {
$model->user_id = array_get($input, 'user');
}
$model->name = array_get($input, 'name');
$model->value = array_only($input, ['field_1', 'field_2']);
$form = $this->form($model);
if (!$form->isValid()) {
return redirect_with_errors(handles('antares::sample_module/index/' . $id . '/edit'), $form->getMessageBag());
}
if (!$model->save()) {
event('notifications.item_has_not_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_error'), 'error');
}
event('notifications.item_has_been_updated', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.update_success'), 'success');
}
return view('antares/sample_module::admin.module.create', ['form' => $form]);
} | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"ModuleRow",
"::",
"withoutGlobalScopes",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"request",
"(",
")",
"->",
"isMethod",
"(",
"'put'",
")",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"form",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"hasRoles",
"(",
"'member'",
")",
")",
"{",
"$",
"model",
"->",
"user_id",
"=",
"array_get",
"(",
"$",
"input",
",",
"'user'",
")",
";",
"}",
"$",
"model",
"->",
"name",
"=",
"array_get",
"(",
"$",
"input",
",",
"'name'",
")",
";",
"$",
"model",
"->",
"value",
"=",
"array_only",
"(",
"$",
"input",
",",
"[",
"'field_1'",
",",
"'field_2'",
"]",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"form",
"(",
"$",
"model",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"redirect_with_errors",
"(",
"handles",
"(",
"'antares::sample_module/index/'",
".",
"$",
"id",
".",
"'/edit'",
")",
",",
"$",
"form",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"event",
"(",
"'notifications.item_has_not_been_updated'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"user",
"(",
")",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.update_error'",
")",
",",
"'error'",
")",
";",
"}",
"event",
"(",
"'notifications.item_has_been_updated'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"user",
"(",
")",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.update_success'",
")",
",",
"'success'",
")",
";",
"}",
"return",
"view",
"(",
"'antares/sample_module::admin.module.create'",
",",
"[",
"'form'",
"=>",
"$",
"form",
"]",
")",
";",
"}"
] | When updates form fields in database
@param mixes $id
@return \Illuminate\Http\RedirectResponse | [
"When",
"updates",
"form",
"fields",
"in",
"database"
] | aceab14f392c25e32729018518e9d6b4e6fe23db | https://github.com/antaresproject/sample_module/blob/aceab14f392c25e32729018518e9d6b4e6fe23db/src/Processor/ModuleProcessor.php#L202-L233 | train |
antaresproject/sample_module | src/Processor/ModuleProcessor.php | ModuleProcessor.delete | public function delete($id)
{
$builder = ModuleRow::withoutGlobalScopes();
if (auth()->user()->hasRoles('member')) {
$builder->where(['user_id' => auth()->user()->id]);
}
$model = $builder->findOrFail($id);
$name = $model->name;
if ($model->delete()) {
event('notifications.item_has_been_deleted', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.item_has_been_deleted', ['name' => $name]), 'success');
}
event('notifications.item_has_not_been_deleted', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.item_has_not_been_deleted', ['name' => $name]), 'error');
} | php | public function delete($id)
{
$builder = ModuleRow::withoutGlobalScopes();
if (auth()->user()->hasRoles('member')) {
$builder->where(['user_id' => auth()->user()->id]);
}
$model = $builder->findOrFail($id);
$name = $model->name;
if ($model->delete()) {
event('notifications.item_has_been_deleted', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.item_has_been_deleted', ['name' => $name]), 'success');
}
event('notifications.item_has_not_been_deleted', ['variables' => ['user' => user(), 'item' => $model]]);
return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.item_has_not_been_deleted', ['name' => $name]), 'error');
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"builder",
"=",
"ModuleRow",
"::",
"withoutGlobalScopes",
"(",
")",
";",
"if",
"(",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"hasRoles",
"(",
"'member'",
")",
")",
"{",
"$",
"builder",
"->",
"where",
"(",
"[",
"'user_id'",
"=>",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
"]",
")",
";",
"}",
"$",
"model",
"=",
"$",
"builder",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"name",
"=",
"$",
"model",
"->",
"name",
";",
"if",
"(",
"$",
"model",
"->",
"delete",
"(",
")",
")",
"{",
"event",
"(",
"'notifications.item_has_been_deleted'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"user",
"(",
")",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.item_has_been_deleted'",
",",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
",",
"'success'",
")",
";",
"}",
"event",
"(",
"'notifications.item_has_not_been_deleted'",
",",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"user",
"(",
")",
",",
"'item'",
"=>",
"$",
"model",
"]",
"]",
")",
";",
"return",
"redirect_with_message",
"(",
"handles",
"(",
"'antares::sample_module/index'",
")",
",",
"trans",
"(",
"'antares/sample_module::messages.item_has_not_been_deleted'",
",",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
",",
"'error'",
")",
";",
"}"
] | When deletes item
@param mixed $id
@return \Illuminate\Http\RedirectResponse | [
"When",
"deletes",
"item"
] | aceab14f392c25e32729018518e9d6b4e6fe23db | https://github.com/antaresproject/sample_module/blob/aceab14f392c25e32729018518e9d6b4e6fe23db/src/Processor/ModuleProcessor.php#L241-L255 | train |
kouks/laravel-casters | src/Casters/Caster.php | Caster.cast | public function cast($model)
{
if ($model instanceof Collection) {
return $model->map([$this, 'cast'])->toArray();
}
if (empty($model)) {
return;
}
$transformed = [];
foreach ($this->castRules() as $old => $desired) {
$this->resolveCast($old, $desired, $model, $transformed);
}
return $transformed;
} | php | public function cast($model)
{
if ($model instanceof Collection) {
return $model->map([$this, 'cast'])->toArray();
}
if (empty($model)) {
return;
}
$transformed = [];
foreach ($this->castRules() as $old => $desired) {
$this->resolveCast($old, $desired, $model, $transformed);
}
return $transformed;
} | [
"public",
"function",
"cast",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"instanceof",
"Collection",
")",
"{",
"return",
"$",
"model",
"->",
"map",
"(",
"[",
"$",
"this",
",",
"'cast'",
"]",
")",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"model",
")",
")",
"{",
"return",
";",
"}",
"$",
"transformed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"castRules",
"(",
")",
"as",
"$",
"old",
"=>",
"$",
"desired",
")",
"{",
"$",
"this",
"->",
"resolveCast",
"(",
"$",
"old",
",",
"$",
"desired",
",",
"$",
"model",
",",
"$",
"transformed",
")",
";",
"}",
"return",
"$",
"transformed",
";",
"}"
] | Casts collection fields.
@param mixed $model
@return array | [
"Casts",
"collection",
"fields",
"."
] | 6b5ada1147b658cf2866a9e9573b66ff699edbbf | https://github.com/kouks/laravel-casters/blob/6b5ada1147b658cf2866a9e9573b66ff699edbbf/src/Casters/Caster.php#L35-L52 | train |
kouks/laravel-casters | src/Casters/Caster.php | Caster.resolveCast | private function resolveCast($old, $desired, Model $model, &$transformed)
{
if ($desired instanceof Closure) {
return $transformed[$old] = call_user_func($desired, $model);
}
if (is_string($desired) && strpos($desired, $this->functionSign) !== false) {
return $transformed[$old] = call_user_func([$this, substr($desired, 1)], $model);
}
if (is_string($desired) && strpos($desired, $this->querySign) !== false) {
return $this->parse($old, substr($desired, 1), $model, $transformed);
}
if (is_string($old)) {
return $transformed[$desired] = $model->$old;
}
return $transformed[$desired] = $model->$desired;
} | php | private function resolveCast($old, $desired, Model $model, &$transformed)
{
if ($desired instanceof Closure) {
return $transformed[$old] = call_user_func($desired, $model);
}
if (is_string($desired) && strpos($desired, $this->functionSign) !== false) {
return $transformed[$old] = call_user_func([$this, substr($desired, 1)], $model);
}
if (is_string($desired) && strpos($desired, $this->querySign) !== false) {
return $this->parse($old, substr($desired, 1), $model, $transformed);
}
if (is_string($old)) {
return $transformed[$desired] = $model->$old;
}
return $transformed[$desired] = $model->$desired;
} | [
"private",
"function",
"resolveCast",
"(",
"$",
"old",
",",
"$",
"desired",
",",
"Model",
"$",
"model",
",",
"&",
"$",
"transformed",
")",
"{",
"if",
"(",
"$",
"desired",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"transformed",
"[",
"$",
"old",
"]",
"=",
"call_user_func",
"(",
"$",
"desired",
",",
"$",
"model",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"desired",
")",
"&&",
"strpos",
"(",
"$",
"desired",
",",
"$",
"this",
"->",
"functionSign",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"transformed",
"[",
"$",
"old",
"]",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"substr",
"(",
"$",
"desired",
",",
"1",
")",
"]",
",",
"$",
"model",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"desired",
")",
"&&",
"strpos",
"(",
"$",
"desired",
",",
"$",
"this",
"->",
"querySign",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"old",
",",
"substr",
"(",
"$",
"desired",
",",
"1",
")",
",",
"$",
"model",
",",
"$",
"transformed",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"old",
")",
")",
"{",
"return",
"$",
"transformed",
"[",
"$",
"desired",
"]",
"=",
"$",
"model",
"->",
"$",
"old",
";",
"}",
"return",
"$",
"transformed",
"[",
"$",
"desired",
"]",
"=",
"$",
"model",
"->",
"$",
"desired",
";",
"}"
] | Resolves casts based on supplied array of arguments.
@param string $old
@param string|Closure $desired
@param \Illuminate\Database\Eloquent\Model $model
@param array &$transformed
@return array | [
"Resolves",
"casts",
"based",
"on",
"supplied",
"array",
"of",
"arguments",
"."
] | 6b5ada1147b658cf2866a9e9573b66ff699edbbf | https://github.com/kouks/laravel-casters/blob/6b5ada1147b658cf2866a9e9573b66ff699edbbf/src/Casters/Caster.php#L63-L82 | train |
SpoonX/SxBootstrap | src/SxBootstrap/View/Helper/Bootstrap/Tabs.php | Tabs.render | protected function render()
{
if (null === $this->active) {
$this->setActive(key($this->tabs));
}
$tabs = new ViewModel;
$tabs->tabs = $this->tabs;
$tabs->setTemplate('sxbootstrap/tabs/tabs');
return $this->getView()->render($tabs);
} | php | protected function render()
{
if (null === $this->active) {
$this->setActive(key($this->tabs));
}
$tabs = new ViewModel;
$tabs->tabs = $this->tabs;
$tabs->setTemplate('sxbootstrap/tabs/tabs');
return $this->getView()->render($tabs);
} | [
"protected",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"active",
")",
"{",
"$",
"this",
"->",
"setActive",
"(",
"key",
"(",
"$",
"this",
"->",
"tabs",
")",
")",
";",
"}",
"$",
"tabs",
"=",
"new",
"ViewModel",
";",
"$",
"tabs",
"->",
"tabs",
"=",
"$",
"this",
"->",
"tabs",
";",
"$",
"tabs",
"->",
"setTemplate",
"(",
"'sxbootstrap/tabs/tabs'",
")",
";",
"return",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"render",
"(",
"$",
"tabs",
")",
";",
"}"
] | Renders the tabs and returns the markup.
@return string | [
"Renders",
"the",
"tabs",
"and",
"returns",
"the",
"markup",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/Tabs.php#L69-L81 | train |
SpoonX/SxBootstrap | src/SxBootstrap/View/Helper/Bootstrap/Tabs.php | Tabs.add | public function add($label, $content = null, $tabId = null, $active = false)
{
$tabId = is_null($tabId) ? $this->getTabId() : $tabId;
$label = is_null($label) ? $tabId : $label;
$this->tabs[$tabId] = array (
'label' => $label,
'content' => $content,
'active' => $active,
);
return $this;
} | php | public function add($label, $content = null, $tabId = null, $active = false)
{
$tabId = is_null($tabId) ? $this->getTabId() : $tabId;
$label = is_null($label) ? $tabId : $label;
$this->tabs[$tabId] = array (
'label' => $label,
'content' => $content,
'active' => $active,
);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"label",
",",
"$",
"content",
"=",
"null",
",",
"$",
"tabId",
"=",
"null",
",",
"$",
"active",
"=",
"false",
")",
"{",
"$",
"tabId",
"=",
"is_null",
"(",
"$",
"tabId",
")",
"?",
"$",
"this",
"->",
"getTabId",
"(",
")",
":",
"$",
"tabId",
";",
"$",
"label",
"=",
"is_null",
"(",
"$",
"label",
")",
"?",
"$",
"tabId",
":",
"$",
"label",
";",
"$",
"this",
"->",
"tabs",
"[",
"$",
"tabId",
"]",
"=",
"array",
"(",
"'label'",
"=>",
"$",
"label",
",",
"'content'",
"=>",
"$",
"content",
",",
"'active'",
"=>",
"$",
"active",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a new tab.
@param string $label The label for the tab.
@param string $content The tab's content. Can be added later.
@param string $tabId The tab's id. Autogenerated when left empty.
@param boolean $active If this tab should be active.
@return Tabs Fluent interface | [
"Add",
"a",
"new",
"tab",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/Tabs.php#L118-L130 | train |
SpoonX/SxBootstrap | src/SxBootstrap/View/Helper/Bootstrap/Tabs.php | Tabs.getTabId | protected function getTabId($current = false)
{
if (true === $current) {
return key($this->tabs);
}
$c = $this->tabCount++;
return $this->defaultTabIdentifier . $c;
} | php | protected function getTabId($current = false)
{
if (true === $current) {
return key($this->tabs);
}
$c = $this->tabCount++;
return $this->defaultTabIdentifier . $c;
} | [
"protected",
"function",
"getTabId",
"(",
"$",
"current",
"=",
"false",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"current",
")",
"{",
"return",
"key",
"(",
"$",
"this",
"->",
"tabs",
")",
";",
"}",
"$",
"c",
"=",
"$",
"this",
"->",
"tabCount",
"++",
";",
"return",
"$",
"this",
"->",
"defaultTabIdentifier",
".",
"$",
"c",
";",
"}"
] | Generate an id for a tab, or get the last added one.
@param boolean $current Whether or not to get the last added id.
@return string | [
"Generate",
"an",
"id",
"for",
"a",
"tab",
"or",
"get",
"the",
"last",
"added",
"one",
"."
] | 768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6 | https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/Tabs.php#L177-L186 | train |
smalldb/libSmalldb | class/FlupdoGenericListing.php | FlupdoGenericListing.query | public function query()
{
if ($this->result === null) {
$this->before_called = true;
foreach ($this->before_query as $callable) {
$callable();
}
try {
$this->result = $this->query->query();
$this->result->setFetchMode(\PDO::FETCH_ASSOC);
}
catch (\Smalldb\Flupdo\FlupdoSqlException $ex) {
error_log("Failed SQL query:\n".$this->query->getSqlQuery());
error_log("Parameters of failed SQL query:\n".$this->query->getSqlParams());
throw $ex;
}
} else {
throw new RuntimeException('Query already performed.');
}
return $this->result;
} | php | public function query()
{
if ($this->result === null) {
$this->before_called = true;
foreach ($this->before_query as $callable) {
$callable();
}
try {
$this->result = $this->query->query();
$this->result->setFetchMode(\PDO::FETCH_ASSOC);
}
catch (\Smalldb\Flupdo\FlupdoSqlException $ex) {
error_log("Failed SQL query:\n".$this->query->getSqlQuery());
error_log("Parameters of failed SQL query:\n".$this->query->getSqlParams());
throw $ex;
}
} else {
throw new RuntimeException('Query already performed.');
}
return $this->result;
} | [
"public",
"function",
"query",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"result",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"before_called",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"before_query",
"as",
"$",
"callable",
")",
"{",
"$",
"callable",
"(",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"query",
"->",
"query",
"(",
")",
";",
"$",
"this",
"->",
"result",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}",
"catch",
"(",
"\\",
"Smalldb",
"\\",
"Flupdo",
"\\",
"FlupdoSqlException",
"$",
"ex",
")",
"{",
"error_log",
"(",
"\"Failed SQL query:\\n\"",
".",
"$",
"this",
"->",
"query",
"->",
"getSqlQuery",
"(",
")",
")",
";",
"error_log",
"(",
"\"Parameters of failed SQL query:\\n\"",
".",
"$",
"this",
"->",
"query",
"->",
"getSqlParams",
"(",
")",
")",
";",
"throw",
"$",
"ex",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Query already performed.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"result",
";",
"}"
] | Execute SQL query or do whatever is required to get this listing
populated. | [
"Execute",
"SQL",
"query",
"or",
"do",
"whatever",
"is",
"required",
"to",
"get",
"this",
"listing",
"populated",
"."
] | b94d22af5014e8060d0530fc7043768cdc57b01a | https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/FlupdoGenericListing.php#L456-L477 | train |
smalldb/libSmalldb | class/FlupdoGenericListing.php | FlupdoGenericListing.fetchAll | public function fetchAll()
{
if ($this->result === null) {
$this->query();
}
$machine = $this->machine;
$id_keys = $this->machine->describeId();
if (count($id_keys) == 1) {
$list = array();
while(($properties = $this->result->fetch(\PDO::FETCH_ASSOC))) {
$item = $machine->hotRef($machine->decodeProperties($properties));
$list[$item->id] = $item;
}
return $list;
} else {
return array_map(function($properties) use ($machine) {
return $machine->hotRef($machine->decodeProperties($properties));
}, $this->result->fetchAll(\PDO::FETCH_ASSOC));
}
} | php | public function fetchAll()
{
if ($this->result === null) {
$this->query();
}
$machine = $this->machine;
$id_keys = $this->machine->describeId();
if (count($id_keys) == 1) {
$list = array();
while(($properties = $this->result->fetch(\PDO::FETCH_ASSOC))) {
$item = $machine->hotRef($machine->decodeProperties($properties));
$list[$item->id] = $item;
}
return $list;
} else {
return array_map(function($properties) use ($machine) {
return $machine->hotRef($machine->decodeProperties($properties));
}, $this->result->fetchAll(\PDO::FETCH_ASSOC));
}
} | [
"public",
"function",
"fetchAll",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"result",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"query",
"(",
")",
";",
"}",
"$",
"machine",
"=",
"$",
"this",
"->",
"machine",
";",
"$",
"id_keys",
"=",
"$",
"this",
"->",
"machine",
"->",
"describeId",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"id_keys",
")",
"==",
"1",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"while",
"(",
"(",
"$",
"properties",
"=",
"$",
"this",
"->",
"result",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
")",
"{",
"$",
"item",
"=",
"$",
"machine",
"->",
"hotRef",
"(",
"$",
"machine",
"->",
"decodeProperties",
"(",
"$",
"properties",
")",
")",
";",
"$",
"list",
"[",
"$",
"item",
"->",
"id",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"list",
";",
"}",
"else",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"properties",
")",
"use",
"(",
"$",
"machine",
")",
"{",
"return",
"$",
"machine",
"->",
"hotRef",
"(",
"$",
"machine",
"->",
"decodeProperties",
"(",
"$",
"properties",
")",
")",
";",
"}",
",",
"$",
"this",
"->",
"result",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
")",
";",
"}",
"}"
] | Returns an array of all items in the listing.
This decodes properties. | [
"Returns",
"an",
"array",
"of",
"all",
"items",
"in",
"the",
"listing",
"."
] | b94d22af5014e8060d0530fc7043768cdc57b01a | https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/FlupdoGenericListing.php#L504-L525 | train |
smalldb/libSmalldb | class/FlupdoGenericListing.php | FlupdoGenericListing.calculateAdditionalFiltersData | protected function calculateAdditionalFiltersData(& $filters)
{
if (!empty($this->additional_filters_data)) {
foreach ($this->additional_filters_data as $f => $src) {
if (isset($src['query'])) {
$filters[$f] = $this->query->pdo->query($src['query'])->fetchColumn();
}
}
}
} | php | protected function calculateAdditionalFiltersData(& $filters)
{
if (!empty($this->additional_filters_data)) {
foreach ($this->additional_filters_data as $f => $src) {
if (isset($src['query'])) {
$filters[$f] = $this->query->pdo->query($src['query'])->fetchColumn();
}
}
}
} | [
"protected",
"function",
"calculateAdditionalFiltersData",
"(",
"&",
"$",
"filters",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"additional_filters_data",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"additional_filters_data",
"as",
"$",
"f",
"=>",
"$",
"src",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"src",
"[",
"'query'",
"]",
")",
")",
"{",
"$",
"filters",
"[",
"$",
"f",
"]",
"=",
"$",
"this",
"->",
"query",
"->",
"pdo",
"->",
"query",
"(",
"$",
"src",
"[",
"'query'",
"]",
")",
"->",
"fetchColumn",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Calculate additional filter data.
@param $filters Filters to populate with additional data.
@return Nothing. | [
"Calculate",
"additional",
"filter",
"data",
"."
] | b94d22af5014e8060d0530fc7043768cdc57b01a | https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/FlupdoGenericListing.php#L581-L590 | train |
smalldb/libSmalldb | class/FlupdoGenericListing.php | FlupdoGenericListing.setupSphinxSearch | protected function setupSphinxSearch($filter_name, $value, $machine_filter)
{
$sphinx_key_column = $this->query->quoteIdent($machine_filter['sphinx_key_column']);
$temp_table = $this->query->quoteIdent('_sphinx_temp_'.$filter_name);
$index_name = $this->query->quoteIdent($machine_filter['index_name']);
$this->query->where("$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)");
$this->before_query[] = function() use ($temp_table, $index_name, $value, $machine_filter) {
$this->query->pdo->query("CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)");
$sq = $this->sphinx->select('*')->from($index_name)->where('MATCH(?)', $value);
if (!empty($machine_filter['sphinx_option'])) {
$sq->option($machine_filter['sphinx_option']);
}
// TODO: Add param. conditions here
$sr = $sq->query();
$ins = $this->query->pdo->prepare("INSERT INTO $temp_table (id) VALUES (:id)");
foreach ($sr as $row) {
$ins->execute(array('id' => $row['id']));
}
};
$this->after_query[] = function() use ($temp_table) {
$this->query->pdo->query("DROP TEMPORARY TABLE $temp_table");
};
} | php | protected function setupSphinxSearch($filter_name, $value, $machine_filter)
{
$sphinx_key_column = $this->query->quoteIdent($machine_filter['sphinx_key_column']);
$temp_table = $this->query->quoteIdent('_sphinx_temp_'.$filter_name);
$index_name = $this->query->quoteIdent($machine_filter['index_name']);
$this->query->where("$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)");
$this->before_query[] = function() use ($temp_table, $index_name, $value, $machine_filter) {
$this->query->pdo->query("CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)");
$sq = $this->sphinx->select('*')->from($index_name)->where('MATCH(?)', $value);
if (!empty($machine_filter['sphinx_option'])) {
$sq->option($machine_filter['sphinx_option']);
}
// TODO: Add param. conditions here
$sr = $sq->query();
$ins = $this->query->pdo->prepare("INSERT INTO $temp_table (id) VALUES (:id)");
foreach ($sr as $row) {
$ins->execute(array('id' => $row['id']));
}
};
$this->after_query[] = function() use ($temp_table) {
$this->query->pdo->query("DROP TEMPORARY TABLE $temp_table");
};
} | [
"protected",
"function",
"setupSphinxSearch",
"(",
"$",
"filter_name",
",",
"$",
"value",
",",
"$",
"machine_filter",
")",
"{",
"$",
"sphinx_key_column",
"=",
"$",
"this",
"->",
"query",
"->",
"quoteIdent",
"(",
"$",
"machine_filter",
"[",
"'sphinx_key_column'",
"]",
")",
";",
"$",
"temp_table",
"=",
"$",
"this",
"->",
"query",
"->",
"quoteIdent",
"(",
"'_sphinx_temp_'",
".",
"$",
"filter_name",
")",
";",
"$",
"index_name",
"=",
"$",
"this",
"->",
"query",
"->",
"quoteIdent",
"(",
"$",
"machine_filter",
"[",
"'index_name'",
"]",
")",
";",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"\"$sphinx_key_column IN (SELECT $temp_table.id FROM $temp_table)\"",
")",
";",
"$",
"this",
"->",
"before_query",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"temp_table",
",",
"$",
"index_name",
",",
"$",
"value",
",",
"$",
"machine_filter",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"pdo",
"->",
"query",
"(",
"\"CREATE TEMPORARY TABLE $temp_table (`id` INT(11) NOT NULL)\"",
")",
";",
"$",
"sq",
"=",
"$",
"this",
"->",
"sphinx",
"->",
"select",
"(",
"'*'",
")",
"->",
"from",
"(",
"$",
"index_name",
")",
"->",
"where",
"(",
"'MATCH(?)'",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"machine_filter",
"[",
"'sphinx_option'",
"]",
")",
")",
"{",
"$",
"sq",
"->",
"option",
"(",
"$",
"machine_filter",
"[",
"'sphinx_option'",
"]",
")",
";",
"}",
"// TODO: Add param. conditions here",
"$",
"sr",
"=",
"$",
"sq",
"->",
"query",
"(",
")",
";",
"$",
"ins",
"=",
"$",
"this",
"->",
"query",
"->",
"pdo",
"->",
"prepare",
"(",
"\"INSERT INTO $temp_table (id) VALUES (:id)\"",
")",
";",
"foreach",
"(",
"$",
"sr",
"as",
"$",
"row",
")",
"{",
"$",
"ins",
"->",
"execute",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"row",
"[",
"'id'",
"]",
")",
")",
";",
"}",
"}",
";",
"$",
"this",
"->",
"after_query",
"[",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"temp_table",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"pdo",
"->",
"query",
"(",
"\"DROP TEMPORARY TABLE $temp_table\"",
")",
";",
"}",
";",
"}"
] | Setup query for lookup in Sphinx search engine.
Since Sphinx is accessed using standalone MySQL connection, this
will create temporary table and populate it with the fulltext search
result. Then the temporary table will be used to access and filter
the original query. | [
"Setup",
"query",
"for",
"lookup",
"in",
"Sphinx",
"search",
"engine",
"."
] | b94d22af5014e8060d0530fc7043768cdc57b01a | https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/FlupdoGenericListing.php#L601-L627 | train |
alxmsl/Cli | source/Option.php | Option.setValue | public function setValue($value) {
switch ($this->type) {
case self::TYPE_BOOLEAN:
$this->value = (bool) $value;
break;
case self::TYPE_STRING:
$this->value = (string) $value;
break;
}
return $this;
} | php | public function setValue($value) {
switch ($this->type) {
case self::TYPE_BOOLEAN:
$this->value = (bool) $value;
break;
case self::TYPE_STRING:
$this->value = (string) $value;
break;
}
return $this;
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_BOOLEAN",
":",
"$",
"this",
"->",
"value",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"break",
";",
"case",
"self",
"::",
"TYPE_STRING",
":",
"$",
"this",
"->",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Option value setter
@param string|bool $value option value
@return Option self | [
"Option",
"value",
"setter"
] | 806fc2baa23e5a3d32734a4b913c3730342a8bb1 | https://github.com/alxmsl/Cli/blob/806fc2baa23e5a3d32734a4b913c3730342a8bb1/source/Option.php#L123-L133 | train |
wearesho-team/cpa-integration | src/SalesDoubler/PostbackService.php | PostbackService.send | public function send(ConversionInterface $conversion): ResponseInterface
{
if (!$conversion instanceof Conversion) {
throw new UnsupportedConversionTypeException($this, $conversion);
}
$previousSentConversion = $this->repository->pull(
$conversion->getId(),
get_class($conversion)
);
if ($previousSentConversion instanceof StoredConversionInterface) {
throw new DuplicatedConversionException($conversion);
}
$request = new Request("get", $this->getPath($conversion));
$response = $this->client->send($request);
$this->repository->push($conversion, $response);
return $response;
} | php | public function send(ConversionInterface $conversion): ResponseInterface
{
if (!$conversion instanceof Conversion) {
throw new UnsupportedConversionTypeException($this, $conversion);
}
$previousSentConversion = $this->repository->pull(
$conversion->getId(),
get_class($conversion)
);
if ($previousSentConversion instanceof StoredConversionInterface) {
throw new DuplicatedConversionException($conversion);
}
$request = new Request("get", $this->getPath($conversion));
$response = $this->client->send($request);
$this->repository->push($conversion, $response);
return $response;
} | [
"public",
"function",
"send",
"(",
"ConversionInterface",
"$",
"conversion",
")",
":",
"ResponseInterface",
"{",
"if",
"(",
"!",
"$",
"conversion",
"instanceof",
"Conversion",
")",
"{",
"throw",
"new",
"UnsupportedConversionTypeException",
"(",
"$",
"this",
",",
"$",
"conversion",
")",
";",
"}",
"$",
"previousSentConversion",
"=",
"$",
"this",
"->",
"repository",
"->",
"pull",
"(",
"$",
"conversion",
"->",
"getId",
"(",
")",
",",
"get_class",
"(",
"$",
"conversion",
")",
")",
";",
"if",
"(",
"$",
"previousSentConversion",
"instanceof",
"StoredConversionInterface",
")",
"{",
"throw",
"new",
"DuplicatedConversionException",
"(",
"$",
"conversion",
")",
";",
"}",
"$",
"request",
"=",
"new",
"Request",
"(",
"\"get\"",
",",
"$",
"this",
"->",
"getPath",
"(",
"$",
"conversion",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"repository",
"->",
"push",
"(",
"$",
"conversion",
",",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Sending POST query to CPA network after creating conversion
@param ConversionInterface $conversion
@throws UnsupportedConversionTypeException
@throws DuplicatedConversionException
@throws RequestException
@return ResponseInterface | [
"Sending",
"POST",
"query",
"to",
"CPA",
"network",
"after",
"creating",
"conversion"
] | 6b78d2315e893ecf09132ae3e9d8e8c1b5ae6291 | https://github.com/wearesho-team/cpa-integration/blob/6b78d2315e893ecf09132ae3e9d8e8c1b5ae6291/src/SalesDoubler/PostbackService.php#L88-L107 | train |
as3io/modlr | src/StorageLayerManager.php | StorageLayerManager.getPersister | public function getPersister($key)
{
if (empty($key) || false === $this->hasPersister($key)) {
throw PersisterException::persisterNotFound($key);
}
return $this->persisters[$key];
} | php | public function getPersister($key)
{
if (empty($key) || false === $this->hasPersister($key)) {
throw PersisterException::persisterNotFound($key);
}
return $this->persisters[$key];
} | [
"public",
"function",
"getPersister",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
"||",
"false",
"===",
"$",
"this",
"->",
"hasPersister",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"PersisterException",
"::",
"persisterNotFound",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"persisters",
"[",
"$",
"key",
"]",
";",
"}"
] | Gets a Persister service by key.
@param string $key
@return PersisterInterface
@throws PersisterException If the service was not found. | [
"Gets",
"a",
"Persister",
"service",
"by",
"key",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/StorageLayerManager.php#L62-L68 | train |
as3io/modlr | src/StorageLayerManager.php | StorageLayerManager.getSearchClient | public function getSearchClient($key)
{
if (empty($key) || false === $this->hasSearchClient($key)) {
throw ClientException::clientNotFound($key);
}
return $this->searchClients[$key];
} | php | public function getSearchClient($key)
{
if (empty($key) || false === $this->hasSearchClient($key)) {
throw ClientException::clientNotFound($key);
}
return $this->searchClients[$key];
} | [
"public",
"function",
"getSearchClient",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
"||",
"false",
"===",
"$",
"this",
"->",
"hasSearchClient",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"ClientException",
"::",
"clientNotFound",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"searchClients",
"[",
"$",
"key",
"]",
";",
"}"
] | Gets a Search Client service by key.
@param string $key
@return ClientInterface
@throws ClientException If the service was not found. | [
"Gets",
"a",
"Search",
"Client",
"service",
"by",
"key",
"."
] | 7e684b88bb22a2e18397df9402075c6533084b16 | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/StorageLayerManager.php#L88-L94 | train |
webeith/dnsbl | src/Dnsbl/Dnsbl.php | Dnsbl.check | public function check($hostname)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
$result[] = $blServer->getResolver()->execute($hostname);
}
return $result;
} | php | public function check($hostname)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
$result[] = $blServer->getResolver()->execute($hostname);
}
return $result;
} | [
"public",
"function",
"check",
"(",
"$",
"hostname",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getBlServers",
"(",
")",
"as",
"$",
"blServer",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"blServer",
"->",
"getResolver",
"(",
")",
"->",
"execute",
"(",
"$",
"hostname",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Check hostname in all bl servers
@param string $hostname
@return Dnsbl\Resolver\Response\InterfaceResponse | [
"Check",
"hostname",
"in",
"all",
"bl",
"servers"
] | 062e30f1ccaf6578bebe1bbe51a6a833337ba825 | https://github.com/webeith/dnsbl/blob/062e30f1ccaf6578bebe1bbe51a6a833337ba825/src/Dnsbl/Dnsbl.php#L35-L43 | train |
webeith/dnsbl | src/Dnsbl/Dnsbl.php | Dnsbl.checkIP | public function checkIP($ip)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
if ($blServer->supportIPv4()) {
$result[] = $blServer->getResolver()->execute($ip);
}
}
return $result;
} | php | public function checkIP($ip)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
if ($blServer->supportIPv4()) {
$result[] = $blServer->getResolver()->execute($ip);
}
}
return $result;
} | [
"public",
"function",
"checkIP",
"(",
"$",
"ip",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getBlServers",
"(",
")",
"as",
"$",
"blServer",
")",
"{",
"if",
"(",
"$",
"blServer",
"->",
"supportIPv4",
"(",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"blServer",
"->",
"getResolver",
"(",
")",
"->",
"execute",
"(",
"$",
"ip",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Check IP in black list
@param string $ip
@return Dnsbl\Resolver\Response\InterfaceResponse | [
"Check",
"IP",
"in",
"black",
"list"
] | 062e30f1ccaf6578bebe1bbe51a6a833337ba825 | https://github.com/webeith/dnsbl/blob/062e30f1ccaf6578bebe1bbe51a6a833337ba825/src/Dnsbl/Dnsbl.php#L52-L62 | train |
webeith/dnsbl | src/Dnsbl/Dnsbl.php | Dnsbl.checkDomain | public function checkDomain($hostname)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
if ($blServer->supportDomain()) {
$result[] = $blServer->getResolver()->execute($hostname);
}
}
return $result;
} | php | public function checkDomain($hostname)
{
$result = array();
foreach ($this->getBlServers() as $blServer) {
if ($blServer->supportDomain()) {
$result[] = $blServer->getResolver()->execute($hostname);
}
}
return $result;
} | [
"public",
"function",
"checkDomain",
"(",
"$",
"hostname",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getBlServers",
"(",
")",
"as",
"$",
"blServer",
")",
"{",
"if",
"(",
"$",
"blServer",
"->",
"supportDomain",
"(",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"blServer",
"->",
"getResolver",
"(",
")",
"->",
"execute",
"(",
"$",
"hostname",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Check domain name in black list
@param string $domain
@return Dnsbl\Resolver\Response\InterfaceResponse | [
"Check",
"domain",
"name",
"in",
"black",
"list"
] | 062e30f1ccaf6578bebe1bbe51a6a833337ba825 | https://github.com/webeith/dnsbl/blob/062e30f1ccaf6578bebe1bbe51a6a833337ba825/src/Dnsbl/Dnsbl.php#L70-L80 | train |
atelierspierrot/templatengine | src/TemplateEngine/TemplateObject/LinkTag.php | LinkTag.set | public function set(array $tags)
{
if (!empty($tags)) {
foreach ($tags as $_tag) {
$this->add($_tag);
}
}
return $this;
} | php | public function set(array $tags)
{
if (!empty($tags)) {
foreach ($tags as $_tag) {
$this->add($_tag);
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"tags",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tags",
")",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"_tag",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"_tag",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set a full links header stack
@param array $tags An array of tags definitions
@return self
@see self::add() | [
"Set",
"a",
"full",
"links",
"header",
"stack"
] | de01b117f882670bed7b322e2d3b8b30fa9ae45f | https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/TemplateEngine/TemplateObject/LinkTag.php#L81-L89 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.getImageStorage | public function getImageStorage($image)
{
if (@file_exists('file://' . $image)) {
return DriverInterface::IMAGE_STORAGE_FILE;
} elseif (false === strpos($image, '://')) {
return DriverInterface::IMAGE_STORAGE_STRING;
} else {
return DriverInterface::IMAGE_STORAGE_URL;
}
} | php | public function getImageStorage($image)
{
if (@file_exists('file://' . $image)) {
return DriverInterface::IMAGE_STORAGE_FILE;
} elseif (false === strpos($image, '://')) {
return DriverInterface::IMAGE_STORAGE_STRING;
} else {
return DriverInterface::IMAGE_STORAGE_URL;
}
} | [
"public",
"function",
"getImageStorage",
"(",
"$",
"image",
")",
"{",
"if",
"(",
"@",
"file_exists",
"(",
"'file://'",
".",
"$",
"image",
")",
")",
"{",
"return",
"DriverInterface",
"::",
"IMAGE_STORAGE_FILE",
";",
"}",
"elseif",
"(",
"false",
"===",
"strpos",
"(",
"$",
"image",
",",
"'://'",
")",
")",
"{",
"return",
"DriverInterface",
"::",
"IMAGE_STORAGE_STRING",
";",
"}",
"else",
"{",
"return",
"DriverInterface",
"::",
"IMAGE_STORAGE_URL",
";",
"}",
"}"
] | Get storage type of image
@param string $image
@return string | [
"Get",
"storage",
"type",
"of",
"image"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L29-L38 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.getInfo | public function getInfo($image)
{
if (DriverInterface::IMAGE_STORAGE_STRING == $this->getImageStorage($image)) {
$image = 'data://application/octet-stream;base64,' . base64_encode($image);
}
return getimagesize($image);
} | php | public function getInfo($image)
{
if (DriverInterface::IMAGE_STORAGE_STRING == $this->getImageStorage($image)) {
$image = 'data://application/octet-stream;base64,' . base64_encode($image);
}
return getimagesize($image);
} | [
"public",
"function",
"getInfo",
"(",
"$",
"image",
")",
"{",
"if",
"(",
"DriverInterface",
"::",
"IMAGE_STORAGE_STRING",
"==",
"$",
"this",
"->",
"getImageStorage",
"(",
"$",
"image",
")",
")",
"{",
"$",
"image",
"=",
"'data://application/octet-stream;base64,'",
".",
"base64_encode",
"(",
"$",
"image",
")",
";",
"}",
"return",
"getimagesize",
"(",
"$",
"image",
")",
";",
"}"
] | Get info of image
@param string $image
@return array | [
"Get",
"info",
"of",
"image"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L58-L64 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.ensure | public function ensure($image, $formats, $storages)
{
$storage = $this->getImageStorage($image);
$format = $this->getImageFormat($image);
$storages = is_string($storages) ? array($storages) : $storages;
$formats = is_int($formats) ? array($formats) : $formats;
if (in_array($format, $formats)) {
if (in_array($storage, $storages)) {
return $image;
} else {
$file = $this->getFileOptionForSaving($storages);
$image = $this->loadToString($image);
return $this->saveFromString($image, array('file' => $file));
}
} else {
$file = $this->getFileOptionForSaving($storages);
$resource = $this->load($image);
return $this->save($resource, array('file' => $file, 'format' => $formats[0]));
}
} | php | public function ensure($image, $formats, $storages)
{
$storage = $this->getImageStorage($image);
$format = $this->getImageFormat($image);
$storages = is_string($storages) ? array($storages) : $storages;
$formats = is_int($formats) ? array($formats) : $formats;
if (in_array($format, $formats)) {
if (in_array($storage, $storages)) {
return $image;
} else {
$file = $this->getFileOptionForSaving($storages);
$image = $this->loadToString($image);
return $this->saveFromString($image, array('file' => $file));
}
} else {
$file = $this->getFileOptionForSaving($storages);
$resource = $this->load($image);
return $this->save($resource, array('file' => $file, 'format' => $formats[0]));
}
} | [
"public",
"function",
"ensure",
"(",
"$",
"image",
",",
"$",
"formats",
",",
"$",
"storages",
")",
"{",
"$",
"storage",
"=",
"$",
"this",
"->",
"getImageStorage",
"(",
"$",
"image",
")",
";",
"$",
"format",
"=",
"$",
"this",
"->",
"getImageFormat",
"(",
"$",
"image",
")",
";",
"$",
"storages",
"=",
"is_string",
"(",
"$",
"storages",
")",
"?",
"array",
"(",
"$",
"storages",
")",
":",
"$",
"storages",
";",
"$",
"formats",
"=",
"is_int",
"(",
"$",
"formats",
")",
"?",
"array",
"(",
"$",
"formats",
")",
":",
"$",
"formats",
";",
"if",
"(",
"in_array",
"(",
"$",
"format",
",",
"$",
"formats",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"storage",
",",
"$",
"storages",
")",
")",
"{",
"return",
"$",
"image",
";",
"}",
"else",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFileOptionForSaving",
"(",
"$",
"storages",
")",
";",
"$",
"image",
"=",
"$",
"this",
"->",
"loadToString",
"(",
"$",
"image",
")",
";",
"return",
"$",
"this",
"->",
"saveFromString",
"(",
"$",
"image",
",",
"array",
"(",
"'file'",
"=>",
"$",
"file",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFileOptionForSaving",
"(",
"$",
"storages",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"image",
")",
";",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"resource",
",",
"array",
"(",
"'file'",
"=>",
"$",
"file",
",",
"'format'",
"=>",
"$",
"formats",
"[",
"0",
"]",
")",
")",
";",
"}",
"}"
] | Ensure certain image storages und formats
@param string $image
@param array|int $formats
@param array|string $storages
@return string | [
"Ensure",
"certain",
"image",
"storages",
"und",
"formats"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L74-L94 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.getFileOptionForSaving | protected function getFileOptionForSaving($storages)
{
if (in_array(DriverInterface::IMAGE_STORAGE_STRING, $storages)) {
return null;
} elseif (in_array(DriverInterface::IMAGE_STORAGE_FILE, $storages)) {
return sys_get_temp_dir() . '/tmp-image-' . rand();
} else {
throw new Exception\RuntimeException('cannot save to url storage');
}
} | php | protected function getFileOptionForSaving($storages)
{
if (in_array(DriverInterface::IMAGE_STORAGE_STRING, $storages)) {
return null;
} elseif (in_array(DriverInterface::IMAGE_STORAGE_FILE, $storages)) {
return sys_get_temp_dir() . '/tmp-image-' . rand();
} else {
throw new Exception\RuntimeException('cannot save to url storage');
}
} | [
"protected",
"function",
"getFileOptionForSaving",
"(",
"$",
"storages",
")",
"{",
"if",
"(",
"in_array",
"(",
"DriverInterface",
"::",
"IMAGE_STORAGE_STRING",
",",
"$",
"storages",
")",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"DriverInterface",
"::",
"IMAGE_STORAGE_FILE",
",",
"$",
"storages",
")",
")",
"{",
"return",
"sys_get_temp_dir",
"(",
")",
".",
"'/tmp-image-'",
".",
"rand",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'cannot save to url storage'",
")",
";",
"}",
"}"
] | Get file option from storages for saving
@param array $storages
@return string|null | [
"Get",
"file",
"option",
"from",
"storages",
"for",
"saving"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L102-L111 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.loadToString | public function loadToString($image)
{
$srcStorage = $this->getImageStorage($image);
if ($srcStorage !== DriverInterface::IMAGE_STORAGE_STRING) {
$image = @file_get_contents($image);
if (false === $image) {
throw new Exception\RuntimeException('could not load image');
}
}
return $image;
} | php | public function loadToString($image)
{
$srcStorage = $this->getImageStorage($image);
if ($srcStorage !== DriverInterface::IMAGE_STORAGE_STRING) {
$image = @file_get_contents($image);
if (false === $image) {
throw new Exception\RuntimeException('could not load image');
}
}
return $image;
} | [
"public",
"function",
"loadToString",
"(",
"$",
"image",
")",
"{",
"$",
"srcStorage",
"=",
"$",
"this",
"->",
"getImageStorage",
"(",
"$",
"image",
")",
";",
"if",
"(",
"$",
"srcStorage",
"!==",
"DriverInterface",
"::",
"IMAGE_STORAGE_STRING",
")",
"{",
"$",
"image",
"=",
"@",
"file_get_contents",
"(",
"$",
"image",
")",
";",
"if",
"(",
"false",
"===",
"$",
"image",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'could not load image'",
")",
";",
"}",
"}",
"return",
"$",
"image",
";",
"}"
] | Load image to string
@param string $image
@return string | [
"Load",
"image",
"to",
"string"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L144-L154 | train |
GordonSchmidt/GSImage | src/GSImage/Driver/AbstractDriver.php | AbstractDriver.saveFromString | public function saveFromString($image, $options = array())
{
if (isset($options['file'])) {
if (false === @file_put_contents($options['file'], $image)) {
throw new Exception\RuntimeException('could not save image');
}
return $options['file'];
}
return $image;
} | php | public function saveFromString($image, $options = array())
{
if (isset($options['file'])) {
if (false === @file_put_contents($options['file'], $image)) {
throw new Exception\RuntimeException('could not save image');
}
return $options['file'];
}
return $image;
} | [
"public",
"function",
"saveFromString",
"(",
"$",
"image",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'file'",
"]",
")",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"file_put_contents",
"(",
"$",
"options",
"[",
"'file'",
"]",
",",
"$",
"image",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'could not save image'",
")",
";",
"}",
"return",
"$",
"options",
"[",
"'file'",
"]",
";",
"}",
"return",
"$",
"image",
";",
"}"
] | Save image from string
@param string $image
@param array $options
@return string | [
"Save",
"image",
"from",
"string"
] | c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d | https://github.com/GordonSchmidt/GSImage/blob/c36c5ce2131ac535f5ca2d9ce7b3c66cf6f2b72d/src/GSImage/Driver/AbstractDriver.php#L163-L172 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getAllowedDbValues | public function getAllowedDbValues(array $except = [])
{
$map = $this->getMap();
$dbValues = array_diff(array_keys($map), $except);
return $dbValues;
} | php | public function getAllowedDbValues(array $except = [])
{
$map = $this->getMap();
$dbValues = array_diff(array_keys($map), $except);
return $dbValues;
} | [
"public",
"function",
"getAllowedDbValues",
"(",
"array",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
";",
"$",
"dbValues",
"=",
"array_diff",
"(",
"array_keys",
"(",
"$",
"map",
")",
",",
"$",
"except",
")",
";",
"return",
"$",
"dbValues",
";",
"}"
] | Returns list of the all registered database values
@param array $except List of the database values which should be excluded
@return array | [
"Returns",
"list",
"of",
"the",
"all",
"registered",
"database",
"values"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L81-L87 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getAllowedHumanValues | public function getAllowedHumanValues(array $except = [])
{
$map = $this->getMap();
$humanValues = array_diff(array_values($map), $except);
return $humanValues;
} | php | public function getAllowedHumanValues(array $except = [])
{
$map = $this->getMap();
$humanValues = array_diff(array_values($map), $except);
return $humanValues;
} | [
"public",
"function",
"getAllowedHumanValues",
"(",
"array",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
";",
"$",
"humanValues",
"=",
"array_diff",
"(",
"array_values",
"(",
"$",
"map",
")",
",",
"$",
"except",
")",
";",
"return",
"$",
"humanValues",
";",
"}"
] | Returns list of the all registered humanized values
@param array $except List of the humanized values which should be excluded
@return array | [
"Returns",
"list",
"of",
"the",
"all",
"registered",
"humanized",
"values"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L96-L102 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getMap | public function getMap()
{
$result = [];
foreach ($this->getConstants() as $dbName => $dbValue) {
if (0 === strpos($dbName, self::PREFIX_DB)) {
$result[$dbValue] = $this->getAppropriateConstValue(self::PREFIX_DB, $dbName);
}
}
return $result;
} | php | public function getMap()
{
$result = [];
foreach ($this->getConstants() as $dbName => $dbValue) {
if (0 === strpos($dbName, self::PREFIX_DB)) {
$result[$dbValue] = $this->getAppropriateConstValue(self::PREFIX_DB, $dbName);
}
}
return $result;
} | [
"public",
"function",
"getMap",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConstants",
"(",
")",
"as",
"$",
"dbName",
"=>",
"$",
"dbValue",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"dbName",
",",
"self",
"::",
"PREFIX_DB",
")",
")",
"{",
"$",
"result",
"[",
"$",
"dbValue",
"]",
"=",
"$",
"this",
"->",
"getAppropriateConstValue",
"(",
"self",
"::",
"PREFIX_DB",
",",
"$",
"dbName",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns map of the all registered values in the 'key' => 'value' pairs.
The 'key' equal to database value and the 'value' equal to humanized value.
@return array | [
"Returns",
"map",
"of",
"the",
"all",
"registered",
"values",
"in",
"the",
"key",
"=",
">",
"value",
"pairs",
".",
"The",
"key",
"equal",
"to",
"database",
"value",
"and",
"the",
"value",
"equal",
"to",
"humanized",
"value",
"."
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L110-L121 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getRandomDbValue | public function getRandomDbValue(array $except = [])
{
$values = $this->getAllowedDbValues($except);
shuffle($values);
return array_shift($values);
} | php | public function getRandomDbValue(array $except = [])
{
$values = $this->getAllowedDbValues($except);
shuffle($values);
return array_shift($values);
} | [
"public",
"function",
"getRandomDbValue",
"(",
"array",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getAllowedDbValues",
"(",
"$",
"except",
")",
";",
"shuffle",
"(",
"$",
"values",
")",
";",
"return",
"array_shift",
"(",
"$",
"values",
")",
";",
"}"
] | Returns random database value
@param array $except List of the database values which should be excluded
@return string|int | [
"Returns",
"random",
"database",
"value"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L130-L137 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getRandomHumanValue | public function getRandomHumanValue(array $except = [])
{
$values = $this->getAllowedHumanValues($except);
shuffle($values);
return array_shift($values);
} | php | public function getRandomHumanValue(array $except = [])
{
$values = $this->getAllowedHumanValues($except);
shuffle($values);
return array_shift($values);
} | [
"public",
"function",
"getRandomHumanValue",
"(",
"array",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getAllowedHumanValues",
"(",
"$",
"except",
")",
";",
"shuffle",
"(",
"$",
"values",
")",
";",
"return",
"array_shift",
"(",
"$",
"values",
")",
";",
"}"
] | Returns random humanized value
@param array $except List of the humanized values which should be excluded
@return string|int | [
"Returns",
"random",
"humanized",
"value"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L146-L153 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getAppropriateConstValue | protected function getAppropriateConstValue($prefixFrom, $constName)
{
$prefixTo = $prefixFrom === self::PREFIX_DB ? self::PREFIX_HUMAN : self::PREFIX_DB;
$count = 1;
$constName = str_replace($prefixFrom, $prefixTo, $constName, $count);
return constant('static::'.$constName);
} | php | protected function getAppropriateConstValue($prefixFrom, $constName)
{
$prefixTo = $prefixFrom === self::PREFIX_DB ? self::PREFIX_HUMAN : self::PREFIX_DB;
$count = 1;
$constName = str_replace($prefixFrom, $prefixTo, $constName, $count);
return constant('static::'.$constName);
} | [
"protected",
"function",
"getAppropriateConstValue",
"(",
"$",
"prefixFrom",
",",
"$",
"constName",
")",
"{",
"$",
"prefixTo",
"=",
"$",
"prefixFrom",
"===",
"self",
"::",
"PREFIX_DB",
"?",
"self",
"::",
"PREFIX_HUMAN",
":",
"self",
"::",
"PREFIX_DB",
";",
"$",
"count",
"=",
"1",
";",
"$",
"constName",
"=",
"str_replace",
"(",
"$",
"prefixFrom",
",",
"$",
"prefixTo",
",",
"$",
"constName",
",",
"$",
"count",
")",
";",
"return",
"constant",
"(",
"'static::'",
".",
"$",
"constName",
")",
";",
"}"
] | Returns appropriated pair value
@param string $prefixFrom Constant prefix which determine what the value should be returns
put self::PREFIX_DB to get appropriated humanized value
or self::PREFIX_HUMAN to get appropriated database value
@param string $constName Constant name which should be processed
@return int|string | [
"Returns",
"appropriated",
"pair",
"value"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L165-L172 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.convert | private function convert($value, $prefixFrom)
{
foreach ($this->getConstants() as $constName => $constValue) {
// process constant if she's does start from reserved prefix and values was equals
if (0 === strpos($constName, $prefixFrom) && $value === $constValue) {
return $this->getAppropriateConstValue($prefixFrom, $constName);
}
}
throw new UndefinedMapValueException($this->getClassName(), $value);
} | php | private function convert($value, $prefixFrom)
{
foreach ($this->getConstants() as $constName => $constValue) {
// process constant if she's does start from reserved prefix and values was equals
if (0 === strpos($constName, $prefixFrom) && $value === $constValue) {
return $this->getAppropriateConstValue($prefixFrom, $constName);
}
}
throw new UndefinedMapValueException($this->getClassName(), $value);
} | [
"private",
"function",
"convert",
"(",
"$",
"value",
",",
"$",
"prefixFrom",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getConstants",
"(",
")",
"as",
"$",
"constName",
"=>",
"$",
"constValue",
")",
"{",
"// process constant if she's does start from reserved prefix and values was equals",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"constName",
",",
"$",
"prefixFrom",
")",
"&&",
"$",
"value",
"===",
"$",
"constValue",
")",
"{",
"return",
"$",
"this",
"->",
"getAppropriateConstValue",
"(",
"$",
"prefixFrom",
",",
"$",
"constName",
")",
";",
"}",
"}",
"throw",
"new",
"UndefinedMapValueException",
"(",
"$",
"this",
"->",
"getClassName",
"(",
")",
",",
"$",
"value",
")",
";",
"}"
] | Returns appropriated value by received origin value. Humanized value by received database value and vise versa.
@param string|int $value Value for convert
@param string $prefixFrom Constant prefix which determine what the value should be returns
put self::PREFIX_DB to get appropriated humanized value
or self::PREFIX_HUMAN to get appropriated database value
@throws UndefinedMapValueException When received value does not exists
@return string|int | [
"Returns",
"appropriated",
"value",
"by",
"received",
"origin",
"value",
".",
"Humanized",
"value",
"by",
"received",
"database",
"value",
"and",
"vise",
"versa",
"."
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L186-L196 | train |
adrenalinkin/enum-mapper | Mapper/AbstractEnumMapper.php | AbstractEnumMapper.getConstants | private function getConstants()
{
if (empty($this->constants)) {
try {
$reflection = new \ReflectionClass($this->getClassName());
$this->constants = $reflection->getConstants();
} catch (\ReflectionException $e) {
$this->constants = [];
}
}
return $this->constants;
} | php | private function getConstants()
{
if (empty($this->constants)) {
try {
$reflection = new \ReflectionClass($this->getClassName());
$this->constants = $reflection->getConstants();
} catch (\ReflectionException $e) {
$this->constants = [];
}
}
return $this->constants;
} | [
"private",
"function",
"getConstants",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"constants",
")",
")",
"{",
"try",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"getClassName",
"(",
")",
")",
";",
"$",
"this",
"->",
"constants",
"=",
"$",
"reflection",
"->",
"getConstants",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"constants",
"=",
"[",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"constants",
";",
"}"
] | Returns list of the all available constants of the current class
@return array | [
"Returns",
"list",
"of",
"the",
"all",
"available",
"constants",
"of",
"the",
"current",
"class"
] | 3385e6cdf75f7f9863cd3222ece76de1a3e5961d | https://github.com/adrenalinkin/enum-mapper/blob/3385e6cdf75f7f9863cd3222ece76de1a3e5961d/Mapper/AbstractEnumMapper.php#L217-L229 | train |
ttools/ttools | src/TTools/TTools.php | TTools.getAuthorizeUrl | public function getAuthorizeUrl(array $params = [])
{
$result = $this->OAuthRequest(self::API_BASE . self::REQUEST_PATH, $params);
if ($result->getCode() == 200) {
$tokens = $this->parseResponse($result->getResponse());
return [
'auth_url' => self::API_BASE . $this->auth_method . '?oauth_token=' . $tokens['oauth_token'],
'secret' => $tokens['oauth_token_secret'],
'token' => $tokens['oauth_token']
];
}
return $this->handleError($result);
} | php | public function getAuthorizeUrl(array $params = [])
{
$result = $this->OAuthRequest(self::API_BASE . self::REQUEST_PATH, $params);
if ($result->getCode() == 200) {
$tokens = $this->parseResponse($result->getResponse());
return [
'auth_url' => self::API_BASE . $this->auth_method . '?oauth_token=' . $tokens['oauth_token'],
'secret' => $tokens['oauth_token_secret'],
'token' => $tokens['oauth_token']
];
}
return $this->handleError($result);
} | [
"public",
"function",
"getAuthorizeUrl",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"OAuthRequest",
"(",
"self",
"::",
"API_BASE",
".",
"self",
"::",
"REQUEST_PATH",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"result",
"->",
"getCode",
"(",
")",
"==",
"200",
")",
"{",
"$",
"tokens",
"=",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"result",
"->",
"getResponse",
"(",
")",
")",
";",
"return",
"[",
"'auth_url'",
"=>",
"self",
"::",
"API_BASE",
".",
"$",
"this",
"->",
"auth_method",
".",
"'?oauth_token='",
".",
"$",
"tokens",
"[",
"'oauth_token'",
"]",
",",
"'secret'",
"=>",
"$",
"tokens",
"[",
"'oauth_token_secret'",
"]",
",",
"'token'",
"=>",
"$",
"tokens",
"[",
"'oauth_token'",
"]",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"handleError",
"(",
"$",
"result",
")",
";",
"}"
] | Gets the authorization url.
@param array $params Custom parameters passed to the OAuth request
@return array If successful, returns an array with 'auth_url', 'secret' and 'token';
otherwise, returns an array with error code and message. | [
"Gets",
"the",
"authorization",
"url",
"."
] | 32e6b1d9ffa346db3bbfff46a258f12d0c322819 | https://github.com/ttools/ttools/blob/32e6b1d9ffa346db3bbfff46a258f12d0c322819/src/TTools/TTools.php#L77-L93 | train |
beyoio/beyod | protocol/http/Request.php | Request.loadRequest | public function loadRequest($buffer)
{
$this->requestAt = microtime(true);
list($this->_rawHeader, $this->_rawBody) = explode("\r\n\r\n", $buffer, 2);
$headers = explode("\r\n", $this->_rawHeader, 2);
list($this->method, $this->uri, $this->version) = explode(' ',$headers[0]);
$this->loadHeaders();
$this->loadBody();
$this->_REQUEST = array_merge($this->_GET, $this->_POST);
$this->loadServerVars();
$this->loadGet();
} | php | public function loadRequest($buffer)
{
$this->requestAt = microtime(true);
list($this->_rawHeader, $this->_rawBody) = explode("\r\n\r\n", $buffer, 2);
$headers = explode("\r\n", $this->_rawHeader, 2);
list($this->method, $this->uri, $this->version) = explode(' ',$headers[0]);
$this->loadHeaders();
$this->loadBody();
$this->_REQUEST = array_merge($this->_GET, $this->_POST);
$this->loadServerVars();
$this->loadGet();
} | [
"public",
"function",
"loadRequest",
"(",
"$",
"buffer",
")",
"{",
"$",
"this",
"->",
"requestAt",
"=",
"microtime",
"(",
"true",
")",
";",
"list",
"(",
"$",
"this",
"->",
"_rawHeader",
",",
"$",
"this",
"->",
"_rawBody",
")",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"buffer",
",",
"2",
")",
";",
"$",
"headers",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"this",
"->",
"_rawHeader",
",",
"2",
")",
";",
"list",
"(",
"$",
"this",
"->",
"method",
",",
"$",
"this",
"->",
"uri",
",",
"$",
"this",
"->",
"version",
")",
"=",
"explode",
"(",
"' '",
",",
"$",
"headers",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"loadHeaders",
"(",
")",
";",
"$",
"this",
"->",
"loadBody",
"(",
")",
";",
"$",
"this",
"->",
"_REQUEST",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_GET",
",",
"$",
"this",
"->",
"_POST",
")",
";",
"$",
"this",
"->",
"loadServerVars",
"(",
")",
";",
"$",
"this",
"->",
"loadGet",
"(",
")",
";",
"}"
] | load reqeust buffer to this object
@param string $buffer | [
"load",
"reqeust",
"buffer",
"to",
"this",
"object"
] | 11941db9c4ae4abbca6c8e634d21873c690efc79 | https://github.com/beyoio/beyod/blob/11941db9c4ae4abbca6c8e634d21873c690efc79/protocol/http/Request.php#L92-L112 | train |
brick/validation | src/Internal/Luhn.php | Luhn.getCheckDigit | public static function getCheckDigit(string $number) : int
{
if (! ctype_digit($number)) {
throw new \InvalidArgumentException('The number must be a string of digits');
}
$checksum = self::checksum($number . '0');
return ($checksum === 0) ? 0 : 10 - $checksum;
} | php | public static function getCheckDigit(string $number) : int
{
if (! ctype_digit($number)) {
throw new \InvalidArgumentException('The number must be a string of digits');
}
$checksum = self::checksum($number . '0');
return ($checksum === 0) ? 0 : 10 - $checksum;
} | [
"public",
"static",
"function",
"getCheckDigit",
"(",
"string",
"$",
"number",
")",
":",
"int",
"{",
"if",
"(",
"!",
"ctype_digit",
"(",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The number must be a string of digits'",
")",
";",
"}",
"$",
"checksum",
"=",
"self",
"::",
"checksum",
"(",
"$",
"number",
".",
"'0'",
")",
";",
"return",
"(",
"$",
"checksum",
"===",
"0",
")",
"?",
"0",
":",
"10",
"-",
"$",
"checksum",
";",
"}"
] | Computes and returns the check digit of a number.
@param string $number
@return int
@throws \InvalidArgumentException | [
"Computes",
"and",
"returns",
"the",
"check",
"digit",
"of",
"a",
"number",
"."
] | b33593f75df80530417007bde97c4772807563ab | https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L23-L32 | train |
brick/validation | src/Internal/Luhn.php | Luhn.isValid | public static function isValid(string $number) : bool
{
if (ctype_digit($number)) {
return self::checksum($number) === 0;
}
return false;
} | php | public static function isValid(string $number) : bool
{
if (ctype_digit($number)) {
return self::checksum($number) === 0;
}
return false;
} | [
"public",
"static",
"function",
"isValid",
"(",
"string",
"$",
"number",
")",
":",
"bool",
"{",
"if",
"(",
"ctype_digit",
"(",
"$",
"number",
")",
")",
"{",
"return",
"self",
"::",
"checksum",
"(",
"$",
"number",
")",
"===",
"0",
";",
"}",
"return",
"false",
";",
"}"
] | Checks that a number is valid.
@param string $number
@return bool | [
"Checks",
"that",
"a",
"number",
"is",
"valid",
"."
] | b33593f75df80530417007bde97c4772807563ab | https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L41-L48 | train |
brick/validation | src/Internal/Luhn.php | Luhn.checksum | private static function checksum(string $number) : int
{
$number = strrev($number);
$length = strlen($number);
$sum = 0;
for ($i = 0; $i < $length; $i++) {
$value = $number[$i] * ($i % 2 + 1);
$sum += ($value >= 10 ? $value - 9 : $value);
}
return $sum % 10;
} | php | private static function checksum(string $number) : int
{
$number = strrev($number);
$length = strlen($number);
$sum = 0;
for ($i = 0; $i < $length; $i++) {
$value = $number[$i] * ($i % 2 + 1);
$sum += ($value >= 10 ? $value - 9 : $value);
}
return $sum % 10;
} | [
"private",
"static",
"function",
"checksum",
"(",
"string",
"$",
"number",
")",
":",
"int",
"{",
"$",
"number",
"=",
"strrev",
"(",
"$",
"number",
")",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"number",
")",
";",
"$",
"sum",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"value",
"=",
"$",
"number",
"[",
"$",
"i",
"]",
"*",
"(",
"$",
"i",
"%",
"2",
"+",
"1",
")",
";",
"$",
"sum",
"+=",
"(",
"$",
"value",
">=",
"10",
"?",
"$",
"value",
"-",
"9",
":",
"$",
"value",
")",
";",
"}",
"return",
"$",
"sum",
"%",
"10",
";",
"}"
] | Computes the checksum of a number.
@param string $number The number, validated as a string of digits.
@return int | [
"Computes",
"the",
"checksum",
"of",
"a",
"number",
"."
] | b33593f75df80530417007bde97c4772807563ab | https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/Internal/Luhn.php#L57-L70 | train |
Etenil/assegai | src/assegai/modules/mail/services/ses/utilities/info.class.php | CFInfo.api_support | public static function api_support()
{
$existing_classes = get_declared_classes();
foreach (glob(dirname(dirname(__FILE__)) . '/services/*.class.php') as $file)
{
include $file;
}
$with_sdk_classes = get_declared_classes();
$new_classes = array_diff($with_sdk_classes, $existing_classes);
$filtered_classes = array();
$collect = array();
foreach ($new_classes as $class)
{
if (strpos($class, 'Amazon') !== false)
{
$filtered_classes[] = $class;
}
}
$filtered_classes = array_values($filtered_classes);
foreach ($filtered_classes as $class)
{
$obj = new $class();
$collect[get_class($obj)] = $obj->api_version;
unset($obj);
}
return $collect;
} | php | public static function api_support()
{
$existing_classes = get_declared_classes();
foreach (glob(dirname(dirname(__FILE__)) . '/services/*.class.php') as $file)
{
include $file;
}
$with_sdk_classes = get_declared_classes();
$new_classes = array_diff($with_sdk_classes, $existing_classes);
$filtered_classes = array();
$collect = array();
foreach ($new_classes as $class)
{
if (strpos($class, 'Amazon') !== false)
{
$filtered_classes[] = $class;
}
}
$filtered_classes = array_values($filtered_classes);
foreach ($filtered_classes as $class)
{
$obj = new $class();
$collect[get_class($obj)] = $obj->api_version;
unset($obj);
}
return $collect;
} | [
"public",
"static",
"function",
"api_support",
"(",
")",
"{",
"$",
"existing_classes",
"=",
"get_declared_classes",
"(",
")",
";",
"foreach",
"(",
"glob",
"(",
"dirname",
"(",
"dirname",
"(",
"__FILE__",
")",
")",
".",
"'/services/*.class.php'",
")",
"as",
"$",
"file",
")",
"{",
"include",
"$",
"file",
";",
"}",
"$",
"with_sdk_classes",
"=",
"get_declared_classes",
"(",
")",
";",
"$",
"new_classes",
"=",
"array_diff",
"(",
"$",
"with_sdk_classes",
",",
"$",
"existing_classes",
")",
";",
"$",
"filtered_classes",
"=",
"array",
"(",
")",
";",
"$",
"collect",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"new_classes",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"class",
",",
"'Amazon'",
")",
"!==",
"false",
")",
"{",
"$",
"filtered_classes",
"[",
"]",
"=",
"$",
"class",
";",
"}",
"}",
"$",
"filtered_classes",
"=",
"array_values",
"(",
"$",
"filtered_classes",
")",
";",
"foreach",
"(",
"$",
"filtered_classes",
"as",
"$",
"class",
")",
"{",
"$",
"obj",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"collect",
"[",
"get_class",
"(",
"$",
"obj",
")",
"]",
"=",
"$",
"obj",
"->",
"api_version",
";",
"unset",
"(",
"$",
"obj",
")",
";",
"}",
"return",
"$",
"collect",
";",
"}"
] | Gets information about the web service APIs that the SDK supports.
@return array An associative array containing service classes and API versions. | [
"Gets",
"information",
"about",
"the",
"web",
"service",
"APIs",
"that",
"the",
"SDK",
"supports",
"."
] | d43cce1a88f1c332f60dd0a4374b17764852af9e | https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/mail/services/ses/utilities/info.class.php#L36-L68 | train |
oliwierptak/Everon1 | src/Everon/Helper/Asserts/IsInstance.php | IsInstance.assertIsInstance | public function assertIsInstance($class, $instance, $message='%s and %s are not the same instance', $exception='Asserts')
{
$is_instance = (get_class($class) === $instance);
if ($is_instance === false) {
$this->throwException($exception, $message, array(get_class($class), $instance));
}
} | php | public function assertIsInstance($class, $instance, $message='%s and %s are not the same instance', $exception='Asserts')
{
$is_instance = (get_class($class) === $instance);
if ($is_instance === false) {
$this->throwException($exception, $message, array(get_class($class), $instance));
}
} | [
"public",
"function",
"assertIsInstance",
"(",
"$",
"class",
",",
"$",
"instance",
",",
"$",
"message",
"=",
"'%s and %s are not the same instance'",
",",
"$",
"exception",
"=",
"'Asserts'",
")",
"{",
"$",
"is_instance",
"=",
"(",
"get_class",
"(",
"$",
"class",
")",
"===",
"$",
"instance",
")",
";",
"if",
"(",
"$",
"is_instance",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"$",
"exception",
",",
"$",
"message",
",",
"array",
"(",
"get_class",
"(",
"$",
"class",
")",
",",
"$",
"instance",
")",
")",
";",
"}",
"}"
] | Verifies that the specified conditions are of the same instance.
The assertion fails if they are not.
@param mixed $class Concreet class to check
@param string $instance Instance name
@param string $message
@param string $exception
@throws \Everon\Exception\Asserts | [
"Verifies",
"that",
"the",
"specified",
"conditions",
"are",
"of",
"the",
"same",
"instance",
".",
"The",
"assertion",
"fails",
"if",
"they",
"are",
"not",
"."
] | ac93793d1fa517a8394db5f00062f1925dc218a3 | https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Helper/Asserts/IsInstance.php#L24-L30 | train |
RowlandOti/ooglee-blogmodule | src/OoGlee/Application/Entities/Post/Listeners/IncrementPostViewsListener.php | IncrementPostViewsListener.listenerHandle | public function listenerHandle(IEvent $event)
{
$event->post->count_views++;
$event->post->save();
var_dump($event->post->count_views);
} | php | public function listenerHandle(IEvent $event)
{
$event->post->count_views++;
$event->post->save();
var_dump($event->post->count_views);
} | [
"public",
"function",
"listenerHandle",
"(",
"IEvent",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"post",
"->",
"count_views",
"++",
";",
"$",
"event",
"->",
"post",
"->",
"save",
"(",
")",
";",
"var_dump",
"(",
"$",
"event",
"->",
"post",
"->",
"count_views",
")",
";",
"}"
] | Update the post view count
@param IEvent $event
@return void | [
"Update",
"the",
"post",
"view",
"count"
] | d9c0fe4745bb09f8b94047b0cda4fd7438cde16a | https://github.com/RowlandOti/ooglee-blogmodule/blob/d9c0fe4745bb09f8b94047b0cda4fd7438cde16a/src/OoGlee/Application/Entities/Post/Listeners/IncrementPostViewsListener.php#L34-L39 | train |
bennybi/yii2-cza-base | widgets/ActiveField.php | ActiveField.hiddenInput | public function hiddenInput($options = []) {
$options = array_replace_recursive($this->inputOptions, $options);
$this->adjustLabelFor($options);
$this->parts['{label}'] = false;
$this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options);
return $this;
} | php | public function hiddenInput($options = []) {
$options = array_replace_recursive($this->inputOptions, $options);
$this->adjustLabelFor($options);
$this->parts['{label}'] = false;
$this->parts['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $options);
return $this;
} | [
"public",
"function",
"hiddenInput",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"inputOptions",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"adjustLabelFor",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"parts",
"[",
"'{label}'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"parts",
"[",
"'{input}'",
"]",
"=",
"Html",
"::",
"activeHiddenInput",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"this",
"->",
"attribute",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
";",
"}"
] | override original method
@param type $options
@return \cza\base\widgets\ActiveField | [
"override",
"original",
"method"
] | 8257db8034bd948712fa469062921f210f0ba8da | https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/widgets/ActiveField.php#L76-L83 | train |
valu-digital/valuso | src/ValuSo/Annotation/Trigger.php | Trigger.getEventDescription | public function getEventDescription()
{
$event = array(
'type' => null,
'name' => null,
'args' => null,
'params' => null
);
if (is_string($this->value)) {
$event['type'] = $this->value;
} else {
$event['type'] = isset($this->value['type']) ? $this->value['type'] : null;
$event['name'] = isset($this->value['name']) ? $this->value['name'] : null;
$event['args'] = isset($this->value['args']) ? $this->value['args'] : null;
$event['params'] = isset($this->value['params']) ? $this->value['params'] : null;
}
return $event;
} | php | public function getEventDescription()
{
$event = array(
'type' => null,
'name' => null,
'args' => null,
'params' => null
);
if (is_string($this->value)) {
$event['type'] = $this->value;
} else {
$event['type'] = isset($this->value['type']) ? $this->value['type'] : null;
$event['name'] = isset($this->value['name']) ? $this->value['name'] : null;
$event['args'] = isset($this->value['args']) ? $this->value['args'] : null;
$event['params'] = isset($this->value['params']) ? $this->value['params'] : null;
}
return $event;
} | [
"public",
"function",
"getEventDescription",
"(",
")",
"{",
"$",
"event",
"=",
"array",
"(",
"'type'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'args'",
"=>",
"null",
",",
"'params'",
"=>",
"null",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"event",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"value",
";",
"}",
"else",
"{",
"$",
"event",
"[",
"'type'",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"value",
"[",
"'type'",
"]",
")",
"?",
"$",
"this",
"->",
"value",
"[",
"'type'",
"]",
":",
"null",
";",
"$",
"event",
"[",
"'name'",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"value",
"[",
"'name'",
"]",
")",
"?",
"$",
"this",
"->",
"value",
"[",
"'name'",
"]",
":",
"null",
";",
"$",
"event",
"[",
"'args'",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"value",
"[",
"'args'",
"]",
")",
"?",
"$",
"this",
"->",
"value",
"[",
"'args'",
"]",
":",
"null",
";",
"$",
"event",
"[",
"'params'",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"value",
"[",
"'params'",
"]",
")",
"?",
"$",
"this",
"->",
"value",
"[",
"'params'",
"]",
":",
"null",
";",
"}",
"return",
"$",
"event",
";",
"}"
] | Retrieve event description
Event description is an array that contains following keys:
- type (event type, which is either 'pre' or 'post')
- name (name of the event)
- args (event arguments)
@return array | [
"Retrieve",
"event",
"description"
] | c96bed0f6bd21551822334fe6cfe913a7436dd17 | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Annotation/Trigger.php#L34-L53 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getImporters | public function getImporters($all = false)
{
$importers = [];
foreach ($this->importers as $importer) {
if ($importer->isEnabled() || true === $all) {
$importers[$importer->getKey()] = $importer;
}
}
return $importers;
} | php | public function getImporters($all = false)
{
$importers = [];
foreach ($this->importers as $importer) {
if ($importer->isEnabled() || true === $all) {
$importers[$importer->getKey()] = $importer;
}
}
return $importers;
} | [
"public",
"function",
"getImporters",
"(",
"$",
"all",
"=",
"false",
")",
"{",
"$",
"importers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"importers",
"as",
"$",
"importer",
")",
"{",
"if",
"(",
"$",
"importer",
"->",
"isEnabled",
"(",
")",
"||",
"true",
"===",
"$",
"all",
")",
"{",
"$",
"importers",
"[",
"$",
"importer",
"->",
"getKey",
"(",
")",
"]",
"=",
"$",
"importer",
";",
"}",
"}",
"return",
"$",
"importers",
";",
"}"
] | Returns importers keyed by their internal key.
@param bool $all If all importers should be returned, regardless of status.
@return array | [
"Returns",
"importers",
"keyed",
"by",
"their",
"internal",
"key",
"."
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L296-L305 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getImporter | public function getImporter($key)
{
foreach ($this->getImporters(true) as $k => $importer) {
if ($key === $k) {
return $importer;
}
}
throw new \InvalidArgumentException(sprintf('Importer could not be found by key `%s`.', $key));
} | php | public function getImporter($key)
{
foreach ($this->getImporters(true) as $k => $importer) {
if ($key === $k) {
return $importer;
}
}
throw new \InvalidArgumentException(sprintf('Importer could not be found by key `%s`.', $key));
} | [
"public",
"function",
"getImporter",
"(",
"$",
"key",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getImporters",
"(",
"true",
")",
"as",
"$",
"k",
"=>",
"$",
"importer",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"$",
"k",
")",
"{",
"return",
"$",
"importer",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Importer could not be found by key `%s`.'",
",",
"$",
"key",
")",
")",
";",
"}"
] | Retrieves an importer by key
@param string $key
@return ImporterInterface
@throws InvalidArgumentInterface | [
"Retrieves",
"an",
"importer",
"by",
"key"
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L314-L322 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getImporterKeys | public function getImporterKeys($all = false)
{
$keys = [];
if ($all) {
$keys = $this->importerKeys;
} else {
foreach ($this->importerKeys as $key => $bit) {
if ($bit) {
$keys[] = $key;
}
}
}
return $keys;
} | php | public function getImporterKeys($all = false)
{
$keys = [];
if ($all) {
$keys = $this->importerKeys;
} else {
foreach ($this->importerKeys as $key => $bit) {
if ($bit) {
$keys[] = $key;
}
}
}
return $keys;
} | [
"public",
"function",
"getImporterKeys",
"(",
"$",
"all",
"=",
"false",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"all",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"importerKeys",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"importerKeys",
"as",
"$",
"key",
"=>",
"$",
"bit",
")",
"{",
"if",
"(",
"$",
"bit",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"$",
"keys",
";",
"}"
] | Returns the stored enabled importers for this model.
@param bool $all If all importers should be returned, regardless of status.
@return array | [
"Returns",
"the",
"stored",
"enabled",
"importers",
"for",
"this",
"model",
"."
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L330-L343 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getSegmentKeys | public function getSegmentKeys($all = false)
{
$keys = [];
if ($all) {
$keys = $this->segmentKeys;
} else {
foreach ($this->segmentKeys as $key => $bit) {
if ($bit) {
$keys[] = $key;
}
}
}
return $keys;
} | php | public function getSegmentKeys($all = false)
{
$keys = [];
if ($all) {
$keys = $this->segmentKeys;
} else {
foreach ($this->segmentKeys as $key => $bit) {
if ($bit) {
$keys[] = $key;
}
}
}
return $keys;
} | [
"public",
"function",
"getSegmentKeys",
"(",
"$",
"all",
"=",
"false",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"all",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"segmentKeys",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"segmentKeys",
"as",
"$",
"key",
"=>",
"$",
"bit",
")",
"{",
"if",
"(",
"$",
"bit",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"$",
"keys",
";",
"}"
] | Returns the stored enabled segments for this model.
@param bool $all If all segments should be returned, regardless of status.
@return array | [
"Returns",
"the",
"stored",
"enabled",
"segments",
"for",
"this",
"model",
"."
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L351-L364 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getSegment | public function getSegment($key)
{
foreach ($this->getImporters() as $importer) {
if ($importer->hasSegment($key)) {
return $importer->getSegment($key);
}
}
throw new \InvalidArgumentException(sprintf('Segment could not be found by key `%s`.', $key));
} | php | public function getSegment($key)
{
foreach ($this->getImporters() as $importer) {
if ($importer->hasSegment($key)) {
return $importer->getSegment($key);
}
}
throw new \InvalidArgumentException(sprintf('Segment could not be found by key `%s`.', $key));
} | [
"public",
"function",
"getSegment",
"(",
"$",
"key",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getImporters",
"(",
")",
"as",
"$",
"importer",
")",
"{",
"if",
"(",
"$",
"importer",
"->",
"hasSegment",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"importer",
"->",
"getSegment",
"(",
"$",
"key",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Segment could not be found by key `%s`.'",
",",
"$",
"key",
")",
")",
";",
"}"
] | Retrieves a segment by key
@param string $key
@return SegmentInterface
@throws InvalidArgumentInterface | [
"Retrieves",
"a",
"segment",
"by",
"key"
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L373-L381 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.toggleImporter | public function toggleImporter($key)
{
$importer = $this->getImporter($key);
$importer->toggle();
foreach ($importer->getSegments() as $segment) {
if ($importer->isEnabled()) {
$this->addSegment($segment);
} else {
$this->removeSegment($segment);
}
}
} | php | public function toggleImporter($key)
{
$importer = $this->getImporter($key);
$importer->toggle();
foreach ($importer->getSegments() as $segment) {
if ($importer->isEnabled()) {
$this->addSegment($segment);
} else {
$this->removeSegment($segment);
}
}
} | [
"public",
"function",
"toggleImporter",
"(",
"$",
"key",
")",
"{",
"$",
"importer",
"=",
"$",
"this",
"->",
"getImporter",
"(",
"$",
"key",
")",
";",
"$",
"importer",
"->",
"toggle",
"(",
")",
";",
"foreach",
"(",
"$",
"importer",
"->",
"getSegments",
"(",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"importer",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addSegment",
"(",
"$",
"segment",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"removeSegment",
"(",
"$",
"segment",
")",
";",
"}",
"}",
"}"
] | Toggles an importer and its segments
@param string $key | [
"Toggles",
"an",
"importer",
"and",
"its",
"segments"
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L388-L399 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.toggleSegment | public function toggleSegment($key)
{
$segment = $this->getSegment($key);
if (false === $segment->isEnabled()) {
return $segment->enable();
}
return $segment->disable();
} | php | public function toggleSegment($key)
{
$segment = $this->getSegment($key);
if (false === $segment->isEnabled()) {
return $segment->enable();
}
return $segment->disable();
} | [
"public",
"function",
"toggleSegment",
"(",
"$",
"key",
")",
"{",
"$",
"segment",
"=",
"$",
"this",
"->",
"getSegment",
"(",
"$",
"key",
")",
";",
"if",
"(",
"false",
"===",
"$",
"segment",
"->",
"isEnabled",
"(",
")",
")",
"{",
"return",
"$",
"segment",
"->",
"enable",
"(",
")",
";",
"}",
"return",
"$",
"segment",
"->",
"disable",
"(",
")",
";",
"}"
] | Toggles a segment
@param string $key | [
"Toggles",
"a",
"segment"
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L406-L413 | train |
as3io/symfony-data-importer | src/Import/Configuration.php | Configuration.getSegments | public function getSegments($all = false)
{
if ($all) {
return $this->segments;
}
$segments = [];
foreach ($this->segments as $segment) {
if ($segment->isEnabled()) {
$segments[] = $segment;
}
}
return $segments;
} | php | public function getSegments($all = false)
{
if ($all) {
return $this->segments;
}
$segments = [];
foreach ($this->segments as $segment) {
if ($segment->isEnabled()) {
$segments[] = $segment;
}
}
return $segments;
} | [
"public",
"function",
"getSegments",
"(",
"$",
"all",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"all",
")",
"{",
"return",
"$",
"this",
"->",
"segments",
";",
"}",
"$",
"segments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"segments",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"segment",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"segments",
"[",
"]",
"=",
"$",
"segment",
";",
"}",
"}",
"return",
"$",
"segments",
";",
"}"
] | Returns segments keyed by their internal key.
@param bool $all If all segments should be returned, regardless of status.
@return array | [
"Returns",
"segments",
"keyed",
"by",
"their",
"internal",
"key",
"."
] | 33383e38f20f6b7a4b83da619bd028ac84ced579 | https://github.com/as3io/symfony-data-importer/blob/33383e38f20f6b7a4b83da619bd028ac84ced579/src/Import/Configuration.php#L422-L434 | train |
makinacorpus/drupal-calista | src/Datasource/DefaultAccountDatasource.php | DefaultAccountDatasource.process | final protected function process(\SelectQueryInterface $select, Query $query)
{
if ($query->hasSortField()) {
$select->orderBy(
$query->getSortField(),
Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc'
);
}
$select->orderBy(
'u.uid',
Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc'
);
if ($searchstring = $query->getSearchString()) {
$select->condition(
'u.name',
'%'.db_like($searchstring).'%',
'LIKE'
);
}
$this->applyFilters($select, $query);
return $select /*->extend(DrupalPager::class)->setQuery($query) */;
} | php | final protected function process(\SelectQueryInterface $select, Query $query)
{
if ($query->hasSortField()) {
$select->orderBy(
$query->getSortField(),
Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc'
);
}
$select->orderBy(
'u.uid',
Query::SORT_DESC === $query->getSortOrder() ? 'desc' : 'asc'
);
if ($searchstring = $query->getSearchString()) {
$select->condition(
'u.name',
'%'.db_like($searchstring).'%',
'LIKE'
);
}
$this->applyFilters($select, $query);
return $select /*->extend(DrupalPager::class)->setQuery($query) */;
} | [
"final",
"protected",
"function",
"process",
"(",
"\\",
"SelectQueryInterface",
"$",
"select",
",",
"Query",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"->",
"hasSortField",
"(",
")",
")",
"{",
"$",
"select",
"->",
"orderBy",
"(",
"$",
"query",
"->",
"getSortField",
"(",
")",
",",
"Query",
"::",
"SORT_DESC",
"===",
"$",
"query",
"->",
"getSortOrder",
"(",
")",
"?",
"'desc'",
":",
"'asc'",
")",
";",
"}",
"$",
"select",
"->",
"orderBy",
"(",
"'u.uid'",
",",
"Query",
"::",
"SORT_DESC",
"===",
"$",
"query",
"->",
"getSortOrder",
"(",
")",
"?",
"'desc'",
":",
"'asc'",
")",
";",
"if",
"(",
"$",
"searchstring",
"=",
"$",
"query",
"->",
"getSearchString",
"(",
")",
")",
"{",
"$",
"select",
"->",
"condition",
"(",
"'u.name'",
",",
"'%'",
".",
"db_like",
"(",
"$",
"searchstring",
")",
".",
"'%'",
",",
"'LIKE'",
")",
";",
"}",
"$",
"this",
"->",
"applyFilters",
"(",
"$",
"select",
",",
"$",
"query",
")",
";",
"return",
"$",
"select",
"/*->extend(DrupalPager::class)->setQuery($query) */",
";",
"}"
] | Implementors must set the users table with 'u' as alias, and call this
method for the datasource to work correctly.
@param \SelectQueryInterface $select
@param Query $query
@return \SelectQuery
It can be an extended query, so use this object. | [
"Implementors",
"must",
"set",
"the",
"users",
"table",
"with",
"u",
"as",
"alias",
"and",
"call",
"this",
"method",
"for",
"the",
"datasource",
"to",
"work",
"correctly",
"."
] | cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53 | https://github.com/makinacorpus/drupal-calista/blob/cceb6b975fc3e80f0f83c803fc6f6a9ac5852b53/src/Datasource/DefaultAccountDatasource.php#L150-L174 | train |
issei-m/spike-php | src/Spike.php | Spike.requestToken | public function requestToken(TokenRequest $request)
{
$result = $this->request('POST', '/tokens', [
'card[number]' => $request->getCardNumber(),
'card[exp_month]' => $request->getExpirationMonth(),
'card[exp_year]' => $request->getExpirationYear(),
'card[cvc]' => $request->getSecurityCode(),
'card[name]' => $request->getHolderName(),
'currency' => $request->getCurrency(),
'email' => $request->getEmail(),
]);
return $this->objectConverter->convert($result);
} | php | public function requestToken(TokenRequest $request)
{
$result = $this->request('POST', '/tokens', [
'card[number]' => $request->getCardNumber(),
'card[exp_month]' => $request->getExpirationMonth(),
'card[exp_year]' => $request->getExpirationYear(),
'card[cvc]' => $request->getSecurityCode(),
'card[name]' => $request->getHolderName(),
'currency' => $request->getCurrency(),
'email' => $request->getEmail(),
]);
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"requestToken",
"(",
"TokenRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"'/tokens'",
",",
"[",
"'card[number]'",
"=>",
"$",
"request",
"->",
"getCardNumber",
"(",
")",
",",
"'card[exp_month]'",
"=>",
"$",
"request",
"->",
"getExpirationMonth",
"(",
")",
",",
"'card[exp_year]'",
"=>",
"$",
"request",
"->",
"getExpirationYear",
"(",
")",
",",
"'card[cvc]'",
"=>",
"$",
"request",
"->",
"getSecurityCode",
"(",
")",
",",
"'card[name]'",
"=>",
"$",
"request",
"->",
"getHolderName",
"(",
")",
",",
"'currency'",
"=>",
"$",
"request",
"->",
"getCurrency",
"(",
")",
",",
"'email'",
"=>",
"$",
"request",
"->",
"getEmail",
"(",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Returns a new token.
@param TokenRequest $request
@return Token
@throws RequestException | [
"Returns",
"a",
"new",
"token",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L52-L65 | train |
issei-m/spike-php | src/Spike.php | Spike.getToken | public function getToken($id)
{
$result = $this->request('GET', '/tokens/' . $id);
return $this->objectConverter->convert($result);
} | php | public function getToken($id)
{
$result = $this->request('GET', '/tokens/' . $id);
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"getToken",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"'/tokens/'",
".",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Returns the token by id.
@param string $id
@return Token
@throws RequestException | [
"Returns",
"the",
"token",
"by",
"id",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L75-L80 | train |
issei-m/spike-php | src/Spike.php | Spike.getCharges | public function getCharges($limit = 10, $startingAfter = null, $endingBefore = null)
{
$endpointUrl = '/charges?limit=' . $limit;
if ($startingAfter) {
$endpointUrl .= '&starting_after=' . $startingAfter;
}
if ($endingBefore) {
$endpointUrl .= '&ending_before=' . $endingBefore;
}
$result = $this->request('GET', $endpointUrl);
return $this->objectConverter->convert($result);
} | php | public function getCharges($limit = 10, $startingAfter = null, $endingBefore = null)
{
$endpointUrl = '/charges?limit=' . $limit;
if ($startingAfter) {
$endpointUrl .= '&starting_after=' . $startingAfter;
}
if ($endingBefore) {
$endpointUrl .= '&ending_before=' . $endingBefore;
}
$result = $this->request('GET', $endpointUrl);
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"getCharges",
"(",
"$",
"limit",
"=",
"10",
",",
"$",
"startingAfter",
"=",
"null",
",",
"$",
"endingBefore",
"=",
"null",
")",
"{",
"$",
"endpointUrl",
"=",
"'/charges?limit='",
".",
"$",
"limit",
";",
"if",
"(",
"$",
"startingAfter",
")",
"{",
"$",
"endpointUrl",
".=",
"'&starting_after='",
".",
"$",
"startingAfter",
";",
"}",
"if",
"(",
"$",
"endingBefore",
")",
"{",
"$",
"endpointUrl",
".=",
"'&ending_before='",
".",
"$",
"endingBefore",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"$",
"endpointUrl",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Returns the charges.
@param integer $limit
@param Charge|string $startingAfter
@param Charge|string $endingBefore
@return Charge[]
@throws RequestException | [
"Returns",
"the",
"charges",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L92-L106 | train |
issei-m/spike-php | src/Spike.php | Spike.getCharge | public function getCharge($id)
{
$result = $this->request('GET', '/charges/' . $id);
return $this->objectConverter->convert($result);
} | php | public function getCharge($id)
{
$result = $this->request('GET', '/charges/' . $id);
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"getCharge",
"(",
"$",
"id",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"'/charges/'",
".",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Returns the charge by id.
@param string $id
@return Charge
@throws RequestException | [
"Returns",
"the",
"charge",
"by",
"id",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L116-L121 | train |
issei-m/spike-php | src/Spike.php | Spike.charge | public function charge(ChargeRequest $request)
{
$result = $this->request('POST', '/charges', [
'card' => (string) $request->getToken(),
'amount' => $request->getAmount() ? $request->getAmount()->getAmount() : null,
'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null,
'capture' => $request->isCapture() ? 'true' : 'false',
'products' => json_encode($request->getProducts()),
]);
return $this->objectConverter->convert($result);
} | php | public function charge(ChargeRequest $request)
{
$result = $this->request('POST', '/charges', [
'card' => (string) $request->getToken(),
'amount' => $request->getAmount() ? $request->getAmount()->getAmount() : null,
'currency' => $request->getAmount() ? $request->getAmount()->getCurrency() : null,
'capture' => $request->isCapture() ? 'true' : 'false',
'products' => json_encode($request->getProducts()),
]);
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"charge",
"(",
"ChargeRequest",
"$",
"request",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"'/charges'",
",",
"[",
"'card'",
"=>",
"(",
"string",
")",
"$",
"request",
"->",
"getToken",
"(",
")",
",",
"'amount'",
"=>",
"$",
"request",
"->",
"getAmount",
"(",
")",
"?",
"$",
"request",
"->",
"getAmount",
"(",
")",
"->",
"getAmount",
"(",
")",
":",
"null",
",",
"'currency'",
"=>",
"$",
"request",
"->",
"getAmount",
"(",
")",
"?",
"$",
"request",
"->",
"getAmount",
"(",
")",
"->",
"getCurrency",
"(",
")",
":",
"null",
",",
"'capture'",
"=>",
"$",
"request",
"->",
"isCapture",
"(",
")",
"?",
"'true'",
":",
"'false'",
",",
"'products'",
"=>",
"json_encode",
"(",
"$",
"request",
"->",
"getProducts",
"(",
")",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Creates a new charge.
@param ChargeRequest $request
@return Charge
@throws RequestException | [
"Creates",
"a",
"new",
"charge",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L131-L142 | train |
issei-m/spike-php | src/Spike.php | Spike.capture | public function capture($charge)
{
$result = $this->request('POST', '/charges/' . $charge . '/capture');
return $this->objectConverter->convert($result);
} | php | public function capture($charge)
{
$result = $this->request('POST', '/charges/' . $charge . '/capture');
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"capture",
"(",
"$",
"charge",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"'/charges/'",
".",
"$",
"charge",
".",
"'/capture'",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Captures the charge.
@param Charge|string $charge
@return Charge
@throws RequestException | [
"Captures",
"the",
"charge",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L152-L157 | train |
issei-m/spike-php | src/Spike.php | Spike.refund | public function refund($charge)
{
$result = $this->request('POST', '/charges/' . $charge . '/refund');
return $this->objectConverter->convert($result);
} | php | public function refund($charge)
{
$result = $this->request('POST', '/charges/' . $charge . '/refund');
return $this->objectConverter->convert($result);
} | [
"public",
"function",
"refund",
"(",
"$",
"charge",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"'/charges/'",
".",
"$",
"charge",
".",
"'/refund'",
")",
";",
"return",
"$",
"this",
"->",
"objectConverter",
"->",
"convert",
"(",
"$",
"result",
")",
";",
"}"
] | Refunds the charge.
@param Charge|string $charge
@return Charge
@throws RequestException | [
"Refunds",
"the",
"charge",
"."
] | 9205b5047a1132bcdca6731feac02fe3d5dc1023 | https://github.com/issei-m/spike-php/blob/9205b5047a1132bcdca6731feac02fe3d5dc1023/src/Spike.php#L167-L172 | train |
phramework/testphase | src/Expression.php | Expression.getPrefixSuffix | public static function getPrefixSuffix($expressionType = Expression::EXPRESSION_TYPE_PLAIN)
{
$prefix = '';
$suffix = '';
$patternPrefix = '';
$patternSuffix = '';
switch ($expressionType) {
case Expression::EXPRESSION_TYPE_PLAIN:
$patternPrefix = '^';
$patternSuffix = '$';
break;
case Expression::EXPRESSION_TYPE_REPLACE:
$prefix = '{{{';
$suffix = '}}}';
$patternPrefix = '^';
$patternSuffix = '$';
break;
case Expression::EXPRESSION_TYPE_INLINE_REPLACE:
$prefix = '{{';
$suffix = '}}';
break;
}
return [$prefix, $suffix, $patternPrefix, $patternSuffix];
} | php | public static function getPrefixSuffix($expressionType = Expression::EXPRESSION_TYPE_PLAIN)
{
$prefix = '';
$suffix = '';
$patternPrefix = '';
$patternSuffix = '';
switch ($expressionType) {
case Expression::EXPRESSION_TYPE_PLAIN:
$patternPrefix = '^';
$patternSuffix = '$';
break;
case Expression::EXPRESSION_TYPE_REPLACE:
$prefix = '{{{';
$suffix = '}}}';
$patternPrefix = '^';
$patternSuffix = '$';
break;
case Expression::EXPRESSION_TYPE_INLINE_REPLACE:
$prefix = '{{';
$suffix = '}}';
break;
}
return [$prefix, $suffix, $patternPrefix, $patternSuffix];
} | [
"public",
"static",
"function",
"getPrefixSuffix",
"(",
"$",
"expressionType",
"=",
"Expression",
"::",
"EXPRESSION_TYPE_PLAIN",
")",
"{",
"$",
"prefix",
"=",
"''",
";",
"$",
"suffix",
"=",
"''",
";",
"$",
"patternPrefix",
"=",
"''",
";",
"$",
"patternSuffix",
"=",
"''",
";",
"switch",
"(",
"$",
"expressionType",
")",
"{",
"case",
"Expression",
"::",
"EXPRESSION_TYPE_PLAIN",
":",
"$",
"patternPrefix",
"=",
"'^'",
";",
"$",
"patternSuffix",
"=",
"'$'",
";",
"break",
";",
"case",
"Expression",
"::",
"EXPRESSION_TYPE_REPLACE",
":",
"$",
"prefix",
"=",
"'{{{'",
";",
"$",
"suffix",
"=",
"'}}}'",
";",
"$",
"patternPrefix",
"=",
"'^'",
";",
"$",
"patternSuffix",
"=",
"'$'",
";",
"break",
";",
"case",
"Expression",
"::",
"EXPRESSION_TYPE_INLINE_REPLACE",
":",
"$",
"prefix",
"=",
"'{{'",
";",
"$",
"suffix",
"=",
"'}}'",
";",
"break",
";",
"}",
"return",
"[",
"$",
"prefix",
",",
"$",
"suffix",
",",
"$",
"patternPrefix",
",",
"$",
"patternSuffix",
"]",
";",
"}"
] | Get prefix and suffix
@param string $expressionType
@return string[4] Returns the expression type prefix, suffix, pattern prefix and suffix.
@example
```php
list(
$prefix,
$suffix,
$patternPrefix,
$patternSuffix
) = Expression::getPrefixSuffix(Expression::EXPRESSION_TYPE_INLINE_REPLACE);
``` | [
"Get",
"prefix",
"and",
"suffix"
] | b00107b7a37cf1a1b9b8860b3eb031aacfa2634c | https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Expression.php#L74-L99 | train |
znframework/package-hypertext | JQueryBuilder.php | JQueryBuilder.selector | public function selector($selector)
{
if( is_scalar($selector) )
{
$this->selector = json_encode($selector);
}
else
{
$this->selector = Buffering\Callback::do($selector);
}
return $this;
} | php | public function selector($selector)
{
if( is_scalar($selector) )
{
$this->selector = json_encode($selector);
}
else
{
$this->selector = Buffering\Callback::do($selector);
}
return $this;
} | [
"public",
"function",
"selector",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"selector",
")",
")",
"{",
"$",
"this",
"->",
"selector",
"=",
"json_encode",
"(",
"$",
"selector",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"selector",
"=",
"Buffering",
"\\",
"Callback",
"::",
"do",
"(",
"$",
"selector",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Keeps jquery selector
@param string $selector
@return object | [
"Keeps",
"jquery",
"selector"
] | 12bbc3bd47a2fae735f638a3e01cc82c1b9c9005 | https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/JQueryBuilder.php#L63-L76 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.getQueryExecutor | function getQueryExecutor() {
if (!$this->exec) {
$this->exec = new QueryExecutor($this->conn);
}
return $this->exec;
} | php | function getQueryExecutor() {
if (!$this->exec) {
$this->exec = new QueryExecutor($this->conn);
}
return $this->exec;
} | [
"function",
"getQueryExecutor",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exec",
")",
"{",
"$",
"this",
"->",
"exec",
"=",
"new",
"QueryExecutor",
"(",
"$",
"this",
"->",
"conn",
")",
";",
"}",
"return",
"$",
"this",
"->",
"exec",
";",
"}"
] | Get the query executor
@return \pq\Query\ExecutorInterface | [
"Get",
"the",
"query",
"executor"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L175-L180 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.getMetadataCache | function getMetadataCache() {
if (!isset($this->metadatCache)) {
$this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache;
}
return $this->metadataCache;
} | php | function getMetadataCache() {
if (!isset($this->metadatCache)) {
$this->metadataCache = static::$defaultMetadataCache ?: new Table\StaticCache;
}
return $this->metadataCache;
} | [
"function",
"getMetadataCache",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadatCache",
")",
")",
"{",
"$",
"this",
"->",
"metadataCache",
"=",
"static",
"::",
"$",
"defaultMetadataCache",
"?",
":",
"new",
"Table",
"\\",
"StaticCache",
";",
"}",
"return",
"$",
"this",
"->",
"metadataCache",
";",
"}"
] | Get the metadata cache
@return \pq\Gateway\Table\CacheInterface | [
"Get",
"the",
"metadata",
"cache"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L186-L191 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.getIdentity | function getIdentity() {
if (!isset($this->identity)) {
$this->identity = new Table\Identity($this);
}
return $this->identity;
} | php | function getIdentity() {
if (!isset($this->identity)) {
$this->identity = new Table\Identity($this);
}
return $this->identity;
} | [
"function",
"getIdentity",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"identity",
")",
")",
"{",
"$",
"this",
"->",
"identity",
"=",
"new",
"Table",
"\\",
"Identity",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"identity",
";",
"}"
] | Get the primary key
@return \pq\Gateway\Table\Identity | [
"Get",
"the",
"primary",
"key"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L206-L211 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.getRelations | function getRelations() {
if (!isset($this->relations)) {
$this->relations = new Table\Relations($this);
}
return $this->relations;
} | php | function getRelations() {
if (!isset($this->relations)) {
$this->relations = new Table\Relations($this);
}
return $this->relations;
} | [
"function",
"getRelations",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"relations",
")",
")",
"{",
"$",
"this",
"->",
"relations",
"=",
"new",
"Table",
"\\",
"Relations",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"relations",
";",
"}"
] | Get foreign key relations
@return \pq\Gateway\Table\Relations | [
"Get",
"foreign",
"key",
"relations"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L228-L233 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.notify | function notify(\pq\Gateway\Row $row = null, $event = null, array &$where = null) {
foreach ($this->observers as $observer) {
$observer->update($this, $row, $event, $where);
}
} | php | function notify(\pq\Gateway\Row $row = null, $event = null, array &$where = null) {
foreach ($this->observers as $observer) {
$observer->update($this, $row, $event, $where);
}
} | [
"function",
"notify",
"(",
"\\",
"pq",
"\\",
"Gateway",
"\\",
"Row",
"$",
"row",
"=",
"null",
",",
"$",
"event",
"=",
"null",
",",
"array",
"&",
"$",
"where",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"$",
"observer",
"->",
"update",
"(",
"$",
"this",
",",
"$",
"row",
",",
"$",
"event",
",",
"$",
"where",
")",
";",
"}",
"}"
] | Implements \SplSubject | [
"Implements",
"\\",
"SplSubject"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L282-L286 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.onResult | public function onResult(\pq\Result $result = null) {
if ($result && $result->status != \pq\Result::TUPLES_OK) {
return $result;
}
$rowset = $this->getRowsetPrototype();
if (is_callable($rowset)) {
return $rowset($result);
} elseif ($rowset) {
return new $rowset($this, $result);
}
return $result;
} | php | public function onResult(\pq\Result $result = null) {
if ($result && $result->status != \pq\Result::TUPLES_OK) {
return $result;
}
$rowset = $this->getRowsetPrototype();
if (is_callable($rowset)) {
return $rowset($result);
} elseif ($rowset) {
return new $rowset($this, $result);
}
return $result;
} | [
"public",
"function",
"onResult",
"(",
"\\",
"pq",
"\\",
"Result",
"$",
"result",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"result",
"&&",
"$",
"result",
"->",
"status",
"!=",
"\\",
"pq",
"\\",
"Result",
"::",
"TUPLES_OK",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"rowset",
"=",
"$",
"this",
"->",
"getRowsetPrototype",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"rowset",
")",
")",
"{",
"return",
"$",
"rowset",
"(",
"$",
"result",
")",
";",
"}",
"elseif",
"(",
"$",
"rowset",
")",
"{",
"return",
"new",
"$",
"rowset",
"(",
"$",
"this",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Retreives the result of an executed query
@param \pq\Result $result
@return mixed | [
"Retreives",
"the",
"result",
"of",
"an",
"executed",
"query"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L302-L315 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.find | function find(array $where = null, $order = null, $limit = 0, $offset = 0, $lock = null) {
$query = $this->getQueryWriter()->reset();
$query->write("SELECT * FROM", $this->conn->quoteName($this->name));
if ($where) {
$query->write("WHERE")->criteria($where);
}
if ($order) {
$query->write("ORDER BY", $order);
}
if ($limit) {
$query->write("LIMIT", $limit);
}
if ($offset) {
$query->write("OFFSET", $offset);
}
if ($lock) {
$query->write("FOR", $lock);
}
return $this->execute($query);
} | php | function find(array $where = null, $order = null, $limit = 0, $offset = 0, $lock = null) {
$query = $this->getQueryWriter()->reset();
$query->write("SELECT * FROM", $this->conn->quoteName($this->name));
if ($where) {
$query->write("WHERE")->criteria($where);
}
if ($order) {
$query->write("ORDER BY", $order);
}
if ($limit) {
$query->write("LIMIT", $limit);
}
if ($offset) {
$query->write("OFFSET", $offset);
}
if ($lock) {
$query->write("FOR", $lock);
}
return $this->execute($query);
} | [
"function",
"find",
"(",
"array",
"$",
"where",
"=",
"null",
",",
"$",
"order",
"=",
"null",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"lock",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryWriter",
"(",
")",
"->",
"reset",
"(",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"SELECT * FROM\"",
",",
"$",
"this",
"->",
"conn",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"if",
"(",
"$",
"where",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"WHERE\"",
")",
"->",
"criteria",
"(",
"$",
"where",
")",
";",
"}",
"if",
"(",
"$",
"order",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"ORDER BY\"",
",",
"$",
"order",
")",
";",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"LIMIT\"",
",",
"$",
"limit",
")",
";",
"}",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"OFFSET\"",
",",
"$",
"offset",
")",
";",
"}",
"if",
"(",
"$",
"lock",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"FOR\"",
",",
"$",
"lock",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Find rows in the table
@param array $where
@param array|string $order
@param int $limit
@param int $offset
@param string $lock
@return mixed | [
"Find",
"rows",
"in",
"the",
"table"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L326-L345 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.of | function of(Row $foreign, $ref = null, $order = null, $limit = 0, $offset = 0) {
// select * from $this where $this->$foreignColumn = $foreign->$referencedColumn
if (!($rel = $this->getRelation($foreign->getTable()->getName(), $ref))) {
return $this->onResult(null);
}
$where = array();
foreach ($rel as $key => $ref) {
$where["$key="] = $foreign->$ref;
}
return $this->find($where, $order, $limit, $offset);
} | php | function of(Row $foreign, $ref = null, $order = null, $limit = 0, $offset = 0) {
// select * from $this where $this->$foreignColumn = $foreign->$referencedColumn
if (!($rel = $this->getRelation($foreign->getTable()->getName(), $ref))) {
return $this->onResult(null);
}
$where = array();
foreach ($rel as $key => $ref) {
$where["$key="] = $foreign->$ref;
}
return $this->find($where, $order, $limit, $offset);
} | [
"function",
"of",
"(",
"Row",
"$",
"foreign",
",",
"$",
"ref",
"=",
"null",
",",
"$",
"order",
"=",
"null",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"// select * from $this where $this->$foreignColumn = $foreign->$referencedColumn",
"if",
"(",
"!",
"(",
"$",
"rel",
"=",
"$",
"this",
"->",
"getRelation",
"(",
"$",
"foreign",
"->",
"getTable",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"ref",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"onResult",
"(",
"null",
")",
";",
"}",
"$",
"where",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rel",
"as",
"$",
"key",
"=>",
"$",
"ref",
")",
"{",
"$",
"where",
"[",
"\"$key=\"",
"]",
"=",
"$",
"foreign",
"->",
"$",
"ref",
";",
"}",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"where",
",",
"$",
"order",
",",
"$",
"limit",
",",
"$",
"offset",
")",
";",
"}"
] | Get the child rows of a row by foreign key
@param \pq\Gateway\Row $foreign
@param string $ref optional fkey name
@param string $order
@param int $limit
@param int $offset
@return mixed | [
"Get",
"the",
"child",
"rows",
"of",
"a",
"row",
"by",
"foreign",
"key"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L356-L369 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.by | function by(Row $foreign, $ref = null) {
// select * from $this where $this->$referencedColumn = $me->$foreignColumn
if (!($rel = $foreign->getTable()->getRelation($this->getName(), $ref))) {
return $this->onResult(null);
}
$where = array();
foreach ($rel as $key => $ref) {
$where["$ref="] = $foreign->$key;
}
return $this->find($where);
} | php | function by(Row $foreign, $ref = null) {
// select * from $this where $this->$referencedColumn = $me->$foreignColumn
if (!($rel = $foreign->getTable()->getRelation($this->getName(), $ref))) {
return $this->onResult(null);
}
$where = array();
foreach ($rel as $key => $ref) {
$where["$ref="] = $foreign->$key;
}
return $this->find($where);
} | [
"function",
"by",
"(",
"Row",
"$",
"foreign",
",",
"$",
"ref",
"=",
"null",
")",
"{",
"// select * from $this where $this->$referencedColumn = $me->$foreignColumn",
"if",
"(",
"!",
"(",
"$",
"rel",
"=",
"$",
"foreign",
"->",
"getTable",
"(",
")",
"->",
"getRelation",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"ref",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"onResult",
"(",
"null",
")",
";",
"}",
"$",
"where",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rel",
"as",
"$",
"key",
"=>",
"$",
"ref",
")",
"{",
"$",
"where",
"[",
"\"$ref=\"",
"]",
"=",
"$",
"foreign",
"->",
"$",
"key",
";",
"}",
"return",
"$",
"this",
"->",
"find",
"(",
"$",
"where",
")",
";",
"}"
] | Get the parent rows of a row by foreign key
@param \pq\Gateway\Row $foreign
@param string $ref
@return mixed | [
"Get",
"the",
"parent",
"rows",
"of",
"a",
"row",
"by",
"foreign",
"key"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L377-L389 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.with | function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) {
$qthis = $this->conn->quoteName($this->getName());
$query = $this->getQueryWriter()->reset();
$query->write("SELECT", "$qthis.*", "FROM", $qthis);
foreach ($relations as $relation) {
if (!($relation instanceof Table\Reference)) {
$relation = static::resolve($relation)->getRelation($this->getName());
}
if ($this->getName() === $relation->foreignTable) {
$query->write("JOIN", $relation->referencedTable)->write("ON");
foreach ($relation as $key => $ref) {
$query->criteria(
array(
"{$relation->referencedTable}.{$ref}=" =>
new QueryExpr("{$relation->foreignTable}.{$key}")
)
);
}
} else {
$query->write("JOIN", $relation->foreignTable)->write("ON");
foreach ($relation as $key => $ref) {
$query->criteria(
array(
"{$relation->referencedTable}.{$ref}=" =>
new QueryExpr("{$relation->foreignTable}.{$key}")
)
);
}
}
}
if ($where) {
$query->write("WHERE")->criteria($where);
}
if ($order) {
$query->write("ORDER BY", $order);
}
if ($limit) {
$query->write("LIMIT", $limit);
}
if ($offset) {
$query->write("OFFSET", $offset);
}
return $this->execute($query);
} | php | function with(array $relations, array $where = null, $order = null, $limit = 0, $offset = 0) {
$qthis = $this->conn->quoteName($this->getName());
$query = $this->getQueryWriter()->reset();
$query->write("SELECT", "$qthis.*", "FROM", $qthis);
foreach ($relations as $relation) {
if (!($relation instanceof Table\Reference)) {
$relation = static::resolve($relation)->getRelation($this->getName());
}
if ($this->getName() === $relation->foreignTable) {
$query->write("JOIN", $relation->referencedTable)->write("ON");
foreach ($relation as $key => $ref) {
$query->criteria(
array(
"{$relation->referencedTable}.{$ref}=" =>
new QueryExpr("{$relation->foreignTable}.{$key}")
)
);
}
} else {
$query->write("JOIN", $relation->foreignTable)->write("ON");
foreach ($relation as $key => $ref) {
$query->criteria(
array(
"{$relation->referencedTable}.{$ref}=" =>
new QueryExpr("{$relation->foreignTable}.{$key}")
)
);
}
}
}
if ($where) {
$query->write("WHERE")->criteria($where);
}
if ($order) {
$query->write("ORDER BY", $order);
}
if ($limit) {
$query->write("LIMIT", $limit);
}
if ($offset) {
$query->write("OFFSET", $offset);
}
return $this->execute($query);
} | [
"function",
"with",
"(",
"array",
"$",
"relations",
",",
"array",
"$",
"where",
"=",
"null",
",",
"$",
"order",
"=",
"null",
",",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"qthis",
"=",
"$",
"this",
"->",
"conn",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryWriter",
"(",
")",
"->",
"reset",
"(",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"SELECT\"",
",",
"\"$qthis.*\"",
",",
"\"FROM\"",
",",
"$",
"qthis",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"relation",
"instanceof",
"Table",
"\\",
"Reference",
")",
")",
"{",
"$",
"relation",
"=",
"static",
"::",
"resolve",
"(",
"$",
"relation",
")",
"->",
"getRelation",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
"===",
"$",
"relation",
"->",
"foreignTable",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"JOIN\"",
",",
"$",
"relation",
"->",
"referencedTable",
")",
"->",
"write",
"(",
"\"ON\"",
")",
";",
"foreach",
"(",
"$",
"relation",
"as",
"$",
"key",
"=>",
"$",
"ref",
")",
"{",
"$",
"query",
"->",
"criteria",
"(",
"array",
"(",
"\"{$relation->referencedTable}.{$ref}=\"",
"=>",
"new",
"QueryExpr",
"(",
"\"{$relation->foreignTable}.{$key}\"",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"query",
"->",
"write",
"(",
"\"JOIN\"",
",",
"$",
"relation",
"->",
"foreignTable",
")",
"->",
"write",
"(",
"\"ON\"",
")",
";",
"foreach",
"(",
"$",
"relation",
"as",
"$",
"key",
"=>",
"$",
"ref",
")",
"{",
"$",
"query",
"->",
"criteria",
"(",
"array",
"(",
"\"{$relation->referencedTable}.{$ref}=\"",
"=>",
"new",
"QueryExpr",
"(",
"\"{$relation->foreignTable}.{$key}\"",
")",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"where",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"WHERE\"",
")",
"->",
"criteria",
"(",
"$",
"where",
")",
";",
"}",
"if",
"(",
"$",
"order",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"ORDER BY\"",
",",
"$",
"order",
")",
";",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"LIMIT\"",
",",
"$",
"limit",
")",
";",
"}",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"OFFSET\"",
",",
"$",
"offset",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Get rows dependent on other rows by foreign keys
@param array $relations
@param array $where
@param string $order
@param int $limit
@param int $offset
@return mixed | [
"Get",
"rows",
"dependent",
"on",
"other",
"rows",
"by",
"foreign",
"keys"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L400-L443 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.create | function create(array $data = null, $returning = "*") {
$query = $this->getQueryWriter()->reset();
$query->write("INSERT INTO", $this->conn->quoteName($this->name));
if ($data) {
$first = true;
$params = array();
foreach ($data as $key => $val) {
$query->write($first ? "(" : ",", $key);
$params[] = $query->param($val, $this->getAttributes()->getColumn($key)->type);
$first and $first = false;
}
$query->write(") VALUES (", $params, ")");
} else {
$query->write("DEFAULT VALUES");
}
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | php | function create(array $data = null, $returning = "*") {
$query = $this->getQueryWriter()->reset();
$query->write("INSERT INTO", $this->conn->quoteName($this->name));
if ($data) {
$first = true;
$params = array();
foreach ($data as $key => $val) {
$query->write($first ? "(" : ",", $key);
$params[] = $query->param($val, $this->getAttributes()->getColumn($key)->type);
$first and $first = false;
}
$query->write(") VALUES (", $params, ")");
} else {
$query->write("DEFAULT VALUES");
}
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | [
"function",
"create",
"(",
"array",
"$",
"data",
"=",
"null",
",",
"$",
"returning",
"=",
"\"*\"",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryWriter",
"(",
")",
"->",
"reset",
"(",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"INSERT INTO\"",
",",
"$",
"this",
"->",
"conn",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"first",
"=",
"true",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"$",
"first",
"?",
"\"(\"",
":",
"\",\"",
",",
"$",
"key",
")",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"query",
"->",
"param",
"(",
"$",
"val",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"->",
"getColumn",
"(",
"$",
"key",
")",
"->",
"type",
")",
";",
"$",
"first",
"and",
"$",
"first",
"=",
"false",
";",
"}",
"$",
"query",
"->",
"write",
"(",
"\") VALUES (\"",
",",
"$",
"params",
",",
"\")\"",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"write",
"(",
"\"DEFAULT VALUES\"",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"returning",
")",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"RETURNING\"",
",",
"$",
"returning",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Insert a row into the table
@param array $data
@param string $returning
@return mixed | [
"Insert",
"a",
"row",
"into",
"the",
"table"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L451-L471 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.update | function update(array $where, array $data, $returning = "*") {
$query = $this->getQueryWriter()->reset();
$query->write("UPDATE", $this->conn->quoteName($this->name));
$first = true;
foreach ($data as $key => $val) {
$query->write($first ? "SET" : ",", $key, "=",
$query->param($val, $this->getAttributes()->getColumn($key)->type));
$first and $first = false;
}
$query->write("WHERE")->criteria($where);
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | php | function update(array $where, array $data, $returning = "*") {
$query = $this->getQueryWriter()->reset();
$query->write("UPDATE", $this->conn->quoteName($this->name));
$first = true;
foreach ($data as $key => $val) {
$query->write($first ? "SET" : ",", $key, "=",
$query->param($val, $this->getAttributes()->getColumn($key)->type));
$first and $first = false;
}
$query->write("WHERE")->criteria($where);
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | [
"function",
"update",
"(",
"array",
"$",
"where",
",",
"array",
"$",
"data",
",",
"$",
"returning",
"=",
"\"*\"",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryWriter",
"(",
")",
"->",
"reset",
"(",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"UPDATE\"",
",",
"$",
"this",
"->",
"conn",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"$",
"first",
"=",
"true",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"$",
"first",
"?",
"\"SET\"",
":",
"\",\"",
",",
"$",
"key",
",",
"\"=\"",
",",
"$",
"query",
"->",
"param",
"(",
"$",
"val",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"->",
"getColumn",
"(",
"$",
"key",
")",
"->",
"type",
")",
")",
";",
"$",
"first",
"and",
"$",
"first",
"=",
"false",
";",
"}",
"$",
"query",
"->",
"write",
"(",
"\"WHERE\"",
")",
"->",
"criteria",
"(",
"$",
"where",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"returning",
")",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"RETURNING\"",
",",
"$",
"returning",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Update rows in the table
@param array $where
@param array $data
@param string $returning
@retunr mixed | [
"Update",
"rows",
"in",
"the",
"table"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L480-L494 | train |
m6w6/pq-gateway | lib/pq/Gateway/Table.php | Table.delete | function delete(array $where, $returning = null) {
$query = $this->getQueryWriter()->reset();
$query->write("DELETE FROM", $this->conn->quoteName($this->name));
$query->write("WHERE")->criteria($where);
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | php | function delete(array $where, $returning = null) {
$query = $this->getQueryWriter()->reset();
$query->write("DELETE FROM", $this->conn->quoteName($this->name));
$query->write("WHERE")->criteria($where);
if (strlen($returning)) {
$query->write("RETURNING", $returning);
}
return $this->execute($query);
} | [
"function",
"delete",
"(",
"array",
"$",
"where",
",",
"$",
"returning",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryWriter",
"(",
")",
"->",
"reset",
"(",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"DELETE FROM\"",
",",
"$",
"this",
"->",
"conn",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"$",
"query",
"->",
"write",
"(",
"\"WHERE\"",
")",
"->",
"criteria",
"(",
"$",
"where",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"returning",
")",
")",
"{",
"$",
"query",
"->",
"write",
"(",
"\"RETURNING\"",
",",
"$",
"returning",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
")",
";",
"}"
] | Delete rows from the table
@param array $where
@param string $returning
@return mixed | [
"Delete",
"rows",
"from",
"the",
"table"
] | 58233722a06fd742f531f8f012ea540b309303da | https://github.com/m6w6/pq-gateway/blob/58233722a06fd742f531f8f012ea540b309303da/lib/pq/Gateway/Table.php#L502-L510 | train |
schpill/thin | src/Google/Chart.php | Chart.load | public function load($data, $dataType = 'json')
{
$this->_data = ($dataType != 'json') ? $this->dataToJson($data) : $data;
} | php | public function load($data, $dataType = 'json')
{
$this->_data = ($dataType != 'json') ? $this->dataToJson($data) : $data;
} | [
"public",
"function",
"load",
"(",
"$",
"data",
",",
"$",
"dataType",
"=",
"'json'",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"(",
"$",
"dataType",
"!=",
"'json'",
")",
"?",
"$",
"this",
"->",
"dataToJson",
"(",
"$",
"data",
")",
":",
"$",
"data",
";",
"}"
] | loads the dataset and converts it to the correct format | [
"loads",
"the",
"dataset",
"and",
"converts",
"it",
"to",
"the",
"correct",
"format"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L34-L37 | train |
schpill/thin | src/Google/Chart.php | Chart.draw | public function draw($div, array $options = [])
{
$output = '';
if (self::$_first) {
$output .= $this->initChart();
}
// start a code block
$output .= '<script type="text/javascript">' . "\n";
// set callback function
$output .= 'google.setOnLoadCallback(drawChart' . self::$_count . ');' . "\n";
// create callback function
$output .= 'function drawChart' . self::$_count . '() {' . "\n";
$output .= 'var data = new google.visualization.DataTable(' . $this->_data . ');' . "\n";
// set the options
$output .= 'var options = ' . json_encode($options) . ';' . "\n";
// create and draw the chart
$output .= 'var chart = new google.visualization.' . $this->_chartType . '(document.getElementById(\'' . $div . '\'));' . "\n";
$output .= 'chart.draw(data, options);' . "\n";
$output .= '} </script>' . "\n";
return $output;
} | php | public function draw($div, array $options = [])
{
$output = '';
if (self::$_first) {
$output .= $this->initChart();
}
// start a code block
$output .= '<script type="text/javascript">' . "\n";
// set callback function
$output .= 'google.setOnLoadCallback(drawChart' . self::$_count . ');' . "\n";
// create callback function
$output .= 'function drawChart' . self::$_count . '() {' . "\n";
$output .= 'var data = new google.visualization.DataTable(' . $this->_data . ');' . "\n";
// set the options
$output .= 'var options = ' . json_encode($options) . ';' . "\n";
// create and draw the chart
$output .= 'var chart = new google.visualization.' . $this->_chartType . '(document.getElementById(\'' . $div . '\'));' . "\n";
$output .= 'chart.draw(data, options);' . "\n";
$output .= '} </script>' . "\n";
return $output;
} | [
"public",
"function",
"draw",
"(",
"$",
"div",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"$",
"_first",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"initChart",
"(",
")",
";",
"}",
"// start a code block",
"$",
"output",
".=",
"'<script type=\"text/javascript\">'",
".",
"\"\\n\"",
";",
"// set callback function",
"$",
"output",
".=",
"'google.setOnLoadCallback(drawChart'",
".",
"self",
"::",
"$",
"_count",
".",
"');'",
".",
"\"\\n\"",
";",
"// create callback function",
"$",
"output",
".=",
"'function drawChart'",
".",
"self",
"::",
"$",
"_count",
".",
"'() {'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'var data = new google.visualization.DataTable('",
".",
"$",
"this",
"->",
"_data",
".",
"');'",
".",
"\"\\n\"",
";",
"// set the options",
"$",
"output",
".=",
"'var options = '",
".",
"json_encode",
"(",
"$",
"options",
")",
".",
"';'",
".",
"\"\\n\"",
";",
"// create and draw the chart",
"$",
"output",
".=",
"'var chart = new google.visualization.'",
".",
"$",
"this",
"->",
"_chartType",
".",
"'(document.getElementById(\\''",
".",
"$",
"div",
".",
"'\\'));'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'chart.draw(data, options);'",
".",
"\"\\n\"",
";",
"$",
"output",
".=",
"'} </script>'",
".",
"\"\\n\"",
";",
"return",
"$",
"output",
";",
"}"
] | draws the chart | [
"draws",
"the",
"chart"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L58-L87 | train |
schpill/thin | src/Google/Chart.php | Chart.getColumns | private function getColumns($data)
{
$cols = [];
foreach ($data[0] as $key => $value) {
if (is_numeric($key)){
if (is_string($data[1][$key])) {
$cols[] = ['id' => '', 'label' => $value, 'type' => 'string'];
} else {
$cols[] = ['id' => '', 'label' => $value, 'type' => 'number'];
}
$this->_skipFirstRow = true;
} else {
if (is_string($value)) {
$cols[] = ['id' => '', 'label' => $key, 'type' => 'string'];
} else {
$cols[] = ['id' => '', 'label' => $key, 'type' => 'number'];
}
}
}
return $cols;
} | php | private function getColumns($data)
{
$cols = [];
foreach ($data[0] as $key => $value) {
if (is_numeric($key)){
if (is_string($data[1][$key])) {
$cols[] = ['id' => '', 'label' => $value, 'type' => 'string'];
} else {
$cols[] = ['id' => '', 'label' => $value, 'type' => 'number'];
}
$this->_skipFirstRow = true;
} else {
if (is_string($value)) {
$cols[] = ['id' => '', 'label' => $key, 'type' => 'string'];
} else {
$cols[] = ['id' => '', 'label' => $key, 'type' => 'number'];
}
}
}
return $cols;
} | [
"private",
"function",
"getColumns",
"(",
"$",
"data",
")",
"{",
"$",
"cols",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"[",
"0",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"data",
"[",
"1",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"cols",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"''",
",",
"'label'",
"=>",
"$",
"value",
",",
"'type'",
"=>",
"'string'",
"]",
";",
"}",
"else",
"{",
"$",
"cols",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"''",
",",
"'label'",
"=>",
"$",
"value",
",",
"'type'",
"=>",
"'number'",
"]",
";",
"}",
"$",
"this",
"->",
"_skipFirstRow",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"cols",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"''",
",",
"'label'",
"=>",
"$",
"key",
",",
"'type'",
"=>",
"'string'",
"]",
";",
"}",
"else",
"{",
"$",
"cols",
"[",
"]",
"=",
"[",
"'id'",
"=>",
"''",
",",
"'label'",
"=>",
"$",
"key",
",",
"'type'",
"=>",
"'number'",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"cols",
";",
"}"
] | substracts the column names from the first and second row in the dataset | [
"substracts",
"the",
"column",
"names",
"from",
"the",
"first",
"and",
"second",
"row",
"in",
"the",
"dataset"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L92-L115 | train |
schpill/thin | src/Google/Chart.php | Chart.dataToJson | private function dataToJson($data)
{
$cols = $this->getColumns($data);
$rows = [];
foreach ($data as $key => $row) {
if ($key != 0 || !$this->_skipFirstRow) {
$c = [];
foreach ($row as $v) {
$c[] = ['v' => $v];
}
$rows[] = ['c' => $c];
}
}
return json_encode(['cols' => $cols, 'rows' => $rows]);
} | php | private function dataToJson($data)
{
$cols = $this->getColumns($data);
$rows = [];
foreach ($data as $key => $row) {
if ($key != 0 || !$this->_skipFirstRow) {
$c = [];
foreach ($row as $v) {
$c[] = ['v' => $v];
}
$rows[] = ['c' => $c];
}
}
return json_encode(['cols' => $cols, 'rows' => $rows]);
} | [
"private",
"function",
"dataToJson",
"(",
"$",
"data",
")",
"{",
"$",
"cols",
"=",
"$",
"this",
"->",
"getColumns",
"(",
"$",
"data",
")",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"key",
"!=",
"0",
"||",
"!",
"$",
"this",
"->",
"_skipFirstRow",
")",
"{",
"$",
"c",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"v",
")",
"{",
"$",
"c",
"[",
"]",
"=",
"[",
"'v'",
"=>",
"$",
"v",
"]",
";",
"}",
"$",
"rows",
"[",
"]",
"=",
"[",
"'c'",
"=>",
"$",
"c",
"]",
";",
"}",
"}",
"return",
"json_encode",
"(",
"[",
"'cols'",
"=>",
"$",
"cols",
",",
"'rows'",
"=>",
"$",
"rows",
"]",
")",
";",
"}"
] | convert array data to json | [
"convert",
"array",
"data",
"to",
"json"
] | a9102d9d6f70e8b0f6be93153f70849f46489ee1 | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Google/Chart.php#L120-L139 | train |
kamilabs/icobench-client | src/Kami/IcoBench/Client.php | Client.processResponse | protected function processResponse(ResponseInterface $response)
{
if (200 !== $response->getStatusCode()) {
throw new IcoBenchException(
sprintf('IcoBench replied with non-success status (%s)', $response->getStatusCode())
);
}
$data = json_decode($response->getBody(), true);
if (isset($data['error'])) {
throw new IcoBenchException($data['error']);
}
if (isset($data['message'])) {
return $data['message'];
}
return $data;
} | php | protected function processResponse(ResponseInterface $response)
{
if (200 !== $response->getStatusCode()) {
throw new IcoBenchException(
sprintf('IcoBench replied with non-success status (%s)', $response->getStatusCode())
);
}
$data = json_decode($response->getBody(), true);
if (isset($data['error'])) {
throw new IcoBenchException($data['error']);
}
if (isset($data['message'])) {
return $data['message'];
}
return $data;
} | [
"protected",
"function",
"processResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"200",
"!==",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"IcoBenchException",
"(",
"sprintf",
"(",
"'IcoBench replied with non-success status (%s)'",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
")",
";",
"}",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'error'",
"]",
")",
")",
"{",
"throw",
"new",
"IcoBenchException",
"(",
"$",
"data",
"[",
"'error'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'message'",
"]",
")",
")",
"{",
"return",
"$",
"data",
"[",
"'message'",
"]",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Get data from response
@param ResponseInterface $response
@return array | string
@throws IcoBenchException | [
"Get",
"data",
"from",
"response"
] | b06def3015e00de0587b485648d2ff2828595186 | https://github.com/kamilabs/icobench-client/blob/b06def3015e00de0587b485648d2ff2828595186/src/Kami/IcoBench/Client.php#L124-L143 | train |
gregorybesson/PlaygroundFlow | src/Service/Event.php | Event.getTotal | public function getTotal($user, $type = '', $count = 'points')
{
$em = $this->serviceLocator->get('playgroundflow_doctrine_em');
if ($count == 'points') {
$aggregate = 'SUM(e.points)';
} elseif ($count == 'count') {
$aggregate = 'COUNT(e.id)';
}
switch ($type) {
case 'game':
$filter = array(12);
break;
case 'user':
$filter = array(1,4,5,6,7,8,9,10,11);
break;
case 'newsletter':
$filter = array(2,3);
break;
case 'sponsorship':
$filter = array(20);
break;
case 'social':
$filter = array(13,14,15,16,17);
break;
case 'quizAnswer':
$filter = array(30);
break;
case 'badgesBronze':
$filter = array(100);
break;
case 'badgesSilver':
$filter = array(101);
break;
case 'badgesGold':
$filter = array(102);
break;
case 'anniversary':
$filter = array(25);
break;
default:
$filter = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,100,101,102,103);
}
$query = $em->createQuery('SELECT ' . $aggregate . ' FROM PlaygroundFlow\Entity\Event e WHERE e.user = :user AND e.actionId in (?1)');
$query->setParameter('user', $user);
$query->setParameter(1, $filter);
$total = $query->getSingleScalarResult();
return $total;
} | php | public function getTotal($user, $type = '', $count = 'points')
{
$em = $this->serviceLocator->get('playgroundflow_doctrine_em');
if ($count == 'points') {
$aggregate = 'SUM(e.points)';
} elseif ($count == 'count') {
$aggregate = 'COUNT(e.id)';
}
switch ($type) {
case 'game':
$filter = array(12);
break;
case 'user':
$filter = array(1,4,5,6,7,8,9,10,11);
break;
case 'newsletter':
$filter = array(2,3);
break;
case 'sponsorship':
$filter = array(20);
break;
case 'social':
$filter = array(13,14,15,16,17);
break;
case 'quizAnswer':
$filter = array(30);
break;
case 'badgesBronze':
$filter = array(100);
break;
case 'badgesSilver':
$filter = array(101);
break;
case 'badgesGold':
$filter = array(102);
break;
case 'anniversary':
$filter = array(25);
break;
default:
$filter = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,100,101,102,103);
}
$query = $em->createQuery('SELECT ' . $aggregate . ' FROM PlaygroundFlow\Entity\Event e WHERE e.user = :user AND e.actionId in (?1)');
$query->setParameter('user', $user);
$query->setParameter(1, $filter);
$total = $query->getSingleScalarResult();
return $total;
} | [
"public",
"function",
"getTotal",
"(",
"$",
"user",
",",
"$",
"type",
"=",
"''",
",",
"$",
"count",
"=",
"'points'",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'playgroundflow_doctrine_em'",
")",
";",
"if",
"(",
"$",
"count",
"==",
"'points'",
")",
"{",
"$",
"aggregate",
"=",
"'SUM(e.points)'",
";",
"}",
"elseif",
"(",
"$",
"count",
"==",
"'count'",
")",
"{",
"$",
"aggregate",
"=",
"'COUNT(e.id)'",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'game'",
":",
"$",
"filter",
"=",
"array",
"(",
"12",
")",
";",
"break",
";",
"case",
"'user'",
":",
"$",
"filter",
"=",
"array",
"(",
"1",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"9",
",",
"10",
",",
"11",
")",
";",
"break",
";",
"case",
"'newsletter'",
":",
"$",
"filter",
"=",
"array",
"(",
"2",
",",
"3",
")",
";",
"break",
";",
"case",
"'sponsorship'",
":",
"$",
"filter",
"=",
"array",
"(",
"20",
")",
";",
"break",
";",
"case",
"'social'",
":",
"$",
"filter",
"=",
"array",
"(",
"13",
",",
"14",
",",
"15",
",",
"16",
",",
"17",
")",
";",
"break",
";",
"case",
"'quizAnswer'",
":",
"$",
"filter",
"=",
"array",
"(",
"30",
")",
";",
"break",
";",
"case",
"'badgesBronze'",
":",
"$",
"filter",
"=",
"array",
"(",
"100",
")",
";",
"break",
";",
"case",
"'badgesSilver'",
":",
"$",
"filter",
"=",
"array",
"(",
"101",
")",
";",
"break",
";",
"case",
"'badgesGold'",
":",
"$",
"filter",
"=",
"array",
"(",
"102",
")",
";",
"break",
";",
"case",
"'anniversary'",
":",
"$",
"filter",
"=",
"array",
"(",
"25",
")",
";",
"break",
";",
"default",
":",
"$",
"filter",
"=",
"array",
"(",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"7",
",",
"8",
",",
"9",
",",
"10",
",",
"11",
",",
"12",
",",
"13",
",",
"14",
",",
"15",
",",
"16",
",",
"17",
",",
"18",
",",
"19",
",",
"20",
",",
"25",
",",
"100",
",",
"101",
",",
"102",
",",
"103",
")",
";",
"}",
"$",
"query",
"=",
"$",
"em",
"->",
"createQuery",
"(",
"'SELECT '",
".",
"$",
"aggregate",
".",
"' FROM PlaygroundFlow\\Entity\\Event e WHERE e.user = :user AND e.actionId in (?1)'",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'user'",
",",
"$",
"user",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"1",
",",
"$",
"filter",
")",
";",
"$",
"total",
"=",
"$",
"query",
"->",
"getSingleScalarResult",
"(",
")",
";",
"return",
"$",
"total",
";",
"}"
] | This function return count of events or total points by event category for one user
@param unknown_type $user
@param unknown_type $type
@param unknown_type $count | [
"This",
"function",
"return",
"count",
"of",
"events",
"or",
"total",
"points",
"by",
"event",
"category",
"for",
"one",
"user"
] | f97493f8527e425d46223ac7b5c41331ab8b3022 | https://github.com/gregorybesson/PlaygroundFlow/blob/f97493f8527e425d46223ac7b5c41331ab8b3022/src/Service/Event.php#L54-L105 | train |
Phpillip/phpillip | src/Console/Model/Builder.php | Builder.clear | public function clear()
{
if ($this->files->exists($this->destination)) {
$this->files->remove($this->destination);
}
$this->files->mkdir($this->destination);
} | php | public function clear()
{
if ($this->files->exists($this->destination)) {
$this->files->remove($this->destination);
}
$this->files->mkdir($this->destination);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"destination",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"remove",
"(",
"$",
"this",
"->",
"destination",
")",
";",
"}",
"$",
"this",
"->",
"files",
"->",
"mkdir",
"(",
"$",
"this",
"->",
"destination",
")",
";",
"}"
] | Clear destination folder | [
"Clear",
"destination",
"folder"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L53-L60 | train |
Phpillip/phpillip | src/Console/Model/Builder.php | Builder.build | public function build(Route $route, $name, array $parameters = [])
{
$url = $this->app['url_generator']->generate($name, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
$request = Request::create($url, 'GET', array_merge(['_format' => $route->getFormat()], $parameters));
$response = $this->app->handle($request);
$this->write(
$this->getFilePath($route, $parameters),
$response->getContent(),
$request->getFormat($response->headers->get('Content-Type')),
$route->getFileName()
);
} | php | public function build(Route $route, $name, array $parameters = [])
{
$url = $this->app['url_generator']->generate($name, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
$request = Request::create($url, 'GET', array_merge(['_format' => $route->getFormat()], $parameters));
$response = $this->app->handle($request);
$this->write(
$this->getFilePath($route, $parameters),
$response->getContent(),
$request->getFormat($response->headers->get('Content-Type')),
$route->getFileName()
);
} | [
"public",
"function",
"build",
"(",
"Route",
"$",
"route",
",",
"$",
"name",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"app",
"[",
"'url_generator'",
"]",
"->",
"generate",
"(",
"$",
"name",
",",
"$",
"parameters",
",",
"UrlGeneratorInterface",
"::",
"ABSOLUTE_URL",
")",
";",
"$",
"request",
"=",
"Request",
"::",
"create",
"(",
"$",
"url",
",",
"'GET'",
",",
"array_merge",
"(",
"[",
"'_format'",
"=>",
"$",
"route",
"->",
"getFormat",
"(",
")",
"]",
",",
"$",
"parameters",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"app",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"route",
",",
"$",
"parameters",
")",
",",
"$",
"response",
"->",
"getContent",
"(",
")",
",",
"$",
"request",
"->",
"getFormat",
"(",
"$",
"response",
"->",
"headers",
"->",
"get",
"(",
"'Content-Type'",
")",
")",
",",
"$",
"route",
"->",
"getFileName",
"(",
")",
")",
";",
"}"
] | Dump the given Route into a file
@param Route $route
@param string $name
@param array $parameters | [
"Dump",
"the",
"given",
"Route",
"into",
"a",
"file"
] | c37afaafb536361e7e0b564659f1cd5b80b98be9 | https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Console/Model/Builder.php#L69-L81 | train |
nasumilu/geometry | src/Geometry.php | Geometry.getBoundary | public function getBoundary(): Geometry {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::BOUNDARY_EVENT, $event);
return $event->getResults();
} | php | public function getBoundary(): Geometry {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::BOUNDARY_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"getBoundary",
"(",
")",
":",
"Geometry",
"{",
"$",
"event",
"=",
"new",
"AccessorOpEvent",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"AccessorOpEvent",
"::",
"BOUNDARY_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Gets the closure of the combinatorial bound of this Geometry object | [
"Gets",
"the",
"closure",
"of",
"the",
"combinatorial",
"bound",
"of",
"this",
"Geometry",
"object"
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L125-L129 | train |
nasumilu/geometry | src/Geometry.php | Geometry.getEnvelope | public function getEnvelope(): Geometry {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::ENVELOPE_EVENT, $event);
return $event->getResults();
} | php | public function getEnvelope(): Geometry {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::ENVELOPE_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"getEnvelope",
"(",
")",
":",
"Geometry",
"{",
"$",
"event",
"=",
"new",
"AccessorOpEvent",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"AccessorOpEvent",
"::",
"ENVELOPE_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Gets the minimum bounding box for this Geometry as a Geometry.
The polygon is defined by the corner points of the bound box as
[(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINZX, MAXY), (MINX, MINY)].
The minimums for z and m may be added.
@return Geometry | [
"Gets",
"the",
"minimum",
"bounding",
"box",
"for",
"this",
"Geometry",
"as",
"a",
"Geometry",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L171-L175 | train |
nasumilu/geometry | src/Geometry.php | Geometry.asText | public function asText(bool $extended = false): string {
$event = new OutputOpEvent($this, ['extended' => $extended]);
$this->fireOperationEvent(OutputOpEvent::AS_TEXT_EVENT, $event);
return $event->getResults();
} | php | public function asText(bool $extended = false): string {
$event = new OutputOpEvent($this, ['extended' => $extended]);
$this->fireOperationEvent(OutputOpEvent::AS_TEXT_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"asText",
"(",
"bool",
"$",
"extended",
"=",
"false",
")",
":",
"string",
"{",
"$",
"event",
"=",
"new",
"OutputOpEvent",
"(",
"$",
"this",
",",
"[",
"'extended'",
"=>",
"$",
"extended",
"]",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"OutputOpEvent",
"::",
"AS_TEXT_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Exports this Geometry object to a specific Well-known Text Representation.
@param bool $extended true will export to Extended Well-known Text | [
"Exports",
"this",
"Geometry",
"object",
"to",
"a",
"specific",
"Well",
"-",
"known",
"Text",
"Representation",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L193-L197 | train |
nasumilu/geometry | src/Geometry.php | Geometry.asBinary | public function asBinary(bool $extended = false, string $endianness = 'NDR', bool $unpack = false): string {
$event = new OutputOpEvent($this, [
'extended' => $extended,
'endianness' => $endianness,
'unpack' => $unpack]);
$this->fireOperationEvent(OutputOpEvent::AS_BINARY_EVENT, $event);
return $event->getResults();
} | php | public function asBinary(bool $extended = false, string $endianness = 'NDR', bool $unpack = false): string {
$event = new OutputOpEvent($this, [
'extended' => $extended,
'endianness' => $endianness,
'unpack' => $unpack]);
$this->fireOperationEvent(OutputOpEvent::AS_BINARY_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"asBinary",
"(",
"bool",
"$",
"extended",
"=",
"false",
",",
"string",
"$",
"endianness",
"=",
"'NDR'",
",",
"bool",
"$",
"unpack",
"=",
"false",
")",
":",
"string",
"{",
"$",
"event",
"=",
"new",
"OutputOpEvent",
"(",
"$",
"this",
",",
"[",
"'extended'",
"=>",
"$",
"extended",
",",
"'endianness'",
"=>",
"$",
"endianness",
",",
"'unpack'",
"=>",
"$",
"unpack",
"]",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"OutputOpEvent",
"::",
"AS_BINARY_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Exports this Geometry object to a specific Well-known Binary Representation.
@param bool $extended true will export to Extended Well-known Binary
@param string $endianness either 'NDR' little-endian or 'XDR' big-endian
@param bool $unpack true will return hex_string; false binary string | [
"Exports",
"this",
"Geometry",
"object",
"to",
"a",
"specific",
"Well",
"-",
"known",
"Binary",
"Representation",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L206-L213 | train |
nasumilu/geometry | src/Geometry.php | Geometry.isSimple | public function isSimple(): bool {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::IS_SIMPLE_EVENT, $event);
return $event->getResults();
} | php | public function isSimple(): bool {
$event = new AccessorOpEvent($this);
$this->fireOperationEvent(AccessorOpEvent::IS_SIMPLE_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"isSimple",
"(",
")",
":",
"bool",
"{",
"$",
"event",
"=",
"new",
"AccessorOpEvent",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"AccessorOpEvent",
"::",
"IS_SIMPLE_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Indicates whether this Geometry object has no anomalous geometric points,
such as self intersection of self tangency.
@return bool | [
"Indicates",
"whether",
"this",
"Geometry",
"object",
"has",
"no",
"anomalous",
"geometric",
"points",
"such",
"as",
"self",
"intersection",
"of",
"self",
"tangency",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L229-L233 | train |
nasumilu/geometry | src/Geometry.php | Geometry.convexHull | public function convexHull(): Geometry {
$event = new ProcessOpEvent($this);
$this->fireOperationEvent(ProcessOpEvent::CONVEX_HULL_EVENT, $event);
return $event->getResults();
} | php | public function convexHull(): Geometry {
$event = new ProcessOpEvent($this);
$this->fireOperationEvent(ProcessOpEvent::CONVEX_HULL_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"convexHull",
"(",
")",
":",
"Geometry",
"{",
"$",
"event",
"=",
"new",
"ProcessOpEvent",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"ProcessOpEvent",
"::",
"CONVEX_HULL_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | Gets a Geometry that represents the convex hull of this Geometry.
@return \Nasumilu\Geometry\Geometry | [
"Gets",
"a",
"Geometry",
"that",
"represents",
"the",
"convex",
"hull",
"of",
"this",
"Geometry",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L403-L407 | train |
nasumilu/geometry | src/Geometry.php | Geometry.getCentroid | public function getCentroid(bool $use_spheriod = false): Point {
$event = new AccessorOpEvent($this, ['use_spheriod' => $use_spheriod]);
$this->fireOperationEvent(AccessorOpEvent::CENTROID_EVENT, $event);
return $event->getResults();
} | php | public function getCentroid(bool $use_spheriod = false): Point {
$event = new AccessorOpEvent($this, ['use_spheriod' => $use_spheriod]);
$this->fireOperationEvent(AccessorOpEvent::CENTROID_EVENT, $event);
return $event->getResults();
} | [
"public",
"function",
"getCentroid",
"(",
"bool",
"$",
"use_spheriod",
"=",
"false",
")",
":",
"Point",
"{",
"$",
"event",
"=",
"new",
"AccessorOpEvent",
"(",
"$",
"this",
",",
"[",
"'use_spheriod'",
"=>",
"$",
"use_spheriod",
"]",
")",
";",
"$",
"this",
"->",
"fireOperationEvent",
"(",
"AccessorOpEvent",
"::",
"CENTROID_EVENT",
",",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getResults",
"(",
")",
";",
"}"
] | The mathematical centroid for this Surface as a Point. The result is not
guaranteed to be on this Surface.
@param bool $use_spheriod
@return \Nasumilu\Geometry\Point | [
"The",
"mathematical",
"centroid",
"for",
"this",
"Surface",
"as",
"a",
"Point",
".",
"The",
"result",
"is",
"not",
"guaranteed",
"to",
"be",
"on",
"this",
"Surface",
"."
] | 000fafe3e61f1d0682952ad236b7486dded65eae | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Geometry.php#L490-L494 | train |
caouecs/Laravel4-Clef | example/ClefController.php | ClefController.authentication | public function authentication()
{
$response = \Aperdia\Clef::authentication($_GET['code']);
// error
if (!$response) {
$error = 'Error';
// error
} elseif (isset($response['error'])) {
$error = $response['error'];
// success
} elseif (isset($response['success'])) {
// verif if exists account in Authentication table
$verif = Authentication::whereprovider("clef")->whereprovider_uid($response['info']['id'])->first();
// no account
if (empty($verif)) {
// Find account
} else {
// Find the user using the user id
$user = User::find($verif->user_id);
// RAZ logout
if ($user->logout == 1) {
$user->logout = 0;
$user->save();
}
// Log the user in
Auth::login($user);
return Redirect::intended('/');
}
// error
} else {
$error = 'Unknown error';
}
return Redirect::to("login")->withErrors($error);
} | php | public function authentication()
{
$response = \Aperdia\Clef::authentication($_GET['code']);
// error
if (!$response) {
$error = 'Error';
// error
} elseif (isset($response['error'])) {
$error = $response['error'];
// success
} elseif (isset($response['success'])) {
// verif if exists account in Authentication table
$verif = Authentication::whereprovider("clef")->whereprovider_uid($response['info']['id'])->first();
// no account
if (empty($verif)) {
// Find account
} else {
// Find the user using the user id
$user = User::find($verif->user_id);
// RAZ logout
if ($user->logout == 1) {
$user->logout = 0;
$user->save();
}
// Log the user in
Auth::login($user);
return Redirect::intended('/');
}
// error
} else {
$error = 'Unknown error';
}
return Redirect::to("login")->withErrors($error);
} | [
"public",
"function",
"authentication",
"(",
")",
"{",
"$",
"response",
"=",
"\\",
"Aperdia",
"\\",
"Clef",
"::",
"authentication",
"(",
"$",
"_GET",
"[",
"'code'",
"]",
")",
";",
"// error",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"$",
"error",
"=",
"'Error'",
";",
"// error",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"response",
"[",
"'error'",
"]",
")",
")",
"{",
"$",
"error",
"=",
"$",
"response",
"[",
"'error'",
"]",
";",
"// success",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"response",
"[",
"'success'",
"]",
")",
")",
"{",
"// verif if exists account in Authentication table",
"$",
"verif",
"=",
"Authentication",
"::",
"whereprovider",
"(",
"\"clef\"",
")",
"->",
"whereprovider_uid",
"(",
"$",
"response",
"[",
"'info'",
"]",
"[",
"'id'",
"]",
")",
"->",
"first",
"(",
")",
";",
"// no account",
"if",
"(",
"empty",
"(",
"$",
"verif",
")",
")",
"{",
"// Find account",
"}",
"else",
"{",
"// Find the user using the user id",
"$",
"user",
"=",
"User",
"::",
"find",
"(",
"$",
"verif",
"->",
"user_id",
")",
";",
"// RAZ logout",
"if",
"(",
"$",
"user",
"->",
"logout",
"==",
"1",
")",
"{",
"$",
"user",
"->",
"logout",
"=",
"0",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"// Log the user in",
"Auth",
"::",
"login",
"(",
"$",
"user",
")",
";",
"return",
"Redirect",
"::",
"intended",
"(",
"'/'",
")",
";",
"}",
"// error",
"}",
"else",
"{",
"$",
"error",
"=",
"'Unknown error'",
";",
"}",
"return",
"Redirect",
"::",
"to",
"(",
"\"login\"",
")",
"->",
"withErrors",
"(",
"$",
"error",
")",
";",
"}"
] | Authentication with Clef account
@return Response | [
"Authentication",
"with",
"Clef",
"account"
] | d9d3596df734184cc9937bd83fd06ab8f0f8f7b4 | https://github.com/caouecs/Laravel4-Clef/blob/d9d3596df734184cc9937bd83fd06ab8f0f8f7b4/example/ClefController.php#L11-L52 | train |
caouecs/Laravel4-Clef | example/ClefController.php | ClefController.logout | public function logout()
{
// Token from Clef.io
if (isset($_POST['logout_token'])) {
// Verif token
$clef = \Aperdia\Clef::logout($_POST['logout_token']);
if (!$clef) {
// Verif in Authentication table
$auth = Authentication::whereprovider("clef")->whereprovider_uid($clef)->first();
if (!empty($auth)) {
$user = User::find($auth->user_id);
if (!empty($user)) {
$user->logout = 1;
$user->save();
}
}
}
}
} | php | public function logout()
{
// Token from Clef.io
if (isset($_POST['logout_token'])) {
// Verif token
$clef = \Aperdia\Clef::logout($_POST['logout_token']);
if (!$clef) {
// Verif in Authentication table
$auth = Authentication::whereprovider("clef")->whereprovider_uid($clef)->first();
if (!empty($auth)) {
$user = User::find($auth->user_id);
if (!empty($user)) {
$user->logout = 1;
$user->save();
}
}
}
}
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"// Token from Clef.io",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'logout_token'",
"]",
")",
")",
"{",
"// Verif token",
"$",
"clef",
"=",
"\\",
"Aperdia",
"\\",
"Clef",
"::",
"logout",
"(",
"$",
"_POST",
"[",
"'logout_token'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"clef",
")",
"{",
"// Verif in Authentication table",
"$",
"auth",
"=",
"Authentication",
"::",
"whereprovider",
"(",
"\"clef\"",
")",
"->",
"whereprovider_uid",
"(",
"$",
"clef",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"auth",
")",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"find",
"(",
"$",
"auth",
"->",
"user_id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"->",
"logout",
"=",
"1",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Logout by WebHook
@access public
@return Response | [
"Logout",
"by",
"WebHook"
] | d9d3596df734184cc9937bd83fd06ab8f0f8f7b4 | https://github.com/caouecs/Laravel4-Clef/blob/d9d3596df734184cc9937bd83fd06ab8f0f8f7b4/example/ClefController.php#L60-L81 | train |
MetaModels/attribute_translatedurl | src/EventListener/UrlWizardHandler.php | UrlWizardHandler.getWizard | public function getWizard(ManipulateWidgetEvent $event)
{
if ($event->getModel()->getProviderName() !== $this->metaModel->getTableName()
|| $event->getProperty()->getName() !== $this->propertyName
) {
return;
}
$propName = $event->getProperty()->getName();
$model = $event->getModel();
$inputId = $propName . (!$this->metaModel->getAttribute($this->propertyName)->get('trim_title') ? '_1' : '');
$translator = $event->getEnvironment()->getTranslator();
$this->addStylesheet('metamodelsattribute_url', 'bundles/metamodelsattributeurl/style.css');
$currentField = \deserialize($model->getProperty($propName), true);
/** @var GenerateHtmlEvent $imageEvent */
$imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch(
ContaoEvents::IMAGE_GET_HTML,
new GenerateHtmlEvent(
'pickpage.gif',
$translator->translate('pagepicker', 'MSC'),
'style="vertical-align:top;cursor:pointer"'
)
);
$event->getWidget()->wizard = ' <a href="contao/page.php?do=' . Input::get('do') .
'&table=' . $this->metaModel->getTableName() . '&field=' . $inputId .
'&value=' . \str_replace(array('{{link_url::', '}}'), '', $currentField[1])
. '" title="' .
StringUtil::specialchars($translator->translate('pagepicker', 'MSC')) .
'" onclick="Backend.getScrollOffset();'.
'Backend.openModalSelector({\'width\':765,\'title\':\'' .
StringUtil::specialchars(\str_replace("'", "\\'", $translator->translate('page.0', 'MOD'))) .
'\',\'url\':this.href,\'id\':\'' . $inputId . '\',\'tag\':\'ctrl_' . $inputId
. '\',\'self\':this});' .
'return false">' . $imageEvent->getHtml() . '</a>';
} | php | public function getWizard(ManipulateWidgetEvent $event)
{
if ($event->getModel()->getProviderName() !== $this->metaModel->getTableName()
|| $event->getProperty()->getName() !== $this->propertyName
) {
return;
}
$propName = $event->getProperty()->getName();
$model = $event->getModel();
$inputId = $propName . (!$this->metaModel->getAttribute($this->propertyName)->get('trim_title') ? '_1' : '');
$translator = $event->getEnvironment()->getTranslator();
$this->addStylesheet('metamodelsattribute_url', 'bundles/metamodelsattributeurl/style.css');
$currentField = \deserialize($model->getProperty($propName), true);
/** @var GenerateHtmlEvent $imageEvent */
$imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch(
ContaoEvents::IMAGE_GET_HTML,
new GenerateHtmlEvent(
'pickpage.gif',
$translator->translate('pagepicker', 'MSC'),
'style="vertical-align:top;cursor:pointer"'
)
);
$event->getWidget()->wizard = ' <a href="contao/page.php?do=' . Input::get('do') .
'&table=' . $this->metaModel->getTableName() . '&field=' . $inputId .
'&value=' . \str_replace(array('{{link_url::', '}}'), '', $currentField[1])
. '" title="' .
StringUtil::specialchars($translator->translate('pagepicker', 'MSC')) .
'" onclick="Backend.getScrollOffset();'.
'Backend.openModalSelector({\'width\':765,\'title\':\'' .
StringUtil::specialchars(\str_replace("'", "\\'", $translator->translate('page.0', 'MOD'))) .
'\',\'url\':this.href,\'id\':\'' . $inputId . '\',\'tag\':\'ctrl_' . $inputId
. '\',\'self\':this});' .
'return false">' . $imageEvent->getHtml() . '</a>';
} | [
"public",
"function",
"getWizard",
"(",
"ManipulateWidgetEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getModel",
"(",
")",
"->",
"getProviderName",
"(",
")",
"!==",
"$",
"this",
"->",
"metaModel",
"->",
"getTableName",
"(",
")",
"||",
"$",
"event",
"->",
"getProperty",
"(",
")",
"->",
"getName",
"(",
")",
"!==",
"$",
"this",
"->",
"propertyName",
")",
"{",
"return",
";",
"}",
"$",
"propName",
"=",
"$",
"event",
"->",
"getProperty",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"model",
"=",
"$",
"event",
"->",
"getModel",
"(",
")",
";",
"$",
"inputId",
"=",
"$",
"propName",
".",
"(",
"!",
"$",
"this",
"->",
"metaModel",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"propertyName",
")",
"->",
"get",
"(",
"'trim_title'",
")",
"?",
"'_1'",
":",
"''",
")",
";",
"$",
"translator",
"=",
"$",
"event",
"->",
"getEnvironment",
"(",
")",
"->",
"getTranslator",
"(",
")",
";",
"$",
"this",
"->",
"addStylesheet",
"(",
"'metamodelsattribute_url'",
",",
"'bundles/metamodelsattributeurl/style.css'",
")",
";",
"$",
"currentField",
"=",
"\\",
"deserialize",
"(",
"$",
"model",
"->",
"getProperty",
"(",
"$",
"propName",
")",
",",
"true",
")",
";",
"/** @var GenerateHtmlEvent $imageEvent */",
"$",
"imageEvent",
"=",
"$",
"event",
"->",
"getEnvironment",
"(",
")",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ContaoEvents",
"::",
"IMAGE_GET_HTML",
",",
"new",
"GenerateHtmlEvent",
"(",
"'pickpage.gif'",
",",
"$",
"translator",
"->",
"translate",
"(",
"'pagepicker'",
",",
"'MSC'",
")",
",",
"'style=\"vertical-align:top;cursor:pointer\"'",
")",
")",
";",
"$",
"event",
"->",
"getWidget",
"(",
")",
"->",
"wizard",
"=",
"' <a href=\"contao/page.php?do='",
".",
"Input",
"::",
"get",
"(",
"'do'",
")",
".",
"'&table='",
".",
"$",
"this",
"->",
"metaModel",
"->",
"getTableName",
"(",
")",
".",
"'&field='",
".",
"$",
"inputId",
".",
"'&value='",
".",
"\\",
"str_replace",
"(",
"array",
"(",
"'{{link_url::'",
",",
"'}}'",
")",
",",
"''",
",",
"$",
"currentField",
"[",
"1",
"]",
")",
".",
"'\" title=\"'",
".",
"StringUtil",
"::",
"specialchars",
"(",
"$",
"translator",
"->",
"translate",
"(",
"'pagepicker'",
",",
"'MSC'",
")",
")",
".",
"'\" onclick=\"Backend.getScrollOffset();'",
".",
"'Backend.openModalSelector({\\'width\\':765,\\'title\\':\\''",
".",
"StringUtil",
"::",
"specialchars",
"(",
"\\",
"str_replace",
"(",
"\"'\"",
",",
"\"\\\\'\"",
",",
"$",
"translator",
"->",
"translate",
"(",
"'page.0'",
",",
"'MOD'",
")",
")",
")",
".",
"'\\',\\'url\\':this.href,\\'id\\':\\''",
".",
"$",
"inputId",
".",
"'\\',\\'tag\\':\\'ctrl_'",
".",
"$",
"inputId",
".",
"'\\',\\'self\\':this});'",
".",
"'return false\">'",
".",
"$",
"imageEvent",
"->",
"getHtml",
"(",
")",
".",
"'</a>'",
";",
"}"
] | Build the wizard string.
@param ManipulateWidgetEvent $event The event.
@return void | [
"Build",
"the",
"wizard",
"string",
"."
] | ad6b4967244614be49d382934043c766b5fa08d8 | https://github.com/MetaModels/attribute_translatedurl/blob/ad6b4967244614be49d382934043c766b5fa08d8/src/EventListener/UrlWizardHandler.php#L68-L106 | train |
CodeCollab/Http | src/Cookie/Factory.php | Factory.build | public function build(string $key, $value, \DateTimeInterface $expire = null): Cookie
{
return new Cookie($key, $this->encryptor->encrypt($value), $expire, '/', $this->domain, $this->secure);
} | php | public function build(string $key, $value, \DateTimeInterface $expire = null): Cookie
{
return new Cookie($key, $this->encryptor->encrypt($value), $expire, '/', $this->domain, $this->secure);
} | [
"public",
"function",
"build",
"(",
"string",
"$",
"key",
",",
"$",
"value",
",",
"\\",
"DateTimeInterface",
"$",
"expire",
"=",
"null",
")",
":",
"Cookie",
"{",
"return",
"new",
"Cookie",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"encryptor",
"->",
"encrypt",
"(",
"$",
"value",
")",
",",
"$",
"expire",
",",
"'/'",
",",
"$",
"this",
"->",
"domain",
",",
"$",
"this",
"->",
"secure",
")",
";",
"}"
] | Builds a new cookie
@param string $key The name of the cookie
@param mixed $value The value of the cookie
@param \DateTimeInterface $expire The expiration time of the cookie
@return \CodeCollab\Http\Cookie\Cookie The built cookie | [
"Builds",
"a",
"new",
"cookie"
] | b1f8306b20daebcf26ed4b13c032c5bc008a0861 | https://github.com/CodeCollab/Http/blob/b1f8306b20daebcf26ed4b13c032c5bc008a0861/src/Cookie/Factory.php#L67-L70 | train |
rujiali/acquia-site-factory-cli | src/AppBundle/Connector/ConnectorSites.php | ConnectorSites.clearCache | public function clearCache()
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/cache-clear';
$params = [];
$response = $this->connector->connecting($url, $params, 'POST');
return $response;
} | php | public function clearCache()
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/cache-clear';
$params = [];
$response = $this->connector->connecting($url, $params, 'POST');
return $response;
} | [
"public",
"function",
"clearCache",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
"===",
"null",
")",
"{",
"return",
"'Cannot find site URL from configuration.'",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
".",
"self",
"::",
"VERSION",
".",
"$",
"this",
"->",
"connector",
"->",
"getSiteID",
"(",
")",
".",
"'/cache-clear'",
";",
"$",
"params",
"=",
"[",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connector",
"->",
"connecting",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'POST'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Clear site cache.
@return mixed|string | [
"Clear",
"site",
"cache",
"."
] | c9dbb9dfd71408adff0ea26db94678a61c584df6 | https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L34-L44 | train |
rujiali/acquia-site-factory-cli | src/AppBundle/Connector/ConnectorSites.php | ConnectorSites.createBackup | public function createBackup($label, $components)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backup';
$params = [
'label' => $label,
'components' => $components,
];
$response = $this->connector->connecting($url, $params, 'POST');
// @codingStandardsIgnoreStart
if (isset($response->task_id)) {
return $response->task_id;
// @codingStandardsIgnoreEnd
}
return $response;
} | php | public function createBackup($label, $components)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backup';
$params = [
'label' => $label,
'components' => $components,
];
$response = $this->connector->connecting($url, $params, 'POST');
// @codingStandardsIgnoreStart
if (isset($response->task_id)) {
return $response->task_id;
// @codingStandardsIgnoreEnd
}
return $response;
} | [
"public",
"function",
"createBackup",
"(",
"$",
"label",
",",
"$",
"components",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
"===",
"null",
")",
"{",
"return",
"'Cannot find site URL from configuration.'",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
".",
"self",
"::",
"VERSION",
".",
"$",
"this",
"->",
"connector",
"->",
"getSiteID",
"(",
")",
".",
"'/backup'",
";",
"$",
"params",
"=",
"[",
"'label'",
"=>",
"$",
"label",
",",
"'components'",
"=>",
"$",
"components",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connector",
"->",
"connecting",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'POST'",
")",
";",
"// @codingStandardsIgnoreStart",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"task_id",
")",
")",
"{",
"return",
"$",
"response",
"->",
"task_id",
";",
"// @codingStandardsIgnoreEnd",
"}",
"return",
"$",
"response",
";",
"}"
] | Create backup for specific site in site factory.
@param string $label Backup label.
@param array $components Backup components.
@return integer
Task ID. | [
"Create",
"backup",
"for",
"specific",
"site",
"in",
"site",
"factory",
"."
] | c9dbb9dfd71408adff0ea26db94678a61c584df6 | https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L55-L75 | train |
rujiali/acquia-site-factory-cli | src/AppBundle/Connector/ConnectorSites.php | ConnectorSites.deleteBackup | public function deleteBackup($backupId, $callbackUrl, $callbackMethod, $callerData)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId;
$params = [
'callback_url' => $callbackUrl,
'callback_method' => $callbackMethod,
'callerData' => $callerData,
];
$response = $this->connector->connecting($url, $params, 'DELETE');
// @codingStandardsIgnoreStart
if (isset($response->task_id)) {
return $response->task_id;
// @codingStandardsIgnoreEnd
}
return $response;
} | php | public function deleteBackup($backupId, $callbackUrl, $callbackMethod, $callerData)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId;
$params = [
'callback_url' => $callbackUrl,
'callback_method' => $callbackMethod,
'callerData' => $callerData,
];
$response = $this->connector->connecting($url, $params, 'DELETE');
// @codingStandardsIgnoreStart
if (isset($response->task_id)) {
return $response->task_id;
// @codingStandardsIgnoreEnd
}
return $response;
} | [
"public",
"function",
"deleteBackup",
"(",
"$",
"backupId",
",",
"$",
"callbackUrl",
",",
"$",
"callbackMethod",
",",
"$",
"callerData",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
"===",
"null",
")",
"{",
"return",
"'Cannot find site URL from configuration.'",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
".",
"self",
"::",
"VERSION",
".",
"$",
"this",
"->",
"connector",
"->",
"getSiteID",
"(",
")",
".",
"'/backups/'",
".",
"$",
"backupId",
";",
"$",
"params",
"=",
"[",
"'callback_url'",
"=>",
"$",
"callbackUrl",
",",
"'callback_method'",
"=>",
"$",
"callbackMethod",
",",
"'callerData'",
"=>",
"$",
"callerData",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connector",
"->",
"connecting",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'DELETE'",
")",
";",
"// @codingStandardsIgnoreStart",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"task_id",
")",
")",
"{",
"return",
"$",
"response",
"->",
"task_id",
";",
"// @codingStandardsIgnoreEnd",
"}",
"return",
"$",
"response",
";",
"}"
] | Delete backup.
@param int $backupId BackupId.
@param string $callbackUrl Callback URL.
@param string $callbackMethod Callback method.
@param string $callerData Caller data in JSON format.
@return mixed|string | [
"Delete",
"backup",
"."
] | c9dbb9dfd71408adff0ea26db94678a61c584df6 | https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L87-L108 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.