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 list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
yajra/cms-core | src/Http/Controllers/UtilitiesController.php | UtilitiesController.views | public function views()
{
Artisan::call('view:clear');
$this->log->info(sprintf("%s %s",
trans('cms::utilities.views.success'),
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
return $this->notifySuccess(trans('cms::utilities.views.success'));
} | php | public function views()
{
Artisan::call('view:clear');
$this->log->info(sprintf("%s %s",
trans('cms::utilities.views.success'),
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
return $this->notifySuccess(trans('cms::utilities.views.success'));
} | [
"public",
"function",
"views",
"(",
")",
"{",
"Artisan",
"::",
"call",
"(",
"'view:clear'",
")",
";",
"$",
"this",
"->",
"log",
"->",
"info",
"(",
"sprintf",
"(",
"\"%s %s\"",
",",
"trans",
"(",
"'cms::utilities.views.success'",
")",
",",
"trans",
"(",
"... | Clear views manually.
@return \Illuminate\Http\JsonResponse | [
"Clear",
"views",
"manually",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UtilitiesController.php#L144-L153 | train |
yajra/cms-core | src/Http/Controllers/UtilitiesController.php | UtilitiesController.route | public function route($task)
{
if (! in_array($task, ['cache', 'clear'])) {
$this->log->info(sprintf("%s %s",
trans('cms::utilities.route.not_allowed', ['task' => $task]),
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
return $this->notifyError($message);
}
$message = $task == 'cache' ? trans('cms::utilities.route.cached') : trans('cms::utilities.route.cleared');
$this->log->info(sprintf("%s %s",
$message,
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
try {
Artisan::call('route:' . $task);
} catch (\Exception $e) {
return $this->notifyError($e->getMessage());
}
return $this->notifySuccess($message);
} | php | public function route($task)
{
if (! in_array($task, ['cache', 'clear'])) {
$this->log->info(sprintf("%s %s",
trans('cms::utilities.route.not_allowed', ['task' => $task]),
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
return $this->notifyError($message);
}
$message = $task == 'cache' ? trans('cms::utilities.route.cached') : trans('cms::utilities.route.cleared');
$this->log->info(sprintf("%s %s",
$message,
trans('cms::utilities.field.executed_by', ['name' => $this->getCurrentUserName()])
));
try {
Artisan::call('route:' . $task);
} catch (\Exception $e) {
return $this->notifyError($e->getMessage());
}
return $this->notifySuccess($message);
} | [
"public",
"function",
"route",
"(",
"$",
"task",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"task",
",",
"[",
"'cache'",
",",
"'clear'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"info",
"(",
"sprintf",
"(",
"\"%s %s\"",
",",
"tran... | Clear routes manually.
@return \Illuminate\Http\JsonResponse | [
"Clear",
"routes",
"manually",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UtilitiesController.php#L160-L183 | train |
yajra/cms-core | src/Http/Controllers/UtilitiesController.php | UtilitiesController.logs | public function logs(Request $request, DataTables $dataTables)
{
if ($request->input('l')) {
LaravelLogViewer::setFile(base64_decode($request->input('l')));
}
if ($request->input('dl')) {
return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($request->input('dl'))));
} elseif ($request->has('del')) {
File::delete(LaravelLogViewer::pathToLogFile(base64_decode($request->input('del'))));
return redirect()->to($request->url());
}
$logs = LaravelLogViewer::all();
if ($request->wantsJson()) {
return $dataTables->collection(collect($logs))
->editColumn('stack', '{!! nl2br($stack) !!}')
->editColumn('level', function ($log) {
$content = html()->tag('span', '', [
'class' => "glyphicon glyphicon-{$log['level_img']}-sign",
]);
$content .= ' ' . $log['level'];
return html()->tag('span', $content, ['class' => "text-{$log['level_class']}"]);
})
->addColumn('content', function ($log) {
$html = '';
if ($log['stack']) {
$html = '<a class="pull-right expand btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></a>';
}
$html .= $log['text'];
if (isset($log['in_file'])) {
$html .= '<br>' . $log['in_file'];
}
return $html;
})
->rawColumns(['content'])
->toJson();
}
return view('administrator.utilities.log', [
'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName(),
]);
} | php | public function logs(Request $request, DataTables $dataTables)
{
if ($request->input('l')) {
LaravelLogViewer::setFile(base64_decode($request->input('l')));
}
if ($request->input('dl')) {
return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($request->input('dl'))));
} elseif ($request->has('del')) {
File::delete(LaravelLogViewer::pathToLogFile(base64_decode($request->input('del'))));
return redirect()->to($request->url());
}
$logs = LaravelLogViewer::all();
if ($request->wantsJson()) {
return $dataTables->collection(collect($logs))
->editColumn('stack', '{!! nl2br($stack) !!}')
->editColumn('level', function ($log) {
$content = html()->tag('span', '', [
'class' => "glyphicon glyphicon-{$log['level_img']}-sign",
]);
$content .= ' ' . $log['level'];
return html()->tag('span', $content, ['class' => "text-{$log['level_class']}"]);
})
->addColumn('content', function ($log) {
$html = '';
if ($log['stack']) {
$html = '<a class="pull-right expand btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></a>';
}
$html .= $log['text'];
if (isset($log['in_file'])) {
$html .= '<br>' . $log['in_file'];
}
return $html;
})
->rawColumns(['content'])
->toJson();
}
return view('administrator.utilities.log', [
'logs' => $logs,
'files' => LaravelLogViewer::getFiles(true),
'current_file' => LaravelLogViewer::getFileName(),
]);
} | [
"public",
"function",
"logs",
"(",
"Request",
"$",
"request",
",",
"DataTables",
"$",
"dataTables",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"input",
"(",
"'l'",
")",
")",
"{",
"LaravelLogViewer",
"::",
"setFile",
"(",
"base64_decode",
"(",
"$",
"reque... | Log viewer.
@param \Illuminate\Http\Request $request
@param \Yajra\DataTables\DataTables $dataTables
@return \Illuminate\Http\JsonResponse
@throws \Exception | [
"Log",
"viewer",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/UtilitiesController.php#L193-L244 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.generate | public function generate($input, $output, array $options = array(),
$overwrite = false)
{
$this->log(sprintf(
'Generate from file (%s) to file (%s)',
$input, $output
));
return $this->getGenerator()->generate(
$input, $output, $options, $overwrite
);
} | php | public function generate($input, $output, array $options = array(),
$overwrite = false)
{
$this->log(sprintf(
'Generate from file (%s) to file (%s)',
$input, $output
));
return $this->getGenerator()->generate(
$input, $output, $options, $overwrite
);
} | [
"public",
"function",
"generate",
"(",
"$",
"input",
",",
"$",
"output",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Generate from file (%s) to file... | Generates the output media file from the specified input HTML file
@param string $input The input HTML filename or URL
@param string $output The output media filename
@param array $options An array of options for this generation only
@param bool $overwrite Overwrite the file if it exists. If not, throw an InvalidArgumentException | [
"Generates",
"the",
"output",
"media",
"file",
"from",
"the",
"specified",
"input",
"HTML",
"file"
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L148-L159 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.generateFromHtml | public function generateFromHtml($html, $output, array $options = array(),
$overwrite = false)
{
$this->log(sprintf('Generate output in file (%s) from html.', $output));
return $this->getGenerator()->generateFromHtml(
$html, $output, $options, $overwrite
);
} | php | public function generateFromHtml($html, $output, array $options = array(),
$overwrite = false)
{
$this->log(sprintf('Generate output in file (%s) from html.', $output));
return $this->getGenerator()->generateFromHtml(
$html, $output, $options, $overwrite
);
} | [
"public",
"function",
"generateFromHtml",
"(",
"$",
"html",
",",
"$",
"output",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Generate output in file ... | Generates the output media file from the given HTML
@param string $html The HTML to be converted
@param string $output The output media filename
@param array $options An array of options for this generation only
@param bool $overwrite Overwrite the file if it exists. If not, throw an InvalidArgumentException | [
"Generates",
"the",
"output",
"media",
"file",
"from",
"the",
"given",
"HTML"
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L169-L177 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.getOutput | public function getOutput($input, array $options = array())
{
$this->log(sprintf('Getting output from file (%s)', $input));
return $this->getGenerator()->getOutput($input, $options);
} | php | public function getOutput($input, array $options = array())
{
$this->log(sprintf('Getting output from file (%s)', $input));
return $this->getGenerator()->getOutput($input, $options);
} | [
"public",
"function",
"getOutput",
"(",
"$",
"input",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Getting output from file (%s)'",
",",
"$",
"input",
")",
")",
";",
"return",
"$",
"th... | Returns the output of the media generated from the specified input HTML
file
@param string $input The input HTML filename or URL
@param array $options An array of options for this output only
@return string | [
"Returns",
"the",
"output",
"of",
"the",
"media",
"generated",
"from",
"the",
"specified",
"input",
"HTML",
"file"
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L188-L193 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.getOutputFromView | public function getOutputFromView($view, array $parameters = array(),
array $options = array())
{
$this->log(sprintf('Get converted output from view (%s).', $view));
$html = $this->getTemplatingEngine()->render($view, $parameters);
return $this->getOutputFromHtml($html, $options);
} | php | public function getOutputFromView($view, array $parameters = array(),
array $options = array())
{
$this->log(sprintf('Get converted output from view (%s).', $view));
$html = $this->getTemplatingEngine()->render($view, $parameters);
return $this->getOutputFromHtml($html, $options);
} | [
"public",
"function",
"getOutputFromView",
"(",
"$",
"view",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Get converted output fr... | Retrieve the output from a Symfony view. This uses the selected
template engine and renders it trough that.
@param string $view
@param array $parameters
@param array $options
@return string | [
"Retrieve",
"the",
"output",
"from",
"a",
"Symfony",
"view",
".",
"This",
"uses",
"the",
"selected",
"template",
"engine",
"and",
"renders",
"it",
"trough",
"that",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L222-L230 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.downloadFromView | public function downloadFromView($view, array $parameters = array(),
array $options = array())
{
$this->log(sprintf('Download pdf from view (%s).', $view));
$contentDisposition = 'attachment; filename="' . $this->getName() . '"';
return $this->generateResponse($view, $contentDisposition, $parameters,
$options);
} | php | public function downloadFromView($view, array $parameters = array(),
array $options = array())
{
$this->log(sprintf('Download pdf from view (%s).', $view));
$contentDisposition = 'attachment; filename="' . $this->getName() . '"';
return $this->generateResponse($view, $contentDisposition, $parameters,
$options);
} | [
"public",
"function",
"downloadFromView",
"(",
"$",
"view",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Download pdf from view (... | From a given view and parameters, create the proper response so we can
easily download the file.
@param string $view
@param array $parameters
@param array $options Additional options for WKHTMLToPDF.
@return Response | [
"From",
"a",
"given",
"view",
"and",
"parameters",
"create",
"the",
"proper",
"response",
"so",
"we",
"can",
"easily",
"download",
"the",
"file",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L241-L249 | train |
siphoc/PdfBundle | Generator/PdfGenerator.php | PdfGenerator.generateResponse | private function generateResponse($view, $contentDisposition, $parameters,
$options)
{
return new Response(
$this->getOutputFromView($view, $parameters, $options),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => $contentDisposition,
)
);
} | php | private function generateResponse($view, $contentDisposition, $parameters,
$options)
{
return new Response(
$this->getOutputFromView($view, $parameters, $options),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => $contentDisposition,
)
);
} | [
"private",
"function",
"generateResponse",
"(",
"$",
"view",
",",
"$",
"contentDisposition",
",",
"$",
"parameters",
",",
"$",
"options",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"getOutputFromView",
"(",
"$",
"view",
",",
"$",
"param... | Create a Response object for the inputted data.
@param string $view
@param string $contentDisposition
@param array $parameters
@param array $options Additional options for WKHTMLToPDF. | [
"Create",
"a",
"Response",
"object",
"for",
"the",
"inputted",
"data",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Generator/PdfGenerator.php#L305-L316 | train |
yajra/cms-core | src/Providers/CoreServiceProvider.php | CoreServiceProvider.bootCustomBladeDirectives | protected function bootCustomBladeDirectives()
{
/** @var BladeCompiler $blade */
$blade = $this->app['blade.compiler'];
$blade->directive('tooltip', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\TooltipDirective')->handle({$expression}); ?>";
});
$blade->directive('pageHeader', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\PageHeaderDirective')->handle({$expression}); ?>";
});
$blade->directive('error', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\ErrorDirective')->handle({$expression}); ?>";
});
} | php | protected function bootCustomBladeDirectives()
{
/** @var BladeCompiler $blade */
$blade = $this->app['blade.compiler'];
$blade->directive('tooltip', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\TooltipDirective')->handle({$expression}); ?>";
});
$blade->directive('pageHeader', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\PageHeaderDirective')->handle({$expression}); ?>";
});
$blade->directive('error', function ($expression) {
return "<?php echo app('Yajra\\CMS\\View\\Directives\\ErrorDirective')->handle({$expression}); ?>";
});
} | [
"protected",
"function",
"bootCustomBladeDirectives",
"(",
")",
"{",
"/** @var BladeCompiler $blade */",
"$",
"blade",
"=",
"$",
"this",
"->",
"app",
"[",
"'blade.compiler'",
"]",
";",
"$",
"blade",
"->",
"directive",
"(",
"'tooltip'",
",",
"function",
"(",
"$",... | Boot custom blade directives. | [
"Boot",
"custom",
"blade",
"directives",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/CoreServiceProvider.php#L43-L58 | train |
yajra/cms-core | src/Providers/CoreServiceProvider.php | CoreServiceProvider.registerProviders | protected function registerProviders()
{
$this->app->register(ConfigurationServiceProvider::class);
$this->app->register(RouteServiceProvider::class);
$this->app->register(ViewComposerServiceProvider::class);
$this->app->register(BaumServiceProvider::class);
$this->app->register(RepositoryServiceProvider::class);
$this->app->register(FormServiceProvider::class);
$this->app->register(WidgetServiceProvider::class);
$this->app->register(TaggingServiceProvider::class);
} | php | protected function registerProviders()
{
$this->app->register(ConfigurationServiceProvider::class);
$this->app->register(RouteServiceProvider::class);
$this->app->register(ViewComposerServiceProvider::class);
$this->app->register(BaumServiceProvider::class);
$this->app->register(RepositoryServiceProvider::class);
$this->app->register(FormServiceProvider::class);
$this->app->register(WidgetServiceProvider::class);
$this->app->register(TaggingServiceProvider::class);
} | [
"protected",
"function",
"registerProviders",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"ConfigurationServiceProvider",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"register",
"(",
"RouteServiceProvider",
"::",
"class",
")",
... | Registered required administrator providers. | [
"Registered",
"required",
"administrator",
"providers",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/CoreServiceProvider.php#L106-L116 | train |
yajra/cms-core | src/Providers/CoreServiceProvider.php | CoreServiceProvider.registerBindings | protected function registerBindings()
{
$this->app->singleton(PageHeaderDirective::class, PageHeaderDirective::class);
$this->app->singleton(TooltipDirective::class, TooltipDirective::class);
$this->app->singleton(SearchEngine::class, LocalSearch::class);
} | php | protected function registerBindings()
{
$this->app->singleton(PageHeaderDirective::class, PageHeaderDirective::class);
$this->app->singleton(TooltipDirective::class, TooltipDirective::class);
$this->app->singleton(SearchEngine::class, LocalSearch::class);
} | [
"protected",
"function",
"registerBindings",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"PageHeaderDirective",
"::",
"class",
",",
"PageHeaderDirective",
"::",
"class",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"Toolti... | Register IOC bindings. | [
"Register",
"IOC",
"bindings",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/CoreServiceProvider.php#L121-L126 | train |
yajra/cms-core | src/Http/Controllers/RolesController.php | RolesController.create | public function create()
{
$role = new Role;
$permissions = Permission::all();
$selectedPermissions = $this->request->old('permissions', []);
return view('administrator.roles.create', compact('role', 'permissions', 'selectedPermissions'));
} | php | public function create()
{
$role = new Role;
$permissions = Permission::all();
$selectedPermissions = $this->request->old('permissions', []);
return view('administrator.roles.create', compact('role', 'permissions', 'selectedPermissions'));
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"role",
"=",
"new",
"Role",
";",
"$",
"permissions",
"=",
"Permission",
"::",
"all",
"(",
")",
";",
"$",
"selectedPermissions",
"=",
"$",
"this",
"->",
"request",
"->",
"old",
"(",
"'permissions'",
",... | Show role form.
@return \Illuminate\View\View | [
"Show",
"role",
"form",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/RolesController.php#L45-L52 | train |
yajra/cms-core | src/Http/Controllers/RolesController.php | RolesController.store | public function store()
{
$this->validate($this->request, [
'name' => 'required',
'slug' => 'required|unique:roles,slug',
]);
$role = Role::create($this->request->all());
$role->syncPermissions($this->request->get('permissions', []));
flash()->success('Role ' . $role->name . ' successfully created!');
return redirect()->route('administrator.roles.index');
} | php | public function store()
{
$this->validate($this->request, [
'name' => 'required',
'slug' => 'required|unique:roles,slug',
]);
$role = Role::create($this->request->all());
$role->syncPermissions($this->request->get('permissions', []));
flash()->success('Role ' . $role->name . ' successfully created!');
return redirect()->route('administrator.roles.index');
} | [
"public",
"function",
"store",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"this",
"->",
"request",
",",
"[",
"'name'",
"=>",
"'required'",
",",
"'slug'",
"=>",
"'required|unique:roles,slug'",
",",
"]",
")",
";",
"$",
"role",
"=",
"Role",
"... | Store a newly created role.
@return \Illuminate\Http\RedirectResponse | [
"Store",
"a",
"newly",
"created",
"role",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/RolesController.php#L59-L71 | train |
yajra/cms-core | src/Http/Controllers/RolesController.php | RolesController.update | public function update(Role $role)
{
$this->validate($this->request, [
'name' => 'required',
'slug' => 'required|unique:roles,slug,' . $role->id,
]);
$role->name = $this->request->get('name');
if (! $role->system) {
$role->slug = $this->request->get('slug');
}
$role->save();
$role->syncPermissions($this->request->get('permissions', []));
flash()->success('Role ' . $role->name . ' successfully updated!');
return redirect()->route('administrator.roles.index');
} | php | public function update(Role $role)
{
$this->validate($this->request, [
'name' => 'required',
'slug' => 'required|unique:roles,slug,' . $role->id,
]);
$role->name = $this->request->get('name');
if (! $role->system) {
$role->slug = $this->request->get('slug');
}
$role->save();
$role->syncPermissions($this->request->get('permissions', []));
flash()->success('Role ' . $role->name . ' successfully updated!');
return redirect()->route('administrator.roles.index');
} | [
"public",
"function",
"update",
"(",
"Role",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"this",
"->",
"request",
",",
"[",
"'name'",
"=>",
"'required'",
",",
"'slug'",
"=>",
"'required|unique:roles,slug,'",
".",
"$",
"role",
"->",
"i... | Update role permission.
@param \Yajra\Acl\Models\Role $role
@return \Illuminate\Http\RedirectResponse | [
"Update",
"role",
"permission",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/RolesController.php#L92-L109 | train |
yajra/cms-core | src/Http/Controllers/RolesController.php | RolesController.destroy | public function destroy(Role $role)
{
if (! $role->system) {
try {
$role->delete();
return $this->notifySuccess('Role successfully deleted!');
} catch (QueryException $e) {
return $this->notifyError($e->getMessage());
}
}
return $this->notifyError('Role is protected and cannot be deleted!');
} | php | public function destroy(Role $role)
{
if (! $role->system) {
try {
$role->delete();
return $this->notifySuccess('Role successfully deleted!');
} catch (QueryException $e) {
return $this->notifyError($e->getMessage());
}
}
return $this->notifyError('Role is protected and cannot be deleted!');
} | [
"public",
"function",
"destroy",
"(",
"Role",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"$",
"role",
"->",
"system",
")",
"{",
"try",
"{",
"$",
"role",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"notifySuccess",
"(",
"'Role successfully... | Remove selected role.
@param \Yajra\Acl\Models\Role $role
@return \Illuminate\Http\RedirectResponse | [
"Remove",
"selected",
"role",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/RolesController.php#L117-L130 | train |
eviweb/fuelphp-phpcs | src/evidev/fuelphpcs/CLI.php | CLI.printPHPCSUsage | public function printPHPCSUsage()
{
ob_start();
parent::printPHPCSUsage();
$help = ob_get_contents();
ob_end_clean();
echo $this->fixHelp($help);
} | php | public function printPHPCSUsage()
{
ob_start();
parent::printPHPCSUsage();
$help = ob_get_contents();
ob_end_clean();
echo $this->fixHelp($help);
} | [
"public",
"function",
"printPHPCSUsage",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"parent",
"::",
"printPHPCSUsage",
"(",
")",
";",
"$",
"help",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"fixHelp",
... | Prints out the usage information for PHPCS.
@return void | [
"Prints",
"out",
"the",
"usage",
"information",
"for",
"PHPCS",
"."
] | 6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be | https://github.com/eviweb/fuelphp-phpcs/blob/6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be/src/evidev/fuelphpcs/CLI.php#L113-L121 | train |
eviweb/fuelphp-phpcs | src/evidev/fuelphpcs/CLI.php | CLI.fixHelp | private function fixHelp($help)
{
$help = $this->fixCLIName($help);
$help = $this->fixStandard($help);
return $help;
} | php | private function fixHelp($help)
{
$help = $this->fixCLIName($help);
$help = $this->fixStandard($help);
return $help;
} | [
"private",
"function",
"fixHelp",
"(",
"$",
"help",
")",
"{",
"$",
"help",
"=",
"$",
"this",
"->",
"fixCLIName",
"(",
"$",
"help",
")",
";",
"$",
"help",
"=",
"$",
"this",
"->",
"fixStandard",
"(",
"$",
"help",
")",
";",
"return",
"$",
"help",
";... | alter the PHP_CodeSniffer_CLI usage message to match FuelPHPCS
@param string $help PHP_CodeSniffer_CLI usage message to alter
@return string returns the usage message updated | [
"alter",
"the",
"PHP_CodeSniffer_CLI",
"usage",
"message",
"to",
"match",
"FuelPHPCS"
] | 6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be | https://github.com/eviweb/fuelphp-phpcs/blob/6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be/src/evidev/fuelphpcs/CLI.php#L139-L145 | train |
PendalF89/yii2-blog | models/Post.php | Post.getThumbnailImage | public function getThumbnailImage($alias, $options=[])
{
$thumbnail = $this->getThumbnailModel();
if (empty($thumbnail)) {
return '';
}
return $thumbnail->getThumbImage($alias, $options);
} | php | public function getThumbnailImage($alias, $options=[])
{
$thumbnail = $this->getThumbnailModel();
if (empty($thumbnail)) {
return '';
}
return $thumbnail->getThumbImage($alias, $options);
} | [
"public",
"function",
"getThumbnailImage",
"(",
"$",
"alias",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"thumbnail",
"=",
"$",
"this",
"->",
"getThumbnailModel",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"thumbnail",
")",
")",
"{",
"retur... | Html thumbnail image tag
@param string $alias thumbnail alias
@param array $options html options
@return string Html image tag | [
"Html",
"thumbnail",
"image",
"tag"
] | 1e60195c952b0fb85f0925abe1c2f2e9094e86fa | https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/models/Post.php#L198-L207 | train |
brick/reflection | src/ImportResolver.php | ImportResolver.getDeclaringClass | private function getDeclaringClass(\Reflector $reflector) : ?\ReflectionClass
{
if ($reflector instanceof \ReflectionClass) {
return $reflector;
}
if ($reflector instanceof \ReflectionProperty) {
return $reflector->getDeclaringClass();
}
if ($reflector instanceof \ReflectionMethod) {
return $reflector->getDeclaringClass();
}
if ($reflector instanceof \ReflectionParameter) {
return $reflector->getDeclaringClass();
}
return null;
} | php | private function getDeclaringClass(\Reflector $reflector) : ?\ReflectionClass
{
if ($reflector instanceof \ReflectionClass) {
return $reflector;
}
if ($reflector instanceof \ReflectionProperty) {
return $reflector->getDeclaringClass();
}
if ($reflector instanceof \ReflectionMethod) {
return $reflector->getDeclaringClass();
}
if ($reflector instanceof \ReflectionParameter) {
return $reflector->getDeclaringClass();
}
return null;
} | [
"private",
"function",
"getDeclaringClass",
"(",
"\\",
"Reflector",
"$",
"reflector",
")",
":",
"?",
"\\",
"ReflectionClass",
"{",
"if",
"(",
"$",
"reflector",
"instanceof",
"\\",
"ReflectionClass",
")",
"{",
"return",
"$",
"reflector",
";",
"}",
"if",
"(",
... | Returns the ReflectionClass of the given Reflector.
@param \Reflector $reflector
@return \ReflectionClass|null | [
"Returns",
"the",
"ReflectionClass",
"of",
"the",
"given",
"Reflector",
"."
] | 4c1736b1ef0d27cf651c5f08c61751b379697d0b | https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ImportResolver.php#L67-L86 | train |
Speicher210/CloudinaryBundle | Twig/Extension/CloudinaryExtension.php | CloudinaryExtension.getUrl | public function getUrl($id, $options = [])
{
$cloudinary = $this->cloudinary;
return $cloudinary::cloudinary_url($id, $options);
} | php | public function getUrl($id, $options = [])
{
$cloudinary = $this->cloudinary;
return $cloudinary::cloudinary_url($id, $options);
} | [
"public",
"function",
"getUrl",
"(",
"$",
"id",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"cloudinary",
"=",
"$",
"this",
"->",
"cloudinary",
";",
"return",
"$",
"cloudinary",
"::",
"cloudinary_url",
"(",
"$",
"id",
",",
"$",
"options",
")",... | Get the cloudinary URL.
@param string $id Public ID.
@param array $options options for the image.
@return string | [
"Get",
"the",
"cloudinary",
"URL",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Twig/Extension/CloudinaryExtension.php#L57-L62 | train |
madewithlove/phpunit-snapshots | src/SnapshotsManager.php | SnapshotsManager.getAssertionIdentifier | public static function getAssertionIdentifier($identifier = null)
{
// Keep a registry of how many assertions were run
// in this test suite, and in this test
$methodName = static::$suite->getName();
static::$assertionsInTest[$methodName] = isset(static::$assertionsInTest[$methodName])
? static::$assertionsInTest[$methodName]
: -1;
$name = $methodName.'-'.++static::$assertionsInTest[$methodName];
$name = $identifier ? $name.': '.$identifier : $name;
return $name;
} | php | public static function getAssertionIdentifier($identifier = null)
{
// Keep a registry of how many assertions were run
// in this test suite, and in this test
$methodName = static::$suite->getName();
static::$assertionsInTest[$methodName] = isset(static::$assertionsInTest[$methodName])
? static::$assertionsInTest[$methodName]
: -1;
$name = $methodName.'-'.++static::$assertionsInTest[$methodName];
$name = $identifier ? $name.': '.$identifier : $name;
return $name;
} | [
"public",
"static",
"function",
"getAssertionIdentifier",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"// Keep a registry of how many assertions were run",
"// in this test suite, and in this test",
"$",
"methodName",
"=",
"static",
"::",
"$",
"suite",
"->",
"getName",
... | Get an unique identifier for this particular assertion.
@param string|null $identifier
@return string | [
"Get",
"an",
"unique",
"identifier",
"for",
"this",
"particular",
"assertion",
"."
] | a7924d66b25955ed036cea97aaa50f35c022dfca | https://github.com/madewithlove/phpunit-snapshots/blob/a7924d66b25955ed036cea97aaa50f35c022dfca/src/SnapshotsManager.php#L106-L119 | train |
yajra/cms-core | src/Http/Middleware/DynamicMenusBuilder.php | DynamicMenusBuilder.generateMenu | protected function generateMenu($menuBuilder, $menu)
{
$subMenu = $this->registerMenu($menuBuilder, $menu);
$menu->children->each(function (Menu $subItem) use ($subMenu) {
$subMenuChild = $this->registerMenu($subMenu, $subItem);
if (count($subItem->children)) {
$this->generateMenu($subMenuChild, $subItem);
}
});
} | php | protected function generateMenu($menuBuilder, $menu)
{
$subMenu = $this->registerMenu($menuBuilder, $menu);
$menu->children->each(function (Menu $subItem) use ($subMenu) {
$subMenuChild = $this->registerMenu($subMenu, $subItem);
if (count($subItem->children)) {
$this->generateMenu($subMenuChild, $subItem);
}
});
} | [
"protected",
"function",
"generateMenu",
"(",
"$",
"menuBuilder",
",",
"$",
"menu",
")",
"{",
"$",
"subMenu",
"=",
"$",
"this",
"->",
"registerMenu",
"(",
"$",
"menuBuilder",
",",
"$",
"menu",
")",
";",
"$",
"menu",
"->",
"children",
"->",
"each",
"(",... | Generate the menu.
@param \Caffeinated\Menus\Builder|\Caffeinated\Menus\Item $menuBuilder
@param \Yajra\CMS\Entities\Menu $menu | [
"Generate",
"the",
"menu",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Middleware/DynamicMenusBuilder.php#L50-L59 | train |
siphoc/PdfBundle | Converter/JSToHTML.php | JSToHTML.convertToString | public function convertToString($html)
{
$externalJavaScript = $this->extractExternalJavaScript($html);
return $this->replaceJavaScriptTags($html, $externalJavaScript);
} | php | public function convertToString($html)
{
$externalJavaScript = $this->extractExternalJavaScript($html);
return $this->replaceJavaScriptTags($html, $externalJavaScript);
} | [
"public",
"function",
"convertToString",
"(",
"$",
"html",
")",
"{",
"$",
"externalJavaScript",
"=",
"$",
"this",
"->",
"extractExternalJavaScript",
"(",
"$",
"html",
")",
";",
"return",
"$",
"this",
"->",
"replaceJavaScriptTags",
"(",
"$",
"html",
",",
"$",... | Extract all the linked JS files and put them in the proper place on the
given HTML string.
@param string $html
@return string | [
"Extract",
"all",
"the",
"linked",
"JS",
"files",
"and",
"put",
"them",
"in",
"the",
"proper",
"place",
"on",
"the",
"given",
"HTML",
"string",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/JSToHTML.php#L53-L58 | train |
siphoc/PdfBundle | Converter/JSToHTML.php | JSToHTML.extractExternalJavaScript | public function extractExternalJavaScript($html)
{
$matches = array();
preg_match_all(
'!' . $this->getExternalJavaScriptRegex() . '!isU',
$html, $matches
);
$links = $this->createJavaScriptPaths($matches['links']);
return array('tags' => $matches[0], 'links' => $links);
} | php | public function extractExternalJavaScript($html)
{
$matches = array();
preg_match_all(
'!' . $this->getExternalJavaScriptRegex() . '!isU',
$html, $matches
);
$links = $this->createJavaScriptPaths($matches['links']);
return array('tags' => $matches[0], 'links' => $links);
} | [
"public",
"function",
"extractExternalJavaScript",
"(",
"$",
"html",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"'!'",
".",
"$",
"this",
"->",
"getExternalJavaScriptRegex",
"(",
")",
".",
"'!isU'",
",",
"$",
"html",
",",
... | Given a HTML string, find all the JS files that should be loaded.
@param string $html
@return array | [
"Given",
"a",
"HTML",
"string",
"find",
"all",
"the",
"JS",
"files",
"that",
"should",
"be",
"loaded",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/JSToHTML.php#L66-L78 | train |
siphoc/PdfBundle | Converter/JSToHTML.php | JSToHTML.createJavaScriptPaths | private function createJavaScriptPaths(array $javascripts)
{
$files = array();
foreach ($javascripts as $file) {
if (!$this->isExternalJavaScriptFile($file)) {
if (false !== strpos($file, '?')) {
$file = strstr($file, '?', true);
}
$file = $this->getBasePath() . $file;
}
$files[] = $file;
}
return $files;
} | php | private function createJavaScriptPaths(array $javascripts)
{
$files = array();
foreach ($javascripts as $file) {
if (!$this->isExternalJavaScriptFile($file)) {
if (false !== strpos($file, '?')) {
$file = strstr($file, '?', true);
}
$file = $this->getBasePath() . $file;
}
$files[] = $file;
}
return $files;
} | [
"private",
"function",
"createJavaScriptPaths",
"(",
"array",
"$",
"javascripts",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"javascripts",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isExternalJavaScri... | Check if a JavaScript file is a local or externalJavaScript file or. If
it is a local file, prepend our basepath to the link so we can properly
fetch the data to insert.
@param array $javascripts
@return array | [
"Check",
"if",
"a",
"JavaScript",
"file",
"is",
"a",
"local",
"or",
"externalJavaScript",
"file",
"or",
".",
"If",
"it",
"is",
"a",
"local",
"file",
"prepend",
"our",
"basepath",
"to",
"the",
"link",
"so",
"we",
"can",
"properly",
"fetch",
"the",
"data",... | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/JSToHTML.php#L121-L139 | train |
siphoc/PdfBundle | Converter/JSToHTML.php | JSToHTML.getJavaScriptContent | private function getJavaScriptContent($path)
{
if ($this->isExternalJavaScriptFile($path)) {
$fileData = $this->getRequestHandler()->getContent($path);
} else {
$fileData = '';
if (file_exists($path)) {
$fileData = file_get_contents($path);
}
}
return "<script type=\"text/javascript\">\n" . $fileData . "</script>";
} | php | private function getJavaScriptContent($path)
{
if ($this->isExternalJavaScriptFile($path)) {
$fileData = $this->getRequestHandler()->getContent($path);
} else {
$fileData = '';
if (file_exists($path)) {
$fileData = file_get_contents($path);
}
}
return "<script type=\"text/javascript\">\n" . $fileData . "</script>";
} | [
"private",
"function",
"getJavaScriptContent",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isExternalJavaScriptFile",
"(",
"$",
"path",
")",
")",
"{",
"$",
"fileData",
"=",
"$",
"this",
"->",
"getRequestHandler",
"(",
")",
"->",
"getContent"... | Fetch the content of a JavaScript file from a given path.
@param string $path
@return string | [
"Fetch",
"the",
"content",
"of",
"a",
"JavaScript",
"file",
"from",
"a",
"given",
"path",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/JSToHTML.php#L157-L169 | train |
siphoc/PdfBundle | Converter/JSToHTML.php | JSToHTML.replaceJavaScriptTags | private function replaceJavaScriptTags($html, array $javaScriptFiles)
{
foreach ($javaScriptFiles['links'] as $key => $file) {
if (!$this->isExternalJavaScriptFile($file)) {
$html = str_replace(
$javaScriptFiles['tags'][$key],
$this->getJavaScriptContent($file),
$html
);
}
}
return $html;
} | php | private function replaceJavaScriptTags($html, array $javaScriptFiles)
{
foreach ($javaScriptFiles['links'] as $key => $file) {
if (!$this->isExternalJavaScriptFile($file)) {
$html = str_replace(
$javaScriptFiles['tags'][$key],
$this->getJavaScriptContent($file),
$html
);
}
}
return $html;
} | [
"private",
"function",
"replaceJavaScriptTags",
"(",
"$",
"html",
",",
"array",
"$",
"javaScriptFiles",
")",
"{",
"foreach",
"(",
"$",
"javaScriptFiles",
"[",
"'links'",
"]",
"as",
"$",
"key",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"... | Replace the JavaScript tags that do external requests with inline
script blocks.
@param string $html
@param array $javaScriptFiles
@return string | [
"Replace",
"the",
"JavaScript",
"tags",
"that",
"do",
"external",
"requests",
"with",
"inline",
"script",
"blocks",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Converter/JSToHTML.php#L197-L210 | train |
yajra/cms-core | src/Entities/Configuration.php | Configuration.key | public static function key($key)
{
$config = static::where('key', $key)->first();
return $config->value ?? config($key, null);
} | php | public static function key($key)
{
$config = static::where('key', $key)->first();
return $config->value ?? config($key, null);
} | [
"public",
"static",
"function",
"key",
"(",
"$",
"key",
")",
"{",
"$",
"config",
"=",
"static",
"::",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
"->",
"first",
"(",
")",
";",
"return",
"$",
"config",
"->",
"value",
"??",
"config",
"(",
"$",
"ke... | Get value by key.
@param string $key
@return string | [
"Get",
"value",
"by",
"key",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Configuration.php#L31-L36 | train |
yajra/cms-core | src/Presenters/CategoryPresenter.php | CategoryPresenter.slugList | public function slugList()
{
$categories = explode('/', $this->alias());
$html = [];
foreach ($categories as $category) {
$html[] = new HtmlString('<span class="label label-info">' . e(Str::title($category)) . '</span> ');
}
return new HtmlString(implode('', $html));
} | php | public function slugList()
{
$categories = explode('/', $this->alias());
$html = [];
foreach ($categories as $category) {
$html[] = new HtmlString('<span class="label label-info">' . e(Str::title($category)) . '</span> ');
}
return new HtmlString(implode('', $html));
} | [
"public",
"function",
"slugList",
"(",
")",
"{",
"$",
"categories",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"alias",
"(",
")",
")",
";",
"$",
"html",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"category",
")",
"... | Display nested categories of the article.
@return \Illuminate\Support\HtmlString | [
"Display",
"nested",
"categories",
"of",
"the",
"article",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/CategoryPresenter.php#L61-L71 | train |
swoft-cloud/swoft-websocket-server | src/Command/WsCommand.php | WsCommand.start | public function start()
{
$server = $this->createServerManager();
// 是否正在运行
if ($server->isRunning()) {
$serverOpts = $server->getServerSetting();
\output()->writeln("<error>The server have been running!(PID: {$serverOpts['masterPid']})</error>", true, true);
} else {
$serverOpts = $server->getServerSetting();
}
// 启动参数
$this->configServer($server);
$ws = $server->getWsSettings();
$tcp = $server->getTcpSetting();
// Setting
$workerNum = $server->setting['worker_num'];
// Ws(http) 启动参数
$wsHost = $ws['host'];
$wsPort = $ws['port'];
$wsMode = $ws['mode'];
$wsType = $ws['type'];
$httpStatus = $ws['enable_http'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';
// TCP 启动参数
$tcpHost = $tcp['host'];
$tcpPort = $tcp['port'];
$tcpType = $tcp['type'];
$tcpStatus = $serverOpts['tcpable'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';
// 信息面板
$lines = [
' Server Information ',
'************************************************************************************',
"* WS | host: <note>$wsHost</note>, port: <note>$wsPort</note>, type: <note>$wsType</note>, worker: <note>$workerNum</note>, mode: <note>$wsMode</note> (http is $httpStatus)",
"* TCP | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpStatus)",
'************************************************************************************',
];
// 启动服务器
\output()->writeln(implode("\n", $lines));
$server->start();
} | php | public function start()
{
$server = $this->createServerManager();
// 是否正在运行
if ($server->isRunning()) {
$serverOpts = $server->getServerSetting();
\output()->writeln("<error>The server have been running!(PID: {$serverOpts['masterPid']})</error>", true, true);
} else {
$serverOpts = $server->getServerSetting();
}
// 启动参数
$this->configServer($server);
$ws = $server->getWsSettings();
$tcp = $server->getTcpSetting();
// Setting
$workerNum = $server->setting['worker_num'];
// Ws(http) 启动参数
$wsHost = $ws['host'];
$wsPort = $ws['port'];
$wsMode = $ws['mode'];
$wsType = $ws['type'];
$httpStatus = $ws['enable_http'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';
// TCP 启动参数
$tcpHost = $tcp['host'];
$tcpPort = $tcp['port'];
$tcpType = $tcp['type'];
$tcpStatus = $serverOpts['tcpable'] ? '<info>Enabled</info>' : '<warning>Disabled</warning>';
// 信息面板
$lines = [
' Server Information ',
'************************************************************************************',
"* WS | host: <note>$wsHost</note>, port: <note>$wsPort</note>, type: <note>$wsType</note>, worker: <note>$workerNum</note>, mode: <note>$wsMode</note> (http is $httpStatus)",
"* TCP | host: <note>$tcpHost</note>, port: <note>$tcpPort</note>, type: <note>$tcpType</note>, worker: <note>$workerNum</note> ($tcpStatus)",
'************************************************************************************',
];
// 启动服务器
\output()->writeln(implode("\n", $lines));
$server->start();
} | [
"public",
"function",
"start",
"(",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"createServerManager",
"(",
")",
";",
"// 是否正在运行",
"if",
"(",
"$",
"server",
"->",
"isRunning",
"(",
")",
")",
"{",
"$",
"serverOpts",
"=",
"$",
"server",
"->",
"get... | Start the webSocket server
@Usage {fullCommand} [-d|--daemon]
@Options
-d, --daemon Run server on the background
@Example
{fullCommand}
{fullCommand} -d
@throws \InvalidArgumentException
@throws \Swoft\Exception\RuntimeException
@throws \RuntimeException | [
"Start",
"the",
"webSocket",
"server"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Command/WsCommand.php#L29-L75 | train |
swoft-cloud/swoft-websocket-server | src/Command/WsCommand.php | WsCommand.reload | public function reload()
{
$server = $this->createServerManager();
if (!$server->isRunning()) {
\output()->writeln('<error>The server is not running! cannot reload</error>', true, true);
}
\output()->writeln(sprintf('<info>Server %s is reloading</info>', input()->getScript()));
$reloadTask = input()->hasOpt('t');
$server->reload($reloadTask);
\output()->writeln(sprintf('<success>Server %s reload success</success>', input()->getScript()));
} | php | public function reload()
{
$server = $this->createServerManager();
if (!$server->isRunning()) {
\output()->writeln('<error>The server is not running! cannot reload</error>', true, true);
}
\output()->writeln(sprintf('<info>Server %s is reloading</info>', input()->getScript()));
$reloadTask = input()->hasOpt('t');
$server->reload($reloadTask);
\output()->writeln(sprintf('<success>Server %s reload success</success>', input()->getScript()));
} | [
"public",
"function",
"reload",
"(",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"createServerManager",
"(",
")",
";",
"if",
"(",
"!",
"$",
"server",
"->",
"isRunning",
"(",
")",
")",
"{",
"\\",
"output",
"(",
")",
"->",
"writeln",
"(",
"'<err... | Reload worker processes for the running server
@Usage {fullCommand} [-t]
@Options
-t Only to reload task processes, default to reload worker and task
@Example {fullCommand}
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Reload",
"worker",
"processes",
"for",
"the",
"running",
"server"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Command/WsCommand.php#L87-L100 | train |
swoft-cloud/swoft-websocket-server | src/Command/WsCommand.php | WsCommand.stop | public function stop()
{
$server = $this->createServerManager();
// 是否已启动
if (!$server->isRunning()) {
\output()->writeln('<error>The server is not running! cannot stop</error>', true, true);
}
// pid文件
$serverOpts = $server->getServerSetting();
$pidFile = $serverOpts['pfile'];
\output()->writeln(sprintf('<info>Swoft %s is stopping ...</info>', input()->getScript()));
$result = $server->stop();
// 停止失败
if (!$result) {
\output()->writeln(sprintf('<error>Swoft %s stop fail</error>', input()->getScript()), true, true);
}
//删除pid文件
@unlink($pidFile);
\output()->writeln(sprintf('<success>Swoft %s stop success!</success>', input()->getScript()));
} | php | public function stop()
{
$server = $this->createServerManager();
// 是否已启动
if (!$server->isRunning()) {
\output()->writeln('<error>The server is not running! cannot stop</error>', true, true);
}
// pid文件
$serverOpts = $server->getServerSetting();
$pidFile = $serverOpts['pfile'];
\output()->writeln(sprintf('<info>Swoft %s is stopping ...</info>', input()->getScript()));
$result = $server->stop();
// 停止失败
if (!$result) {
\output()->writeln(sprintf('<error>Swoft %s stop fail</error>', input()->getScript()), true, true);
}
//删除pid文件
@unlink($pidFile);
\output()->writeln(sprintf('<success>Swoft %s stop success!</success>', input()->getScript()));
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"createServerManager",
"(",
")",
";",
"// 是否已启动",
"if",
"(",
"!",
"$",
"server",
"->",
"isRunning",
"(",
")",
")",
"{",
"\\",
"output",
"(",
")",
"->",
"writeln",
"... | Stop the running server
@Usage {fullCommand}
@Example {fullCommand}
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Stop",
"the",
"running",
"server"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Command/WsCommand.php#L110-L135 | train |
swoft-cloud/swoft-websocket-server | src/Command/WsCommand.php | WsCommand.restart | public function restart()
{
$server = $this->createServerManager();
// 是否已启动
if ($server->isRunning()) {
$this->stop();
}
// 重启默认是守护进程
$server->setDaemonize();
$this->start();
} | php | public function restart()
{
$server = $this->createServerManager();
// 是否已启动
if ($server->isRunning()) {
$this->stop();
}
// 重启默认是守护进程
$server->setDaemonize();
$this->start();
} | [
"public",
"function",
"restart",
"(",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"createServerManager",
"(",
")",
";",
"// 是否已启动",
"if",
"(",
"$",
"server",
"->",
"isRunning",
"(",
")",
")",
"{",
"$",
"this",
"->",
"stop",
"(",
")",
";",
"}",... | Restart the running server
@Usage {fullCommand} [-d|--daemon]
@Options
-d, --daemon Run server on the background
@Example
{fullCommand}
{fullCommand} -d
@throws \Swoft\Exception\RuntimeException
@throws \InvalidArgumentException
@throws \RuntimeException | [
"Restart",
"the",
"running",
"server"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Command/WsCommand.php#L150-L162 | train |
PendalF89/yii2-blog | helpers/Helper.php | Helper.cutStr | public static function cutStr($str, $length=100, $postfix='...')
{
if ( strlen($str) < $length)
return $str;
$temp = substr($str, 0, $length);
return substr($temp, 0, strrpos($temp, ' ') ) . $postfix;
} | php | public static function cutStr($str, $length=100, $postfix='...')
{
if ( strlen($str) < $length)
return $str;
$temp = substr($str, 0, $length);
return substr($temp, 0, strrpos($temp, ' ') ) . $postfix;
} | [
"public",
"static",
"function",
"cutStr",
"(",
"$",
"str",
",",
"$",
"length",
"=",
"100",
",",
"$",
"postfix",
"=",
"'...'",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"str",
")",
"<",
"$",
"length",
")",
"return",
"$",
"str",
";",
"$",
"temp",
... | Truncates the string to a certain number of characters without breaking words.
@param string $str string
@param int $length max length of string
@param string $postfix postfix
@return string truncated string | [
"Truncates",
"the",
"string",
"to",
"a",
"certain",
"number",
"of",
"characters",
"without",
"breaking",
"words",
"."
] | 1e60195c952b0fb85f0925abe1c2f2e9094e86fa | https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/helpers/Helper.php#L46-L53 | train |
PendalF89/yii2-blog | helpers/Helper.php | Helper.isJustInstalled | public static function isJustInstalled()
{
$types = Type::find()->all();
$categories = Category::find()->all();
return empty($types) || empty($categories) ? : false;
} | php | public static function isJustInstalled()
{
$types = Type::find()->all();
$categories = Category::find()->all();
return empty($types) || empty($categories) ? : false;
} | [
"public",
"static",
"function",
"isJustInstalled",
"(",
")",
"{",
"$",
"types",
"=",
"Type",
"::",
"find",
"(",
")",
"->",
"all",
"(",
")",
";",
"$",
"categories",
"=",
"Category",
"::",
"find",
"(",
")",
"->",
"all",
"(",
")",
";",
"return",
"empt... | Check that blog just installed
@return bool | [
"Check",
"that",
"blog",
"just",
"installed"
] | 1e60195c952b0fb85f0925abe1c2f2e9094e86fa | https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/helpers/Helper.php#L59-L65 | train |
Contao-DD/advanced-classes-bundle | src/Resources/contao/dca/tl_settings.php | tl_settings_advanced_classes.getAvailableSetFiles | public function getAvailableSetFiles()
{
$arrSets = array();
foreach ($GLOBALS['TL_CONFIG']['advancedClassesSets'] as $key => $value)
{
if(!strpos($value,"system/")!==false)
{
$arrSets[$value] = basename( $value ) . ' (custom)';
continue;
}
$arrSets[$value] = basename( $value );
}
return $arrSets;
} | php | public function getAvailableSetFiles()
{
$arrSets = array();
foreach ($GLOBALS['TL_CONFIG']['advancedClassesSets'] as $key => $value)
{
if(!strpos($value,"system/")!==false)
{
$arrSets[$value] = basename( $value ) . ' (custom)';
continue;
}
$arrSets[$value] = basename( $value );
}
return $arrSets;
} | [
"public",
"function",
"getAvailableSetFiles",
"(",
")",
"{",
"$",
"arrSets",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'advancedClassesSets'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
... | Return all available sets
@return array | [
"Return",
"all",
"available",
"sets"
] | ea89de7e96096b2b1139fae844caaca8c9326f2a | https://github.com/Contao-DD/advanced-classes-bundle/blob/ea89de7e96096b2b1139fae844caaca8c9326f2a/src/Resources/contao/dca/tl_settings.php#L63-L77 | train |
yajra/cms-core | src/Http/Requests/Request.php | Request.authorizeResource | protected function authorizeResource($resource)
{
if ($this->isEditing($resource)) {
return $this->user()->can($resource . '.update');
}
return $this->user()->can($resource . '.create');
} | php | protected function authorizeResource($resource)
{
if ($this->isEditing($resource)) {
return $this->user()->can($resource . '.update');
}
return $this->user()->can($resource . '.create');
} | [
"protected",
"function",
"authorizeResource",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEditing",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"$",
"this",
"->",
"user",
"(",
")",
"->",
"can",
"(",
"$",
"resource",
".",
"'.up... | Check if user is authorized to perform the action.
@param string $resource
@return bool | [
"Check",
"if",
"user",
"is",
"authorized",
"to",
"perform",
"the",
"action",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Requests/Request.php#L15-L22 | train |
yajra/cms-core | src/Entities/Traits/HasParameters.php | HasParameters.setParametersAttribute | public function setParametersAttribute($parameters)
{
if (is_array($parameters)) {
$this->attributes['parameters'] = json_encode($parameters);
} else {
$this->attributes['parameters'] = $parameters;
}
} | php | public function setParametersAttribute($parameters)
{
if (is_array($parameters)) {
$this->attributes['parameters'] = json_encode($parameters);
} else {
$this->attributes['parameters'] = $parameters;
}
} | [
"public",
"function",
"setParametersAttribute",
"(",
"$",
"parameters",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'parameters'",
"]",
"=",
"json_encode",
"(",
"$",
"parameters",
")",
";",... | Parameters attribute setter.
@param array|string $parameters | [
"Parameters",
"attribute",
"setter",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Traits/HasParameters.php#L12-L19 | train |
yajra/cms-core | src/Http/Controllers/ImageBrowserController.php | ImageBrowserController.index | public function index(Request $request)
{
$currentPath = $request->get('path');
$dir = storage_path('app/public/' . $currentPath);
$imageFiles = $this->getImageFiles($dir);
foreach (Finder::create()->in($dir)->sortByType()->directories() as $file) {
$imageFiles->name($file->getBaseName());
}
$files = new Collection;
$parts = explode('/', $currentPath);
array_pop($parts);
if ($parts <> '' && $currentPath <> '') {
$files->push([
'name' => '.. Up',
'relPath' => implode('/', $parts),
'type' => 'dir',
'url' => \Storage::url($currentPath),
]);
}
foreach ($imageFiles as $file) {
$path = str_replace(storage_path('app/public/'), '', $file->getRealPath());
$files->push([
'name' => $file->getFilename(),
'relPath' => $path,
'type' => $file->getType(),
'url' => \Storage::url($path),
]);
}
return response()->json($files->groupBy('type'));
} | php | public function index(Request $request)
{
$currentPath = $request->get('path');
$dir = storage_path('app/public/' . $currentPath);
$imageFiles = $this->getImageFiles($dir);
foreach (Finder::create()->in($dir)->sortByType()->directories() as $file) {
$imageFiles->name($file->getBaseName());
}
$files = new Collection;
$parts = explode('/', $currentPath);
array_pop($parts);
if ($parts <> '' && $currentPath <> '') {
$files->push([
'name' => '.. Up',
'relPath' => implode('/', $parts),
'type' => 'dir',
'url' => \Storage::url($currentPath),
]);
}
foreach ($imageFiles as $file) {
$path = str_replace(storage_path('app/public/'), '', $file->getRealPath());
$files->push([
'name' => $file->getFilename(),
'relPath' => $path,
'type' => $file->getType(),
'url' => \Storage::url($path),
]);
}
return response()->json($files->groupBy('type'));
} | [
"public",
"function",
"index",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"currentPath",
"=",
"$",
"request",
"->",
"get",
"(",
"'path'",
")",
";",
"$",
"dir",
"=",
"storage_path",
"(",
"'app/public/'",
".",
"$",
"currentPath",
")",
";",
"$",
"imag... | Get files by directory path.
@param \Illuminate\Http\Request $request
@return array | [
"Get",
"files",
"by",
"directory",
"path",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ImageBrowserController.php#L25-L58 | train |
yajra/cms-core | src/Http/Controllers/ImageBrowserController.php | ImageBrowserController.getImageFiles | protected function getImageFiles($path)
{
$finder = Finder::create()->in($path)->sortByType()->depth(0);
foreach (config('media.images_ext') as $file) {
$finder->name('*' . $file);
}
return $finder;
} | php | protected function getImageFiles($path)
{
$finder = Finder::create()->in($path)->sortByType()->depth(0);
foreach (config('media.images_ext') as $file) {
$finder->name('*' . $file);
}
return $finder;
} | [
"protected",
"function",
"getImageFiles",
"(",
"$",
"path",
")",
"{",
"$",
"finder",
"=",
"Finder",
"::",
"create",
"(",
")",
"->",
"in",
"(",
"$",
"path",
")",
"->",
"sortByType",
"(",
")",
"->",
"depth",
"(",
"0",
")",
";",
"foreach",
"(",
"confi... | Get image files by path.
@param string $path
@return Finder | [
"Get",
"image",
"files",
"by",
"path",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ImageBrowserController.php#L66-L74 | train |
PendalF89/yii2-blog | controllers/PostController.php | PostController.actionUpdate | public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('postSaved');
}
if ($model->type->show_category) {
$model->setScenario('required_category');
}
return $this->render('update', ['model' => $model]);
} | php | public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('postSaved');
}
if ($model->type->show_category) {
$model->setScenario('required_category');
}
return $this->render('update', ['model' => $model]);
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
... | Updates an existing Post model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"Post",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 1e60195c952b0fb85f0925abe1c2f2e9094e86fa | https://github.com/PendalF89/yii2-blog/blob/1e60195c952b0fb85f0925abe1c2f2e9094e86fa/controllers/PostController.php#L81-L94 | train |
Speicher210/CloudinaryBundle | Command/InfoCommand.php | InfoCommand.renderProperties | protected function renderProperties(OutputInterface $output, Response $response)
{
$table = new Table($output);
$table->setHeaders(['Property', 'Value']);
foreach ($response as $property => $value) {
if (is_scalar($value)) {
$table->addRow([$property, $value]);
}
}
$table->render();
} | php | protected function renderProperties(OutputInterface $output, Response $response)
{
$table = new Table($output);
$table->setHeaders(['Property', 'Value']);
foreach ($response as $property => $value) {
if (is_scalar($value)) {
$table->addRow([$property, $value]);
}
}
$table->render();
} | [
"protected",
"function",
"renderProperties",
"(",
"OutputInterface",
"$",
"output",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"$",
"table",
"->",
"setHeaders",
"(",
"[",
"'Property'",
",",
... | Render the general properties.
@param OutputInterface $output The output.
@param Response $response The API response. | [
"Render",
"the",
"general",
"properties",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/InfoCommand.php#L52-L62 | train |
Speicher210/CloudinaryBundle | Command/InfoCommand.php | InfoCommand.renderDerivedResources | protected function renderDerivedResources(OutputInterface $output, array $derivedResources)
{
$table = new Table($output);
$table->setHeaders(
[
[new TableCell('Derived resources', ['colspan' => 5])],
['ID', 'Format', 'Size', 'Transformation', 'URL'],
]
);
foreach ($derivedResources as $resource) {
$table->addRow(
[
$resource['id'],
$resource['format'],
$this->formatSize($resource['bytes']),
$resource['transformation'],
$resource['url'],
]
);
}
$table->render();
} | php | protected function renderDerivedResources(OutputInterface $output, array $derivedResources)
{
$table = new Table($output);
$table->setHeaders(
[
[new TableCell('Derived resources', ['colspan' => 5])],
['ID', 'Format', 'Size', 'Transformation', 'URL'],
]
);
foreach ($derivedResources as $resource) {
$table->addRow(
[
$resource['id'],
$resource['format'],
$this->formatSize($resource['bytes']),
$resource['transformation'],
$resource['url'],
]
);
}
$table->render();
} | [
"protected",
"function",
"renderDerivedResources",
"(",
"OutputInterface",
"$",
"output",
",",
"array",
"$",
"derivedResources",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"$",
"table",
"->",
"setHeaders",
"(",
"[",
"[",
"ne... | Render the derived resources.
@param OutputInterface $output The output.
@param array $derivedResources The derived resources. | [
"Render",
"the",
"derived",
"resources",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/InfoCommand.php#L70-L91 | train |
Speicher210/CloudinaryBundle | Command/InfoCommand.php | InfoCommand.formatSize | private function formatSize($bytes)
{
$unit = 1024;
if ($bytes <= $unit) {
return $bytes.' b';
}
$exp = (int)(log($bytes) / log($unit));
$pre = 'kMGTPE';
$pre = $pre[$exp - 1];
return sprintf('%.1f %sB', $bytes / pow($unit, $exp), $pre);
} | php | private function formatSize($bytes)
{
$unit = 1024;
if ($bytes <= $unit) {
return $bytes.' b';
}
$exp = (int)(log($bytes) / log($unit));
$pre = 'kMGTPE';
$pre = $pre[$exp - 1];
return sprintf('%.1f %sB', $bytes / pow($unit, $exp), $pre);
} | [
"private",
"function",
"formatSize",
"(",
"$",
"bytes",
")",
"{",
"$",
"unit",
"=",
"1024",
";",
"if",
"(",
"$",
"bytes",
"<=",
"$",
"unit",
")",
"{",
"return",
"$",
"bytes",
".",
"' b'",
";",
"}",
"$",
"exp",
"=",
"(",
"int",
")",
"(",
"log",
... | Format the size of a file.
@param int $bytes The number of bytes.
@return string | [
"Format",
"the",
"size",
"of",
"a",
"file",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/InfoCommand.php#L100-L111 | train |
yajra/cms-core | src/Http/Controllers/AuthController.php | AuthController.authenticated | public function authenticated(Request $request, $user)
{
if ($user->is_blocked || ! $user->is_activated) {
if ($user->is_blocked) {
$message = 'Your account is currently banned from accessing the site!';
} else {
$message = 'Your account is not yet activated!';
}
$this->guard()->logout();
flash()->error($message);
return redirect()->route('administrator.login')->withErrors($message);
}
return redirect()->intended($this->redirectPath);
} | php | public function authenticated(Request $request, $user)
{
if ($user->is_blocked || ! $user->is_activated) {
if ($user->is_blocked) {
$message = 'Your account is currently banned from accessing the site!';
} else {
$message = 'Your account is not yet activated!';
}
$this->guard()->logout();
flash()->error($message);
return redirect()->route('administrator.login')->withErrors($message);
}
return redirect()->intended($this->redirectPath);
} | [
"public",
"function",
"authenticated",
"(",
"Request",
"$",
"request",
",",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"is_blocked",
"||",
"!",
"$",
"user",
"->",
"is_activated",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"is_blocked",
")",
"{... | Handle event when the user was authenticated.
@param \Illuminate\Http\Request $request
@param mixed $user
@return \Illuminate\Http\RedirectResponse | [
"Handle",
"event",
"when",
"the",
"user",
"was",
"authenticated",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/AuthController.php#L69-L84 | train |
flamecore/user-agent | lib/UserAgentDefinition.php | UserAgentDefinition.filter | public function filter(array $information)
{
$information = $this->filterBots($information);
$information = $this->filterBrowserNames($information);
$information = $this->filterBrowserVersions($information);
$information = $this->filterBrowserEngines($information);
$information = $this->filterOperatingSystems($information);
$information = $this->filterDevices($information);
return $information;
} | php | public function filter(array $information)
{
$information = $this->filterBots($information);
$information = $this->filterBrowserNames($information);
$information = $this->filterBrowserVersions($information);
$information = $this->filterBrowserEngines($information);
$information = $this->filterOperatingSystems($information);
$information = $this->filterDevices($information);
return $information;
} | [
"public",
"function",
"filter",
"(",
"array",
"$",
"information",
")",
"{",
"$",
"information",
"=",
"$",
"this",
"->",
"filterBots",
"(",
"$",
"information",
")",
";",
"$",
"information",
"=",
"$",
"this",
"->",
"filterBrowserNames",
"(",
"$",
"informatio... | Filters the results to increase accuracy.
@param array $information The user agent information
@return array Returns the updated user agent information. | [
"Filters",
"the",
"results",
"to",
"increase",
"accuracy",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentDefinition.php#L136-L146 | train |
flamecore/user-agent | lib/UserAgentDefinition.php | UserAgentDefinition.filterBrowserNames | protected function filterBrowserNames(array $userAgent)
{
// IE11 hasn't 'MSIE' in its user agent string
if (empty($userAgent['browser_name']) && $userAgent['browser_engine'] === 'trident' && strpos($userAgent['string'], 'rv:')) {
$userAgent['browser_name'] = 'msie';
$userAgent['browser_version'] = preg_replace('|.+rv:([0-9]+(?:\.[0-9]+)+).+|', '$1', $userAgent['string']);
return $userAgent;
}
return $userAgent;
} | php | protected function filterBrowserNames(array $userAgent)
{
// IE11 hasn't 'MSIE' in its user agent string
if (empty($userAgent['browser_name']) && $userAgent['browser_engine'] === 'trident' && strpos($userAgent['string'], 'rv:')) {
$userAgent['browser_name'] = 'msie';
$userAgent['browser_version'] = preg_replace('|.+rv:([0-9]+(?:\.[0-9]+)+).+|', '$1', $userAgent['string']);
return $userAgent;
}
return $userAgent;
} | [
"protected",
"function",
"filterBrowserNames",
"(",
"array",
"$",
"userAgent",
")",
"{",
"// IE11 hasn't 'MSIE' in its user agent string",
"if",
"(",
"empty",
"(",
"$",
"userAgent",
"[",
"'browser_name'",
"]",
")",
"&&",
"$",
"userAgent",
"[",
"'browser_engine'",
"]... | Filters browser names to increase accuracy.
@param array $userAgent The user agent information
@return array Returns the updated user agent information. | [
"Filters",
"browser",
"names",
"to",
"increase",
"accuracy",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentDefinition.php#L174-L185 | train |
flamecore/user-agent | lib/UserAgentDefinition.php | UserAgentDefinition.filterBrowserVersions | protected function filterBrowserVersions(array $userAgent)
{
// Safari and Opera 10.00+ version number is not encoded "normally"
if (in_array($userAgent['browser_name'], ['safari', 'opera']) && stripos($userAgent['string'], ' version/')) {
$userAgent['browser_version'] = preg_replace('|.+ version/([0-9]+(?:\.[0-9]+)?).*|i', '$1', $userAgent['string']);
return $userAgent;
}
return $userAgent;
} | php | protected function filterBrowserVersions(array $userAgent)
{
// Safari and Opera 10.00+ version number is not encoded "normally"
if (in_array($userAgent['browser_name'], ['safari', 'opera']) && stripos($userAgent['string'], ' version/')) {
$userAgent['browser_version'] = preg_replace('|.+ version/([0-9]+(?:\.[0-9]+)?).*|i', '$1', $userAgent['string']);
return $userAgent;
}
return $userAgent;
} | [
"protected",
"function",
"filterBrowserVersions",
"(",
"array",
"$",
"userAgent",
")",
"{",
"// Safari and Opera 10.00+ version number is not encoded \"normally\"",
"if",
"(",
"in_array",
"(",
"$",
"userAgent",
"[",
"'browser_name'",
"]",
",",
"[",
"'safari'",
",",
"'op... | Filters browser versions to increase accuracy.
@param array $userAgent The user agent information
@return array Returns the updated user agent information. | [
"Filters",
"browser",
"versions",
"to",
"increase",
"accuracy",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentDefinition.php#L194-L204 | train |
yajra/cms-core | src/Http/Controllers/ModulesController.php | ModulesController.destroy | public function destroy($module)
{
/** @var \Nwidart\Modules\Module $module */
$module = $this->modules->find($module);
$module->delete();
return $this->notifySuccess(trans('cms::module.destroy', ['module' => (string) $module]));
} | php | public function destroy($module)
{
/** @var \Nwidart\Modules\Module $module */
$module = $this->modules->find($module);
$module->delete();
return $this->notifySuccess(trans('cms::module.destroy', ['module' => (string) $module]));
} | [
"public",
"function",
"destroy",
"(",
"$",
"module",
")",
"{",
"/** @var \\Nwidart\\Modules\\Module $module */",
"$",
"module",
"=",
"$",
"this",
"->",
"modules",
"->",
"find",
"(",
"$",
"module",
")",
";",
"$",
"module",
"->",
"delete",
"(",
")",
";",
"re... | Remove selected module.
@param string $module
@return \Illuminate\Http\JsonResponse
@throws \Exception | [
"Remove",
"selected",
"module",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ModulesController.php#L50-L57 | train |
yajra/cms-core | src/Http/Controllers/ModulesController.php | ModulesController.toggle | public function toggle($module)
{
/** @var \Nwidart\Modules\Module $module */
$module = $this->modules->findByAlias($module);
if ($module->disabled()) {
$module->enable();
} else {
$module->disable();
}
$message = 'cms::module.toggle.' . ($module->enabled() ? 'enable' : 'disable');
return $this->notifySuccess(trans($message, ['module' => (string) $module]));
} | php | public function toggle($module)
{
/** @var \Nwidart\Modules\Module $module */
$module = $this->modules->findByAlias($module);
if ($module->disabled()) {
$module->enable();
} else {
$module->disable();
}
$message = 'cms::module.toggle.' . ($module->enabled() ? 'enable' : 'disable');
return $this->notifySuccess(trans($message, ['module' => (string) $module]));
} | [
"public",
"function",
"toggle",
"(",
"$",
"module",
")",
"{",
"/** @var \\Nwidart\\Modules\\Module $module */",
"$",
"module",
"=",
"$",
"this",
"->",
"modules",
"->",
"findByAlias",
"(",
"$",
"module",
")",
";",
"if",
"(",
"$",
"module",
"->",
"disabled",
"... | Toggle module active status.
@param string $module
@return \Illuminate\Http\JsonResponse | [
"Toggle",
"module",
"active",
"status",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ModulesController.php#L65-L79 | train |
bringyourownideas/silverstripe-composer-security-checker | src/Extensions/PackageSecurityExtension.php | PackageSecurityExtension.updateBadges | public function updateBadges($badges)
{
if ($this->owner->SecurityAlerts()->exists()) {
$badges->push(ArrayData::create([
'Title' => _t(__CLASS__ . '.BADGE_SECURITY', 'RISK: Security'),
'Type' => 'warning security-alerts__toggler',
]));
}
} | php | public function updateBadges($badges)
{
if ($this->owner->SecurityAlerts()->exists()) {
$badges->push(ArrayData::create([
'Title' => _t(__CLASS__ . '.BADGE_SECURITY', 'RISK: Security'),
'Type' => 'warning security-alerts__toggler',
]));
}
} | [
"public",
"function",
"updateBadges",
"(",
"$",
"badges",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"SecurityAlerts",
"(",
")",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"badges",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"[",
... | updates the badges that render as part of the screen targeted
summary for this Package
@param ArrayList $badges | [
"updates",
"the",
"badges",
"that",
"render",
"as",
"part",
"of",
"the",
"screen",
"targeted",
"summary",
"for",
"this",
"Package"
] | e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6 | https://github.com/bringyourownideas/silverstripe-composer-security-checker/blob/e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6/src/Extensions/PackageSecurityExtension.php#L36-L44 | train |
bringyourownideas/silverstripe-composer-security-checker | src/Extensions/PackageSecurityExtension.php | PackageSecurityExtension.updateDataSchema | public function updateDataSchema(&$schema)
{
// The keys from the SecurityAlert model that we need in the React component
$keysToPass = ['Identifier', 'ExternalLink'];
$alerts = [];
foreach ($this->owner->SecurityAlerts()->toNestedArray() as $alert) {
$alerts[] = array_intersect_key($alert, array_flip($keysToPass));
}
$schema['securityAlerts'] = $alerts;
} | php | public function updateDataSchema(&$schema)
{
// The keys from the SecurityAlert model that we need in the React component
$keysToPass = ['Identifier', 'ExternalLink'];
$alerts = [];
foreach ($this->owner->SecurityAlerts()->toNestedArray() as $alert) {
$alerts[] = array_intersect_key($alert, array_flip($keysToPass));
}
$schema['securityAlerts'] = $alerts;
} | [
"public",
"function",
"updateDataSchema",
"(",
"&",
"$",
"schema",
")",
"{",
"// The keys from the SecurityAlert model that we need in the React component",
"$",
"keysToPass",
"=",
"[",
"'Identifier'",
",",
"'ExternalLink'",
"]",
";",
"$",
"alerts",
"=",
"[",
"]",
";"... | Adds security alert notifications into the schema
@param array &$schema
@return string | [
"Adds",
"security",
"alert",
"notifications",
"into",
"the",
"schema"
] | e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6 | https://github.com/bringyourownideas/silverstripe-composer-security-checker/blob/e8e18929752c0ca7fb51c7f52d1858c3ab3e5ee6/src/Extensions/PackageSecurityExtension.php#L52-L63 | train |
swoft-cloud/swoft-websocket-server | src/WebSocketServer.php | WebSocketServer.sendToAll | public function sendToAll(string $data, int $sender = 0, int $pageSize = 50): int
{
$startFd = 0;
$count = 0;
$fromUser = $sender < 1 ? 'SYSTEM' : $sender;
$this->log("(broadcast)The #{$fromUser} send a message to all users. Data: {$data}");
while (true) {
$fdList = $this->server->connection_list($startFd, $pageSize);
if ($fdList === false || ($num = \count($fdList)) === 0) {
break;
}
$count += $num;
$startFd = \end($fdList);
/** @var $fdList array */
foreach ($fdList as $fd) {
$info = $this->getClientInfo($fd);
if (isset($info['websocket_status']) && $info['websocket_status'] > 0) {
$this->server->push($fd, $data);
}
}
}
return $count;
} | php | public function sendToAll(string $data, int $sender = 0, int $pageSize = 50): int
{
$startFd = 0;
$count = 0;
$fromUser = $sender < 1 ? 'SYSTEM' : $sender;
$this->log("(broadcast)The #{$fromUser} send a message to all users. Data: {$data}");
while (true) {
$fdList = $this->server->connection_list($startFd, $pageSize);
if ($fdList === false || ($num = \count($fdList)) === 0) {
break;
}
$count += $num;
$startFd = \end($fdList);
/** @var $fdList array */
foreach ($fdList as $fd) {
$info = $this->getClientInfo($fd);
if (isset($info['websocket_status']) && $info['websocket_status'] > 0) {
$this->server->push($fd, $data);
}
}
}
return $count;
} | [
"public",
"function",
"sendToAll",
"(",
"string",
"$",
"data",
",",
"int",
"$",
"sender",
"=",
"0",
",",
"int",
"$",
"pageSize",
"=",
"50",
")",
":",
"int",
"{",
"$",
"startFd",
"=",
"0",
";",
"$",
"count",
"=",
"0",
";",
"$",
"fromUser",
"=",
... | send message to all connections
@param string $data
@param int $sender
@param int $pageSize
@return int | [
"send",
"message",
"to",
"all",
"connections"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/WebSocketServer.php#L225-L253 | train |
swoft-cloud/swoft-websocket-server | src/WebSocketServer.php | WebSocketServer.writeTo | public function writeTo($fd, string $data): int
{
return $this->server->send($fd, $data) ? 0 : 1;
} | php | public function writeTo($fd, string $data): int
{
return $this->server->send($fd, $data) ? 0 : 1;
} | [
"public",
"function",
"writeTo",
"(",
"$",
"fd",
",",
"string",
"$",
"data",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"server",
"->",
"send",
"(",
"$",
"fd",
",",
"$",
"data",
")",
"?",
"0",
":",
"1",
";",
"}"
] | response data to client by socket connection
@param int $fd
@param string $data
param int $length
@return int Return error number code. gt 0 on failure, eq 0 on success | [
"response",
"data",
"to",
"client",
"by",
"socket",
"connection"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/WebSocketServer.php#L322-L325 | train |
siphoc/PdfBundle | Util/BuzzRequestHandler.php | BuzzRequestHandler.getContent | public function getContent($url)
{
$this->getRequest()->setHost($url);
$this->getClient()->send(
$this->getRequest(),
$this->getResponse()
);
return $this->getResponse()->getContent();
} | php | public function getContent($url)
{
$this->getRequest()->setHost($url);
$this->getClient()->send(
$this->getRequest(),
$this->getResponse()
);
return $this->getResponse()->getContent();
} | [
"public",
"function",
"getContent",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"setHost",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"send",
"(",
"$",
"this",
"->",
"getRequest",
"(",... | Retrieve the contents from a given url.
@param string $url
@return string | [
"Retrieve",
"the",
"contents",
"from",
"a",
"given",
"url",
"."
] | 89fcc6974158069a4e97b9a8cba2587b9c9b8ce0 | https://github.com/siphoc/PdfBundle/blob/89fcc6974158069a4e97b9a8cba2587b9c9b8ce0/Util/BuzzRequestHandler.php#L76-L85 | train |
swoft-cloud/swoft-websocket-server | src/Router/Dispatcher.php | Dispatcher.handshake | public function handshake(Request $request, Response $response): array
{
try {
$path = $request->getUri()->getPath();
list($className,) = $this->getHandler($path);
} catch (\Throwable $e) {
/* @var ErrorHandler $errorHandler */
// $errorHandler = \bean(ErrorHandler::class);
// $response = $errorHandler->handle($e);
if ($e instanceof WsRouteException) {
return [
HandlerInterface::HANDSHAKE_FAIL,
$response->withStatus(404)->withAddedHeader('Failure-Reason', 'Route not found')
];
}
// other error
throw $e;
}
/** @var HandlerInterface $handler */
$handler = \bean($className);
if (!\method_exists($handler, 'checkHandshake')) {
return [
HandlerInterface::HANDSHAKE_OK,
$response->withAddedHeader('swoft-ws-handshake', 'auto')
];
}
return $handler->checkHandshake($request, $response);
} | php | public function handshake(Request $request, Response $response): array
{
try {
$path = $request->getUri()->getPath();
list($className,) = $this->getHandler($path);
} catch (\Throwable $e) {
/* @var ErrorHandler $errorHandler */
// $errorHandler = \bean(ErrorHandler::class);
// $response = $errorHandler->handle($e);
if ($e instanceof WsRouteException) {
return [
HandlerInterface::HANDSHAKE_FAIL,
$response->withStatus(404)->withAddedHeader('Failure-Reason', 'Route not found')
];
}
// other error
throw $e;
}
/** @var HandlerInterface $handler */
$handler = \bean($className);
if (!\method_exists($handler, 'checkHandshake')) {
return [
HandlerInterface::HANDSHAKE_OK,
$response->withAddedHeader('swoft-ws-handshake', 'auto')
];
}
return $handler->checkHandshake($request, $response);
} | [
"public",
"function",
"handshake",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
":",
"array",
"{",
"try",
"{",
"$",
"path",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"list",
"(",
"$",
"... | dispatch handshake request
@param Request $request
@param Response $response
@return array eg. [status, response]
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \InvalidArgumentException
@throws \Throwable | [
"dispatch",
"handshake",
"request"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Router/Dispatcher.php#L32-L63 | train |
swoft-cloud/swoft-websocket-server | src/Router/Dispatcher.php | Dispatcher.message | public function message(Server $server, Frame $frame)
{
$fd = $frame->fd;
try {
if (!$path = WebSocketContext::getMeta('path', $fd)) {
throw new ContextLostException("The connection info has lost of the fd#$fd, on message");
}
$className = $this->getHandler($path)[0];
/** @var HandlerInterface $handler */
$handler = \bean($className);
$handler->onMessage($server, $frame);
} catch (\Throwable $e) {
/** @see \Swoft\Event\EventManager::hasListenerQueue() */
if (App::hasBean('eventManager') && \bean('eventManager')->hasListenerQueue(WsEvent::ON_ERROR)) {
App::trigger(WsEvent::ON_ERROR, $frame, $e);
} else {
App::error($e->getMessage(), ['fd' => $fd, 'data' => $frame->data]);
// close connection
$server->close($fd);
}
}
} | php | public function message(Server $server, Frame $frame)
{
$fd = $frame->fd;
try {
if (!$path = WebSocketContext::getMeta('path', $fd)) {
throw new ContextLostException("The connection info has lost of the fd#$fd, on message");
}
$className = $this->getHandler($path)[0];
/** @var HandlerInterface $handler */
$handler = \bean($className);
$handler->onMessage($server, $frame);
} catch (\Throwable $e) {
/** @see \Swoft\Event\EventManager::hasListenerQueue() */
if (App::hasBean('eventManager') && \bean('eventManager')->hasListenerQueue(WsEvent::ON_ERROR)) {
App::trigger(WsEvent::ON_ERROR, $frame, $e);
} else {
App::error($e->getMessage(), ['fd' => $fd, 'data' => $frame->data]);
// close connection
$server->close($fd);
}
}
} | [
"public",
"function",
"message",
"(",
"Server",
"$",
"server",
",",
"Frame",
"$",
"frame",
")",
"{",
"$",
"fd",
"=",
"$",
"frame",
"->",
"fd",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"path",
"=",
"WebSocketContext",
"::",
"getMeta",
"(",
"'path'",
",... | dispatch ws message
@param Server $server
@param Frame $frame
@throws \InvalidArgumentException
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \Swoft\WebSocket\Server\Exception\ContextLostException | [
"dispatch",
"ws",
"message"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Router/Dispatcher.php#L93-L117 | train |
swoft-cloud/swoft-websocket-server | src/Router/Dispatcher.php | Dispatcher.close | public function close(Server $server, int $fd)
{
try {
if (!$path = WebSocketContext::getMeta('path', $fd)) {
throw new ContextLostException(
"The connection info has lost of the fd#$fd, on connection closed"
);
}
$className = $this->getHandler($path)[0];
/** @var HandlerInterface $handler */
$handler = \bean($className);
if (\method_exists($handler, 'onClose')) {
$handler->onClose($server, $fd);
}
} catch (\Throwable $e) {
App::error($e->getMessage(), ['fd' => $fd]);
}
} | php | public function close(Server $server, int $fd)
{
try {
if (!$path = WebSocketContext::getMeta('path', $fd)) {
throw new ContextLostException(
"The connection info has lost of the fd#$fd, on connection closed"
);
}
$className = $this->getHandler($path)[0];
/** @var HandlerInterface $handler */
$handler = \bean($className);
if (\method_exists($handler, 'onClose')) {
$handler->onClose($server, $fd);
}
} catch (\Throwable $e) {
App::error($e->getMessage(), ['fd' => $fd]);
}
} | [
"public",
"function",
"close",
"(",
"Server",
"$",
"server",
",",
"int",
"$",
"fd",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"path",
"=",
"WebSocketContext",
"::",
"getMeta",
"(",
"'path'",
",",
"$",
"fd",
")",
")",
"{",
"throw",
"new",
"ContextL... | dispatch ws close
@param Server $server
@param int $fd
@throws \InvalidArgumentException
@throws \Swoft\WebSocket\Server\Exception\WsRouteException
@throws \Swoft\WebSocket\Server\Exception\ContextLostException | [
"dispatch",
"ws",
"close"
] | b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5 | https://github.com/swoft-cloud/swoft-websocket-server/blob/b1f7ae57618a1b4746d5f92b114d23bc3f5f91e5/src/Router/Dispatcher.php#L127-L147 | train |
flamecore/user-agent | lib/UserAgentStringParser.php | UserAgentStringParser.parse | public function parse($string, $strict = true)
{
// Parse quickly (with medium accuracy)
$information = $this->doParse($string);
// Run some filters to increase accuracy
if ($strict) {
$information = $this->definition->filter($information);
}
return $information;
} | php | public function parse($string, $strict = true)
{
// Parse quickly (with medium accuracy)
$information = $this->doParse($string);
// Run some filters to increase accuracy
if ($strict) {
$information = $this->definition->filter($information);
}
return $information;
} | [
"public",
"function",
"parse",
"(",
"$",
"string",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"// Parse quickly (with medium accuracy)",
"$",
"information",
"=",
"$",
"this",
"->",
"doParse",
"(",
"$",
"string",
")",
";",
"// Run some filters to increase accuracy"... | Parses a user agent string.
@param string $string The user agent string
@param bool $strict Enable strict mode. This makes the parser run a bit slower but increases the accuracy significantly.
@return array Returns the user agent information:
- `string`: The original user agent string
- `browser_name`: The browser name, e.g. `"chrome"`
- `browser_version`: The browser version, e.g. `"43.0"`
- `browser_engine`: The browser engine, e.g. `"webkit"`
- `operating_system`: The operating system, e.g. `"linux"` | [
"Parses",
"a",
"user",
"agent",
"string",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentStringParser.php#L53-L64 | train |
flamecore/user-agent | lib/UserAgentStringParser.php | UserAgentStringParser.parseFromGlobal | public function parseFromGlobal($strict = true)
{
$string = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
return $this->parse($string, $strict);
} | php | public function parseFromGlobal($strict = true)
{
$string = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
return $this->parse($string, $strict);
} | [
"public",
"function",
"parseFromGlobal",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"$",
"string",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
":",
"null",
";",
"return",
"$",... | Parses the user agent string provided by the global.
@param bool $strict Enable strict mode. This makes the parser run a bit slower but increases the accuracy significantly.
@return array Returns the user agent information.
@see UserAgentStringParser::parse() | [
"Parses",
"the",
"user",
"agent",
"string",
"provided",
"by",
"the",
"global",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentStringParser.php#L75-L80 | train |
flamecore/user-agent | lib/UserAgentStringParser.php | UserAgentStringParser.doParse | protected function doParse($string)
{
$userAgent = array(
'string' => $this->cleanString($string),
'browser_name' => null,
'browser_version' => null,
'browser_engine' => null,
'operating_system' => null,
'device' => 'Other'
);
if (empty($userAgent['string'])) {
return $userAgent;
}
$browsers = $this->definition->getKnownBrowsers();
$bots = $this->definition->getKnownBots();
$userAgents = $browsers + $bots;
// Find the right name/version phrase (or return empty array if none found)
foreach ($userAgents as $name => $regexes) {
if ($matches = $this->matchBrowser($regexes, $userAgent['string'])) {
if (isset($matches[3])) {
$name = str_replace('*', strtolower($matches[2]), $name);
}
$userAgent['browser_name'] = $name;
$userAgent['browser_version'] = end($matches);
break;
}
}
// Find browser engine
$engines = $this->definition->getKnownEngines();
if ($result = $this->find($engines, $userAgent['string'])) {
$userAgent['browser_engine'] = $result;
}
// Find operating system
$operatingSystems = $this->definition->getKnownOperatingSystems();
if ($result = $this->find($operatingSystems, $userAgent['string'])) {
$userAgent['operating_system'] = $result;
}
// Find device name
$devices = $this->definition->getKnownDevices();
if ($result = $this->find($devices, $userAgent['string'], true)) {
$userAgent['device'] = $result;
}
return $userAgent;
} | php | protected function doParse($string)
{
$userAgent = array(
'string' => $this->cleanString($string),
'browser_name' => null,
'browser_version' => null,
'browser_engine' => null,
'operating_system' => null,
'device' => 'Other'
);
if (empty($userAgent['string'])) {
return $userAgent;
}
$browsers = $this->definition->getKnownBrowsers();
$bots = $this->definition->getKnownBots();
$userAgents = $browsers + $bots;
// Find the right name/version phrase (or return empty array if none found)
foreach ($userAgents as $name => $regexes) {
if ($matches = $this->matchBrowser($regexes, $userAgent['string'])) {
if (isset($matches[3])) {
$name = str_replace('*', strtolower($matches[2]), $name);
}
$userAgent['browser_name'] = $name;
$userAgent['browser_version'] = end($matches);
break;
}
}
// Find browser engine
$engines = $this->definition->getKnownEngines();
if ($result = $this->find($engines, $userAgent['string'])) {
$userAgent['browser_engine'] = $result;
}
// Find operating system
$operatingSystems = $this->definition->getKnownOperatingSystems();
if ($result = $this->find($operatingSystems, $userAgent['string'])) {
$userAgent['operating_system'] = $result;
}
// Find device name
$devices = $this->definition->getKnownDevices();
if ($result = $this->find($devices, $userAgent['string'], true)) {
$userAgent['device'] = $result;
}
return $userAgent;
} | [
"protected",
"function",
"doParse",
"(",
"$",
"string",
")",
"{",
"$",
"userAgent",
"=",
"array",
"(",
"'string'",
"=>",
"$",
"this",
"->",
"cleanString",
"(",
"$",
"string",
")",
",",
"'browser_name'",
"=>",
"null",
",",
"'browser_version'",
"=>",
"null",... | Extracts information from the user agent string.
@param string $string The user agent string
@return array Returns the user agent information. | [
"Extracts",
"information",
"from",
"the",
"user",
"agent",
"string",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentStringParser.php#L105-L157 | train |
flamecore/user-agent | lib/UserAgentStringParser.php | UserAgentStringParser.matchBrowser | protected function matchBrowser(array $regexes, $string)
{
// Build regex that matches phrases for known browsers (e.g. "Firefox/2.0" or "MSIE 6.0").
// This only matches the major and minor version numbers (e.g. "2.0.0.6" is parsed as simply "2.0").
$pattern = '#('.join('|', $regexes).')[/ ]+([0-9]+(?:\.[0-9]+)?)#i';
if (preg_match($pattern, $string, $matches)) {
return $matches;
}
return false;
} | php | protected function matchBrowser(array $regexes, $string)
{
// Build regex that matches phrases for known browsers (e.g. "Firefox/2.0" or "MSIE 6.0").
// This only matches the major and minor version numbers (e.g. "2.0.0.6" is parsed as simply "2.0").
$pattern = '#('.join('|', $regexes).')[/ ]+([0-9]+(?:\.[0-9]+)?)#i';
if (preg_match($pattern, $string, $matches)) {
return $matches;
}
return false;
} | [
"protected",
"function",
"matchBrowser",
"(",
"array",
"$",
"regexes",
",",
"$",
"string",
")",
"{",
"// Build regex that matches phrases for known browsers (e.g. \"Firefox/2.0\" or \"MSIE 6.0\").",
"// This only matches the major and minor version numbers (e.g. \"2.0.0.6\" is parsed as si... | Matches the list of browser regexes against the given User Agent string.
@param array $regexes The list of regexes
@param string $string The User Agent string
@return array|false Returns the parts of the matching regex or FALSE if no regex matched. | [
"Matches",
"the",
"list",
"of",
"browser",
"regexes",
"against",
"the",
"given",
"User",
"Agent",
"string",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgentStringParser.php#L167-L178 | train |
Speicher210/CloudinaryBundle | Command/DeleteCommand.php | DeleteCommand.removeByPrefix | private function removeByPrefix(InputInterface $input, OutputInterface $output)
{
$prefix = $input->getOption('prefix');
$output->writeln(
sprintf('<comment>Removing all resources from <info>%s</info></comment>', $prefix)
);
$api = $this->getCloudinaryApi();
$response = $api->delete_resources_by_prefix($prefix);
$this->outputApiResponse($response, 'deleted', $output);
} | php | private function removeByPrefix(InputInterface $input, OutputInterface $output)
{
$prefix = $input->getOption('prefix');
$output->writeln(
sprintf('<comment>Removing all resources from <info>%s</info></comment>', $prefix)
);
$api = $this->getCloudinaryApi();
$response = $api->delete_resources_by_prefix($prefix);
$this->outputApiResponse($response, 'deleted', $output);
} | [
"private",
"function",
"removeByPrefix",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"prefix",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'prefix'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"... | Remove resources by prefix.
@param InputInterface $input Console input.
@param OutputInterface $output Console output. | [
"Remove",
"resources",
"by",
"prefix",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/DeleteCommand.php#L70-L81 | train |
Speicher210/CloudinaryBundle | Command/DeleteCommand.php | DeleteCommand.removeResource | private function removeResource(InputInterface $input, OutputInterface $output)
{
$resource = $input->getOption('resource');
$output->writeln(
sprintf('<comment>Removing resource <info>%s</info></comment>', $resource)
);
$api = $this->getCloudinaryApi();
$response = $api->delete_resources($resource);
$this->outputApiResponse($response, 'deleted', $output);
} | php | private function removeResource(InputInterface $input, OutputInterface $output)
{
$resource = $input->getOption('resource');
$output->writeln(
sprintf('<comment>Removing resource <info>%s</info></comment>', $resource)
);
$api = $this->getCloudinaryApi();
$response = $api->delete_resources($resource);
$this->outputApiResponse($response, 'deleted', $output);
} | [
"private",
"function",
"removeResource",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"resource",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'resource'",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",... | Remove a resource.
@param InputInterface $input Console input.
@param OutputInterface $output Console output. | [
"Remove",
"a",
"resource",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/DeleteCommand.php#L89-L100 | train |
Speicher210/CloudinaryBundle | Command/DeleteCommand.php | DeleteCommand.outputApiResponse | private function outputApiResponse(Response $response, $part, OutputInterface $output)
{
$table = new Table($output);
$table->setHeaders(['Resource', 'Status']);
foreach ($response[$part] as $file => $status) {
$table->addRow([$file, $status]);
}
$table->render();
} | php | private function outputApiResponse(Response $response, $part, OutputInterface $output)
{
$table = new Table($output);
$table->setHeaders(['Resource', 'Status']);
foreach ($response[$part] as $file => $status) {
$table->addRow([$file, $status]);
}
$table->render();
} | [
"private",
"function",
"outputApiResponse",
"(",
"Response",
"$",
"response",
",",
"$",
"part",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"output",
")",
";",
"$",
"table",
"->",
"setHeaders",
"(",
"[",
... | Output the API response.
@param Response $response The response
@param string $part The part of the response to output.
@param OutputInterface $output The console output. | [
"Output",
"the",
"API",
"response",
"."
] | a8234c8da91c4802a4cbba399cada3181f02f03e | https://github.com/Speicher210/CloudinaryBundle/blob/a8234c8da91c4802a4cbba399cada3181f02f03e/Command/DeleteCommand.php#L109-L118 | train |
yajra/cms-core | src/Http/Controllers/CategoriesController.php | CategoriesController.publish | public function publish(Category $category)
{
$category->togglePublishedState();
$category->getDescendants()->each(
function (Category $cat) use ($category) {
$cat->published = $category->published;
$cat->save();
}
);
$message = $category->published ? trans('cms::categories.publish.success') : trans('cms::categories.publish.error');
return $this->notifySuccess($message);
} | php | public function publish(Category $category)
{
$category->togglePublishedState();
$category->getDescendants()->each(
function (Category $cat) use ($category) {
$cat->published = $category->published;
$cat->save();
}
);
$message = $category->published ? trans('cms::categories.publish.success') : trans('cms::categories.publish.error');
return $this->notifySuccess($message);
} | [
"public",
"function",
"publish",
"(",
"Category",
"$",
"category",
")",
"{",
"$",
"category",
"->",
"togglePublishedState",
"(",
")",
";",
"$",
"category",
"->",
"getDescendants",
"(",
")",
"->",
"each",
"(",
"function",
"(",
"Category",
"$",
"cat",
")",
... | Button Response from DataTable request to publish status.
@param \Yajra\CMS\Entities\Category $category
@return \Illuminate\Http\JsonResponse | [
"Button",
"Response",
"from",
"DataTable",
"request",
"to",
"publish",
"status",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/CategoriesController.php#L130-L144 | train |
yajra/cms-core | src/Http/LogoutGuard.php | LogoutGuard.isActiveGuard | public function isActiveGuard(Request $request, $guard)
{
$name = Auth::guard($guard)->getName();
return ($this->sessionHas($request, $name) && $this->sessionGet($request,
$name) === $this->getAuthIdentifier($guard));
} | php | public function isActiveGuard(Request $request, $guard)
{
$name = Auth::guard($guard)->getName();
return ($this->sessionHas($request, $name) && $this->sessionGet($request,
$name) === $this->getAuthIdentifier($guard));
} | [
"public",
"function",
"isActiveGuard",
"(",
"Request",
"$",
"request",
",",
"$",
"guard",
")",
"{",
"$",
"name",
"=",
"Auth",
"::",
"guard",
"(",
"$",
"guard",
")",
"->",
"getName",
"(",
")",
";",
"return",
"(",
"$",
"this",
"->",
"sessionHas",
"(",
... | Check if a particular guard is active.
@param Request $request
@param string $guard
@return bool | [
"Check",
"if",
"a",
"particular",
"guard",
"is",
"active",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/LogoutGuard.php#L42-L48 | train |
bipbop/bipbop-php | src/Client/Push.php | Push.open | public function open($id, $label = null) {
return $this->webService->post("SELECT FROM 'PUSH'.'DOCUMENT'", array_filter([
"id" => $id,
"label" => $label
]));
} | php | public function open($id, $label = null) {
return $this->webService->post("SELECT FROM 'PUSH'.'DOCUMENT'", array_filter([
"id" => $id,
"label" => $label
]));
} | [
"public",
"function",
"open",
"(",
"$",
"id",
",",
"$",
"label",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"webService",
"->",
"post",
"(",
"\"SELECT FROM 'PUSH'.'DOCUMENT'\"",
",",
"array_filter",
"(",
"[",
"\"id\"",
"=>",
"$",
"id",
",",
"\"l... | Abre um documento criado
@param string $id
@param string $label | [
"Abre",
"um",
"documento",
"criado"
] | c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb | https://github.com/bipbop/bipbop-php/blob/c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb/src/Client/Push.php#L69-L74 | train |
bipbop/bipbop-php | src/Client/Push.php | Push.changeInterval | public function changeInterval($id, $interval) {
return $this->webService->post("UPDATE 'PUSH'.'PUSHINTERVAL'", [
self::PARAMETER_PUSH_ID => $id,
self::PARAMETER_PUSH_INTERVAL => $interval
]);
} | php | public function changeInterval($id, $interval) {
return $this->webService->post("UPDATE 'PUSH'.'PUSHINTERVAL'", [
self::PARAMETER_PUSH_ID => $id,
self::PARAMETER_PUSH_INTERVAL => $interval
]);
} | [
"public",
"function",
"changeInterval",
"(",
"$",
"id",
",",
"$",
"interval",
")",
"{",
"return",
"$",
"this",
"->",
"webService",
"->",
"post",
"(",
"\"UPDATE 'PUSH'.'PUSHINTERVAL'\"",
",",
"[",
"self",
"::",
"PARAMETER_PUSH_ID",
"=>",
"$",
"id",
",",
"self... | Muda o intervalo do PUSH
@param type $id
@param type $interval | [
"Muda",
"o",
"intervalo",
"do",
"PUSH"
] | c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb | https://github.com/bipbop/bipbop-php/blob/c826ef908e37fb7db7bcd7d2da52a65d5c6df4eb/src/Client/Push.php#L81-L86 | train |
yajra/cms-core | src/Presenters/MenuPresenter.php | MenuPresenter.url | public function url()
{
/** @var \Yajra\CMS\Repositories\Extension\Repository $repository */
$repository = app('extensions');
/** @var \Yajra\CMS\Entities\Extension $extension */
$extension = $repository->findOrFail($this->entity->extension_id);
$class = $extension->param('class');
if (class_exists($class)) {
$entity = app($class)->findOrNew($this->entity->param('id'));
if ($entity instanceof UrlGenerator) {
if (! $entity->exists) {
return '#';
}
return $entity->getUrl($this->entity->param('data'));
}
}
return url($this->entity->url);
} | php | public function url()
{
/** @var \Yajra\CMS\Repositories\Extension\Repository $repository */
$repository = app('extensions');
/** @var \Yajra\CMS\Entities\Extension $extension */
$extension = $repository->findOrFail($this->entity->extension_id);
$class = $extension->param('class');
if (class_exists($class)) {
$entity = app($class)->findOrNew($this->entity->param('id'));
if ($entity instanceof UrlGenerator) {
if (! $entity->exists) {
return '#';
}
return $entity->getUrl($this->entity->param('data'));
}
}
return url($this->entity->url);
} | [
"public",
"function",
"url",
"(",
")",
"{",
"/** @var \\Yajra\\CMS\\Repositories\\Extension\\Repository $repository */",
"$",
"repository",
"=",
"app",
"(",
"'extensions'",
")",
";",
"/** @var \\Yajra\\CMS\\Entities\\Extension $extension */",
"$",
"extension",
"=",
"$",
"repo... | Generate menu url depending on type the menu.
@return string | [
"Generate",
"menu",
"url",
"depending",
"on",
"type",
"the",
"menu",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/MenuPresenter.php#L49-L68 | train |
yajra/cms-core | src/Presenters/MenuPresenter.php | MenuPresenter.linkTitle | public function linkTitle()
{
return $this->entity->param('link_title') ? $this->entity->param('link_title') : $this->entity->title;
} | php | public function linkTitle()
{
return $this->entity->param('link_title') ? $this->entity->param('link_title') : $this->entity->title;
} | [
"public",
"function",
"linkTitle",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"entity",
"->",
"param",
"(",
"'link_title'",
")",
"?",
"$",
"this",
"->",
"entity",
"->",
"param",
"(",
"'link_title'",
")",
":",
"$",
"this",
"->",
"entity",
"->",
"title"... | Get menu link title.
@return mixed | [
"Get",
"menu",
"link",
"title",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Presenters/MenuPresenter.php#L85-L88 | train |
yajra/cms-core | src/Http/Controllers/ConfigurationsController.php | ConfigurationsController.store | public function store(Request $request)
{
$config = $request->input('config');
foreach (array_dot($request->input('data')) as $key => $value) {
$path = $config . '.' . $key;
$this->destroy($path);
if (is_array($value)) {
$value = implode(',', $value);
}
Configuration::create(['key' => $path, 'value' => $value]);
}
return $this->notifySuccess(trans('cms::config.success', ['config' => $config]));
} | php | public function store(Request $request)
{
$config = $request->input('config');
foreach (array_dot($request->input('data')) as $key => $value) {
$path = $config . '.' . $key;
$this->destroy($path);
if (is_array($value)) {
$value = implode(',', $value);
}
Configuration::create(['key' => $path, 'value' => $value]);
}
return $this->notifySuccess(trans('cms::config.success', ['config' => $config]));
} | [
"public",
"function",
"store",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"config",
"=",
"$",
"request",
"->",
"input",
"(",
"'config'",
")",
";",
"foreach",
"(",
"array_dot",
"(",
"$",
"request",
"->",
"input",
"(",
"'data'",
")",
")",
"as",
"$"... | Store submitted configurations.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse | [
"Store",
"submitted",
"configurations",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ConfigurationsController.php#L58-L72 | train |
yajra/cms-core | src/Http/Controllers/ConfigurationsController.php | ConfigurationsController.show | public function show($key)
{
$config = config($key) ?? [];
if (! isset($this->limits[$key])) {
return $this->filter($config);
}
return response()->json(
$this->filter(array_only($config, $this->limits[$key]))
);
} | php | public function show($key)
{
$config = config($key) ?? [];
if (! isset($this->limits[$key])) {
return $this->filter($config);
}
return response()->json(
$this->filter(array_only($config, $this->limits[$key]))
);
} | [
"public",
"function",
"show",
"(",
"$",
"key",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"$",
"key",
")",
"??",
"[",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"limits",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
... | Show configuration by key.
@param string $key
@return array|mixed | [
"Show",
"configuration",
"by",
"key",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ConfigurationsController.php#L91-L102 | train |
yajra/cms-core | src/Http/Controllers/ConfigurationsController.php | ConfigurationsController.filter | protected function filter(array $array)
{
$config = collect(array_dot($array))->map(function ($value, $key) {
if (str_contains($key, $this->hidden)) {
return '';
}
if (in_array($key, $this->boolean)) {
return (bool) $value;
}
return $value;
});
$array = [];
foreach ($config as $key => $value) {
array_set($array, $key, $value);
}
return $array;
} | php | protected function filter(array $array)
{
$config = collect(array_dot($array))->map(function ($value, $key) {
if (str_contains($key, $this->hidden)) {
return '';
}
if (in_array($key, $this->boolean)) {
return (bool) $value;
}
return $value;
});
$array = [];
foreach ($config as $key => $value) {
array_set($array, $key, $value);
}
return $array;
} | [
"protected",
"function",
"filter",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"config",
"=",
"collect",
"(",
"array_dot",
"(",
"$",
"array",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"str_conta... | Filter array response.
@param array $array
@return array | [
"Filter",
"array",
"response",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ConfigurationsController.php#L110-L130 | train |
yajra/cms-core | src/Http/Controllers/ProfileController.php | ProfileController.removeAvatar | public function removeAvatar()
{
$profile = auth()->user();
$profile->avatar = '';
$profile->save();
event(new ProfileWasUpdated($profile));
return redirect()->route('administrator.profile.edit');
} | php | public function removeAvatar()
{
$profile = auth()->user();
$profile->avatar = '';
$profile->save();
event(new ProfileWasUpdated($profile));
return redirect()->route('administrator.profile.edit');
} | [
"public",
"function",
"removeAvatar",
"(",
")",
"{",
"$",
"profile",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"profile",
"->",
"avatar",
"=",
"''",
";",
"$",
"profile",
"->",
"save",
"(",
")",
";",
"event",
"(",
"new",
"ProfileWasUp... | Remove current user's avatar.
@return \Illuminate\Http\RedirectResponse | [
"Remove",
"current",
"user",
"s",
"avatar",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/ProfileController.php#L57-L66 | train |
flamecore/user-agent | lib/UserAgent.php | UserAgent.configureFromUserAgentString | public function configureFromUserAgentString($string, UserAgentStringParser $parser = null)
{
$parser = $parser ?: new UserAgentStringParser();
$result = $string !== null ? $parser->parse($string) : $parser->parseFromGlobal();
$this->setUserAgentString($string);
$this->fromArray($result);
} | php | public function configureFromUserAgentString($string, UserAgentStringParser $parser = null)
{
$parser = $parser ?: new UserAgentStringParser();
$result = $string !== null ? $parser->parse($string) : $parser->parseFromGlobal();
$this->setUserAgentString($string);
$this->fromArray($result);
} | [
"public",
"function",
"configureFromUserAgentString",
"(",
"$",
"string",
",",
"UserAgentStringParser",
"$",
"parser",
"=",
"null",
")",
"{",
"$",
"parser",
"=",
"$",
"parser",
"?",
":",
"new",
"UserAgentStringParser",
"(",
")",
";",
"$",
"result",
"=",
"$",... | Configures the user agent information from a user agent string.
@param string $string The user agent string
@param \FlameCore\UserAgent\UserAgentStringParser $parser The parser used to parse the string | [
"Configures",
"the",
"user",
"agent",
"information",
"from",
"a",
"user",
"agent",
"string",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgent.php#L215-L222 | train |
flamecore/user-agent | lib/UserAgent.php | UserAgent.toArray | public function toArray()
{
return array(
'browser_name' => $this->getBrowserName(),
'browser_version' => $this->getBrowserVersion(),
'browser_engine' => $this->getBrowserEngine(),
'operating_system' => $this->getOperatingSystem(),
'device' => $this->getDevice()
);
} | php | public function toArray()
{
return array(
'browser_name' => $this->getBrowserName(),
'browser_version' => $this->getBrowserVersion(),
'browser_engine' => $this->getBrowserEngine(),
'operating_system' => $this->getOperatingSystem(),
'device' => $this->getDevice()
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'browser_name'",
"=>",
"$",
"this",
"->",
"getBrowserName",
"(",
")",
",",
"'browser_version'",
"=>",
"$",
"this",
"->",
"getBrowserVersion",
"(",
")",
",",
"'browser_engine'",
"=>",
"$... | Converts the user agent information to an array.
@return array | [
"Converts",
"the",
"user",
"agent",
"information",
"to",
"an",
"array",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgent.php#L229-L238 | train |
flamecore/user-agent | lib/UserAgent.php | UserAgent.fromArray | private function fromArray(array $data)
{
$this->browserName = $data['browser_name'];
$this->browserVersion = $data['browser_version'];
$this->browserEngine = $data['browser_engine'];
$this->operatingSystem = $data['operating_system'];
$this->device = $data['device'];
} | php | private function fromArray(array $data)
{
$this->browserName = $data['browser_name'];
$this->browserVersion = $data['browser_version'];
$this->browserEngine = $data['browser_engine'];
$this->operatingSystem = $data['operating_system'];
$this->device = $data['device'];
} | [
"private",
"function",
"fromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"browserName",
"=",
"$",
"data",
"[",
"'browser_name'",
"]",
";",
"$",
"this",
"->",
"browserVersion",
"=",
"$",
"data",
"[",
"'browser_version'",
"]",
";",
"$",
... | Configures the user agent information from an array.
@param array $data The data array | [
"Configures",
"the",
"user",
"agent",
"information",
"from",
"an",
"array",
"."
] | 3e8517ddb37754d620c8c4b28f96fd992cdcc1bc | https://github.com/flamecore/user-agent/blob/3e8517ddb37754d620c8c4b28f96fd992cdcc1bc/lib/UserAgent.php#L245-L252 | train |
symfony-bundles/bundle-dependency | BundleDependency.php | BundleDependency.registerBundleDependencies | protected function registerBundleDependencies(ContainerBuilder $container)
{
if (true === $this->booted) {
return;
}
$this->bundles = $container->getParameter('kernel.bundles');
if ($this->createBundles($this->getBundleDependencies())) {
$container->setParameter('kernel.bundles', $this->bundles);
$this->initializeBundles($container);
$pass = new Compiler\ExtensionLoadPass($this->instances);
$container->addCompilerPass($pass);
}
$this->booted = true;
} | php | protected function registerBundleDependencies(ContainerBuilder $container)
{
if (true === $this->booted) {
return;
}
$this->bundles = $container->getParameter('kernel.bundles');
if ($this->createBundles($this->getBundleDependencies())) {
$container->setParameter('kernel.bundles', $this->bundles);
$this->initializeBundles($container);
$pass = new Compiler\ExtensionLoadPass($this->instances);
$container->addCompilerPass($pass);
}
$this->booted = true;
} | [
"protected",
"function",
"registerBundleDependencies",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"booted",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"bundles",
"=",
"$",
"container",
"->",
"get... | Register the bundle dependencies.
@param ContainerBuilder $container | [
"Register",
"the",
"bundle",
"dependencies",
"."
] | 9d86d2bbed4dd01ef04b76a5faab67a59ef5e760 | https://github.com/symfony-bundles/bundle-dependency/blob/9d86d2bbed4dd01ef04b76a5faab67a59ef5e760/BundleDependency.php#L38-L57 | train |
symfony-bundles/bundle-dependency | BundleDependency.php | BundleDependency.createBundles | protected function createBundles(array $dependencies)
{
foreach ($dependencies as $bundleClass) {
$name = substr($bundleClass, strrpos($bundleClass, '\\') + 1);
if (false === isset($this->bundles[$name])) {
$bundle = new $bundleClass();
$this->bundles[$name] = $bundleClass;
$this->instances[$name] = $bundle;
if ($bundle instanceof BundleDependencyInterface) {
$this->createBundles($bundle->getBundleDependencies());
}
}
}
return count($this->instances) > 0;
} | php | protected function createBundles(array $dependencies)
{
foreach ($dependencies as $bundleClass) {
$name = substr($bundleClass, strrpos($bundleClass, '\\') + 1);
if (false === isset($this->bundles[$name])) {
$bundle = new $bundleClass();
$this->bundles[$name] = $bundleClass;
$this->instances[$name] = $bundle;
if ($bundle instanceof BundleDependencyInterface) {
$this->createBundles($bundle->getBundleDependencies());
}
}
}
return count($this->instances) > 0;
} | [
"protected",
"function",
"createBundles",
"(",
"array",
"$",
"dependencies",
")",
"{",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"bundleClass",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"bundleClass",
",",
"strrpos",
"(",
"$",
"bundleClass",
",... | Creating the instances of bundle dependencies.
@param array $dependencies
@return bool Has new instances or not. | [
"Creating",
"the",
"instances",
"of",
"bundle",
"dependencies",
"."
] | 9d86d2bbed4dd01ef04b76a5faab67a59ef5e760 | https://github.com/symfony-bundles/bundle-dependency/blob/9d86d2bbed4dd01ef04b76a5faab67a59ef5e760/BundleDependency.php#L66-L83 | train |
mmoreram/extractor | src/Extractor/Extractor.php | Extractor.extractFromFile | public function extractFromFile($filePath)
{
if (!is_file($filePath)) {
throw new FileNotFoundException($filePath);
}
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
$this->checkDirectory();
$extractorAdapterNamespace = $this->getAdapterNamespaceGivenExtension($extension);
$extractorAdapter = $this
->instanceExtractorAdapter($extractorAdapterNamespace);
if (!$extractorAdapter->isAvailable()) {
throw new AdapterNotAvailableException($extractorAdapter->getIdentifier());
}
return $extractorAdapter->extract($filePath);
} | php | public function extractFromFile($filePath)
{
if (!is_file($filePath)) {
throw new FileNotFoundException($filePath);
}
$extension = pathinfo($filePath, PATHINFO_EXTENSION);
$this->checkDirectory();
$extractorAdapterNamespace = $this->getAdapterNamespaceGivenExtension($extension);
$extractorAdapter = $this
->instanceExtractorAdapter($extractorAdapterNamespace);
if (!$extractorAdapter->isAvailable()) {
throw new AdapterNotAvailableException($extractorAdapter->getIdentifier());
}
return $extractorAdapter->extract($filePath);
} | [
"public",
"function",
"extractFromFile",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"filePath",
")",
";",
"}",
"$",
"extension",
"=",
"pathinfo",
"(",... | Extract files from compressed file
@param string $filePath Compressed file path
@return Finder Finder instance with all files added
@throws ExtensionNotSupportedException Exception not found
@throws AdapterNotAvailableException Adapter not available
@throws FileNotFoundException File not found | [
"Extract",
"files",
"from",
"compressed",
"file"
] | 0ca76992fab2573e2fe512d0ee2a4d45e936fee4 | https://github.com/mmoreram/extractor/blob/0ca76992fab2573e2fe512d0ee2a4d45e936fee4/src/Extractor/Extractor.php#L58-L79 | train |
mmoreram/extractor | src/Extractor/Extractor.php | Extractor.checkDirectory | protected function checkDirectory()
{
$directoryPath = $this
->directory
->getDirectoryPath();
if (!is_dir($directoryPath)) {
mkdir($directoryPath);
}
return $this;
} | php | protected function checkDirectory()
{
$directoryPath = $this
->directory
->getDirectoryPath();
if (!is_dir($directoryPath)) {
mkdir($directoryPath);
}
return $this;
} | [
"protected",
"function",
"checkDirectory",
"(",
")",
"{",
"$",
"directoryPath",
"=",
"$",
"this",
"->",
"directory",
"->",
"getDirectoryPath",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directoryPath",
")",
")",
"{",
"mkdir",
"(",
"$",
"director... | Check directory existence and integrity
@return $this self Object | [
"Check",
"directory",
"existence",
"and",
"integrity"
] | 0ca76992fab2573e2fe512d0ee2a4d45e936fee4 | https://github.com/mmoreram/extractor/blob/0ca76992fab2573e2fe512d0ee2a4d45e936fee4/src/Extractor/Extractor.php#L98-L110 | train |
mmoreram/extractor | src/Extractor/Extractor.php | Extractor.getAdapterNamespaceGivenExtension | protected function getAdapterNamespaceGivenExtension($fileExtension)
{
$adapterNamespace = '\Mmoreram\Extractor\Adapter\\';
switch ($fileExtension) {
case 'zip':
$adapterNamespace .= 'ZipExtractorAdapter';
break;
case 'rar':
$adapterNamespace .= 'RarExtractorAdapter';
break;
case 'phar':
$adapterNamespace .= 'PharExtractorAdapter';
break;
case 'tar':
$adapterNamespace .= 'TarExtractorAdapter';
break;
case 'gz':
$adapterNamespace .= 'TarGzExtractorAdapter';
break;
case 'bz2':
$adapterNamespace .= 'TarBz2ExtractorAdapter';
break;
default:
throw new ExtensionNotSupportedException($fileExtension);
}
return $adapterNamespace;
} | php | protected function getAdapterNamespaceGivenExtension($fileExtension)
{
$adapterNamespace = '\Mmoreram\Extractor\Adapter\\';
switch ($fileExtension) {
case 'zip':
$adapterNamespace .= 'ZipExtractorAdapter';
break;
case 'rar':
$adapterNamespace .= 'RarExtractorAdapter';
break;
case 'phar':
$adapterNamespace .= 'PharExtractorAdapter';
break;
case 'tar':
$adapterNamespace .= 'TarExtractorAdapter';
break;
case 'gz':
$adapterNamespace .= 'TarGzExtractorAdapter';
break;
case 'bz2':
$adapterNamespace .= 'TarBz2ExtractorAdapter';
break;
default:
throw new ExtensionNotSupportedException($fileExtension);
}
return $adapterNamespace;
} | [
"protected",
"function",
"getAdapterNamespaceGivenExtension",
"(",
"$",
"fileExtension",
")",
"{",
"$",
"adapterNamespace",
"=",
"'\\Mmoreram\\Extractor\\Adapter\\\\'",
";",
"switch",
"(",
"$",
"fileExtension",
")",
"{",
"case",
"'zip'",
":",
"$",
"adapterNamespace",
... | Return a extractor adapter namespace given an extension
@param string $fileExtension File extension
@return string Adapter namespace
@throws ExtensionNotSupportedException Exception not found | [
"Return",
"a",
"extractor",
"adapter",
"namespace",
"given",
"an",
"extension"
] | 0ca76992fab2573e2fe512d0ee2a4d45e936fee4 | https://github.com/mmoreram/extractor/blob/0ca76992fab2573e2fe512d0ee2a4d45e936fee4/src/Extractor/Extractor.php#L121-L156 | train |
yajra/cms-core | src/Entities/Extension.php | Extension.widget | public static function widget($name)
{
$builder = static::query();
return $builder->where('type', 'widget')
->whereRaw('LOWER(name) = ?', [Str::lower($name)])
->first();
} | php | public static function widget($name)
{
$builder = static::query();
return $builder->where('type', 'widget')
->whereRaw('LOWER(name) = ?', [Str::lower($name)])
->first();
} | [
"public",
"static",
"function",
"widget",
"(",
"$",
"name",
")",
"{",
"$",
"builder",
"=",
"static",
"::",
"query",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"where",
"(",
"'type'",
",",
"'widget'",
")",
"->",
"whereRaw",
"(",
"'LOWER(name) = ?'",
... | Get a widget by name.
@param string $name
@return \Illuminate\Database\Eloquent\Builder|\Yajra\CMS\Entities\Extension | [
"Get",
"a",
"widget",
"by",
"name",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Entities/Extension.php#L53-L60 | train |
camspiers/json-pretty | src/Camspiers/JsonPretty/JsonPretty.php | JsonPretty.prettify | public function prettify($json, $flags = null, $indent = "\t", $is_json=null)
{
if (!isset($is_json)) {
$is_json = $this->isJson($json);
}
if (!$is_json) {
return $this->process(json_encode($json, $flags), $indent);
}
return $this->process($json, $indent);
} | php | public function prettify($json, $flags = null, $indent = "\t", $is_json=null)
{
if (!isset($is_json)) {
$is_json = $this->isJson($json);
}
if (!$is_json) {
return $this->process(json_encode($json, $flags), $indent);
}
return $this->process($json, $indent);
} | [
"public",
"function",
"prettify",
"(",
"$",
"json",
",",
"$",
"flags",
"=",
"null",
",",
"$",
"indent",
"=",
"\"\\t\"",
",",
"$",
"is_json",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"is_json",
")",
")",
"{",
"$",
"is_json",
"=",
... | Checks if input is string, if so, straight runs
process, else it encodes the input as json then
runs prettify.
@param mixed $json The json string or object to prettify
@param int $flags The flags to use in json encoding
@param string $indent The indentation character string
@param bool $is_json Is the input already in JSON format?
@return string The prettified json | [
"Checks",
"if",
"input",
"is",
"string",
"if",
"so",
"straight",
"runs",
"process",
"else",
"it",
"encodes",
"the",
"input",
"as",
"json",
"then",
"runs",
"prettify",
"."
] | 17be37cb83af8014658da48fa0012604179039a7 | https://github.com/camspiers/json-pretty/blob/17be37cb83af8014658da48fa0012604179039a7/src/Camspiers/JsonPretty/JsonPretty.php#L18-L29 | train |
yajra/cms-core | src/Http/Controllers/NavigationController.php | NavigationController.store | public function store(Request $request)
{
$this->validate($request, [
'title' => 'required|max:255',
'type' => 'required|max:255|alpha|unique:navigation,type',
]);
$navigation = new Navigation;
$navigation->fill($request->all());
$navigation->published = $request->get('published', false);
$navigation->save();
flash()->success(trans('cms::navigation.store.success'));
return redirect()->route('administrator.navigation.index');
} | php | public function store(Request $request)
{
$this->validate($request, [
'title' => 'required|max:255',
'type' => 'required|max:255|alpha|unique:navigation,type',
]);
$navigation = new Navigation;
$navigation->fill($request->all());
$navigation->published = $request->get('published', false);
$navigation->save();
flash()->success(trans('cms::navigation.store.success'));
return redirect()->route('administrator.navigation.index');
} | [
"public",
"function",
"store",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"[",
"'title'",
"=>",
"'required|max:255'",
",",
"'type'",
"=>",
"'required|max:255|alpha|unique:navigation,type'",
",",
"]",
")",
... | Store a newly created navigation.
@param \Illuminate\Http\Request $request
@return mixed | [
"Store",
"a",
"newly",
"created",
"navigation",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Http/Controllers/NavigationController.php#L57-L71 | train |
gourmet/social-meta | src/View/Helper/OpenGraphHelper.php | OpenGraphHelper.html | public function html(array $options = [], array $namespaces = [])
{
$this->addNamespace('og', 'http://ogp.me/ns#');
$this->addNamespace('fb', 'http://ogp.me/ns/fb#');
if ($namespaces) {
foreach ($namespaces as $ns => $url) {
$this->addNamespace($ns, $url);
}
}
$this->setType($this->config('type'));
$this->setUri($this->request->here);
$this->setTitle($this->_View->fetch('title'));
if ($appId = $this->config('app_id')) {
$this->setAppId($appId);
}
return $this->Html->tag('html', null, $this->config('namespaces') + $options);
} | php | public function html(array $options = [], array $namespaces = [])
{
$this->addNamespace('og', 'http://ogp.me/ns#');
$this->addNamespace('fb', 'http://ogp.me/ns/fb#');
if ($namespaces) {
foreach ($namespaces as $ns => $url) {
$this->addNamespace($ns, $url);
}
}
$this->setType($this->config('type'));
$this->setUri($this->request->here);
$this->setTitle($this->_View->fetch('title'));
if ($appId = $this->config('app_id')) {
$this->setAppId($appId);
}
return $this->Html->tag('html', null, $this->config('namespaces') + $options);
} | [
"public",
"function",
"html",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"array",
"$",
"namespaces",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"addNamespace",
"(",
"'og'",
",",
"'http://ogp.me/ns#'",
")",
";",
"$",
"this",
"->",
"addNamespace"... | Generate HTML tag.
@param array $options Options
@param array $namespaces Namespaces
@return string | [
"Generate",
"HTML",
"tag",
"."
] | d4ffe7ba417d06dca0664a5b1f0870652b1df2e8 | https://github.com/gourmet/social-meta/blob/d4ffe7ba417d06dca0664a5b1f0870652b1df2e8/src/View/Helper/OpenGraphHelper.php#L40-L60 | train |
umbrellaTech/ya-boleto-php | src/Builder/BoletoBuilder.php | BoletoBuilder.cedente | public function cedente($nome, $documento, Endereco $endereco)
{
$this->cedente = new Cedente($nome, $documento, $endereco);
return $this;
} | php | public function cedente($nome, $documento, Endereco $endereco)
{
$this->cedente = new Cedente($nome, $documento, $endereco);
return $this;
} | [
"public",
"function",
"cedente",
"(",
"$",
"nome",
",",
"$",
"documento",
",",
"Endereco",
"$",
"endereco",
")",
"{",
"$",
"this",
"->",
"cedente",
"=",
"new",
"Cedente",
"(",
"$",
"nome",
",",
"$",
"documento",
",",
"$",
"endereco",
")",
";",
"retur... | Define o cedente.
@param string $nome Nome do cedente
@param string $documento CNPJ do cedente
@param Endereco $endereco Endereço do cedente
@return \Umbrella\YaBoleto\Builder\BoletoBuilder | [
"Define",
"o",
"cedente",
"."
] | 3d2e0f2db63e380eaa6db66d1103294705197118 | https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/Builder/BoletoBuilder.php#L117-L122 | train |
umbrellaTech/ya-boleto-php | src/Builder/BoletoBuilder.php | BoletoBuilder.banco | public function banco($agencia, $conta)
{
$reflection = new ReflectionClass($this->namespace . '\\' . $this->type);
$this->banco = $reflection->newInstanceArgs(array($agencia, $conta));
return $this;
} | php | public function banco($agencia, $conta)
{
$reflection = new ReflectionClass($this->namespace . '\\' . $this->type);
$this->banco = $reflection->newInstanceArgs(array($agencia, $conta));
return $this;
} | [
"public",
"function",
"banco",
"(",
"$",
"agencia",
",",
"$",
"conta",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"namespace",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"type",
")",
";",
"$",
"this",
"->",
"banco... | Define o banco.
@param string $agencia Agência bancária favorecida
@param string $conta Conta bancária favorecida
@return \Umbrella\YaBoleto\Builder\BoletoBuilder | [
"Define",
"o",
"banco",
"."
] | 3d2e0f2db63e380eaa6db66d1103294705197118 | https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/Builder/BoletoBuilder.php#L131-L137 | train |
umbrellaTech/ya-boleto-php | src/Builder/BoletoBuilder.php | BoletoBuilder.carteira | public function carteira($carteira)
{
$reflection = new ReflectionClass($this->namespace . '\\Carteira\\Carteira' . $carteira);
$this->carteira = $reflection->newInstanceArgs();
return $this;
} | php | public function carteira($carteira)
{
$reflection = new ReflectionClass($this->namespace . '\\Carteira\\Carteira' . $carteira);
$this->carteira = $reflection->newInstanceArgs();
return $this;
} | [
"public",
"function",
"carteira",
"(",
"$",
"carteira",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"namespace",
".",
"'\\\\Carteira\\\\Carteira'",
".",
"$",
"carteira",
")",
";",
"$",
"this",
"->",
"carteira",
"=",
... | Define a carteira.
@param string $carteira Número da carteira
@return \Umbrella\YaBoleto\Builder\BoletoBuilder | [
"Define",
"a",
"carteira",
"."
] | 3d2e0f2db63e380eaa6db66d1103294705197118 | https://github.com/umbrellaTech/ya-boleto-php/blob/3d2e0f2db63e380eaa6db66d1103294705197118/src/Builder/BoletoBuilder.php#L145-L151 | train |
yajra/cms-core | src/Repositories/Navigation/EloquentRepository.php | EloquentRepository.getPublished | public function getPublished()
{
return $this->getModel()->with([
'menus' => function ($query) {
$query->limitDepth(1)->orderBy('order', 'asc');
},
'menus.permissions',
'menus.children',
])->published()->get();
} | php | public function getPublished()
{
return $this->getModel()->with([
'menus' => function ($query) {
$query->limitDepth(1)->orderBy('order', 'asc');
},
'menus.permissions',
'menus.children',
])->published()->get();
} | [
"public",
"function",
"getPublished",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"with",
"(",
"[",
"'menus'",
"=>",
"function",
"(",
"$",
"query",
")",
"{",
"$",
"query",
"->",
"limitDepth",
"(",
"1",
")",
"->",
"orderBy"... | Get all published navigation.
@return \Illuminate\Database\Eloquent\Collection|static[] | [
"Get",
"all",
"published",
"navigation",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Repositories/Navigation/EloquentRepository.php#L15-L24 | train |
eviweb/fuelphp-phpcs | Standards/FuelPHP/Sniffs/NamingConventions/UnderscoredWithScopeFunctionNameSniff.php | FuelPHP_Sniffs_NamingConventions_UnderscoredWithScopeFunctionNameSniff.isUnderscoreName | public static function isUnderscoreName($string)
{
// If there are space in the name, it can't be valid.
if (strpos($string, ' ') !== false) {
return false;
}
if ($string !== strtolower($string)) {
return false;
}
$validName = true;
$nameBits = explode('_', $string);
foreach ($nameBits as $bit) {
if ($bit === '') {
continue;
}
if ($bit{0} !== strtolower($bit{0})) {
$validName = false;
break;
}
}
return $validName;
} | php | public static function isUnderscoreName($string)
{
// If there are space in the name, it can't be valid.
if (strpos($string, ' ') !== false) {
return false;
}
if ($string !== strtolower($string)) {
return false;
}
$validName = true;
$nameBits = explode('_', $string);
foreach ($nameBits as $bit) {
if ($bit === '') {
continue;
}
if ($bit{0} !== strtolower($bit{0})) {
$validName = false;
break;
}
}
return $validName;
} | [
"public",
"static",
"function",
"isUnderscoreName",
"(",
"$",
"string",
")",
"{",
"// If there are space in the name, it can't be valid.",
"if",
"(",
"strpos",
"(",
"$",
"string",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(... | Returns true if the specified string is in the underscore caps format.
@param string $string The string to verify.
@return boolean | [
"Returns",
"true",
"if",
"the",
"specified",
"string",
"is",
"in",
"the",
"underscore",
"caps",
"format",
"."
] | 6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be | https://github.com/eviweb/fuelphp-phpcs/blob/6042b3ad72e4b1250e5bc05aa9c22bf6b641d1be/Standards/FuelPHP/Sniffs/NamingConventions/UnderscoredWithScopeFunctionNameSniff.php#L216-L243 | train |
Matthimatiker/OpcacheBundle | DataCollector/ByteCodeCacheDataCollector.php | ByteCodeCacheDataCollector.getByteCodeCache | public function getByteCodeCache()
{
if (count($this->data) === 0) {
return $this->byteCodeCache;
}
$mapper = new ArrayMapper();
return $mapper->fromArray($this->data);
} | php | public function getByteCodeCache()
{
if (count($this->data) === 0) {
return $this->byteCodeCache;
}
$mapper = new ArrayMapper();
return $mapper->fromArray($this->data);
} | [
"public",
"function",
"getByteCodeCache",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"data",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"byteCodeCache",
";",
"}",
"$",
"mapper",
"=",
"new",
"ArrayMapper",
"(",
")",
";",
... | Provides information about the byte code cache.
@return ByteCodeCacheInterface | [
"Provides",
"information",
"about",
"the",
"byte",
"code",
"cache",
"."
] | c0e7c7400d40ff9da64c9855097f7581d731fcb9 | https://github.com/Matthimatiker/OpcacheBundle/blob/c0e7c7400d40ff9da64c9855097f7581d731fcb9/DataCollector/ByteCodeCacheDataCollector.php#L51-L58 | train |
yajra/cms-core | src/Providers/RouteServiceProvider.php | RouteServiceProvider.mapWebRoutes | protected function mapWebRoutes(Router $router)
{
$this->mapArticleRoutes($router);
$this->mapCategoryRoutes($router);
$this->mapTagsRoutes($router);
$this->mapAdministratorAuthenticationRoutes($router);
$this->mapAdministratorRoutes($router);
$this->mapFrontendRoutes($router);
} | php | protected function mapWebRoutes(Router $router)
{
$this->mapArticleRoutes($router);
$this->mapCategoryRoutes($router);
$this->mapTagsRoutes($router);
$this->mapAdministratorAuthenticationRoutes($router);
$this->mapAdministratorRoutes($router);
$this->mapFrontendRoutes($router);
} | [
"protected",
"function",
"mapWebRoutes",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"this",
"->",
"mapArticleRoutes",
"(",
"$",
"router",
")",
";",
"$",
"this",
"->",
"mapCategoryRoutes",
"(",
"$",
"router",
")",
";",
"$",
"this",
"->",
"mapTagsRoutes",
... | Define the "web" routes for the application.
These routes all receive session state, CSRF protection, etc.
@param \Illuminate\Routing\Router $router
@return void | [
"Define",
"the",
"web",
"routes",
"for",
"the",
"application",
".",
"These",
"routes",
"all",
"receive",
"session",
"state",
"CSRF",
"protection",
"etc",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/RouteServiceProvider.php#L65-L73 | train |
yajra/cms-core | src/Providers/RouteServiceProvider.php | RouteServiceProvider.mapAdministratorAuthenticationRoutes | protected function mapAdministratorAuthenticationRoutes(Router $router)
{
$router->group(['prefix' => admin_prefix(), 'middleware' => 'web'], function () use ($router) {
$router->get('login', AuthController::class . '@showLoginForm')->name('administrator.login');
$router->get('logout', AuthController::class . '@logout')->name('administrator.logout');
$router->post('login', AuthController::class . '@login')->name('administrator.login');
});
} | php | protected function mapAdministratorAuthenticationRoutes(Router $router)
{
$router->group(['prefix' => admin_prefix(), 'middleware' => 'web'], function () use ($router) {
$router->get('login', AuthController::class . '@showLoginForm')->name('administrator.login');
$router->get('logout', AuthController::class . '@logout')->name('administrator.logout');
$router->post('login', AuthController::class . '@login')->name('administrator.login');
});
} | [
"protected",
"function",
"mapAdministratorAuthenticationRoutes",
"(",
"Router",
"$",
"router",
")",
"{",
"$",
"router",
"->",
"group",
"(",
"[",
"'prefix'",
"=>",
"admin_prefix",
"(",
")",
",",
"'middleware'",
"=>",
"'web'",
"]",
",",
"function",
"(",
")",
"... | Map administrator authentication routes.
@param \Illuminate\Routing\Router $router | [
"Map",
"administrator",
"authentication",
"routes",
"."
] | 50e6a03a6b3c5dd0884509d151825dfa51d7e406 | https://github.com/yajra/cms-core/blob/50e6a03a6b3c5dd0884509d151825dfa51d7e406/src/Providers/RouteServiceProvider.php#L192-L199 | train |
brick/reflection | src/ReflectionTools.php | ReflectionTools.getClassMethods | public function getClassMethods(\ReflectionClass $class) : array
{
$classes = $this->getClassHierarchy($class);
$methods = [];
foreach ($classes as $hClass) {
$hClassName = $hClass->getName();
foreach ($hClass->getMethods() as $method) {
if ($method->isStatic()) {
// exclude static methods
continue;
}
if ($method->getDeclaringClass()->getName() !== $hClassName) {
// exclude inherited methods
continue;
}
$methods[] = $method;
}
}
return $this->filterReflectors($methods);
} | php | public function getClassMethods(\ReflectionClass $class) : array
{
$classes = $this->getClassHierarchy($class);
$methods = [];
foreach ($classes as $hClass) {
$hClassName = $hClass->getName();
foreach ($hClass->getMethods() as $method) {
if ($method->isStatic()) {
// exclude static methods
continue;
}
if ($method->getDeclaringClass()->getName() !== $hClassName) {
// exclude inherited methods
continue;
}
$methods[] = $method;
}
}
return $this->filterReflectors($methods);
} | [
"public",
"function",
"getClassMethods",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
":",
"array",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"getClassHierarchy",
"(",
"$",
"class",
")",
";",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"... | Returns reflections of all the non-static methods that make up one object.
Like ReflectionClass::getMethods(), this method:
- does not return overridden protected or public class methods, and only return the overriding one;
- returns methods inside a class in the order they are declared.
Unlike ReflectionClass::getMethods(), this method:
- returns the private methods of parent classes;
- returns methods in hierarchical order: methods from parent classes are returned first.
@param \ReflectionClass $class
@return \ReflectionMethod[] | [
"Returns",
"reflections",
"of",
"all",
"the",
"non",
"-",
"static",
"methods",
"that",
"make",
"up",
"one",
"object",
"."
] | 4c1736b1ef0d27cf651c5f08c61751b379697d0b | https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L40-L65 | train |
brick/reflection | src/ReflectionTools.php | ReflectionTools.getClassProperties | public function getClassProperties(\ReflectionClass $class) : array
{
$classes = $this->getClassHierarchy($class);
/** @var \ReflectionProperty[] $properties */
$properties = [];
foreach ($classes as $hClass) {
$hClassName = $hClass->getName();
foreach ($hClass->getProperties() as $property) {
if ($property->isStatic()) {
// exclude static properties
continue;
}
if ($property->getDeclaringClass()->getName() !== $hClassName) {
// exclude inherited properties
continue;
}
$properties[] = $property;
}
}
return $this->filterReflectors($properties);
} | php | public function getClassProperties(\ReflectionClass $class) : array
{
$classes = $this->getClassHierarchy($class);
/** @var \ReflectionProperty[] $properties */
$properties = [];
foreach ($classes as $hClass) {
$hClassName = $hClass->getName();
foreach ($hClass->getProperties() as $property) {
if ($property->isStatic()) {
// exclude static properties
continue;
}
if ($property->getDeclaringClass()->getName() !== $hClassName) {
// exclude inherited properties
continue;
}
$properties[] = $property;
}
}
return $this->filterReflectors($properties);
} | [
"public",
"function",
"getClassProperties",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
":",
"array",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"getClassHierarchy",
"(",
"$",
"class",
")",
";",
"/** @var \\ReflectionProperty[] $properties */",
"$",
"proper... | Returns reflections of all the non-static properties that make up one object.
Like ReflectionClass::getProperties(), this method:
- does not return overridden protected or public class properties, and only return the overriding one;
- returns properties inside a class in the order they are declared.
Unlike ReflectionClass::getProperties(), this method:
- returns the private properties of parent classes;
- returns properties in hierarchical order: properties from parent classes are returned first.
@param \ReflectionClass $class
@return \ReflectionProperty[] | [
"Returns",
"reflections",
"of",
"all",
"the",
"non",
"-",
"static",
"properties",
"that",
"make",
"up",
"one",
"object",
"."
] | 4c1736b1ef0d27cf651c5f08c61751b379697d0b | https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L84-L110 | train |
brick/reflection | src/ReflectionTools.php | ReflectionTools.filterReflectors | private function filterReflectors(array $reflectors) : array
{
$filteredReflectors = [];
foreach ($reflectors as $index => $reflector) {
if ($reflector->isPrivate()) {
$filteredReflectors[] = $reflector;
continue;
}
foreach ($reflectors as $index2 => $reflector2) {
if ($index2 <= $index) {
continue;
}
if ($reflector->getName() === $reflector2->getName()) {
// overridden
continue 2;
}
}
$filteredReflectors[] = $reflector;
}
return $filteredReflectors;
} | php | private function filterReflectors(array $reflectors) : array
{
$filteredReflectors = [];
foreach ($reflectors as $index => $reflector) {
if ($reflector->isPrivate()) {
$filteredReflectors[] = $reflector;
continue;
}
foreach ($reflectors as $index2 => $reflector2) {
if ($index2 <= $index) {
continue;
}
if ($reflector->getName() === $reflector2->getName()) {
// overridden
continue 2;
}
}
$filteredReflectors[] = $reflector;
}
return $filteredReflectors;
} | [
"private",
"function",
"filterReflectors",
"(",
"array",
"$",
"reflectors",
")",
":",
"array",
"{",
"$",
"filteredReflectors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reflectors",
"as",
"$",
"index",
"=>",
"$",
"reflector",
")",
"{",
"if",
"(",
"$",
... | Filters a list of ReflectionProperty or ReflectionMethod objects.
This method removes overridden properties, while keeping original order.
Note: ReflectionProperty and ReflectionObject do not explicitly share the same interface, but for the current
purpose they share the same set of methods, and as such are duck typed here.
@param \ReflectionProperty[]|\ReflectionMethod[] $reflectors
@return \ReflectionProperty[]|\ReflectionMethod[] | [
"Filters",
"a",
"list",
"of",
"ReflectionProperty",
"or",
"ReflectionMethod",
"objects",
"."
] | 4c1736b1ef0d27cf651c5f08c61751b379697d0b | https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L124-L149 | train |
brick/reflection | src/ReflectionTools.php | ReflectionTools.getFunctionParameterTypes | public function getFunctionParameterTypes(\ReflectionFunctionAbstract $function) : array
{
return $this->cache(__FUNCTION__, $function, static function() use ($function) {
$docComment = $function->getDocComment();
if ($docComment === false) {
return [];
}
preg_match_all('/@param\s+(\S+)\s+\$(\S+)/', $docComment, $matches, PREG_SET_ORDER);
$types = [];
foreach ($matches as $match) {
$types[$match[2]] = explode('|', $match[1]);
}
return $types;
});
} | php | public function getFunctionParameterTypes(\ReflectionFunctionAbstract $function) : array
{
return $this->cache(__FUNCTION__, $function, static function() use ($function) {
$docComment = $function->getDocComment();
if ($docComment === false) {
return [];
}
preg_match_all('/@param\s+(\S+)\s+\$(\S+)/', $docComment, $matches, PREG_SET_ORDER);
$types = [];
foreach ($matches as $match) {
$types[$match[2]] = explode('|', $match[1]);
}
return $types;
});
} | [
"public",
"function",
"getFunctionParameterTypes",
"(",
"\\",
"ReflectionFunctionAbstract",
"$",
"function",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__FUNCTION__",
",",
"$",
"function",
",",
"static",
"function",
"(",
")",
"use",
"(... | Returns an associative array of the types documented on a function.
The keys are the parameter names, and values the documented types as an array.
This method does not check that parameter names actually exist,
so documented types might not match the function parameter names.
@param \ReflectionFunctionAbstract $function
@return array | [
"Returns",
"an",
"associative",
"array",
"of",
"the",
"types",
"documented",
"on",
"a",
"function",
"."
] | 4c1736b1ef0d27cf651c5f08c61751b379697d0b | https://github.com/brick/reflection/blob/4c1736b1ef0d27cf651c5f08c61751b379697d0b/src/ReflectionTools.php#L201-L219 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.